Skip to content
Open
Changes from 1 commit
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
36 changes: 35 additions & 1 deletion fern/products/sdks/overview/typescript/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,40 @@ groups:
noSerdeLayer: false
```

<ParamField path="allowCustomFetcher" type="boolean" default="false" toc={true}>
When enabled, the generated SDK accepts a `fetcher` parameter in the client options. This allows you to wrap the default fetcher with custom logic, enabling dynamic authentication patterns like JWT signing, OAuth token refresh, or HMAC signing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'HMAC' has no definition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not make this solely about authentication. I think we can remove all of this


The custom fetcher acts as middleware for all HTTP requests, giving you a single injection point for authentication logic without overriding individual methods.

```yaml title="generators.yml"
config:
allowCustomFetcher: true
```

With this enabled, you can provide a custom fetcher when instantiating the client:

```typescript
import { PlantStoreClient } from "plant-store-sdk";
import { fetcher as defaultFetcher } from "plant-store-sdk/core";

const customFetcher = async (args) => {
// Add custom authentication logic here
const headers = {
...args.headers,
Authorization: `Bearer ${getToken()}`,
};
return defaultFetcher({ ...args, headers });
};

const client = new PlantStoreClient({
environment: "https://api.plantstore.com",
fetcher: customFetcher,
});
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this example not about authentication


See [Dynamic authentication](/sdks/generators/typescript/dynamic-authentication) for detailed implementation examples.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's say something like:

Suggested change
See [Dynamic authentication](/sdks/generators/typescript/dynamic-authentication) for detailed implementation examples.
See [Dynamic authentication](/sdks/generators/typescript/dynamic-authentication) for an example of adding authentication middleware with a custom fetcher.

</ParamField>

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

Expand Down Expand Up @@ -555,4 +589,4 @@ interface ObjectWithLongAndBigInt {
printMyString(myString);
```

</ParamField>
</ParamField>
Loading