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/overview/python/configuration.mdx
+43-5Lines changed: 43 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,47 @@ groups:
18
18
class_name: "YourClient"
19
19
```
20
20
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
0 commit comments