-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
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
I used open-api generator for creating Java client. In one of the endpoint, I used oneOf which must follow polymorphism property to generate codes. It generated a OneOfBody empty interface and two classes ObjectA and ObjectB which implements OneOfBody. So ideally the endpoint's method should expect the OneOfBody parameter but it expects a Body parameter which is an empty class implementing OneOfBody. So this way, passing ObjectA OR ObjectB seems impossible.
openapi-generator version
4.3.1
OpenAPI declaration file content or url
https://gist.github.com/swarnim-sib/94a6ad4b31f63d1c6ad45b8de5961333
Generation Details
openapi-generator generate -i ~/Documents/Project/api/client/file.yml -g java -o ~/JavaClient
Steps to reproduce
- Take any yml file, for example Swagger Petstore example and add configurations mentioned here (related to oneOf)
- Run openapi-generator script mentioned above to generate Java client
- Check files,
OneOfBody.java, possiblyBody.java, and API class mentioned in above endpoint
Related issues/PRs
Suggest a fix
- If we could tell the API classes to accept
OneOfBodyparameters instead ofBodyparameters thenObjectAandObjectBcould be type casted toOneOfBodyand the API class would process the passed parameters OR - If we could define a method in
OneOfBodyinterface which could be used for typecasting betweenObjectA/ObjectBandBodythen too the API method could accept the parameter and would process it
Reactions are currently unavailable