Skip to content

Commit a06003e

Browse files
committed
Update configuration.mdx based on issue #266
1 parent 376e712 commit a06003e

File tree

1 file changed

+66
-30
lines changed

1 file changed

+66
-30
lines changed

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

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ groups:
2121
## SDK Configuration Options
2222
2323
<ParamField path="additional_init_exports" type="array" default="null" required={false} toc={true}>
24+
Additional objects to export from the package's __init__.py file.
2425
</ParamField>
2526
2627
<ParamField path="default_bytes_stream_chunk_size" type="number" default="null" required={false} toc={true}>
2728
The chunk size to use (if any) when processing a response bytes stream within `iter_bytes` or `aiter_bytes` results in: `for chunk in response.iter_bytes(chunk_size=<default_bytes_stream_chunk_size>):`
2829
</ParamField>
2930

3031
<ParamField path="exclude_types_from_init_exports" type="bool" default="false" required={false} toc={true}>
32+
When true, types will not be exported from the package's __init__.py file.
3133
</ParamField>
3234

3335
<ParamField path="extra_dependencies" type="object" default="{}" required={false} toc={true}>
@@ -40,27 +42,31 @@ groups:
4042
</ParamField>
4143

4244
<ParamField path="extra_dev_dependencies" type="object" default="{}" required={false} toc={true}>
45+
Additional development dependencies to include in the generated package.
4346
</ParamField>
4447

4548
<ParamField path="extras" type="object" default="{}" required={false} toc={true}>
49+
Optional extras/features to include in the generated package setup.
4650
</ParamField>
4751

4852
<ParamField path="flat_layout" type="bool" default="false" required={false} toc={true}>
53+
When true, generates a flatter directory structure without nested subdirectories.
4954
</ParamField>
5055

5156
<ParamField path="follow_redirects_by_default" type="bool" default="true" required={false} toc={true}>
5257
Whether to follow redirects by default in HTTP requests.
5358
</ParamField>
5459

5560
<ParamField path="improved_imports" type="bool" default="true" required={false} toc={true}>
56-
Feature flag that improves imports in the Python SDK by removing nested `resources` directory
61+
Feature flag that improves imports in the Python SDK by removing nested `resources` directory.
5762
</ParamField>
5863

5964
<ParamField path="include_legacy_wire_tests" type="bool" default="false" required={false} toc={true}>
60-
Whether or not to include legacy wire tests in the generated SDK
65+
Whether or not to include legacy wire tests in the generated SDK.
6166
</ParamField>
6267

6368
<ParamField path="include_union_utils" type="bool" default="false" required={false} toc={true}>
69+
When enabled, includes additional utility functions for working with union types.
6470
</ParamField>
6571

6672
<ParamField path="inline_path_params" type="bool" default="false" required={false} toc={true}>
@@ -72,26 +78,18 @@ groups:
7278
</ParamField>
7379

7480
<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.
81+
Specifies the Python package name that users will import your generated client from.
7882

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

82-
```yaml {7-10}
83-
default-group: local
84-
groups:
85-
local:
86-
generators:
87-
- name: fernapi/fern-python
88-
version: 0.7.1
89-
config:
90-
package_name: "my_custom_package"
91-
```
85+
```yaml
86+
config:
87+
package_name: "my_custom_package"
88+
```
9289
</ParamField>
9390

9491
<ParamField path="pydantic_config" type="SdkPydanticModelCustomConfig" default="SdkPydanticModelCustomConfig()" required={false} toc={true}>
92+
Configuration options for Pydantic model generation.
9593
</ParamField>
9694

