Skip to content

Commit 10a5886

Browse files
committed
Update configuration.mdx based on issue #266
1 parent f7db0c8 commit 10a5886

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

fern/products/sdks/overview/python/configuration.mdx

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,47 @@ groups:
1818
class_name: "YourClient"
1919
```
2020
21+
## Extension Headers
22+
23+
The Python SDK generator supports injection of variables into request paths through the `x-fern-sdk-variables` extension in your OpenAPI spec. This allows you to define variables that will be set once in the client constructor and automatically injected into relevant request paths.
24+
25+
For example, to inject a project ID into all relevant paths:
26+
27+
```yaml
28+
components:
29+
x-fern-sdk-variables:
30+
project_id:
31+
type: string
32+
description: "The ID of the project"
33+
pattern: "^proj_[a-zA-Z0-9]+$"
34+
```
35+
36+
Then in your paths:
37+
38+
```yaml
39+
/v1/connect/{project_id}/accounts:
40+
parameters:
41+
- name: project_id
42+
in: path
43+
required: true
44+
schema:
45+
type: string
46+
x-fern-sdk-variable: project_id
47+
```
48+
49+
The generated client will accept the variable in its constructor:
50+
51+
```python
52+
client = Client(project_id="proj_123")
53+
```
54+
55+
And automatically inject it into requests:
56+
57+
```python
58+
# project_id is injected from the client constructor
59+
accounts = client.accounts.list()
60+
```
61+
2162
## SDK Configuration Options
2263

2364
<ParamField path="additional_init_exports" type="array" default="null" required={false} toc={true}>
@@ -72,12 +113,9 @@ groups:
72113
</ParamField>
73114

74115
<ParamField path="package_name" type="string" default="null" required={false} toc={true}>
75-
76-
Specifies the Python package name that users will import your generated client
77-
from.
116+
Specifies the Python package name that users will import your generated client from.
78117

79-
For example, setting `package_name: "my_custom_package"` enables users to use
80-
`my_custom_package import Client` to import your client:
118+
For example, setting `package_name: "my_custom_package"` enables users to use `my_custom_package import Client` to import your client:
81119

82120
```yaml {7-10}
83121
default-group: local

0 commit comments

Comments
 (0)