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 extension headers to customize query parameter, header and path parameter naming.
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
+
These extensions allow you to customize parameter names and behavior in your generated SDKs.
8
8
</Note>
9
9
10
-
## Headers
10
+
## Available 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
14
13
15
-
```yaml {8}
14
+
Customize the variable names of parameters in your generated SDKs.
15
+
16
+
#### Headers
17
+
18
+
In the example below, the header `X-API-Version` is renamed to `version` in the generated SDK for better readability:
19
+
20
+
```yaml
16
21
paths:
17
22
"/user":
18
23
get:
@@ -26,16 +31,15 @@ paths:
26
31
required: true
27
32
```
28
33
29
-
## Query parameters
34
+
#### Query parameters
30
35
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.
36
+
Rename query parameters to be more descriptive in the SDK:
33
37
34
-
```yaml {8}
38
+
```yaml
35
39
paths:
36
40
"/user/search":
37
41
get:
38
-
operationId: search_user
42
+
operationId: search_user
39
43
parameters:
40
44
- in: query
41
45
name: q
@@ -45,12 +49,11 @@ paths:
45
49
required: false
46
50
```
47
51
48
-
## Path parameters
52
+
#### Path parameters
49
53
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.
54
+
Make path parameter names more concise in the SDK:
52
55
53
-
```yaml {8}
56
+
```yaml
54
57
paths:
55
58
"/user/{userId}":
56
59
get:
@@ -63,3 +66,103 @@ paths:
63
66
type: string
64
67
required: false
65
68
```
69
+
70
+
### x-fern-sdk-variables
71
+
72
+
Define variables that can be provided when instantiating the SDK client. This allows setting values that will be automatically injected into API paths.
73
+
74
+
Example defining a project ID variable:
75
+
76
+
```yaml
77
+
x-fern-sdk-variables:
78
+
project_id:
79
+
type: string
80
+
description: "The ID of the project"
81
+
pattern: "^proj_[a-zA-Z0-9]+$"
82
+
```
83
+
84
+
Then use the variable in paths:
85
+
86
+
```yaml
87
+
paths:
88
+
"/v1/connect/{project_id}/accounts":
89
+
parameters:
90
+
- name: project_id
91
+
in: path
92
+
required: true
93
+
schema:
94
+
type: string
95
+
x-fern-sdk-variable: project_id
96
+
```
97
+
98
+
The SDK will automatically inject the project ID value provided during client instantiation into the path.
99
+
100
+
<Note>
101
+
The variable pattern allows validating the format of values at runtime.
102
+
</Note>
103
+
104
+
### x-fern-sdk-method-name
105
+
106
+
Customize the generated method name in the SDK:
107
+
108
+
```yaml
109
+
paths:
110
+
"/users":
111
+
get:
112
+
operationId: list_users
113
+
x-fern-sdk-method-name: getUsers
114
+
```
115
+
116
+
### x-fern-sdk-group-name
117
+
118
+
Group related endpoints under a namespace in the SDK:
119
+
120
+
```yaml
121
+
paths:
122
+
"/users":
123
+
get:
124
+
operationId: list_users
125
+
x-fern-sdk-group-name: users
126
+
```
127
+
128
+
### x-fern-ignore
129
+
130
+
Exclude an endpoint from SDK generation:
131
+
132
+
```yaml
133
+
paths:
134
+
"/internal/metrics":
135
+
get:
136
+
x-fern-ignore: true
137
+
```
138
+
139
+
<Note>
140
+
Use x-fern-ignore sparingly and only for endpoints that should not be exposed in SDKs.
141
+
</Note>
142
+
143
+
### x-fern-sdk-return-value
144
+
145
+
Specify what part of the response should be returned:
146
+
147
+
```yaml
148
+
paths:
149
+
"/users/{id}":
150
+
get:
151
+
x-fern-sdk-return-value: data
152
+
```
153
+
154
+
### x-fern-pagination
155
+
156
+
Configure pagination behavior for list endpoints:
157
+
158
+
```yaml
159
+
paths:
160
+
"/users":
161
+
get:
162
+
x-fern-pagination:
163
+
cursor: "$request.after"
164
+
next_cursor: "$response.page_info.end_cursor"
165
+
results: "$response.data"
166
+
```
167
+
168
+
This configures how pagination fields map between requests and responses.
0 commit comments