Skip to content

Commit ca099b2

Browse files
committed
Update configure-global-headers.mdx based on issue #266
1 parent 6689869 commit ca099b2

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

fern/products/sdks/guides/configure-global-headers.mdx

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ If you'd like to see this feature, please upvote [this issue](https://github.com
7777
</Accordion>
7878
<Accordion title="OpenAPI">
7979

80-
Use the `x-fern-global-headers` extension to label additional headers as global
81-
or to alias the names of global headers:
80+
Use one of the following extensions to specify global configuration:
81+
82+
### x-fern-global-headers
83+
Use this to label additional headers as global or to alias header names:
8284

8385
```yaml title="openapi.yml"
8486
x-fern-global-headers:
@@ -97,5 +99,56 @@ class Client:
9799
98100
def __init__(self, *, apiKey: str, userpoolId: typing.Optional[str])
99101
```
102+
103+
### x-fern-sdk-variables
104+
Use this to specify variables that should be part of the SDK client constructor and injected into paths:
105+
106+
```yaml title="openapi.yml"
107+
x-fern-sdk-variables:
108+
project_id:
109+
type: string
110+
description: "The ID of the project"
111+
pattern: "^proj_[a-zA-Z0-9]+$"
112+
```
113+
114+
This will generate a client that accepts the variable in the constructor and automatically injects it into paths:
115+
116+
```python
117+
class Client:
118+
def __init__(self, *, project_id: str):
119+
# Variable will be injected into paths like /v1/connect/{project_id}/accounts
120+
```
121+
100122
</Accordion>
101-
</AccordionGroup>
123+
</AccordionGroup>
124+
125+
## Supported Extension Fields
126+
127+
The following extension fields are supported for configuring global headers and variables:
128+
129+
<ParamField query="x-fern-global-headers" type="array">
130+
Array of header configurations with fields:
131+
- `header`: The original header name
132+
- `name`: Optional alias for the header in the SDK
133+
- `optional`: Whether the header is optional
134+
</ParamField>
135+
136+
<ParamField query="x-fern-sdk-variables" type="object">
137+
Object mapping variable names to their configuration:
138+
- `type`: The variable type (string, integer, etc)
139+
- `description`: Description of the variable
140+
- `pattern`: Optional regex pattern for validation
141+
</ParamField>
142+
143+
## Language Support
144+
145+
Global configuration support varies by language:
146+
147+
- TypeScript/JavaScript: Full support for global headers and variables
148+
- Python: Full support as of version 4.24.0+
149+
- Java: Full support for global headers and variables
150+
- Go: Full support for global headers and variables
151+
152+
<Note>
153+
Make sure you're using the latest generator versions to access all global configuration features. You can update your generator versions in `generators.yml`.
154+
</Note>

0 commit comments

Comments
 (0)