Skip to content

Commit eb84217

Browse files
committed
refactor: update Axios method parameter handling
This commit includes: - Refactored the Axios method to improve parameter handling by destructuring props.
1 parent 5a6e222 commit eb84217

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
"license": "MIT",
55
"description": "Generate Axios API clients and React Query options from OpenAPI specifications",
66
"exports": "./dist/index.js",
7-
"files": [
8-
"src",
9-
"dist"
10-
],
7+
"files": ["src", "dist"],
118
"author": {
129
"name": "Oliver Winter",
1310
"email": "owinter86@gmail.com"

src/generator/clientGenerator.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
154154
.filter(Boolean)
155155
.join("\n ");
156156

157+
const requestParms = hasData
158+
? `props: ${dataType} & { axiosConfig?: AxiosRequestConfig; }`
159+
: "props?: { axiosConfig?: AxiosRequestConfig }";
160+
157161
return `
158162
${jsDocLines.join("\n ")}
159-
export async function ${camelCase(operationId)}(props: ${
160-
hasData ? `${dataType} & { axiosConfig?: AxiosRequestConfig; }` : "{ axiosConfig?: AxiosRequestConfig }"
161-
} ): Promise<${responseType}> {
163+
export async function ${camelCase(operationId)}(${requestParms}): Promise<${responseType}> {
162164
${methodBody}
163165
}`;
164166
}

0 commit comments

Comments
 (0)