You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Use `x-fern-parameter-name` to customize query parameter, header and path parameter naming.
3
+
description: Use extensions to customize parameter naming in your generated SDKs.
4
4
---
5
5
6
6
<Note>
7
-
The `x-fern-parameter-name` extension allows you to customize the variable names of parameters in your generated SDKs.
7
+
Extensions allow you to customize how parameters are named and handled in your generated SDKs to improve readability and usability.
8
8
</Note>
9
9
10
-
## Headers
10
+
## Header Extensions
11
11
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
+
### x-fern-parameter-name
13
+
Renames a header parameter in the generated SDK for better readability.
14
14
15
-
```yaml {8}
15
+
```yaml
16
16
paths:
17
17
"/user":
18
18
get:
19
-
operationId: list_user
20
19
parameters:
21
20
- in: header
22
-
name: X-API-Version
21
+
name: X-API-Version
23
22
x-fern-parameter-name: version
24
23
schema:
25
24
type: string
26
25
required: true
27
26
```
28
27
29
-
## Query parameters
30
-
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.
28
+
### x-fern-sdk-header
29
+
Marks a header to be provided in the SDK client constructor rather than per-request.
33
30
34
31
```yaml {8}
32
+
paths:
33
+
"/user":
34
+
get:
35
+
parameters:
36
+
- in: header
37
+
name: X-API-Key
38
+
schema:
39
+
x-fern-sdk-header: api_key
40
+
type: string
41
+
required: true
42
+
```
43
+
44
+
## Query Parameter Extensions
45
+
46
+
### x-fern-parameter-name
47
+
Renames a query parameter in the generated SDK to be more descriptive.
48
+
49
+
```yaml
35
50
paths:
36
51
"/user/search":
37
52
get:
38
-
operationId: search_user
39
53
parameters:
40
54
- in: query
41
55
name: q
@@ -45,21 +59,61 @@ paths:
45
59
required: false
46
60
```
47
61
48
-
## Path parameters
49
-
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.
62
+
### x-fern-sdk-variable
63
+
Marks a query parameter to be provided in the SDK client constructor.
52
64
53
65
```yaml {8}
66
+
paths:
67
+
"/user/search":
68
+
get:
69
+
parameters:
70
+
- in: query
71
+
name: org_id
72
+
schema:
73
+
x-fern-sdk-variable: organization_id
74
+
type: string
75
+
required: true
76
+
```
77
+
78
+
## Path Parameter Extensions
79
+
80
+
### x-fern-parameter-name
81
+
Renames a path parameter in the generated SDK for conciseness.
82
+
83
+
```yaml
54
84
paths:
55
85
"/user/{userId}":
56
86
get:
57
-
operationId: get_user
58
87
parameters:
59
88
- in: path
60
89
name: userId
61
90
x-fern-parameter-name: id
62
91
schema:
63
92
type: string
64
-
required: false
93
+
required: true
65
94
```
95
+
96
+
### x-fern-sdk-variable
97
+
Marks a path parameter to be provided in the SDK client constructor. This is useful for values that are common across many endpoints.
98
+
99
+
```yaml
100
+
paths:
101
+
"/projects/{project_id}/users":
102
+
get:
103
+
parameters:
104
+
- in: path
105
+
name: project_id
106
+
schema:
107
+
x-fern-sdk-variable: project_id
108
+
type: string
109
+
pattern: "^proj_[a-zA-Z0-9]+$"
110
+
required: true
111
+
```
112
+
113
+
<Note>
114
+
When using `x-fern-sdk-variable` or `x-fern-sdk-header`, the specified value will be provided once in the client constructor rather than needing to be passed to each individual API call.
115
+
</Note>
116
+
117
+
<Tip>
118
+
Use these extensions strategically to create a more ergonomic SDK. Consider renaming cryptic parameter names to be more descriptive, and moving commonly used values like API keys or project IDs to the client constructor.
0 commit comments