Skip to content

Commit 64ccd45

Browse files
committed
Update parameter-names.mdx based on issue #266
1 parent 77c93b8 commit 64ccd45

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

fern/products/openapi-def/pages/extensions/parameter-names.mdx

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
---
22
title: Customize parameter names
3-
description: Use `x-fern-parameter-name` to customize query parameter, header and path parameter naming.
3+
description: Use Fern's parameter extensions to customize naming and behavior of parameters in your OpenAPI definition.
44
---
55

66
<Note>
7-
The `x-fern-parameter-name` extension allows you to customize the variable names of parameters in your generated SDKs.
7+
Fern provides several extensions that let you customize how parameters are handled in your OpenAPI definition and generated SDKs.
88
</Note>
99

10-
## Headers
10+
## x-fern-parameter-name
1111

12-
In the example below, the header `X-API-Version` is renamed to `version` in the
13-
generated SDK. The rename makes the SDK more human readable.
12+
The `x-fern-parameter-name` extension allows you to customize the variable names of parameters in your generated SDKs.
13+
14+
### Headers
15+
16+
In the example below, the header `X-API-Version` is renamed to `version` in the generated SDK. The rename makes the SDK more human readable.
1417

1518
```yaml {8}
1619
paths:
@@ -26,10 +29,9 @@ paths:
2629
required: true
2730
```
2831
29-
## Query parameters
32+
### Query parameters
3033
31-
In the example below, the query parameter `q` is renamed to `search_terms` in the
32-
generated SDK. The rename makes the parameter more approachable for end users.
34+
In the example below, the query parameter `q` is renamed to `search_terms` in the generated SDK. The rename makes the parameter more approachable for end users.
3335

3436
```yaml {8}
3537
paths:
@@ -45,10 +47,9 @@ paths:
4547
required: false
4648
```
4749

48-
## Path parameters
50+
### Path parameters
4951

50-
In the example below, the path parameter `userId` is renamed to `id` in the
51-
generated SDK. The rename makes the SDK less verbose.
52+
In the example below, the path parameter `userId` is renamed to `id` in the generated SDK. The rename makes the SDK less verbose.
5253

5354
```yaml {8}
5455
paths:
@@ -63,3 +64,41 @@ paths:
6364
type: string
6465
required: false
6566
```
67+
68+
## x-fern-sdk-variables
69+
70+
The `x-fern-sdk-variables` extension allows you to define variables that will be injected into paths when making requests. These variables can be provided once during client initialization rather than passing them with every request.
71+
72+
For example, to automatically inject a project ID into all paths:
73+
74+
```yaml
75+
components:
76+
x-fern-sdk-variables:
77+
project_id:
78+
type: string
79+
description: "The ID of the project"
80+
pattern: "^proj_[a-zA-Z0-9]+$"
81+
82+
paths:
83+
"/v1/connect/{project_id}/accounts":
84+
parameters:
85+
- name: project_id
86+
in: path
87+
required: true
88+
schema:
89+
type: string
90+
pattern: "^proj_[a-zA-Z0-9]+$"
91+
x-fern-sdk-variable: project_id
92+
```
93+
94+
When using the generated SDK, the `project_id` can be provided once during client initialization:
95+
96+
```python
97+
client = Client(project_id="proj_123")
98+
```
99+
100+
And it will automatically be injected into all paths that reference it.
101+
102+
<Note>
103+
The `x-fern-sdk-variables` extension is currently supported in Python (version 4.24.0+) and TypeScript SDKs.
104+
</Note>

0 commit comments

Comments
 (0)