-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] [JAVA] OneOf polymorphism code wasn't generated correctly #7414
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Please try the |
Hi @wing328 Actually, we use the same YAML file to generate multiple clients. And facing the same issue in C#, Python, PHP, and Nodejs wrappers too. Would you please suggest alternatives of Just for the confirmation, are you talking about including |
No oneOf support at the moment. Would you or your team be willing to sponsor the enhancement? Example Or you or your team is willing to contributing the enhancement? For C#, that's something I'm working on. No ETA For python, please try the |
Bug Report Checklist
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 aOneOfBody
empty interface and two classesObjectA
andObjectB
which implementsOneOfBody
. So ideally the endpoint's method should expect theOneOfBody
parameter but it expects aBody
parameter which is an empty class implementingOneOfBody
. So this way, passingObjectA
ORObjectB
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
OneOfBody.java
, possiblyBody.java
, and API class mentioned in above endpointRelated issues/PRs
Suggest a fix
OneOfBody
parameters instead ofBody
parameters thenObjectA
andObjectB
could be type casted toOneOfBody
and the API class would process the passed parameters OROneOfBody
interface which could be used for typecasting betweenObjectA/ObjectB
andBody
then too the API method could accept the parameter and would process itThe text was updated successfully, but these errors were encountered: