feat(typescript): add serverUrlVariables config flag to opt out of server URL variables#17124
feat(typescript): add serverUrlVariables config flag to opt out of server URL variables#17124willkendall01 wants to merge 2 commits into
Conversation
… URL variables Adds a `serverUrlVariables` config flag (default true) to the TypeScript v1 SDK generator. When false, the generated client no longer exposes the server-URL-variable constructor options nor the construction-time URL-template interpolation, falling back to the pre-feature base-URL behavior. When unset or true, behavior is unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
| interpolation is omitted, falling back to the pre-feature base-URL behavior. When | ||
| unset or `true`, behavior is unchanged. | ||
| type: feat | ||
| createdAt: "2026-07-16" |
There was a problem hiding this comment.
🔵 suggestion
createdAt: "2026-07-16" is in the future (2026). Likely meant to be 2025 (or whatever today actually is).
| createdAt: "2026-07-16" | |
| createdAt: "2025-07-16" |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Adds a `disable-server-url-variables` variant (customConfig serverUrlVariables: false) to the server-url-templating and server-url-templating-single-url seed fixtures. The generated BaseClient.ts confirms that, with the flag disabled, the server-URL-variable client options and the templated base-URL interpolation are omitted. The existing no-custom-config snapshots are unchanged, proving the default behavior is preserved. Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Adds a new
serverUrlVariablesboolean config flag (default true) to the TypeScript v1 SDK generator.true(default) or unset: behavior is unchanged. Server URL variables declared on the API's environments are exposed as optional client-constructor options and interpolated into the base URL(s) at construction time.false: the generator opts out of the feature entirely. It emits neither the server-URL-variable client options nor the templated base-URL interpolation, falling back to the pre-feature base-URL behavior.Implementation
The flag is declared as
serverUrlVariables?: booleanin the shared custom-config zod schema, mirrored on the parsedSdkCustomConfiginterface, defaulted totrueat parse time, and threaded throughSdkGenerator.Configinto the two generators that emit server-URL-variable output.Both emission points (the client-options interface and the construction-time interpolation) route through a single helper,
getServerVariableOptions. The gate lives there: when the flag isfalseit returns an empty list, which suppresses both the options and the interpolation at one narrow point.Tests
false, alongside the existing tests that confirm default (true) output is unchanged.Generated with Claude Code