@@ -96,6 +96,31 @@ public void testIssue1367() {
96
96
assertTrue (((Schema )openAPI .getComponents ().getSchemas ().get ("TestDTO" ).getProperties ().get ("choice" )).getEnum () != null );
97
97
}
98
98
99
+ @ Test
100
+ public void testDeserializeExampleFlag () {
101
+ OpenAPIV3Parser openApiParser = new OpenAPIV3Parser ();
102
+ ParseOptions options = new ParseOptions ();
103
+ options .setResolve (true );
104
+ options .setResolveCombinators (true );
105
+ options .setResolveFully (true );
106
+ options .setFlatten (true );
107
+ SwaggerParseResult parseResult = openApiParser .readLocation ("exampleFlag.yaml" , null , options );
108
+ OpenAPI openAPI = parseResult .getOpenAPI ();
109
+ assertTrue (openAPI .getComponents ().getSchemas ().get ("TestDTO" ).getExampleSetFlag ());
110
+ assertNull (openAPI .getComponents ().getSchemas ().get ("TestDTO" ).getExample ());
111
+ assertTrue (openAPI .getComponents ().getSchemas ().get ("TestString" ).getExampleSetFlag ());
112
+ assertNull (openAPI .getComponents ().getSchemas ().get ("TestString" ).getExample ());
113
+ assertTrue (openAPI .getComponents ().getSchemas ().get ("TestNumber" ).getExampleSetFlag ());
114
+ assertNull (openAPI .getComponents ().getSchemas ().get ("TestNumber" ).getExample ());
115
+
116
+ assertFalse (openAPI .getComponents ().getSchemas ().get ("TestDTOMissing" ).getExampleSetFlag ());
117
+ assertNull (openAPI .getComponents ().getSchemas ().get ("TestDTOMissing" ).getExample ());
118
+ assertFalse (openAPI .getComponents ().getSchemas ().get ("TestStringMissing" ).getExampleSetFlag ());
119
+ assertNull (openAPI .getComponents ().getSchemas ().get ("TestStringMissing" ).getExample ());
120
+ assertFalse (openAPI .getComponents ().getSchemas ().get ("TestNumberMissing" ).getExampleSetFlag ());
121
+ assertNull (openAPI .getComponents ().getSchemas ().get ("TestNumberMissing" ).getExample ());
122
+ }
123
+
99
124
@ Test
100
125
public void testIssueFlattenAdditionalPropertiesSchemaInlineModelTrue () {
101
126
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser ();
@@ -2241,7 +2266,7 @@ public void shouldParseApiWithMultipleParameterReferences() {
2241
2266
assertThat (parameters .keySet (), equalTo (new HashSet <>(asList ("IdParam" , "NameParam" ))));
2242
2267
assertThat (parameters .get ("IdParam" ).getName (), equalTo ("id" ));
2243
2268
assertThat (parameters .get ("NameParam" ).getName (), equalTo ("name" ));
2244
-
2269
+
2245
2270
assertThat (result .getMessages (), equalTo (emptyList ()));
2246
2271
2247
2272
}
@@ -2250,22 +2275,22 @@ public void shouldParseApiWithMultipleParameterReferences() {
2250
2275
public void shouldParseApiWithParametersUsingContentvsSchema () {
2251
2276
// Tests that the content method of specifying the format of a parameter
2252
2277
// gets resolved.
2253
- // Test checks if an API's single parameter of array type gets fully resolved to
2278
+ // Test checks if an API's single parameter of array type gets fully resolved to
2254
2279
// referenced definitions.
2255
2280
String location = "src/test/resources/issue-1078/api.yaml" ;
2256
2281
ParseOptions options = new ParseOptions ();
2257
2282
options .setResolve (true );
2258
2283
// This test uses an Array in the parameters, test if it get's fully resolved.
2259
2284
options .setResolveFully (true );
2260
2285
OpenAPIV3Parser tested = new OpenAPIV3Parser ();
2261
-
2286
+
2262
2287
// Parse yaml
2263
2288
SwaggerParseResult result = tested .readLocation (location , emptyList (), options );
2264
2289
2265
2290
OpenAPI api = result .getOpenAPI ();
2266
2291
Paths paths = api .getPaths ();
2267
2292
2268
- // First ensure all schemas were resolved, this is important when this library
2293
+ // First ensure all schemas were resolved, this is important when this library
2269
2294
// is used to generate code
2270
2295
Components components = api .getComponents ();
2271
2296
assertNotNull (components );
@@ -2274,13 +2299,13 @@ public void shouldParseApiWithParametersUsingContentvsSchema() {
2274
2299
assertNotNull (components .getSchemas ().get ("Lat" ));
2275
2300
assertNotNull (components .getSchemas ().get ("Long" ));
2276
2301
assertNotNull (components .getSchemas ().get ("SearchResult" ));
2277
-
2302
+
2278
2303
PathItem apiEndpoint = paths .get ("/api-endpoint-1" );
2279
2304
List <Parameter > parameters = apiEndpoint .getGet ().getParameters ();
2280
-
2305
+
2281
2306
// Ensure there's only one parameter in this test
2282
2307
assertThat (parameters .size (), equalTo (1 ));
2283
-
2308
+
2284
2309
// We are testing content for a parameter so make sure its there.
2285
2310
Content content = parameters .get (0 ).getContent ();
2286
2311
assertNotNull (content );
0 commit comments