diff --git a/fern/products/sdks/overview/python/configuration.mdx b/fern/products/sdks/overview/python/configuration.mdx index 3d9d8726a..1d0262e00 100644 --- a/fern/products/sdks/overview/python/configuration.mdx +++ b/fern/products/sdks/overview/python/configuration.mdx @@ -3,6 +3,152 @@ 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 +```yaml {7-8} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-python + version: 0.7.1 + config: + client: + class_name: `YourClient` +``` + +## 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