-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a spring or java code with a spec that contains an attribute with oneOf, the code generator creates a code with a bug
Spec: https://gist.github.com/wagnerrobsan/88d81d113d4add401667e64ab814e3aa
Creates the following java code:
public Fruit putBodyItem(String key, bodyItem) {
if (this.body == null) {
this.body = ;
}
this.body.put(key, bodyItem);
return this;
}
openapi-generator version
latest version, build from master
OpenAPI declaration file content or url
Providing minimal reproducing example (YAML):
Spec: https://gist.github.com/wagnerrobsan/88d81d113d4add401667e64ab814e3aa
Generation Details
see Steps to reproduce for more details
Steps to reproduce
git clone https://github.com/openapitools/openapi-generator
cd openapi-generator
mvn clean package
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://gist.githubusercontent.com/wagnerrobsan/88d81d113d4add401667e64ab814e3aa/raw/ab969d651c60e76be6b44ba69950c77b9992c108/openapi-oneOfbug.yaml \
-g spring \
-o /outputFolder/oneOfBugApiClient
Related issues/PRs
Related to
- [Feature][Java/Spring] Support Discriminator Based OneOf Interface #11650
- [BUG] [spring][server] oneOf Polymorphism support for spring boot #5381
Suggest a fix
The code generator should skip in the mustache file the putBodyItem method creation.
see file JavaSpring/pojo.mustache