File tree 6 files changed +26
-4
lines changed
docs/src/pages/reference/configuration
6 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -1720,3 +1720,22 @@ module.exports = {
1720
1720
},
1721
1721
};
1722
1722
```
1723
+
1724
+ ### optionsParamRequired
1725
+
1726
+ Type: ` Boolean `
1727
+
1728
+ Valid Values: ` true ` or ` false ` .
1729
+
1730
+ Default Value: ` false ` .
1731
+ Use this property to make the second ` options ` parameter required (such as when using a custom axios instance)
1732
+
1733
+ ``` js
1734
+ module .exports = {
1735
+ petstore: {
1736
+ output: {
1737
+ optionsParamRequired: true ,
1738
+ },
1739
+ },
1740
+ };
1741
+ ```
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ const generateAxiosImplementation = (
140
140
141
141
return `const ${ operationName } = (\n ${ propsImplementation } \n ${
142
142
isRequestOptions && mutator . hasSecondArg
143
- ? `options? : SecondParameter<typeof ${ mutator . name } >,`
143
+ ? `options${ context . output . optionsParamRequired ? '' : '?' } : SecondParameter<typeof ${ mutator . name } >,`
144
144
: ''
145
145
} ) => {${ bodyForm }
146
146
return ${ mutator . name } <${ response . definition . success || 'unknown' } >(
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ export type NormalizedOutputOptions = {
60
60
allParamsOptional : boolean ;
61
61
urlEncodeParameters : boolean ;
62
62
unionAddMissingProperties : boolean ;
63
+ optionsParamRequired : boolean ;
63
64
} ;
64
65
65
66
export type NormalizedParamsSerializerOptions = {
@@ -182,6 +183,7 @@ export type OutputOptions = {
182
183
allParamsOptional ?: boolean ;
183
184
urlEncodeParameters ?: boolean ;
184
185
unionAddMissingProperties ?: boolean ;
186
+ optionsParamRequired ?: boolean ;
185
187
} ;
186
188
187
189
export type SwaggerParserOptions = Omit < SwaggerParser . Options , 'validate' > & {
Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ export const normalizeOptions = async (
253
253
} ,
254
254
allParamsOptional : outputOptions . allParamsOptional ?? false ,
255
255
urlEncodeParameters : outputOptions . urlEncodeParameters ?? false ,
256
+ optionsParamRequired : outputOptions . optionsParamRequired ?? false ,
256
257
} ,
257
258
hooks : options . hooks ? normalizeHooks ( options . hooks ) : { } ,
258
259
} ;
Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ const generateQueryRequestFunction = (
453
453
454
454
return (\n ${ propsImplementation } \n ${
455
455
isRequestOptions && mutator . hasSecondArg
456
- ? `options? : SecondParameter<ReturnType<typeof ${ mutator . name } >>,`
456
+ ? `options${ context . output . optionsParamRequired ? '' : '?' } : SecondParameter<ReturnType<typeof ${ mutator . name } >>,`
457
457
: ''
458
458
} ${
459
459
! isBodyVerb && hasSignal ? 'signal?: AbortSignal\n' : ''
@@ -468,7 +468,7 @@ const generateQueryRequestFunction = (
468
468
469
469
return `${ override . query . shouldExportHttpClient ? 'export ' : '' } const ${ operationName } = (\n ${ propsImplementation } \n ${
470
470
isRequestOptions && mutator . hasSecondArg
471
- ? `options? : SecondParameter<typeof ${ mutator . name } >,`
471
+ ? `options${ context . output . optionsParamRequired ? '' : '?' } : SecondParameter<typeof ${ mutator . name } >,`
472
472
: ''
473
473
} ${ ! isBodyVerb && hasSignal ? 'signal?: AbortSignal\n' : '' } ) => {
474
474
${ isVue ( outputClient ) ? vueUnRefParams ( props ) : '' }
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ const generateSwrRequestFunction = (
171
171
172
172
return `export const ${ operationName } = (\n ${ propsImplementation } \n ${
173
173
isRequestOptions && mutator . hasSecondArg
174
- ? `options? : SecondParameter<typeof ${ mutator . name } >`
174
+ ? `options${ context . output . optionsParamRequired ? '' : '?' } : SecondParameter<typeof ${ mutator . name } >`
175
175
: ''
176
176
} ) => {${ bodyForm }
177
177
return ${ mutator . name } <${ response . definition . success || 'unknown' } >(
You can’t perform that action at this time.
0 commit comments