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
79 changes: 79 additions & 0 deletions fern/products/openapi-definition/pages/extensions/others.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: 'Other OpenAPI Extensions'
description: 'Reference of Fern-supported OpenAPI extensions'
---

# Fern OpenAPI Extensions

Below is a comprehensive list of all OpenAPI extensions supported by Fern:

## x-fern-sdk-variables

Defines variables that can be passed into SDK client constructors. Variables defined here can be referenced in operation paths.

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

## x-fern-sdk-group-name

Groups operations together in generated SDKs under a common namespace/class.

```yaml
x-fern-sdk-group-name: accounts
```

## x-fern-sdk-method-name

Specifies the method name to use in generated SDKs.

```yaml
x-fern-sdk-method-name: retrieve
```

## x-fern-sdk-return-value

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

```yaml
x-fern-sdk-return-value: data
```

## x-fern-pagination

Configures pagination for list endpoints.

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

## x-fern-ignore

Excludes an operation from SDK generation.

```yaml
x-fern-ignore: true
```

## x-fern-sdk-variable

References a variable defined in x-fern-sdk-variables.

```yaml
x-fern-sdk-variable: project_id
```

<Note>
All extensions are optional. Only include the ones needed for your specific use case.
</Note>

<Warning>
Extensions must be properly formatted according to OpenAPI specification rules. Invalid extension formatting may cause SDK generation to fail.
</Warning>
30 changes: 26 additions & 4 deletions fern/products/sdks/overview/python/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,30 @@ groups:
config:
package_name: "your_package"
client:
class_name: "YourClient"
class_name: "YourClient"
```

## Extension Headers

You can configure SDK variables in your OpenAPI spec using the `x-fern-sdk-variables` extension. These variables will be injected into the SDK client constructor.

For example, to add a `project_id` variable that gets automatically injected into path parameters:

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

The variable will be available in the client constructor:

```python
from my_package import Client

client = Client(project_id="proj_123")
```

## SDK Configuration Options
Expand Down Expand Up @@ -72,7 +95,6 @@ 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.

Expand Down Expand Up @@ -112,8 +134,8 @@ 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),
)
```

Expand Down
Loading