From f03e4b81e9f993afd717223f17586a6bf27cd699 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Mon, 21 Jul 2025 11:40:53 -0400 Subject: [PATCH 1/3] copy in openapi and fern def global header pages and modify --- .../sdks/guides/configure-global-headers.mdx | 93 ++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/fern/products/sdks/guides/configure-global-headers.mdx b/fern/products/sdks/guides/configure-global-headers.mdx index 05621c25c..d7ebc78c7 100644 --- a/fern/products/sdks/guides/configure-global-headers.mdx +++ b/fern/products/sdks/guides/configure-global-headers.mdx @@ -3,6 +3,95 @@ title: Configure Global Headers description: Guide to configuring global headers in your SDKs. --- -Learn how to configure global headers for all requests made by your SDKs. +Your API may leverage certain headers for every endpoint or most endpoints. +These are called **global headers**. -Docs are coming soon for this page.

Please [book a demo](https://buildwithfern.com/book-demo) or [reach out to us](https://buildwithfern.com/book-demo) to get set up with this feature.
+Fern automatically pulls out headers that are used in every request, or the +majority of requests, and marks them as global. You can manually configure additional +headers as global in either `api.yml` (Fern Definition) or `openapi.yml`. + +Once you configure a global header, Fern generates an SDK that accepts this as a +constructor parameter. Users can then provide the value once, and the generated +SDK automatically includes the header in all their API calls: + +```python +import os + +class Client: + + def __init__(self, *, apiKey: str): +``` + + + +## Global Headers + +To specify headers that are meant to be included on every request: + + +```yaml {3} +name: api +headers: + X-App-Id: string +``` + + +## Global path parameters +You can also specify path parameters that are meant to be included on every request: + + +```yaml +name: api +base-path: /{userId}/{orgId} +path-parameters: + userId: string + orgId: string +``` + + +### Overriding the base path + +If you have certain endpoints that do not live at the configured `base-path`, you can +override the `base-path` at the endpoint level. + +```yml imdb.yml {5} +service: + endpoints: + getMovie: + method: POST + base-path: "override/{arg}" + path: "movies/{movieId}" + path-parameters: + arg: string +``` + + + You cannot yet specify query parameters that are meant to be included on every request. +If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930). + + + + + +## Global Headers +Use the `x-fern-global-headers` extension to label additional headers as global or to alias the names of global headers: + +```yaml title="openapi.yml" +x-fern-global-headers: + - header: custom_api_key + name: api_key + - header: userpool_id + optional: true +``` + +yields the following client: + +```python +import os + +class Client: + + def __init__(self, *, apiKey: str, userpoolId: typing.Optional[str]) +``` + + \ No newline at end of file From fb3c18e25efe3e6f110fdabe66a9516046ffb99c Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Mon, 21 Jul 2025 12:19:48 -0400 Subject: [PATCH 2/3] some additional small edits --- .../sdks/guides/configure-global-headers.mdx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fern/products/sdks/guides/configure-global-headers.mdx b/fern/products/sdks/guides/configure-global-headers.mdx index d7ebc78c7..51ff76b20 100644 --- a/fern/products/sdks/guides/configure-global-headers.mdx +++ b/fern/products/sdks/guides/configure-global-headers.mdx @@ -6,13 +6,14 @@ description: Guide to configuring global headers in your SDKs. Your API may leverage certain headers for every endpoint or most endpoints. These are called **global headers**. -Fern automatically pulls out headers that are used in every request, or the +Fern automatically identifies headers that are used in every request, or the majority of requests, and marks them as global. You can manually configure additional -headers as global in either `api.yml` (Fern Definition) or `openapi.yml`. +global headers in either `api.yml` (Fern Definition) or `openapi.yml`. -Once you configure a global header, Fern generates an SDK that accepts this as a -constructor parameter. Users can then provide the value once, and the generated -SDK automatically includes the header in all their API calls: +Once you configure a global header (either automatically detected or manually +specified), Fern generates an SDK that accepts this as a constructor parameter. +Users can then provide the value once, and the generated SDK automatically +includes the header in all their API calls: ```python import os @@ -21,10 +22,12 @@ class Client: def __init__(self, *, apiKey: str): ``` + +## Specifying Global Headers in a Fern Definition or OpenAPI spec -## Global Headers +### Global Headers To specify headers that are meant to be included on every request: @@ -36,7 +39,7 @@ headers: ``` -## Global path parameters +### Global path parameters You can also specify path parameters that are meant to be included on every request: @@ -49,7 +52,7 @@ path-parameters: ``` -### Overriding the base path +#### Overriding the base path If you have certain endpoints that do not live at the configured `base-path`, you can override the `base-path` at the endpoint level. @@ -73,7 +76,7 @@ If you'd like to see this feature, please upvote [this issue](https://github.com -## Global Headers +### Global Headers Use the `x-fern-global-headers` extension to label additional headers as global or to alias the names of global headers: ```yaml title="openapi.yml" @@ -84,7 +87,7 @@ x-fern-global-headers: optional: true ``` -yields the following client: +This configuration yields the following client: ```python import os From a78986e63571df40fce1dcb56d3718a0c8aeb104 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Tue, 22 Jul 2025 16:06:22 -0400 Subject: [PATCH 3/3] change tabs to accordions and make some other minor changes --- .../sdks/guides/configure-global-headers.mdx | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/fern/products/sdks/guides/configure-global-headers.mdx b/fern/products/sdks/guides/configure-global-headers.mdx index 51ff76b20..53ec1bd15 100644 --- a/fern/products/sdks/guides/configure-global-headers.mdx +++ b/fern/products/sdks/guides/configure-global-headers.mdx @@ -6,9 +6,7 @@ description: Guide to configuring global headers in your SDKs. Your API may leverage certain headers for every endpoint or most endpoints. These are called **global headers**. -Fern automatically identifies headers that are used in every request, or the -majority of requests, and marks them as global. You can manually configure additional -global headers in either `api.yml` (Fern Definition) or `openapi.yml`. +## How it works for SDK users Once you configure a global header (either automatically detected or manually specified), Fern generates an SDK that accepts this as a constructor parameter. @@ -23,11 +21,14 @@ class Client: def __init__(self, *, apiKey: str): ``` -## Specifying Global Headers in a Fern Definition or OpenAPI spec - - +## Specifying global headers + +Fern automatically identifies headers that are used in every request, or the +majority of requests, and marks them as global. You can manually configure additional +global headers in either `api.yml` (Fern Definition) or `openapi.yml`. -### Global Headers + + To specify headers that are meant to be included on every request: @@ -73,11 +74,11 @@ service: If you'd like to see this feature, please upvote [this issue](https://github.com/fern-api/fern/issues/2930). - - + + -### Global Headers -Use the `x-fern-global-headers` extension to label additional headers as global or to alias the names of global headers: +Use the `x-fern-global-headers` extension to label additional headers as global +or to alias the names of global headers: ```yaml title="openapi.yml" x-fern-global-headers: @@ -96,5 +97,5 @@ class Client: def __init__(self, *, apiKey: str, userpoolId: typing.Optional[str]) ``` - - \ No newline at end of file + + \ No newline at end of file