Skip to content

docs: add server URL templating documentation to SDK design section#3672

Merged
iamnamananand996 merged 14 commits intomainfrom
devin/1771415548-server-url-templating-docs
Feb 25, 2026
Merged

docs: add server URL templating documentation to SDK design section#3672
iamnamananand996 merged 14 commits intomainfrom
devin/1771415548-server-url-templating-docs

Conversation

@iamnamananand996
Copy link
Copy Markdown
Contributor

@iamnamananand996 iamnamananand996 commented Feb 18, 2026

docs: add server URL templating documentation

Summary

Adds documentation for the server URL templating feature across three areas of the docs:

  1. New SDK guide page (guides/server-url-templating.mdx) under "SDK design" — shows Python and Java SDK usage with URL template variables (e.g., region, server_url_environment) passed as constructor/builder parameters, plus compact OpenAPI and Fern Definition setup snippets.

  2. Expanded OpenAPI extensions page (extensions/server-names.mdx) — renamed from "Server names" to "Server names and URL templating". Added sections for multiple base URLs, x-fern-default-url extension, and URL template variable configuration with a full OpenAPI example.

  3. Updated Fern Definition environments page (ferndef/api-yml/environments.mdx) — added a "URL templating" section documenting url-templates, default-urls, and variables configuration in api.yml.

Supporting changes:

  • Updated api-def.yml nav entry title and sdks.yml to include the new page
  • Added redirect from old /server-names to /server-names-and-url-templating
  • Updated cross-references in api-explorer.mdx, runnable-endpoint.mdx, and overview.md
  • Added x-fern-default-url as its own row in the extensions overview table

Python/Java SDK examples were verified against actual seed-generated output in fern-api/fern at seed/python-sdk/server-url-templating/ and seed/java-sdk/server-url-templating/.

Updates since last revision

  • Simplified SDK guide page: removed verbose environment class snippets, kept only the client usage examples showing URL variable parameters per reviewer feedback.
  • Added <Note> callout clarifying Python and Java only support.
  • Restructured page to lead with SDK behavior, then link out to full OpenAPI/Fern Definition config docs via <CardGroup> cards.
  • Added URL templating docs to the OpenAPI extensions page and Fern Definition environments page (previously only had the standalone SDK guide).
  • Updated all cross-references and added redirect for the renamed page.

Review & Testing Checklist for Human

  • Fern Definition api.yml format: The url-templates, default-urls, and variables config was derived from internal schema types (MultipleBaseUrlsEnvironmentSchema). Confirm this matches what users actually write — it may be an internal representation populated only during OpenAPI import.
  • Redirect works: Verify that /learn/api-definitions/openapi/extensions/server-names correctly redirects to /learn/api-definitions/openapi/extensions/server-names-and-url-templating. Test in the preview deployment.
  • Cross-reference links resolve: The following pages were updated with new link targets — verify they all render correctly:
    • api-explorer.mdx
    • runnable-endpoint.mdx
    • overview.md (extensions table)
  • Preview all changed pages: Check the preview deployment for:
  • x-server-name vs x-fern-server-name: The OpenAPI test fixture uses x-server-name at the top level and x-fern-server-name at the endpoint level. Verify the docs correctly explain when to use each (currently documented in the "Multiple base URLs" section).

Notes

Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 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


Server URL templating lets you define base URLs with variable placeholders (e.g., `{region}`, `{environment}`) that SDK users can customize at runtime. This is useful for APIs deployed across multiple regions, environments, or custom domains.

Fern reads the standard OpenAPI `servers` block and generates SDK clients that accept these variables, falling back to sensible defaults when they are not provided.
Copy link
Copy Markdown
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 🐶
[Microsoft.Contractions] Use 'they're' instead of 'they are'.

devin-ai-integration Bot and others added 2 commits February 18, 2026 12:01
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>

## Language support

Server URL templating is currently supported in the following generators:
Copy link
Copy Markdown
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.Current] Avoid time-relative terms like 'currently' that become outdated


<Note> By providing a default environment, the generated SDK will be setup to hit that URL out-of-the-box. </Note>

## URL templating
Copy link
Copy Markdown
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.Headings] 'URL templating' should use sentence-style capitalization.


## URL templating

<Note>URL templating is currently supported for Python and Java SDK generation only.</Note>
Copy link
Copy Markdown
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.Current] Avoid time-relative terms like 'currently' that become outdated


