Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Nov 17, 2025

docs: add allowCustomFetcher config flag documentation for TypeScript SDK

Summary

Added documentation for the allowCustomFetcher configuration 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:

  • Configuration flag description (general-purpose, not auth-specific per reviewer feedback)
  • YAML configuration example
  • Complete TypeScript code example demonstrating request logging with timing and correlation ID injection
  • Link to the dynamic authentication guide for auth-specific use cases

Review & Testing Checklist for Human

  • Verify import paths in code example: The example uses 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.
  • Check documentation rendering: Once the unrelated CI issue is resolved, verify the ParamField renders correctly on the TypeScript configuration page with proper syntax highlighting and formatting.
  • Validate example accuracy: Test that the logging example code actually works with a generated SDK that has allowCustomFetcher: true enabled.
  • Confirm level of detail: Verify the amount of detail in the example matches expectations for a configuration reference entry (vs. a full guide).

Notes

  • CI Status: CI is currently failing due to an unrelated pre-existing parsing error in 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.
  • Feedback addressed: Updated the example from authentication-focused to general-purpose logging per reviewer feedback from @tjb9dc.
  • Local testing: Attempted to test locally with fern docs dev but the server failed due to the same unrelated parsing error. Unable to provide visual proof of rendering.
  • Requested by: [email protected] (@tjb9dc)
  • Devin session: https://app.devin.ai/sessions/9f41e92665c04a09ac0dcd869876a760

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

```
<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.

Comment on lines 19 to 20
<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.

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.
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.

Comment on lines 33 to 48
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

@devin-ai-integration
Copy link
Contributor Author

Updated! I've changed the documentation to be more general-purpose:

  1. Removed the authentication-focused description and replaced it with a general description of the custom fetcher as middleware for cross-cutting concerns
  2. Replaced the authentication example with a logging example that shows request timing and correlation ID injection
  3. Updated the "See also" link text as suggested

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.

@devin-ai-integration devin-ai-integration bot changed the title docs: document allowCustomFetcher config flag for TypeScript generator docs: add allowCustomFetcher config flag documentation for TypeScript SDK Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants