OpenAPITools / OpenAPITools/openapi-generator
AbstractTypeScriptClientCodegen.java@223 returns empty string in case name = "="
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- 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
if ("=".equals(name)) {
name = "equals";
}
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/

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in AbstractTypeScriptClientCodegen.java around line 223, then trace toParamName and its sanitizeName call. Reproduce with the provided OpenAPI declaration and the typescript-fetch or typescript-axios generation commands. Done means a property named "=" no longer disappears and the generated TypeScript has no empty parameter name or resulting syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100