-
-
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] Generator incorrectly altering enum values #19204
Comments
The change was done in #18863. The description in the PR and in #4837 seems to indicate that the underscore is a better choice to follow the java naming convention. Unfortunately this was done in a minor version without even a mention in the release note. A really poor workaround is specified in the PR (enumNameMappings) |
@jpfinne Thanks for adding that context. Do you know why the other enum string i mentioned is also causing issues? |
Good question! It uses a method in StringUtils:
|
I'm having the same problem with enums containing numbers. In my case it's |
I also noticed this. I agree that the naming convention is more suitable for Java, but this change is in particular an issue if you are already using code that depends on a generated client. When you update the generator plugin, you now need to change all the code that depends on that client (assuming you even have access to that code). |
Bug Report Checklist
Description
There are 2 places where i observed this bug. One of which was with an array of
camelCase
values being changed tosnake_case
and the other with an enum value that contains a number.S4A -> S4_A but expected S4A
or
middleAgeFemale -> MIDDLE_AGE_FEMALE but expected MIDDLEAGEFEMALE
openapi-generator version
version >7.4.0. This issue does not occur in 7.4.0
OpenAPI declaration file content or url
This produces enum values S4_A, ENUM_VALUE_ONE, ENUM_VALUE_TWO, ENUM_VALUE_THREE
or
This produces enum values MIDDLE_AGE_FEMALE, MIDDLE_AGE_MALE ...
Generation Details
Java OpenAPI Generator in Spring Boot application
Steps to reproduce
S4A -> S4_A but expected S4A
or
middleAgeFemale -> MIDDLE_AGE_FEMALE but expected MIDDLEAGEFEMALE
Related issues/PRs
Suggest a fix
My work around for this was to use
x-enum-varnames
to manually fix these 2 casesThe text was updated successfully, but these errors were encountered: