-
Notifications
You must be signed in to change notification settings - Fork 4
docs: add allowCustomFetcher config flag documentation for TypeScript SDK #2059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs: add allowCustomFetcher config flag documentation for TypeScript SDK #2059
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| ``` | ||
| <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. |
There was a problem hiding this comment.
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.
| <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. |
There was a problem hiding this comment.
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
| }); | ||
| ``` | ||
|
|
||
| See [Dynamic authentication](/sdks/generators/typescript/dynamic-authentication) for detailed implementation examples. |
There was a problem hiding this comment.
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:
| 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. |
| 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, | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
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
…hentication Co-Authored-By: [email protected] <[email protected]>
|
Updated! I've changed the documentation to be more general-purpose:
The example now demonstrates logging and header injection without focusing on authentication, while still linking to the dynamic-authentication page for users who need that specific use case. |
docs: add allowCustomFetcher config flag documentation for TypeScript SDK
Summary
Added documentation for the
allowCustomFetcherconfiguration flag to the TypeScript SDK configuration reference page. This flag enables passing a custom fetcher function to intercept all SDK HTTP requests for cross-cutting concerns like logging, tracing, metrics, header injection, proxies, or custom retry logic.The documentation includes:
Review & Testing Checklist for Human
import { fetcher as defaultFetcher, type FetchFunction } from "../core/fetcher". Confirm this path is correct for typical SDK generation configurations and that the wrapper pattern (extending the generated client) is the recommended approach.allowCustomFetcher: trueenabled.Notes
products/cli-api-reference/cli-changelog/2025-11-14.mdx(acorn parse error). This file is identical to main and the error reproduces locally. The Vale linter check passed successfully.fern docs devbut the server failed due to the same unrelated parsing error. Unable to provide visual proof of rendering.