Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions fern/products/sdks/overview/typescript/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ groups:

## SDK configuration options

<ParamField path="outputSourceFiles" type="boolean" default="true">
<ParamField path="outputSourceFiles" type="boolean" default="true" toc={true}>
When enabled, the generator outputs raw TypeScript files. When disabled (the default), outputs `.js` and `d.ts` files.

<Note>This only applies when dumping code locally. This configuration is ignored when publishing to Github or npm.</Note>
</ParamField>

<ParamField path="includeCredentialsOnCrossOriginRequests" type="boolean" default="false">
<ParamField path="includeCredentialsOnCrossOriginRequests" type="boolean" default="false" toc={true}>
When enabled, [`withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials) is set to `true` when making network requests.
</ParamField>

<ParamField path="bundle" type="boolean">
<ParamField path="bundle" type="boolean" toc={true}>
</ParamField>

<ParamField path="shouldGenerateWebsocketClients" type="boolean">
<ParamField path="shouldGenerateWebsocketClients" type="boolean" toc={true}>
Generate WebSocket clients from your AsyncAPI specs.
</ParamField>

<ParamField path="defaultTimeoutInSeconds" type="number | 'infinity'">
<ParamField path="defaultTimeoutInSeconds" type="number | 'infinity'" toc={true}>
The default timeout for network requests. In the generated client, this can be overridden at the request level.
</ParamField>

<ParamField path="skipResponseValidation" type="boolean" default="false">
<ParamField path="skipResponseValidation" type="boolean" default="false" toc={true}>
By default, the client will throw an error if the response from the server
doesn't match the expected type (based on how the response is modeled in the
Fern Definition).
Expand All @@ -50,7 +50,7 @@ If `skipResponseValidation` is set to `true`, the client will never throw if the

</ParamField>

<ParamField path="extraDependencies" type="object" default="{}">
<ParamField path="extraDependencies" type="object" default="{}" toc={true}>
Specify extra dependencies in the generated `package.json`. This is useful
when you utilize [`.fernignore`](https://buildwithfern.com/learn/sdks/capabilities/custom-code) to
supplement the generated client with custom code.
Expand All @@ -64,7 +64,7 @@ config:

</ParamField>

<ParamField path="extraDevDependencies" type="object" default="{}">
<ParamField path="extraDevDependencies" type="object" default="{}" toc={true}>
Specify extra dev dependencies in the generated `package.json`.

```yaml
Expand All @@ -77,7 +77,7 @@ config:
<Note>Only applies when publishing to Github.</Note>
</ParamField>

<ParamField path="extraPeerDependencies" type="object">
<ParamField path="extraPeerDependencies" type="object" toc={true}>
Specify extra peer dependencies in the generated `package.json`:

```yaml
Expand All @@ -89,7 +89,7 @@ config:
```
</ParamField>

<ParamField path="extraPeerDependenciesMeta" type="object">
<ParamField path="extraPeerDependenciesMeta" type="object" toc={true}>
Specify extra peer dependencies meta fields in the generated `package.json`:

```yaml
Expand All @@ -101,11 +101,11 @@ config:
```
</ParamField>

<ParamField path="treatUnknownAsAny" type="boolean" default="false">
<ParamField path="treatUnknownAsAny" type="boolean" default="false" toc={true}>
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).
</ParamField>

<ParamField path="noOptionalProperties" type="boolean" default="false">
<ParamField path="noOptionalProperties" type="boolean" default="false" toc={true}>
By default, Fern's `optional<>` properties will translate to optional TypeScript properties:

```yaml {4}
Expand All @@ -132,7 +132,7 @@ config:
```
</ParamField>

<ParamField path="packageJson" type="object">
<ParamField path="packageJson" type="object" toc={true}>
When you specify an object in `packageJson`, it will be merged into the `package.json` file.

```yaml
Expand All @@ -150,12 +150,12 @@ config:
```
</ParamField>

