You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/sdks/guides/configure-global-headers.mdx
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,8 +77,11 @@ If you'd like to see this feature, please upvote [this issue](https://github.com
77
77
</Accordion>
78
78
<Accordion title="OpenAPI">
79
79
80
-
Use the `x-fern-global-headers` extension to label additional headers as global
81
-
or to alias the names of global headers:
80
+
For OpenAPI specifications, you can configure global headers in two ways:
81
+
82
+
#### Method 1: OpenAPI Spec Extension
83
+
84
+
Add global headers directly to your OpenAPI spec using the `x-fern-global-headers` extension to label additional headers as global or to alias the names of global headers:
82
85
83
86
```yaml title="openapi.yml"
84
87
x-fern-global-headers:
@@ -88,14 +91,37 @@ x-fern-global-headers:
88
91
optional: true
89
92
```
90
93
91
-
This configuration yields the following client:
94
+
#### Method 2: `generators.yml` Configuration
95
+
96
+
Alternatively, you can add headers to the `api` block in your `generators.yml` file:
97
+
98
+
```yaml title="generators.yml"
99
+
api:
100
+
- openapi: ./path/to/openapi
101
+
headers:
102
+
custom_api_key:
103
+
name: api_key
104
+
type: string
105
+
userpool_id:
106
+
name: userpool_id
107
+
type: optional<string>
108
+
```
109
+
110
+
For more information, see the [`generators.yml` reference documentation](/sdks/reference/generators-yml#headers).
111
+
112
+
#### Client code
113
+
114
+
Both of the above configurations produce the same client code:
description: Guide to configuring the README in your SDK
4
+
---
5
+
6
+
By default, the README for your SDKs is generated programmatically. You can override this by configuring the `readme` section in `generators.yml` to control the content and structure of generated README files across all your SDKs.
7
+
You can add custom introductions, showcase key endpoints, and organize your SDK documentation with feature sections.
8
+
9
+
```yaml title="generators.yml"
10
+
readme:
11
+
introduction: "Welcome to our API"
12
+
apiReferenceLink: "https://docs.example.com"
13
+
defaultEndpoint:
14
+
method: "POST"
15
+
path: "/users"
16
+
features:
17
+
authentication:
18
+
- method: "POST"
19
+
path: "/auth/login"
20
+
users:
21
+
- method: "GET"
22
+
path: "/users"
23
+
```
24
+
25
+
For more detailed information on `readme` configuration, see the [`generators.yml` documentation](/sdks/reference/generators-yml#readme)
Global headers to include with all API requests. You can specify headers as simple string values or as objects with additional configuration for code generation.
96
+
97
+
**Simple string values:**
98
+
```yaml
99
+
api:
100
+
headers:
101
+
Authorization: "Bearer ${API_TOKEN}"
102
+
X-App-Version: "1.0.0"
103
+
```
104
+
105
+
**Advanced configuration with type information:**
106
+
```yaml
107
+
api:
108
+
- openapi: ./path/to/openapi
109
+
headers:
110
+
X-Version:
111
+
# The variable name to use in generated SDK code.
112
+
# If not specified, uses the header name.
113
+
name: version
114
+
# The type of the header value for code generation
0 commit comments