`x-fern-server-name` is also used alongside URL template variables, as shown below.

## URL templating and `x-fern-default-url`
Copy link
Copy Markdown
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.Headings] 'URL templating and ******************' should use sentence-style capitalization.


## URL templating and `x-fern-default-url`

<Note>URL template variables and `x-fern-default-url` are currently supported for Python and Java SDK generation only.</Note>
Copy link
Copy Markdown
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.Current] Avoid time-relative terms like 'currently' that become outdated


Server URL templating lets you define base URLs with variable placeholders (e.g., `{region}`, `{environment}`) that SDK users can customize at runtime. This is useful for APIs deployed across multiple regions, environments, or custom domains.

<Note>URL templating is currently supported for Python and Java SDK generation only.</Note>
Copy link
Copy Markdown
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.Current] Avoid time-relative terms like 'currently' that become outdated


## Setting up server URL templating

Define URL template variables in your API definition and provide a static fallback URL for SDK users who don't customize variables:
Copy link
Copy Markdown
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 🐶
[Microsoft.URLFormat] Use 'of' (not 'for') to describe the relationship of the word URL to a resource.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +5 to +6

Server URL templating lets you define base URLs with variable placeholders (e.g., `{region}`, `{environment}`) that SDK users can customize at runtime. This is useful for APIs deployed across multiple regions, environments, or custom domains.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 New page missing required <Markdown src="/snippets/agent-directive.mdx"/> directive

The new file fern/products/sdks/guides/server-url-templating.mdx is missing the required <Markdown src="/snippets/agent-directive.mdx"/> agent directive snippet after the front matter.

Convention violation details

The repository's AGENTS.md explicitly states:

Every new .mdx page created under fern/pages/ or fern/products/ must include the agent directive snippet. Add the following line after the closing --- of the front matter.

Every other .mdx file in the same directory (fern/products/sdks/guides/) includes this directive — e.g., generated-sdk.mdx, configure-readme.mdx, customize-method-names.mdx, etc. (12 out of 12 existing files). The new server-url-templating.mdx is the only file missing it.

The directive should be added on line 5 (after the closing --- of the front matter), like:

---

<Markdown src="/snippets/agent-directive.mdx"/>

Impact: The page will be missing whatever agent directive content is injected by this snippet, creating an inconsistency with all other pages in the documentation.

Suggested change
Server URL templating lets you define base URLs with variable placeholders (e.g., `{region}`, `{environment}`) that SDK users can customize at runtime. This is useful for APIs deployed across multiple regions, environments, or custom domains.
<Markdown src="/snippets/agent-directive.mdx"/>
Server URL templating lets you define base URLs with variable placeholders (e.g., `{region}`, `{environment}`) that SDK users can customize at runtime. This is useful for APIs deployed across multiple regions, environments, or custom domains.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

devin-ai-integration Bot and others added 9 commits February 25, 2026 19:50
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
Add a Python Environment class example and update the Python usage to use the environment parameter (was server_url_environment) and show how to pass a custom base_url. Also add a Java builder example demonstrating .url(...) to supply a custom base URL. These edits clarify how SDK users can override the generated default server URLs.
Replace hard-coded .url(...) example with .region("eu-west-1") and .serverUrlEnvironment("staging") to demonstrate server URL templating by region and environment. Updated fern/products/sdks/guides/server-url-templating.mdx.
Replace 'Or provide a custom base URL' with a clearer note: 'Target a specific region and environment via URL variables' in the Python and Java snippets of the server-url-templating guide (fern/products/sdks/guides/server-url-templating.mdx). This improves clarity about using region and environment parameters when constructing MyApiClient.
Insert a Java code example for an Environment class into the server URL templating SDK guide, demonstrating a REGIONAL_API_SERVER constant and a custom() builder. Improves clarity about how the generated SDK exposes environment configuration.
Add inline comments demonstrating the resolved base URLs for default, region+environment, and custom base URL cases in the Python and Java examples in fern/products/sdks/guides/server-url-templating.mdx. These examples clarify what URL the SDK will use in each configuration.
@iamnamananand996 iamnamananand996 merged commit c2a53e9 into main Feb 25, 2026
2 checks passed
@iamnamananand996 iamnamananand996 deleted the devin/1771415548-server-url-templating-docs branch February 25, 2026 20:24
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.

3 participants