File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
modules/openapi-generator/src
main/java/org/openapitools/codegen
java/org/openapitools/codegen Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -943,7 +943,13 @@ private Schema processSimplifyOneOf(Schema schema) {
943
943
if (oneOfSchemas .size () == 6 ) {
944
944
TreeSet <String > ts = new TreeSet <>();
945
945
for (Schema s : oneOfSchemas ) {
946
- ts .add (ModelUtils .getType (s ));
946
+ s = ModelUtils .getReferencedSchema (openAPI , s );
947
+ String type = ModelUtils .getType (s );
948
+ if (type == null ) {
949
+ LOGGER .debug ("Error null type found in schema when simplifying any type with 6 sub-schemas: {}" , s );
950
+ } else {
951
+ ts .add (type );
952
+ }
947
953
}
948
954
949
955
if (ts .equals (anyTypeTreeSet )) {
@@ -1068,7 +1074,13 @@ private Schema processSimplifyAnyOf(Schema schema) {
1068
1074
if (anyOfSchemas .size () == 6 ) {
1069
1075
TreeSet <String > ts = new TreeSet <>();
1070
1076
for (Schema s : anyOfSchemas ) {
1071
- ts .add (ModelUtils .getType (s ));
1077
+ s = ModelUtils .getReferencedSchema (openAPI , s );
1078
+ String type = ModelUtils .getType (s );
1079
+ if (type == null ) {
1080
+ LOGGER .debug ("Error null type found in schema when simplifying any type with 6 sub-schemas: {}" , s );
1081
+ } else {
1082
+ ts .add (type );
1083
+ }
1072
1084
}
1073
1085
1074
1086
if (ts .equals (anyTypeTreeSet )) {
Original file line number Diff line number Diff line change @@ -178,6 +178,9 @@ public void testOpenAPINormalizerSimplifyOneOfAnyOf() {
178
178
Schema schema13 = openAPI .getComponents ().getSchemas ().get ("OneOfAnyType" );
179
179
assertEquals (schema13 .getOneOf ().size (), 6 );
180
180
181
+ Schema schema15 = openAPI .getComponents ().getSchemas ().get ("AnyOfAnyTypeWithRef" );
182
+ assertEquals (schema15 .getAnyOf ().size (), 6 );
183
+
181
184
Map <String , String > options = new HashMap <>();
182
185
options .put ("SIMPLIFY_ONEOF_ANYOF" , "true" );
183
186
OpenAPINormalizer openAPINormalizer = new OpenAPINormalizer (openAPI , options );
@@ -216,6 +219,9 @@ public void testOpenAPINormalizerSimplifyOneOfAnyOf() {
216
219
assertEquals (schema14 .getOneOf (), null );
217
220
assertEquals (schema14 .getType (), null );
218
221
222
+ Schema schema16 = openAPI .getComponents ().getSchemas ().get ("AnyOfAnyTypeWithRef" );
223
+ assertEquals (schema16 .getAnyOf (), null );
224
+ assertEquals (schema16 .getType (), null );
219
225
}
220
226
221
227
@ Test
Original file line number Diff line number Diff line change @@ -103,6 +103,17 @@ components:
103
103
- type : string
104
104
- type : number
105
105
- type : integer
106
+ AnyOfAnyTypeWithRef :
107
+ anyOf :
108
+ - type : boolean
109
+ - type : array
110
+ items : { }
111
+ - type : object
112
+ - type : string
113
+ - type : number
114
+ - $ref : ' #/components/schemas/IntegerRef'
115
+ IntegerRef :
116
+ type : integer
106
117
OneOfAnyType :
107
118
oneOf :
108
119
- type : object
You can’t perform that action at this time.
0 commit comments