OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.54k stars 6.27k forks source link

[BUG] [JAVA] OpenAPI Generator did not generate correct Enum in model if same enum reference with two different object #18611

Open ananddwivediDev opened 1 month ago

ananddwivediDev commented 1 month ago
Description

Right now we are making use of https://jdegre.github.io/editor/?url=https://raw.githubusercontent.com/jdegre/5GC_APIs/Rel-17/TS29510_Nnrf_NFManagement.yaml spec which has below field

image

nfType field is of type NfTypeEnum which is defined inside SubscrCond class as enum with 6 values private NfTypeEnum nfType;

but according to spec it should be of NFType type(which is also used for other fields in class) which has more 56 values.

openapi-generator version

5.4.0 (but did tried with latest version as well )

OpenAPI declaration file content or url

https://jdegre.github.io/editor/?url=https://raw.githubusercontent.com/jdegre/5GC_APIs/Rel-17/TS29510_Nnrf_NFManagement.yaml is the spec that we are making use in order to generate model

Generation Details

mvn clean install

Steps to reproduce

use https://jdegre.github.io/editor/?url=https://raw.githubusercontent.com/jdegre/5GC_APIs/Rel-17/TS29510_Nnrf_NFManagement.yaml spec and other reference file and generate model and look for SubscrCond which only have one variable

private NFTypeEnum nfType; //setter getter .

Ideally it should have two variable as per spec

private NFTypeEnum nfTypeEnum; //setter getter . private NFType nfType; //setter getter .

ananddwivediDev commented 5 days ago

@wing328 could you please help here

wing328 commented 3 days ago

would it be possible to create a minimal spec to reproduce the issue?

the spec you shared is pretty large and not easy to reproduce the issue

ananddwivediDev commented 2 days ago

[open-api.zip](https://github.com/user-attachments/files/16029276/open-api.zip)

Here is the Sample project . steps to validate

  1. import project
  2. run mvn clean install
  3. you can validate SubscrCond generated model has private NfTypeEnum nfType; field which is supposed to have more than 50 ENUM value but it has 6 enum which is incorrect . (as per spec NfTypeEnum should have more than 50 Enum )

Note :- I can not modify Spec (yaml file) so this is all about issue . Thanks

martin-mfg commented 2 days ago

If you use the latest version (7.6.0) of OpenAPI-Generator, then you'll find the desired enum inside NFType. Version 5.4.0 is not supported anymore.