-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[REQ][JAVA] oneOf discriminator type string with enum defined #12412
Comments
Regarding this, the generator also generates code which is syntactically incorrect(the implmenting method inside the classes want to return an enum and the interface method wants to return a String, hence the clash). |
Are there is a chance that this issue will be solved? |
Any plan on fixing this? Or an workaround that allows enums to be used? |
There is still a problem when modelNamePrefix and/or modelNameSuffix is used. The prefix and suffix is currently not considered |
Hi there, does anyone know if this issue is actually closed ? |
Hey,
It looks like this task should not be closed or we have some regression bug. The version I'm using is 7.1.0. |
You have to make sure you are defining the enum correctly (as component) and use it as type (add it as property). This works for me on version 7.5.0 where the type is correctly generated (enum instead of string). Here a minimal example (should maybe be added to docs as well):
|
Description
Using version 6 beta, oneOf is working well, generating POJOs. We get the interface with
public String getType();
and the impl classes. The type we want to use had previously been defined as a string/enum, so it would be nice if we could define teh discriminator string to also be an enum.openapi-generator version
6.0.0-beta
OpenAPI declaration file content or url
Our discriminator is setup like this.
The A object adds the type property, referencing the string with enum above.
If we remove the enum part, everything generates properly and works with type as a String object. Seeing that the mapping is essentially an enum itself, it would be nice, if the above would work, generating
public Type getType();
in the interface. (It already generates nicely with enum in the implementing classes.)Command line used for generation
Maven plugin,
<openapi.generator.maven.plugin.templateResourcePath>JavaSpring</openapi.generator.maven.plugin.templateResourcePath>
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
The text was updated successfully, but these errors were encountered: