Skip to content

Commit 7dc503c

Browse files
committed
fix: refine Axios method generation for conditional body data handling
This commit updates the Axios method generation logic to conditionally use 'bodyData' or 'data' based on the presence of properties in either formDataSchema or requestBodySchema. This change enhances the flexibility and correctness of the generated API client methods.
1 parent b35b08d commit 7dc503c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/generator/clientGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
137137
? "axiosConfig.headers = { ...axiosConfig.headers, 'Content-Type': 'multipart/form-data' };"
138138
: "",
139139
requestBody
140-
? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties ? "bodyData" : "data"}, axiosConfig);`
140+
? `const res = await apiClient.${method}<${responseType}>(url, ${formDataSchema?.properties || requestBodySchema?.properties ? "bodyData" : "data"}, axiosConfig);`
141141
: `const res = await apiClient.${method}<${responseType}>(url, axiosConfig);`,
142142
"return res.data;",
143143
]

0 commit comments

Comments
 (0)