OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] Java code generator creates nonsense comparisons
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
This is meaningless nonsense:
attemptParsing |= ((Pig.class.equals(Integer.class) || Pig.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |= ((Pig.class.equals(Float.class) || Pig.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |= (Pig.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (Pig.class.equals(String.class) && token == JsonToken.VALUE_STRING);
It is impossible for code like Pig.class.equals(Integer.class) to return anything but false.
openapi-generator version
7.2.0
OpenAPI declaration file content or url
Steps to reproduce
Run the javascript generator on the petstore sample.
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 with the generated sample at samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Mammal.java around line 104 and the linked samples/client/petstore/java/native/api/openapi.yaml. Reproduce the output by running the JavaScript generator on the petstore sample, then trace the Java generator source or templates responsible for these comparisons. Done means the generated Java code no longer contains the meaningless class comparisons and the sample output remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, javascript, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100