From e1588db84a592b152d2ad0f01068daa0098c8328 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Thu, 3 Jul 2025 12:59:16 -0400 Subject: [PATCH 1/5] 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/5] 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/5] 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 From fb629f468d37f35c9101acf757e12bf5b1bdab23 Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Thu, 3 Jul 2025 15:51:51 -0400 Subject: [PATCH 4/5] code example nit --- fern/products/sdks/overview/python/configuration.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fern/products/sdks/overview/python/configuration.mdx b/fern/products/sdks/overview/python/configuration.mdx index 1d0262e00..ae44e9925 100644 --- a/fern/products/sdks/overview/python/configuration.mdx +++ b/fern/products/sdks/overview/python/configuration.mdx @@ -5,7 +5,7 @@ description: Configuration options for the Fern Python SDK. You can customize the behavior of the Python SDK generator in `generators.yml`: -```yaml {7-8} +```yaml {7-9} default-group: local groups: local: @@ -14,7 +14,7 @@ groups: version: 0.7.1 config: client: - class_name: `YourClient` + class_name: "YourClient" ``` ## SDK Configuration Options From 20fb6db9ab40c3c9b4c6b78cd400049478b5745c Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Fri, 4 Jul 2025 11:04:43 -0400 Subject: [PATCH 5/5] Add content to Go config page --- .../sdks/overview/go/configuration.mdx | 172 +++++++++++++++++- 1 file changed, 170 insertions(+), 2 deletions(-) diff --git a/fern/products/sdks/overview/go/configuration.mdx b/fern/products/sdks/overview/go/configuration.mdx index 2f92fa332..44f90bbe3 100644 --- a/fern/products/sdks/overview/go/configuration.mdx +++ b/fern/products/sdks/overview/go/configuration.mdx @@ -3,6 +3,174 @@ title: Go Configuration description: Configuration options for the Fern Go SDK. --- -# Go Configuration +You can customize the behavior of the Go SDK generator in `generators.yml`: -Discover how to configure the Fern Go SDK for your project. \ No newline at end of file +```yaml {7-8} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-go-sdk + version: + config: + packageName: acme + output: + location: local-file-system + path: ../generated/go +``` + +## SDK Configuration Options + + +Use this option if you plan to distribute the generated Go SDK as a separate, published Go module. + +If you only plan to use the generated SDK within your own Go module, use the `importPath` configuration option instead. + +You can generate the Go SDK code into a separate module (defined with its own `go.mod`) +with the following `generators.yml` configuration: + +```yaml {7-9} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-go-sdk + version: 0.13.0 + config: + module: + path: github.com// + output: + location: local-file-system + path: ../generated/go +``` + +This configuration will generate a `go.mod` alongside the rest of the Go SDK code at the target output +location. With this, `import` statements within the generated Go SDK are all resolved from the configured +module path. + +By default, the generated `go.mod` will be set to `1.13`. You can override this behavior by specifying +the `version` key: + +```yaml {10} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-go-sdk + version: 0.13.0 + config: + module: + path: github.com// + version: "1.19" + output: + location: local-file-system + path: ../generated/go +``` + +If you want to depend on the generated Go SDK locally (without distributing it as a separate Go module), +and you use the `module` configuration option, you will need to modify your project's top-level `go.mod` to include a [`replace`](https://go.dev/doc/modules/gomod-ref#replace) statement: + +```go +module github.com/your/module + +require "github.com/your/sdk" v0.0.0 +replace "github.com/your/sdk" v0.0.0 => "path/to/generated/sdk" +``` + + + + + + + +Use this option if you plan to depend on the generated Go SDK from within your project, and **not** depend on it as a separate, published Go module. + +If you plan to to distribute the generated Go SDK as a separate, published Go module, use the `module` configuration option instead. + +You can generate the Go SDK code into a `gen/go/api` package with the following `generators.yml` +configuration: + +```yaml {7-8} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-go-sdk + version: 0.13.0 + config: + importPath: github.com///generated/go + output: + location: local-file-system + path: ../generated/go +``` +You must update the `` and `` placeholders +with the relevant elements in your `go.mod` path. In this case, the generated Go SDK uses the same `go.mod` path used by the rest of your Go module. + + + + + + + + + + + + + +By default, it's impossible to send an explicit JSON `null` for optional parameters. `enableExplicitNull: true` opts in to generating a generic `Optional[T]` type that can be used to distinguish between a `nil` value (nothing is sent), a non-`nil` value (the value is sent), and an explicit null (a `null` value is sent). This is particularly useful for `PATCH` endpoints. + +The `Optional` and `Null` constructor functions will be included at the root of your module and can be +used like so: + +```go +client := acmeclient.NewClient() +updatedFoo, err := client.Foo.Update( + context.TODO(), + &acme.UpdateFooRequest{ + Name: acme.Optional("example"), + Tag: acme.Null[string](), + }, + // Serialized as {"name":"example","tag":null} +) +``` + +An example configuration: + +```yaml {7-8} +default-group: local +groups: + local: + generators: + - name: fernapi/fern-go-sdk + version: 0.13.0 + config: + enableExplicitNull: true + output: + location: local-file-system + path: ../generated/go +``` + +This feature requires generics, so the generated `go.mod` will be upgraded to `1.18` (as opposed to `1.13`). + + + + + + + + + + + + + + + + + + + + + +