Open schnabel opened 7 years ago
It is probably better to apply the patch in AbstractJavaCodegen toVarName(String) to avoid side effects in other generators.
@schnabel I wonder if you've time to contribute a PR so that we can review the fix.
@wing328 Yes, I can contribute a PR. There is another Problem with "all upper case properties" like URL or ATT_NAME. Do you need another issue for that?
Ideally we prefer a separate issue for tracking purpose (if it's not too much work to open one)
No that's ok. I can do that tomorrow. Do you want PRs on a fork?
Yes, please fork this repo and create a branch for the change.
If the swagger declaration contains properties with names starting with two uppercase letters, the generated java code is not java bean conform. As a result jackson maps the properties twice.
Jackson maps the property twice because the @JsonProperty annotation is set on the property attribute. If the annotation is moved to the property setter, there is only one mapping (in other words, this is a mustache problem).
Description
If the swagger declaration contains properties with names starting with two uppercase letters, the generated java code is not java bean conform. As a result jackson maps the properties twice. See: http://futuretask.blogspot.de/2005/01/java-tip-6-dont-capitalize-first-two.html
Swagger-codegen version
Tested with 2.2.1 and 2.2.2-SNAPSHOT
Swagger declaration file content or url
generated java code:
jackson serialization result:
Command line used for generation
swagger-codegen-maven-plugin
Steps to reproduce
Build a jaxrs or spring server. Implement controller to return Pet array. Or use jackson mapper and serialize with the generated Pet model code.
Related issues
https://github.com/swagger-api/swagger-codegen/issues/445
Suggest a Fix
DefaultCodegen.java: