docs: add server URL templating documentation to SDK design section#3672
docs: add server URL templating documentation to SDK design section#3672iamnamananand996 merged 14 commits intomainfrom
Conversation
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
🤖 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:
|
|
|
||
| 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. |
There was a problem hiding this comment.
🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'they're' instead of 'they are'.
|
🌿 Preview your docs: https://fern-preview-85a5c79b-d877-40fc-9be4-c27c92a37591.docs.buildwithfern.com/learn Here are the markdown pages you've updated: |
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: |
There was a problem hiding this comment.
[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 |
There was a problem hiding this comment.
📝 [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> |
There was a problem hiding this comment.
[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` |
There was a problem hiding this comment.
📝 [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> |
There was a problem hiding this comment.
[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> |
There was a problem hiding this comment.
[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: |
There was a problem hiding this comment.
📝 [vale] reported by reviewdog 🐶
[Microsoft.URLFormat] Use 'of' (not 'for') to describe the relationship of the word URL to a resource.
|
|
||
| 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. |
There was a problem hiding this comment.
🟡 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
.mdxpage created underfern/pages/orfern/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.
| 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. |
Was this helpful? React with 👍 or 👎 to provide feedback.
Co-Authored-By: naman.anand@buildwithfern.com <iamnamananand996@gmail.com>
…/git-manager.devin.ai/proxy/github.com/fern-api/docs into devin/1771415548-server-url-templating-docs
…ble usage" This reverts commit 81c3d75.
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.
…/github.com/fern-api/docs into devin/1771415548-server-url-templating-docs
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.
docs: add server URL templating documentation
Summary
Adds documentation for the server URL templating feature across three areas of the docs:
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.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-urlextension, and URL template variable configuration with a full OpenAPI example.Updated Fern Definition environments page (
ferndef/api-yml/environments.mdx) — added a "URL templating" section documentingurl-templates,default-urls, andvariablesconfiguration inapi.yml.Supporting changes:
api-def.ymlnav entry title andsdks.ymlto include the new page/server-namesto/server-names-and-url-templatingapi-explorer.mdx,runnable-endpoint.mdx, andoverview.mdx-fern-default-urlas its own row in the extensions overview tablePython/Java SDK examples were verified against actual seed-generated output in
fern-api/fernatseed/python-sdk/server-url-templating/andseed/java-sdk/server-url-templating/.Updates since last revision
<Note>callout clarifying Python and Java only support.<CardGroup>cards.Review & Testing Checklist for Human
api.ymlformat: Theurl-templates,default-urls, andvariablesconfig 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./learn/api-definitions/openapi/extensions/server-namescorrectly redirects to/learn/api-definitions/openapi/extensions/server-names-and-url-templating. Test in the preview deployment.api-explorer.mdxrunnable-endpoint.mdxoverview.md(extensions table)x-server-namevsx-fern-server-name: The OpenAPI test fixture usesx-server-nameat the top level andx-fern-server-nameat the endpoint level. Verify the docs correctly explain when to use each (currently documented in the "Multiple base URLs" section).Notes