Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions fern/products/openapi-def/openapi-def.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ navigation:
- page: Authentication
path: ./pages/auth.mdx
- page: Servers
path: ./pages/servers.mdx
path: ./pages/servers.mdx
- section: Endpoints
slug: endpoints
contents:
Expand All @@ -17,6 +17,9 @@ navigation:
- page: Server-Sent Events
path: ./pages/endpoints/sse.mdx
slug: sse
- page: others
title: Other
path: ./pages/extensions/others.mdx
- section: Extensions
slug: extensions
contents:
Expand All @@ -38,7 +41,7 @@ navigation:
- page: Overlay Customizations
path: ./pages/overrides.mdx
- page: Sync your OpenAPI Specification
path: ./pages/automation.mdx
path: ./pages/automation.mdx
- section: Integrate your Server Framework
slug: frameworks
contents:
Expand Down
91 changes: 91 additions & 0 deletions fern/products/openapi-definition/pages/extensions/others.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# OpenAPI Extension Headers

The following extension headers are supported in Fern's OpenAPI implementation:

## x-fern-sdk-variables

Allows defining reusable variables that can be referenced across SDK operations. Variables defined here will be available as client constructor parameters.

```yaml
x-fern-sdk-variables:
project_id:
type: string
description: "The project ID"
pattern: "^proj_[a-zA-Z0-9]+$"
```

Variables can then be referenced in path parameters using `x-fern-sdk-variable`:

```yaml
paths:
/v1/projects/{project_id}/users:
parameters:
- name: project_id
in: path
required: true
schema:
type: string
x-fern-sdk-variable: project_id
```

This allows SDK users to provide the variable once during client initialization rather than for each API call.

## x-fern-sdk-group-name

Groups related operations together in the generated SDK. Operations with the same group name will be organized under a common namespace/class.

```yaml
paths:
/users:
get:
x-fern-sdk-group-name: users
```

## x-fern-sdk-method-name

Customizes the method name for an operation in the generated SDK.

```yaml
paths:
/users:
get:
x-fern-sdk-method-name: list
```

## x-fern-ignore

Excludes an operation from the generated SDK when set to `true`.

```yaml
paths:
/internal/metrics:
get:
x-fern-ignore: true
```

## x-fern-pagination

Configures pagination behavior for list operations. Requires specifying cursor and results fields.

```yaml
paths:
/users:
get:
x-fern-pagination:
cursor: "$request.after"
next_cursor: "$response.page_info.end_cursor"
results: "$response.data"
```

## x-fern-sdk-return-value

Specifies which part of the response should be returned from SDK methods.

```yaml
paths:
/users/{id}:
get:
x-fern-sdk-return-value: data
```

For complete OpenAPI examples using these extensions, see the [OpenAPI Quick Start guide](/openapi-definition/quickstart).
43 changes: 32 additions & 11 deletions fern/products/sdks/overview/python/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ groups:
## SDK Configuration Options

<ParamField path="additional_init_exports" type="array" default="null" required={false} toc={true}>
Additional items to export in the package's __init__.py file.
</ParamField>

<ParamField path="default_bytes_stream_chunk_size" type="number" default="null" required={false} toc={true}>
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>):`
</ParamField>

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

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

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

<ParamField path="extras" type="object" default="{}" required={false} toc={true}>
Optional package extras/features to include in setup.py.
</ParamField>

<ParamField path="flat_layout" type="bool" default="false" required={false} toc={true}>
When enabled, generates a flatter package structure without nested directories.
</ParamField>

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

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

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

<ParamField path="include_union_utils" type="bool" default="false" required={false} toc={true}>
When enabled, generates additional utilities for union types.
</ParamField>

<ParamField path="inline_path_params" type="bool" default="false" required={false} toc={true}>
Expand All @@ -72,12 +78,9 @@ groups:
</ParamField>

<ParamField path="package_name" type="string" default="null" required={false} toc={true}>

Specifies the Python package name that users will import your generated client
from.
Specifies the Python package name that users will import your generated client from.

For example, setting `package_name: "my_custom_package"` enables users to use
`my_custom_package import Client` to import your client:
For example, setting `package_name: "my_custom_package"` enables users to use `from my_custom_package import Client` to import your client:

```yaml {7-10}
default-group: local
Expand All @@ -92,6 +95,7 @@ groups:
</ParamField>

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

<ParamField path="pydantic_config.include_union_utils" type="bool" default="false" required={false} toc={true}>
Expand All @@ -112,12 +116,10 @@ groups:
# 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),
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.
</ParamField>

<ParamField path="pydantic_config.version" type="'v1' | 'v2' | 'both' | 'v1_on_v2'" default="both" required={false} toc={true}>
Expand All @@ -140,20 +142,39 @@ groups:
</ParamField>

<ParamField path="pyproject_toml" type="string" default="null" required={false} toc={true}>
Custom pyproject.toml content to include in the generated package.
</ParamField>

<ParamField path="sdk_variables" type="object" default="{}" required={false} toc={true}>
Variables that can be set once when instantiating the client and used across multiple requests. For OpenAPI specs, these are defined using the `x-fern-sdk-variables` extension. Example:

```yaml
x-fern-sdk-variables:
project_id:
type: string
description: The project ID to use for all requests
```

This allows setting the variable once when creating the client:
```python
client = Client(project_id="proj_123")
```
</ParamField>

<ParamField path="should_generate_websocket_clients" type="bool" default="false" required={false} toc={true}>
Feature flag that enables generation of Python websocket clients.
</ParamField>

<ParamField path="skip_formatting" type="bool" default="false" required={false} toc={true}>
When true, skips code formatting of the generated SDK.
</ParamField>

<ParamField path="timeout_in_seconds" type="number | 'infinity'" default="60" required={false} toc={true}>
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.
</ParamField>

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

<ParamField path="use_inheritance_for_extended_models" type="bool" default="true" required={false} toc={true}>
Expand Down
Loading
Loading