@@ -115,6 +115,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
115
115
const urlWithParams = urlParams . length > 0 ? `\`${ path . replace ( / { ( \w + ) } / g, "${data.$1}" ) } \`` : `"${ path } "` ;
116
116
117
117
const methodBody = [
118
+ `${ hasData ? "const { axiosConfig, ...data } = props || {};" : "const { axiosConfig } = props || {};" } ` ,
118
119
"const apiClient = getApiClient();" ,
119
120
`const url = ${ urlWithParams } ;` ,
120
121
queryParams . length > 0
@@ -146,7 +147,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
146
147
`const res = await apiClient.${ method } <${ responseType } >(url, {
147
148
${ queryParams . length > 0 ? "params: queryData," : "" }
148
149
${ requestBody ? `data: ${ isFormData ? "formData" : "bodyData" } ,` : "" }
149
- ${ isFormData ? `config: { headers: { 'Content-Type': 'multipart/form-data', ...config ?.headers }, ...config },` : "...config " }
150
+ ${ isFormData ? `config: { headers: { 'Content-Type': 'multipart/form-data', ...axiosConfig ?.headers }, ...axiosConfig },` : "...axiosConfig " }
150
151
});
151
152
return res.data;` ,
152
153
]
@@ -155,7 +156,9 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
155
156
156
157
return `
157
158
${ jsDocLines . join ( "\n " ) }
158
- export async function ${ camelCase ( operationId ) } (data${ hasData ? `: ${ dataType } ` : "?: undefined" } , config?: AxiosRequestConfig): Promise<${ responseType } > {
159
+ export async function ${ camelCase ( operationId ) } (props: ${
160
+ hasData ? `${ dataType } & { axiosConfig?: AxiosRequestConfig; }` : "{ axiosConfig?: AxiosRequestConfig }"
161
+ } ): Promise<${ responseType } > {
159
162
${ methodBody }
160
163
}` ;
161
164
}
0 commit comments