Skip to content

Commit e298544

Browse files
committed
Update parameter-names.mdx based on issue #266
1 parent 407b095 commit e298544

File tree

1 file changed

+118
-15
lines changed

1 file changed

+118
-15
lines changed
Lines changed: 118 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
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 extension headers to customize query parameter, header and path parameter naming.
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+
These extensions allow you to customize parameter names and behavior in your generated SDKs.
88
</Note>
99

10-
## Headers
10+
## Available Extensions
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+
### x-fern-parameter-name
1413

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
1621
paths:
1722
"/user":
1823
get:
@@ -26,16 +31,15 @@ paths:
2631
required: true
2732
```
2833
29-
## Query parameters
34+
#### Query parameters
3035
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:
3337
34-
```yaml {8}
38+
```yaml
3539
paths:
3640
"/user/search":
3741
get:
38-
operationId: search_user
42+
operationId: search_user
3943
parameters:
4044
- in: query
4145
name: q
@@ -45,12 +49,11 @@ paths:
4549
required: false
4650
```
4751
48-
## Path parameters
52+
#### Path parameters
4953
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:
5255
53-
```yaml {8}
56+
```yaml
5457
paths:
5558
"/user/{userId}":
5659
get:
@@ -63,3 +66,103 @@ paths:
6366
type: string
6467
required: false
6568
```
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

Comments
 (0)