9795
<ParamField path="pydantic_config.include_union_utils" type="bool" default="false" required={false} toc={true}>
@@ -112,12 +110,10 @@ groups:
112110
# Visit every case in the union
113111
shape = get_shape()
114112
shape.visit(
115-
circle: lambda circle: do_something_with_circle(circle),
116-
triangle: lambda triangle: do_something_with_triangle(triangle),
113+
circle=lambda circle: do_something_with_circle(circle),
114+
triangle=lambda triangle: do_something_with_triangle(triangle),
117115
)
118116
```
119-
120-
When enabled, the python generator will not run Black formatting in the generated code. Black is slow so this can potentially speed up code generation quite a bit.
121117
</ParamField>
122118

123119
<ParamField path="pydantic_config.version" type="'v1' | 'v2' | 'both' | 'v1_on_v2'" default="both" required={false} toc={true}>
@@ -140,20 +136,23 @@ groups:
140136
</ParamField>
141137
142138
<ParamField path="pyproject_toml" type="string" default="null" required={false} toc={true}>
139+
Custom pyproject.toml content to include in the generated package.
143140
</ParamField>
144141
145142
<ParamField path="should_generate_websocket_clients" type="bool" default="false" required={false} toc={true}>
146143
Feature flag that enables generation of Python websocket clients.
147144
</ParamField>
148145
149146
<ParamField path="skip_formatting" type="bool" default="false" required={false} toc={true}>
147+
When true, skips code formatting of the generated SDK.
150148
</ParamField>
151149
152150
<ParamField path="timeout_in_seconds" type="number | 'infinity'" default="60" required={false} toc={true}>
153151
By default, the generator generates a client that times out after 60 seconds. You can customize this value by providing a different number or setting to `infinity` to get rid of timeouts.
154152
</ParamField>
155153

156154
<ParamField path="use_api_name_in_package" type="bool" default="false" required={false} toc={true}>
155+
When true, includes the API name in the generated package name.
157156
</ParamField>
158157

159158
<ParamField path="use_inheritance_for_extended_models" type="bool" default="true" required={false} toc={true}>
@@ -168,17 +167,54 @@ groups:
168167
Whether or not to generate TypedDicts instead of Pydantic Models for file upload request objects. Note that this flag was only introduced due to an oversight in the `use_typeddict_requests` flag implementation; it should be removed in the future.
169168
</ParamField>
170169

170+
### Extension Headers
171+
172+
The Python SDK generator supports setting extension headers via the `x-fern-sdk-variables` OpenAPI extension. This allows you to define variables that will be passed to the SDK constructor and injected into API paths.
173+
174+
For example, to have a `project_id` variable injected into paths:
175+
176+
```yaml
177+
# OpenAPI spec
178+
x-fern-sdk-variables:
179+
project_id:
180+
type: string
181+
description: The ID of the project
182+
pattern: "^proj_[a-zA-Z0-9]+$"
183+
184+
paths:
185+
/v1/connect/{project_id}/accounts:
186+
parameters:
187+
- name: project_id
188+
in: path
189+
required: true
190+
schema:
191+
type: string
192+
pattern: "^proj_[a-zA-Z0-9]+$"
193+
x-fern-sdk-variable: project_id
194+
```
195+
196+
The variable will be available in the SDK client constructor:
197+
198+
```python
199+
from my_sdk import Client
200+
201+
client = Client(
202+
project_id="proj_123" # Will be injected into paths
203+
)
204+
```
205+
171206
### client
172-
Configuration for the generated client class and file structure.
173207

174-
```yaml
175-
config:
176-
client:
177-
filename: "my_client.py"
178-
class_name: "MyClient"
179-
exported_filename: "my_client.py"
180-
exported_class_name: "MyClient"
181-
```
208+
Configuration for the generated client class and file structure.
209+
210+
```yaml
211+
config:
212+
client:
213+
filename: "my_client.py"
214+
class_name: "MyClient"
215+
exported_filename: "my_client.py"
216+
exported_class_name: "MyClient"
217+
```
182218

183219
<ParamField path="filename" type="string" default="client.py" required={false} toc={true}>
184220
The filename for the generated client file.

0 commit comments

Comments
 (0)