<ParamField path="publishToJsr" type="boolean">
<ParamField path="publishToJsr" type="boolean" toc={true}>
Publish your SDK to [JSR](https://jsr.io/). When enabled, the generator will
generate a `jsr.json` as well as a GitHub workflow to publish to JSR.
</ParamField>

<ParamField path="streamType" type="'wrapper' | 'web'">
<ParamField path="streamType" type="'wrapper' | 'web'" toc={true}>
Change the type of stream that is used in the generated SDK.

* `wrapper`: The streams use a wrapper with multiple underlying implementations to support versions of Node.js before Node.js 18.
Expand All @@ -164,7 +164,7 @@ Change the type of stream that is used in the generated SDK.
The default is `web`.
</ParamField>

<ParamField path="fileResponseType" type="'stream' | 'binary-response'">
<ParamField path="fileResponseType" type="'stream' | 'binary-response'" toc={true}>
Change the type of response returned to the user for a binary HTTP response:

* `stream`: Returns a stream. See `streamType`, which controls the type of stream returned.
Expand All @@ -181,25 +181,25 @@ const bodyUsed = response.bodyUsed;
```
</ParamField>

<ParamField path="formDataSupport" type="'Node16' | 'Node18'">
<ParamField path="formDataSupport" type="'Node16' | 'Node18'" toc={true}>
Choose whether you want to support Node.js 16 and above (`Node16`), or Node.js 18 and above (`Node18`).

* `Node16` uses multiple dependencies to support multipart forms, including `form-data`, `formdata-node`, and `form-data-encoder`.
* `Node18` uses the native FormData API, and accepts a wider range of types for file uploads, such as `Buffer`, `File`, `Blob`, `Readable`, `ReadableStream`, `ArrayBuffer`, and `Uint8Array`
</ParamField>
<ParamField path="fetchSupport" type="'node-fetch' | 'native'">
<ParamField path="fetchSupport" type="'node-fetch' | 'native'" toc={true}>
Choose whether you want to include `node-fetch` to support Node.js versions before Node.js 18, or choose `native` to use the native `fetch` API available in Node.js 18 and later.
</ParamField>

<ParamField path="packagePath" type="string">
<ParamField path="packagePath" type="string" toc={true}>
Specify the path where the source files for the generated SDK should be placed.
</ParamField>

<ParamField path="allowExtraFields" type="boolean">
<ParamField path="allowExtraFields" type="boolean" toc={true}>
Allow fields that are not defined in object schemas. This only applies to serde.
</ParamField>

<ParamField path="enableInlineTypes" type="boolean" default="true">
<ParamField path="enableInlineTypes" type="boolean" default="true" toc={true}>
When enabled, the inline schemas will be generated as nested types in TypeScript.
This results in cleaner type names and a more intuitive developer experience.

Expand Down Expand Up @@ -255,7 +255,7 @@ const bar: MyRootType.Foo.Bar = {};
```
</ParamField>

<ParamField path="inlineFileProperties" type="boolean" default="true">
<ParamField path="inlineFileProperties" type="boolean" default="true" toc={true}>
Generate file upload properties as inline request properties (instead of positional parameters).

`inlineFileProperties: false`:
Expand Down Expand Up @@ -307,7 +307,7 @@ public async post(

</ParamField>

<ParamField path="inlinePathParameters" type="boolean" default="true">
<ParamField path="inlinePathParameters" type="boolean" default="true" toc={true}>
Inline path parameters into request types.

`inlinePathParameters: false`:
Expand All @@ -323,7 +323,7 @@ await service.getFoo({ pathParamName: "pathParamValue", id: "SOME_ID" });

</ParamField>

<ParamField path="namespaceExport" type="string">
<ParamField path="namespaceExport" type="string" toc={true}>
By default, names are based on the organization and API names in the Fern Definition:

```typescript
Expand All @@ -344,7 +344,7 @@ By default, names are based on the organization and API names in the Fern Defini

</ParamField>

<ParamField path="noSerdeLayer" type="boolean" default="true">
<ParamField path="noSerdeLayer" type="boolean" default="true" toc={true}>

No serialization/deserialization code is generated by default. The client uses `JSON.parse()` and `JSON.stringify()` instead of the default Serde layer.

Expand All @@ -359,7 +359,7 @@ No serialization/deserialization code is generated by default. The client uses `

</ParamField>

<ParamField path="retainOriginalCasing" type="boolean" default="false">
<ParamField path="retainOriginalCasing" type="boolean" default="false" toc={true}>
When enabled, property names in the generated code retain their original casing from the API definition instead of being converted to camelCase.

```yaml
Expand Down Expand Up @@ -400,7 +400,7 @@ No serialization/deserialization code is generated by default. The client uses `

</ParamField>

<ParamField path="useBigInt" type="boolean" default="false">
<ParamField path="useBigInt" type="boolean" default="false" toc={true}>
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.

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.
Expand Down Expand Up @@ -451,7 +451,7 @@ interface ObjectWithLongAndBigInt {
```
</ParamField>

<ParamField path="useBrandedStringAliases" type="boolean" default="false">
<ParamField path="useBrandedStringAliases" type="boolean" default="false" toc={true}>

When `useBrandedStringAliases` is disabled (the default), string aliases are generated as
normal TypeScript aliases:
Expand Down Expand Up @@ -504,7 +504,7 @@ interface ObjectWithLongAndBigInt {

</ParamField>

<ParamField path="neverThrowErrors" type="boolean" default="false">
<ParamField path="neverThrowErrors" type="boolean" default="false" toc={true}>
When enabled, the client doesn't throw errors when a non-200 response is received from the server. Instead, the response is wrapped in an [`ApiResponse`](packages/core-utilities/fetcher/src/APIResponse.ts).

```typescript
Expand All @@ -519,7 +519,7 @@ interface ObjectWithLongAndBigInt {

### Beta options

<ParamField path="includeContentHeadersOnFileDownloadResponse" type="boolean">
<ParamField path="includeContentHeadersOnFileDownloadResponse" type="boolean" toc={true}>

Includes the content type and content length from binary responses. The user will receive an object of the following type:

Expand All @@ -534,13 +534,13 @@ Includes the content type and content length from binary responses. The user wil
`<BINARY_RESPONSE_TYPE>` is `core.BinaryResponse` or a stream, depending on `fileResponseType` setting.
</ParamField>

<ParamField path="includeUtilsOnUnionMembers" type="boolean">
<ParamField path="includeUtilsOnUnionMembers" type="boolean" toc={true}>
</ParamField>

<ParamField path="includeOtherInUnionTypes" type="boolean">
<ParamField path="includeOtherInUnionTypes" type="boolean" toc={true}>
</ParamField>

<ParamField path="noScripts" type="boolean">
<ParamField path="noScripts" type="boolean" toc={true}>
Prevent the generator from running any scripts such as `yarn format` or `yarn install`. If any of the scripts cause errors, toggling this option will allow you to receive the generated code.
</ParamField>