Skip to content

Commit 6ff50ee

Browse files
authored
Expand description and add examples for additional_init_exports parameter (Python) (#417)
1 parent 0b2b03f commit 6ff50ee

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Configuration options for the Fern Python SDK.
55

66
You can customize the behavior of the Python SDK generator in `generators.yml`:
77

8-
```yaml {7-12}
8+
```yaml {7-16}
99
default-group: local
1010
groups:
1111
local:
@@ -16,16 +16,45 @@ groups:
1616
package_name: "your_package"
1717
client:
1818
class_name: "YourClient"
19+
additional_init_exports:
20+
- from: file_with_custom_function
21+
imports:
22+
- custom_function
1923
pydantic-config:
2024
skip_validation: true
2125
```
2226
2327
## SDK Configuration Options
2428
25-
<ParamField path="additional_init_exports" type="array" default="null" required={false} toc={true}>
29+
<ParamField path="additional_init_exports" type="array of objects" default="null" required={false} toc={true}>
2630
Additional modules or classes to export from the package's `__init__.py` file. This allows you to customize what's available when users import your package.
31+
32+
Each object should specify which file to import from and what to import:
33+
```yaml
34+
config:
35+
additional_init_exports:
36+
- from: core.oauth_flow
37+
imports:
38+
- validate_token
39+
- from: utils.helpers
40+
imports:
41+
- format_currency
42+
- PhoneValidator
43+
```
44+
45+
This enables users to access your custom functions directly:
46+
```python
47+
from my_package import validate_token, format_currency, PhoneValidator
48+
```
2749
</ParamField>
50+
<ParamField path="additional_init_exports[].from" type="string" required={true}>
51+
The module path to import from, using Python dot notation. Omit the `.py` extension and replace path separators with dots.
2852

53+
For example, if you want to import from the file `core/oauth_flow.py`, specify that as `- from: core.oauth_flow`.
54+
</ParamField>
55+
<ParamField path="additional_init_exports[].imports" type="array of strings" required={true}>
56+
List of class names, function names, or other objects to import from the specified file.
57+
</ParamField>
2958
<ParamField path="default_bytes_stream_chunk_size" type="number" default="null" required={false} toc={true}>
3059
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>):`
3160
</ParamField>

0 commit comments

Comments
 (0)