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

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

[BUG] Incorrect ENUM generation #19066

Noed opened this issue Jul 3, 2024 · 10 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 Tailormap/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] <support@github.com>

* 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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mark Prins <1165786+mprins@users.noreply.github.com>
@AndresBena19
Copy link

Any idea when #19277 will be merged?

@magiusdarrigo
Copy link

magiusdarrigo commented Sep 26, 2024

@AndresBena19 +1000

@goldel777
Copy link

Can you help me understand if this when this will be fixed? I am still seeing underscores on the enums in 7.7.0 through 7.10.0. I've tried both this documented variations:

enumPropertyNaming=original,modelPropertyNaming=original
legacy

@goldel777
Copy link

Looks like this overrode me

Under configOptions:

additionalProperties : enumPropertyNaming=original,modelPropertyNaming=original</additionalProperties

enumPropertyNaming: legacy

@wing328
Copy link
Member

wing328 commented Dec 11, 2024

Merged #20172 two weeks ago.

Please give it a try with the latest master or snapshot version.

@wing328 wing328 closed this as completed Dec 11, 2024
@goldel777
Copy link

Can you help me understand where the mvn repo for openapi snapshots can be found?

@wing328
Copy link
Member

wing328 commented Dec 12, 2024

please refer to the FAQ: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants