From e1588db84a592b152d2ad0f01068daa0098c8328 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Thu, 3 Jul 2025 12:59:16 -0400 Subject: [PATCH 1/3] fill out config file for python sdk --- .../sdks/overview/python/configuration.mdx | 149 +++++++++++++++++- 1 file changed, 147 insertions(+), 2 deletions(-) diff --git a/fern/products/sdks/overview/python/configuration.mdx b/fern/products/sdks/overview/python/configuration.mdx index 3d9d8726a..01ae41f35 100644 --- a/fern/products/sdks/overview/python/configuration.mdx +++ b/fern/products/sdks/overview/python/configuration.mdx @@ -3,6 +3,151 @@ title: Python Configuration description: Configuration options for the Fern Python SDK. --- -# Python Configuration +You can customize the behavior of the Python SDK generator in `generators.yml`: -Discover how to configure the Fern Python SDK for your project. \ No newline at end of file +```yml {7-8} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-python + version: 0.6.6 + config: + include_validators: true +``` + +## SDK Configuration Options + + + If you want to add custom dependencies to your generated SDK, you can specify them using this configuration. For example, to add a dependency on boto3, your config would look like: + ``` + config: + extra_dependencies: + boto3: 1.28.15 + ``` + + + + + + + + + + + + + + + + + + + + + + + + + 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. + + + + + + + + + + When enabled, the generator will output a Pydantic `__root__` class that will contain utilities to visit the union. For example, for the following union type: + + ``` + types: + Shape: + union: + circle: Circle + triangle: Triangle + ``` + you will get a generated `Shape` class that has a factory and visitor: + ```python + # Use a factory to instantiate the union + Shape.factory.circle(Circle(...)) + + # Visit every case in the union + shape = get_shape() + shape.visit( + circle: lambda circle: do_something_with_circle(circle), + triangle: lambda triangle: do_something_with_triangle(triangle), + ) + ``` + + 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. + + + + By default, the generator generates pydantic models that are v1 and v2 compatible. However you can override them to: + - `v1`: strictly use Pydantic v1 + - `v2`: strictly use Pydantic v2 + - `both`: maintain compatibility with both versions + - `v1_on_v2`: use Pydantic v1 compatibility layer on v2 + + Example: + ```yaml + config: + pydantic_config: + version: v1 # or v2 or "both" + ``` + + + + + + + + + + Feature flag that improves imports in the Python SDK by removing nested `resources` directory + + + + Whether to follow redirects by default in HTTP requests. + + + + Feature flag that removes the usage of request objects, and instead uses parameters in function signatures where possible. + + + + If true, treats path parameters as named parameters in endpoint functions. + + + + Feature flag that enables generation of Python websocket clients. + + + + This changes your declared python dependency, which is not meant to be done often if at all. This is a last resort if any dependencies force you to change your version requirements. + + + + Whether or not to generate `TypedDicts` instead of Pydantic Models for request objects. + + + + 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. + + + + Whether to generate Pydantic models that implement inheritance when a model utilizes the Fern `extends` keyword. + + + + + + + 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=):` + + + + Whether or not to include legacy wire tests in the generated SDK + \ No newline at end of file From 245e249f92443949d0cac7ed62b359759d4a05cb Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Thu, 3 Jul 2025 13:52:52 -0400 Subject: [PATCH 2/3] add client example --- fern/products/sdks/overview/python/configuration.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fern/products/sdks/overview/python/configuration.mdx b/fern/products/sdks/overview/python/configuration.mdx index 01ae41f35..a51dcabee 100644 --- a/fern/products/sdks/overview/python/configuration.mdx +++ b/fern/products/sdks/overview/python/configuration.mdx @@ -5,15 +5,19 @@ description: Configuration options for the Fern Python SDK. You can customize the behavior of the Python SDK generator in `generators.yml`: -```yml {7-8} +```yaml {7-8} default-group: local groups: local: generators: - name: fernapi/fern-python - version: 0.6.6 - config: - include_validators: true + version: 0.7.1 + config: + client: null + filename: my_custom_client.py + class_name: MyClient + exported_filename: my_client.py + exported_class_name: APIClient ``` ## SDK Configuration Options From 0132b36dcde01c5db0c23c669c5ef750baa25e04 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Thu, 3 Jul 2025 15:35:47 -0400 Subject: [PATCH 3/3] fix code example --- fern/products/sdks/overview/python/configuration.mdx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fern/products/sdks/overview/python/configuration.mdx b/fern/products/sdks/overview/python/configuration.mdx index a51dcabee..1d0262e00 100644 --- a/fern/products/sdks/overview/python/configuration.mdx +++ b/fern/products/sdks/overview/python/configuration.mdx @@ -13,11 +13,8 @@ groups: - name: fernapi/fern-python version: 0.7.1 config: - client: null - filename: my_custom_client.py - class_name: MyClient - exported_filename: my_client.py - exported_class_name: APIClient + client: + class_name: `YourClient` ``` ## SDK Configuration Options