Skip to content

Commit 6857358

Browse files
committed
Update configuration.mdx based on issue #266
1 parent bce0eea commit 6857358

File tree

1 file changed

+18
-124
lines changed

1 file changed

+18
-124
lines changed

fern/products/sdks/overview/typescript/configuration.mdx

Lines changed: 18 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ groups:
1111
local:
1212
generators:
1313
- name: fernapi/fern-typescript-sdk
14-
version: <Markdown src="/snippets/version-number-ts.mdx"/>
14+
version: <Markdown src="/snippets/version-number-ts.mdx" />
1515
config:
1616
namespaceExport: Acme
1717
```
@@ -23,12 +23,21 @@ Allow fields that are not defined in object schemas. This only applies to serde.
2323
</ParamField>
2424
2525
<ParamField path="bundle" type="boolean" toc={true}>
26+
When enabled, bundles the SDK into a single file.
2627
</ParamField>
2728
2829
<ParamField path="defaultTimeoutInSeconds" type="number | 'infinity'" toc={true}>
2930
The default timeout for network requests. In the generated client, this can be overridden at the request level.
3031
</ParamField>
3132
33+
<ParamField path="enableExtensions" type="boolean" default="true" toc={true}>
34+
When enabled, supports the `x-fern-sdk-*` extension properties in your OpenAPI specification. These include:
35+
- `x-fern-sdk-variable`: Path parameters that should be injected by the client constructor
36+
- `x-fern-sdk-group-name`: Custom service group name for endpoints
37+
- `x-fern-sdk-method-name`: Custom method name for endpoints
38+
- `x-fern-ignore`: Skip generating code for this endpoint/component
39+
</ParamField>
40+
3241
<ParamField path="enableInlineTypes" type="boolean" default="true" toc={true}>
3342
When enabled, the inline schemas will be generated as nested types in TypeScript.
3443
This results in cleaner type names and a more intuitive developer experience.
@@ -130,9 +139,11 @@ Specify extra peer dependencies meta fields in the generated `package.json`:
130139
```yaml
131140
# generators.yml
132141
config:
133-
extraPeerDependencies:
134-
react: ">=16.8.0 <19.0.0"
135-
"react-dom": ">=16.8.0 <19.0.0"
142+
extraPeerDependenciesMeta:
143+
react:
144+
optional: true
145+
"react-dom":
146+
optional: true
136147
```
137148
</ParamField>
138149

@@ -184,9 +195,11 @@ Includes the content type and content length from binary responses. The user wil
184195
</ParamField>
185196

186197
<ParamField path="includeOtherInUnionTypes" type="boolean" toc={true}>
198+
When enabled, union types will include an "other" variant for unrecognized values.
187199
</ParamField>
188200

189201
<ParamField path="includeUtilsOnUnionMembers" type="boolean" toc={true}>
202+
When enabled, generates utility functions for union type members.
190203
</ParamField>
191204

192205
<ParamField path="inlineFileProperties" type="boolean" default="true" toc={true}>
@@ -422,123 +435,4 @@ Fern Definition).
422435

423436
If `skipResponseValidation` is set to `true`, the client will never throw if the response is misshapen. Instead, the client will log the issue using `console.warn` and return the data (casted to the expected response type).
424437

425-
<Warning>Response validation only occurs when the Serde layer is enabled (`noSerdeLayer: false`). The Serde layer is disabled by default (`noSerdeLayer: true`).</Warning>
426-
427-
</ParamField>
428-
429-
<ParamField path="streamType" type="'wrapper' | 'web'" toc={true}>
430-
Change the type of stream that is used in the generated SDK.
431-
432-
* `wrapper`: The streams use a wrapper with multiple underlying implementations to support versions of Node.js before Node.js 18.
433-
* `web`: The streams use the web standard `ReadableStream`.
434-
435-
The default is `web`.
436-
</ParamField>
437-
438-
<ParamField path="treatUnknownAsAny" type="boolean" default="false" toc={true}>
439-
When `treatUnknownAsAny` is enabled, [unknown types from Fern are generated into TypeScript using `any` instead of the `unknown` type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type).
440-
</ParamField>
441-
442-
<ParamField path="useBigInt" type="boolean" default="false" toc={true}>
443-
When `useBigInt` is set to `true`, a customized JSON serializer & deserializer is used that will preserve the precision of `bigint`'s, as opposed to the native `JSON.stringify` and `JSON.parse` function which converts `bigint`'s to number's losing precision.
444-
445-
When combining `useBigInt` with our serialization layer (`no-serde: false`), both the request and response properties that are marked as `long` and `bigint` in OpenAPI/Fern spec, will consistently be `bigint`'s.
446-
However, when disabling the serialization layer (`no-serde: true`), they will be typed as `number | bigint`.
447-
448-
Here's an overview of what to expect from the generated types when combining `useBigInt` and `noSerde` with the following Fern definition:
449-
450-
*Fern definition*:
451-
452-
```yaml
453-
types:
454-
ObjectWithOptionalField:
455-
properties:
456-
longProp: long
457-
bigIntProp: bigint
458-
```
459-
460-
*TypeScript output*:
461-
462-
```typescript
463-
// useBigInt: true
464-
// noSerde: false
465-
interface ObjectWithLongAndBigInt {
466-
longProp: bigint;
467-
bigIntProp: bigint;
468-
}
469-
470-
// useBigInt: true
471-
// noSerde: true
472-
interface ObjectWithLongAndBigInt {
473-
longProp: bigint | number;
474-
bigIntProp: bigint | number;
475-
}
476-
477-
// useBigInt: false
478-
// noSerde: false
479-
interface ObjectWithLongAndBigInt {
480-
longProp: number;
481-
bigIntProp: string;
482-
}
483-
484-
// useBigInt: false
485-
// noSerde: true
486-
interface ObjectWithLongAndBigInt {
487-
longProp: number;
488-
bigIntProp: string;
489-
}
490-
```
491-
</ParamField>
492-
493-
<ParamField path="useBrandedStringAliases" type="boolean" default="false" toc={true}>
494-
495-
When `useBrandedStringAliases` is disabled (the default), string aliases are generated as
496-
normal TypeScript aliases:
497-
498-
```typescript
499-
// generated code
500-
501-
export type MyString = string;
502-
503-
export type OtherString = string;
504-
```
505-
When `useBrandedStringAliases` is enabled, string aliases are generated as branded strings. This makes each alias feel like its own type and improves compile-time safety.
506-
507-
```yaml
508-
# fern definition
509-
510-
types:
511-
MyString: string
512-
OtherString: string
513-
```
514-
515-
```typescript
516-
// generated code
517-
518-
export type MyString = string & { __MyString: void };
519-
export const MyString = (value: string): MyString => value as MyString;
520-
521-
export type OtherString = string & { __OtherString: void };
522-
export const OtherString = (value: string): OtherString => value as OtherString;
523-
```
524-
525-
```typescript
526-
// consuming the generated type
527-
528-
function printMyString(s: MyString): void {
529-
console.log("MyString: " + s);
530-
}
531-
532-
// doesn't compile, "foo" is not assignable to MyString
533-
printMyString("foo");
534-
535-
const otherString = OtherString("other-string");
536-
// doesn't compile, otherString is not assignable to MyString
537-
printMyString(otherString);
538-
539-
// compiles
540-
const myString = MyString("my-string");
541-
printMyString(myString);
542-
```
543-
544-
</ParamField>
438+
<Warning>Response validation only occurs when the

0 commit comments

Comments
 (0)