Default values

View as MarkdownOpen in Claude

The x-fern-default extension lets you specify a client-side default value for a path, header, or query parameter, including headers defined under x-fern-global-headers. When present, the generated SDK makes the parameter optional and automatically sends the default value if the caller omits it. x-fern-default supports string and boolean values; other types (such as numbers) are ignored.

This is useful for pinning an API version header or a region path parameter while still allowing callers to override the value.

Supported languages

x-fern-default is supported for TypeScript, Python, Go, Java, C#, PHP, and Ruby SDKs.

Path parameters

In the example below, the SDK sends us-east-1 for region when the caller doesn’t specify one.

openapi.yml
1paths:
2 /regions/{region}/resources:
3 get:
4 operationId: list_resources
5 parameters:
6 - name: region
7 in: path
8 required: true
9 x-fern-default: "us-east-1"
10 schema:
11 type: string

Headers

In the example below, the SDK sends 2024-02-08 for X-API-Version when the caller doesn’t specify one.

openapi.yml
1paths:
2 /users:
3 get:
4 operationId: list_users
5 parameters:
6 - name: X-API-Version
7 in: header
8 x-fern-default: "2024-02-08"
9 schema:
10 type: string

Query parameters

In the example below, the SDK sends false for verbose when the caller doesn’t specify one.

openapi.yml
1paths:
2 /search:
3 get:
4 operationId: search
5 parameters:
6 - name: verbose
7 in: query
8 x-fern-default: false
9 schema:
10 type: boolean

Global headers

In the example below, the SDK sends 2024-02-08 for the X-API-Version global header when the caller doesn’t specify one.

openapi.yml
1x-fern-global-headers:
2 - header: X-API-Version
3 name: version
4 x-fern-default: "2024-02-08"