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.
Description
The typescript-axios generator outputs an incorrect type check for serialization.
Current output:
Expected output:
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-axiosgenerator.Related issues/PRs
N/A
Suggest a fix/enhancement
In src/main/resources/typescript-axios/apiInner.mustache, replace
With:
This also matches the current
flowgenerator template.