swagger-api / swagger-api/swagger-codegen
Various variable name escape issues
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Using the code search engine in, lgtm.com various toVarName or toParamName methods does not seem to have properly escaped special characters:
https://lgtm.com/query/2023430003/project:12070014/lang:java/
The above shows methods toVarName and toParamName that do not call sanitizeName. Not all of these are problematic, as special characters may have been escaped in another way, but some of them needs fixing. In particular, in the case of c++, this can lead to uncompilable code.
Swagger-codegen version
master branch: cbd7301
Swagger declaration file content or url
e.g. For cpp.
Command line used for generation
Steps to reproduce
java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l cpprest -i cpp.yaml -o ./test
Suggest a Fix
I will create a PR for the c++ case, but perhaps others can take a look at the other languages to see if it is ok. Once a method is found to be correct, I can update the query to exclude it (or others can take a look at the docs https://lgtm.com/docs/ql/primer/ql-primer). Once everything is either fixed or excluded, we can close the issue.
Note: The link posted to the query result is cached for the commit cbd7301 and will require updating from time to time. To do so, copy the content of the query console on the page, enter swagger-api/swagger-codegen in the search box, then click 'Query this project' on the right, paste back the content to the console and click run once it is compiled.
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
Search the language generators for toVarName and toParamName methods, then compare their handling with sanitizeName. Start by reproducing the cpprest generation command with cpp.yaml; done means every affected method is fixed or intentionally excluded and generated C++ no longer contains uncompilable escaped names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100