-
-
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
Java enums are not generated correctly with anyOf #798
Comments
Can you tell the generator and the library you are using? |
I am using openapi-generator maven plugin, version 3.1.2 Below is my configuration for maven plugin. [I have changed the actual package/yaml names below].
Thanks, |
As a workaround, what about using the spec below instead?
|
I am seeing similar issue for C++ enums, @wing328 will the above mentioned workaround works for C ++ as well ?? https://github.com/OpenAPITools/openapi-generator/issues/958 |
Tried removing the "anyOf" as suggested above. Get the below error
Even after skipping validating with spec, the enum class is not generated. Is there some other way around this ? Thanks, |
Is there any update on this? I'm also seeing this issue when generating a java client (maven plugin v 4.0.0-beta) |
Hi, |
similiar to #2906 , i am missing anyOf classes when i try to use openapi-generator for jaxrs-jersey generation. i want to design my API to be able to return different object types depending on the kind of input. the ability to use oneOf or anyOf will be very useful to achieve that. however, the generator is unable to generate either oneOf or anyOf classes, as a result i have to use allOf to design my API. would be very nice if this bug gets resolved. |
I have also bumped into such a spec and I wonder what kind of code is expected to be generated in this case.
into this in the general case:
If we are 100% sure that the server needs to control, exactly, the possible values of EventType, because we want to return, for example, 404 if something unkown arrives, then the replacement is, as someone has suggested:
But IMHO putting this as a bug on the code generator is not fair. If one uses oneOf, or anyOf for pure inheritance of attributes or polimorphism, as the OpenAPI spec documents, then the generator works perfectly... the problem, as I see it is that it is even problematic in human language saying something like "I want to restrict this to some possible values (enum) but I also want to leave it open for everything (String)". I a typed language, or you go for one, or for the other. So what I would suggest is to close this issue, since I've seen in too many places comments like "do this temporarily with enums until #798 is fixed"... but I wonder if it should be fixed at all. |
Using openapi-generator-maven-plugin 3.1.2
Enum is generated as a class EventType and contains only the basic equals, toString and hashCode methods. The values not not available in the class.
The text was updated successfully, but these errors were encountered: