OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[x] Have you provided a full/minimal spec to reproduce the issue?
[x] Have you validated the input using an OpenAPI validator (example)?
[x] What's the version of OpenAPI Generator used?
[x] Have you search for related issues/PRs?
[x] What's the actual output vs expected output?
[ ] [Optional] Bounty to sponsor the fix (example)
Description
When generating properties with a name of "=" into any of Typescript options that property disappears from generated code
Diving deeper into the code I realized its AbstractTypeScriptClientCodegen to blame and more specifically line 223 where after passing "=" to sanitizeName function, it returns an empty string. This results in the whole public String toParamName(String name) function returns empty string too, which I believe is bad behaviour.
Resulting code is invalid due to syntax issue for example:
someFunction(one: string, two: string, :string)
For pure unblocking purposes I introduced, but I believe there is a better solution to that instead
After generating please open any of the generated APIs, typescript should already highlit all the function with invalid syntax (please ignore other errors)
Suggest a fix
AbstractTypeScriptClientCodegen.toParamName should in no case result with empty string.
Internal sanitizeName call should be changed/replaced to not turn "=" into ""
I agree that "=" seems like a poor convention for naming parameters, however, it is in this case being used by https://strapi.io/
Bug Report Checklist
Description
When generating properties with a name of "=" into any of Typescript options that property disappears from generated code
Diving deeper into the code I realized its AbstractTypeScriptClientCodegen to blame and more specifically line 223 where after passing "=" to sanitizeName function, it returns an empty string. This results in the whole
public String toParamName(String name)
function returns empty string too, which I believe is bad behaviour.Resulting code is invalid due to syntax issue for example:
someFunction(one: string, two: string, :string)
For pure unblocking purposes I introduced, but I believe there is a better solution to that instead
openapi-generator version
4.2.3-SNAPSHOT (master)
OpenAPI declaration file content or url
https://gist.github.com/krizic/98db135224e4a84d07ab9ac58d91b720
Command line used for generation
java -jar openapi-generator-cli.jar generate -i full_documentation.json -g typescript-fetch -o temp java -jar openapi-generator-cli.jar generate -i full_documentation.json -g typescript-axios -o temp
Steps to reproduce
After generating please open any of the generated APIs, typescript should already highlit all the function with invalid syntax (please ignore other errors)
Suggest a fix
AbstractTypeScriptClientCodegen.toParamName should in no case result with empty string. Internal sanitizeName call should be changed/replaced to not turn "=" into ""
I agree that "=" seems like a poor convention for naming parameters, however, it is in this case being used by https://strapi.io/