-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Description
Description
The typescript-axios generator outputs an incorrect type check for serialization.
Current output:
const needsSerialization = (<any>"Pet" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
Expected output:
const needsSerialization = (typeof body !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
The issue is <any>"Pet" !== "string" will always evaluate to true, as it's comparing a string value to a string value.
What the correct logic should be is: typeof body !== "string", which checks the body object is not a string in order to run serialization.
openapi-generator version
4.1.2
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Generate any api output using the typescript-axios generator.
Related issues/PRs
N/A
Suggest a fix/enhancement
In src/main/resources/typescript-axios/apiInner.mustache, replace
const needsSerialization = (<any>"{{dataType}}" !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
With:
const needsSerialization = (typeof {{paramName}} !== "string") || localVarRequestOptions.headers['Content-Type'] === 'application/json';
This also matches the current flow generator template.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels