11---
22title : Customize parameter names
3- description : Use `x-fern-parameter-name` to customize query parameter, header and path parameter naming .
3+ description : Use extensions to customize parameter naming and behavior in your generated SDKs .
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+ OpenAPI extensions allow you to customize how parameters are handled in your generated SDKs.
88</Note >
99
10- ## Headers
10+ ## Renaming Parameters
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+ Use ` x-fern-parameter-name ` to customize the variable names of parameters in your generated SDKs:
15+
16+ #### Headers
17+
18+ Rename header parameters to make them more readable:
19+
20+ ``` yaml
1621paths :
1722 " /user " :
1823 get :
@@ -26,12 +31,11 @@ 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+ Make query parameter names more descriptive:
3337
34- ` ` ` yaml {8}
38+ ` ` ` yaml
3539paths :
3640 " /user/search " :
3741 get :
@@ -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+ Simplify path parameter names:
5255
53- ` ` ` yaml {8}
56+ ` ` ` yaml
5457paths :
5558 " /user/{userId} " :
5659 get :
@@ -63,3 +66,46 @@ paths:
6366 type : string
6467 required : false
6568` ` `
69+
70+ ## SDK Variables
71+
72+ ### x-fern-sdk-variables
73+
74+ Use ` x-fern-sdk-variables` to define variables that can be set at the SDK client level and injected into requests:
75+
76+ ` ` ` yaml
77+ components:
78+ x-fern-sdk-variables:
79+ project_id:
80+ type: string
81+ description: "The project ID to use for all requests"
82+ pattern: "^proj_[a-zA-Z0-9]+$"
83+
84+ paths:
85+ "/v1/connect/{project_id}/accounts":
86+ parameters:
87+ - name: project_id
88+ in: path
89+ required: true
90+ schema:
91+ type: string
92+ pattern: "^proj_[a-zA-Z0-9]+$"
93+ x-fern-sdk-variable: project_id
94+ ` ` `
95+
96+ This allows users to set the variable once when instantiating the client :
97+
98+ ` ` ` python
99+ client = Client(project_id="proj_123")
100+ ` ` `
101+
102+ Rather than passing it to every method :
103+
104+ ` ` ` python
105+ # No need to pass project_id to each call
106+ accounts = client.accounts.list()
107+ ` ` `
108+
109+ <Note>
110+ SDK variables help reduce repetition and make your SDK more ergonomic by allowing common parameters to be configured once at the client level.
111+ </Note>
0 commit comments