swagger-api / swagger-api/swagger-codegen
Not All Model Classnames Properly Capitalized When ModelNamePrefix Present
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When specifying a model name prefix in a custom codegen class, some of the generated classes do not have proper capitalization of the original class name. For instance a model name of "account" and a model name prefix of "generated" will produce a class named "Generatedaccount" in file "Generatedaccount.java" when they should be named "GeneratedAccount" and "GeneratedAccount.java", respectively.
Swagger-codegen version
Using 2.2.1
Custom Swagger Codegen Class
import io.swagger.codegen.languages.JavaClientCodegen;
/**
* Custom Java codegen class
*/
public class JavaUapiCodegen extends JavaClientCodegen {
public JavaUapiCodegen() {
super();
setModelNamePrefix("generated");
}
}
Suggest a Fix
In class DefaultCodegen.java:
public String toModelName(final String name) {
return initialCaps(modelNamePrefix)
+ initialCaps(name) + modelNameSuffix;
}
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 DefaultCodegen.java and inspect the toModelName method described in the issue, along with how modelNamePrefix and the original model name are capitalized. Done means a prefix of "generated" and model name "account" produce GeneratedAccount and GeneratedAccount.java rather than Generatedaccount.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100