File tree 3 files changed +47
-1
lines changed
modules/openapi-generator/src
main/java/org/openapitools/codegen/utils
java/org/openapitools/codegen
3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -2375,7 +2375,8 @@ public static boolean isMetadataOnlySchema(Schema schema) {
2375
2375
schema .getContains () != null ||
2376
2376
schema .get$dynamicAnchor () != null ||
2377
2377
schema .get$anchor () != null ||
2378
- schema .getContentSchema () != null ;
2378
+ schema .getContentSchema () != null ||
2379
+ schema .getDefault () != null ;
2379
2380
}
2380
2381
2381
2382
Original file line number Diff line number Diff line change @@ -1205,4 +1205,18 @@ public void doNotWrapSingleAllOfRefs() {
1205
1205
assertNotNull (allOfRefWithDescriptionAndReadonly .getAllOf ());
1206
1206
assertEquals (numberRangeRef , ((Schema ) allOfRefWithDescriptionAndReadonly .getAllOf ().get (0 )).get$ref ());
1207
1207
}
1208
+
1209
+ @ Test
1210
+ public void testAllOfEnumWithDefault () {
1211
+ // The flattened spec should still have both allOf items in query parameter, to allow generators to generate the default value
1212
+ final OpenAPI openAPI = TestUtils .parseFlattenSpec ("src/test/resources/3_0/allOf-enum-default.yaml" );
1213
+ var parameters = openAPI
1214
+ .getPaths ()
1215
+ .get ("/person" )
1216
+ .getGet ()
1217
+ .getParameters ();
1218
+ assertEquals (1 , parameters .size ());
1219
+ var parameter = parameters .get (0 );
1220
+ assertEquals (2 , parameter .getSchema ().getAllOf ().size ());
1221
+ }
1208
1222
}
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.1
2
+ info :
3
+ version : 1.0.0
4
+ title : Example
5
+ license :
6
+ name : MIT
7
+ servers :
8
+ - url : http://api.example.xyz/v1
9
+ paths :
10
+ /person :
11
+ get :
12
+ parameters :
13
+ - name : enum
14
+ in : query
15
+ required : true
16
+ description : Enum value
17
+ schema :
18
+ allOf :
19
+ - $ref : ' #/components/schemas/MyEnum'
20
+ - default : " One"
21
+ operationId : list
22
+ responses :
23
+ ' 200 ' :
24
+ description : OK
25
+ components :
26
+ schemas :
27
+ MyEnum :
28
+ type : string
29
+ enum :
30
+ - One
31
+ - Two
You can’t perform that action at this time.
0 commit comments