Skip to content

Commit 13085c5

Browse files
committed
feat: update parameter typing in Axios method generation
This commit modifies the Axios method generation to use a more specific parameter type, replacing `dataType` with `pascalCase(operationId)Params`. Additionally, it exports the new parameter type when data is present, enhancing type safety and clarity in generated code.
1 parent ee190fe commit 13085c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/generator/clientGenerator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ function generateAxiosMethod(operation: OperationInfo, spec: OpenAPIV3.Document)
167167
.join("\n ");
168168

169169
const requestParms = hasData
170-
? `props: ${dataType} & { axiosConfig?: AxiosRequestConfig; }`
170+
? `props: ${pascalCase(operationId)}Params & { axiosConfig?: AxiosRequestConfig; }`
171171
: "props?: { axiosConfig?: AxiosRequestConfig }";
172172

173173
return `
174+
${hasData ? `export type ${pascalCase(operationId)}Params = ${dataType};` : ""}
174175
${jsDocLines.join("\n ")}
175176
export async function ${camelCase(operationId)}(${requestParms}): Promise<${responseType}> {
176177
${methodBody}

0 commit comments

Comments
 (0)