-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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][Spring] code generation fails if oneOf discriminator is enum #19194
Comments
bye the way: when removing the enum from TonsUnitEnum everything works fine. So with: TonsUnitEnum:
type: string code compiles perfectly |
But does the data type on your concrete class become a String after removing the enum from TonsUnitEnum? This is what happens for me - which is not ideal... |
Yes it becomes a string - which is (as you already mentioned) not ideal. I would like it to be an enum. I figured out a workaround using a regex pattern (see example with KILOGRAMS) - but this is also not ideal:
Below is an even better example why i would like to use an enum. TONS and KILOGRAMS both include cargoGeneralParameter with an allOf. And cargoGeneralParameter has the unit discrimitator which should either be "TONS " or "KILOGRAMS " - that's why an enum would be much better than a string:
|
Hey did anyone find a fix for this without needing regex? |
Bug Report Checklist
Description
I want to limit the possible entries for the discriminator using oneOf. Therefore i want to set the discriminator as enum (See OpenAPI declaration file) below.
The openapi-generator-maven-plugin says:
[WARNING] 'cargoParent' defines discriminator 'unit', but the referenced schema 'TONS' is incorrect. invalid type for unit, set it to string
and the code finally fails to compile.
The Problem is that the generator creates the method
in the TONS.java class. But the CargoParents requires a method returning String:
openapi-generator version
openapi-generator-maven-plugin 7.7.0
OpenAPI declaration file content or url
Related issues/PRs
#12412
The text was updated successfully, but these errors were encountered: