Skip to content
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] Incorrect ENUM generation #19066

Open
4 of 6 tasks
Noed opened this issue Jul 3, 2024 · 3 comments
Open
4 of 6 tasks

[BUG] Incorrect ENUM generation #19066

Noed opened this issue Jul 3, 2024 · 3 comments

Comments

@Noed
Copy link

Noed commented Jul 3, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

ENUM is being generated with additional "_" character when there's a number on the ENUM name.

openapi-generator version

Issue started on 7.7.0, works fine on 7.7.6.

OpenAPI declaration file content or url

Example ENUM attribute in the YAML spec:

        myAttribute:
          description: this is a ENUM            
          type: string
          enum:
          - MOVE2STOCK
          - MOVE2SHELF
          - KEEP
Generation Details

Java 17, Gradle build.

Steps to reproduce

Add ENUM attribute to the spec that has numbers in the attribute name.
Generate java model using openapi generator 7.7.0.
Look into the source code generated, the ENUM attribute names will have an "_" after the number.

For example:

  public enum MyAttributeEnum {
    MOVE2_STOCK("MOVE2STOCK"),
    MOVE2_SHELF("MOVE2SHELF"),
    KEEP("KEEP"),
Related issues/PRs
Suggest a fix
@Noed Noed added the Issue: Bug label Jul 3, 2024
@Trebuac
Copy link

Trebuac commented Jul 4, 2024

Hello,
I got the same issue (different behaviour in my Java Enum generation between 7.6.0 and 7.7.0).

I suspect this commit to be the root cause : bfa26ea#diff-a98cba8ecadaf5a662edc508aa5857972339552ec6bd6e4216680c7c6070e643

which is linked to this request #4837

Sadly it seems that we can't change this behavior (some generator have the option to choose the 'enumPropertyNaming' -
'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'), a feature request has been opened for Java/Spring : #18987

@wing328
Copy link
Member

wing328 commented Jul 4, 2024

please refer to #18594 (comment) on how to fallback

@Maran23
Copy link

Maran23 commented Jul 5, 2024

Is there an option to just use the enum as is? Without any futher modifications?

mprins added a commit to B3Partners/tailormap-api that referenced this issue Jul 8, 2024
…7.0 (#873)

* Bump org.openapitools:openapi-generator-maven-plugin from 7.6.0 to 7.7.0

Bumps org.openapitools:openapi-generator-maven-plugin from 7.6.0 to 7.7.0.

---
updated-dependencies:
- dependency-name: org.openapitools:openapi-generator-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Force the enum variable names to be uppercase without underscores

see:
- OpenAPITools/openapi-generator#19086
- OpenAPITools/openapi-generator#19066
and cause:
- OpenAPITools/openapi-generator#4837

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mark Prins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants