File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed
docs/src/pages/reference/configuration Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -2430,6 +2430,8 @@ export function handleDates(body: any) {
2430
2430
}
2431
2431
```
2432
2432
2433
+ ** Note:** If you are using the fetch client and useDates is set to true, query parameters of type Date will be stringified using toISOString()
2434
+
2433
2435
#### useBigInt
2434
2436
2435
2437
Type: ` Boolean `
Original file line number Diff line number Diff line change @@ -73,13 +73,22 @@ export const generateRequestFunction = (
73
73
74
74
return schema . name ;
75
75
} ) ;
76
+ const hasDateParams =
77
+ context . output . override . useDates &&
78
+ parameters . some (
79
+ ( p ) =>
80
+ 'schema' in p &&
81
+ p . schema &&
82
+ 'format' in p . schema &&
83
+ p . schema . format === 'date-time' ,
84
+ ) ;
76
85
77
86
const explodeArrayImplementation =
78
87
explodeParameters . length > 0
79
88
? `const explodeParameters = ${ JSON . stringify ( explodeParametersNames ) } ;
80
89
81
90
if (Array.isArray(value) && explodeParameters.includes(key)) {
82
- value.forEach((v) => normalizedParams.append(key, v === null ? 'null' : v.toString()));
91
+ value.forEach((v) => normalizedParams.append(key, v === null ? 'null' : ${ hasDateParams ? 'v instanceof Date ? v.toISOString() : ' : '' } v.toString()));
83
92
return;
84
93
}
85
94
`
@@ -89,7 +98,7 @@ export const generateRequestFunction = (
89
98
explodeParameters . length === parameters . length ;
90
99
91
100
const nomalParamsImplementation = `if (value !== undefined) {
92
- normalizedParams.append(key, value === null ? 'null' : value.toString())
101
+ normalizedParams.append(key, value === null ? 'null' : ${ hasDateParams ? 'value instanceof Date ? value.toISOString() : ' : '' } value.toString())
93
102
}` ;
94
103
95
104
const getUrlFnImplementation = `export const ${ getUrlFnName } = (${ getUrlFnProps } ) => {
Original file line number Diff line number Diff line change @@ -243,4 +243,18 @@ export default defineConfig({
243
243
target : '../specifications/petstore.yaml' ,
244
244
} ,
245
245
} ,
246
+ dateParams : {
247
+ output : {
248
+ target : '../generated/fetch/dateParams/endpoints.ts' ,
249
+ schemas : '../generated/fetch/dateParams/model' ,
250
+ client : 'fetch' ,
251
+ mode : 'tags-split' ,
252
+ override : {
253
+ useDates : true ,
254
+ } ,
255
+ } ,
256
+ input : {
257
+ target : '../specifications/parameters.yaml' ,
258
+ } ,
259
+ } ,
246
260
} ) ;
Original file line number Diff line number Diff line change @@ -120,6 +120,15 @@ paths:
120
120
required : false
121
121
schema :
122
122
type : string
123
+ - name : latestBirthdate
124
+ in : query
125
+ description : |
126
+ Filter by latest birthdate.
127
+ Example: 2020-01-01T00:00:00Z
128
+ required : false
129
+ schema :
130
+ type : string
131
+ format : date-time
123
132
responses :
124
133
' 200 ' :
125
134
description : A paged array of pets
You can’t perform that action at this time.
0 commit comments