openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open ananddwivediDev opened this issue 1 year ago • 4 comments

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 avatar May 08 '24 14:05 ananddwivediDev

@wing328 could you please help here

ananddwivediDev avatar Jun 25 '24 15:06 ananddwivediDev

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

wing328 avatar Jun 28 '24 09:06 wing328

[ open-api.zip ](url)

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

ananddwivediDev avatar Jun 28 '24 12:06 ananddwivediDev

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.

martin-mfg avatar Jun 28 '24 13:06 martin-mfg