@@ -274,60 +274,22 @@ public void testInlineResponseModelWithTitle() throws Exception {
274
274
assertTrue (model .getProperties ().get ("name" ) instanceof StringSchema );
275
275
}
276
276
277
-
278
-
279
- /*
280
277
@ Test
281
- public void resolveInlineArraySchemaWithTitle() throws Exception {
282
- OpenAPI openapi = new OpenAPI();
283
-
284
- openapi.getComponents().addSchemas("User", new ArraySchema()
285
- .items(new ObjectSchema()
286
- .title("InnerUserTitle")
287
- .access("access")
288
- .readOnly(false)
289
- .required(true)
290
- .description("description")
291
- .name("name")
292
- .addProperties("street", new StringSchema())
293
- .addProperties("city", new StringSchema())));
278
+ public void resolveInlineArraySchemaWithTitle () {
279
+ OpenAPI openAPI = new OpenAPIParser ().readLocation ("src/test/resources/3_0/inline_model_resolver.yaml" , null , new ParseOptions ()).getOpenAPI ();
280
+ new InlineModelResolver ().flatten (openAPI );
294
281
295
- new InlineModelResolver().flatten(openapi );
282
+ assertTrue ( openAPI . getComponents (). getSchemas (). get ( "Users" ) instanceof ArraySchema );
296
283
297
- Schema model = openapi .getComponents().getSchemas().get("User ");
298
- assertTrue(model instanceof ArraySchema );
284
+ ArraySchema users = ( ArraySchema ) openAPI .getComponents ().getSchemas ().get ("Users " );
285
+ assertTrue (users . getItems () instanceof ObjectSchema );
299
286
300
- Schema user = openapi.getComponents().getSchemas().get("InnerUserTitle");
301
- assertNotNull(user);
302
- assertEquals("description", user.getDescription());
287
+ ObjectSchema user = (ObjectSchema ) users .getItems ();
288
+ assertEquals ("User" , user .getTitle ());
289
+ assertTrue (user .getProperties ().get ("street" ) instanceof StringSchema );
290
+ assertTrue (user .getProperties ().get ("city" ) instanceof StringSchema );
303
291
}
304
- /*
305
- @Test
306
- public void resolveInlineArraySchemaWithoutTitle() throws Exception {
307
- OpenAPI openapi = new OpenAPI();
308
-
309
- openapi.getComponents().addSchemas("User", new ArraySchema()
310
- .items(new ObjectSchema()
311
- ._default("default")
312
- .access("access")
313
- .readOnly(false)
314
- .required(true)
315
- .description("description")
316
- .name("name")
317
- .addProperties("street", new StringSchema())
318
- .addProperties("city", new StringSchema())));
319
-
320
- new InlineModelResolver().flatten(openapi);
321
-
322
- Schema model = openapi.getComponents().getSchemas().get("User");
323
- assertTrue(model instanceof ArraySchema);
324
-
325
- Model user = openapi.getComponents().getSchemas().get("User_inner");
326
- assertNotNull(user);
327
- assertEquals("description", user.getDescription());
328
- }
329
- */
330
-
292
+
331
293
@ Test
332
294
public void resolveInlineRequestBody () {
333
295
OpenAPI openAPI = new OpenAPIParser ().readLocation ("src/test/resources/3_0/inline_model_resolver.yaml" , null , new ParseOptions ()).getOpenAPI ();
@@ -385,30 +347,22 @@ public void resolveInlineBodyParameterWithTitle() throws Exception {
385
347
386
348
ObjectSchema impl = (ObjectSchema) body;
387
349
assertNotNull(impl.getProperties().get("address"));
388
- }
350
+ }
351
+ */
389
352
390
353
@ Test
391
- public void notResolveNonModelBodyParameter() throws Exception {
392
- OpenAPI openapi = new OpenAPI();
393
-
394
- openapi.path("/hello", new Path()
395
- .get(new Operation()
396
- .parameter(new BodyParameter()
397
- .name("body")
398
- .schema(new ObjectSchema()
399
- .type("string")
400
- .format("binary")))));
354
+ public void nonModelRequestBody () {
355
+ OpenAPI openAPI = new OpenAPIParser ().readLocation ("src/test/resources/3_0/inline_model_resolver.yaml" , null , new ParseOptions ()).getOpenAPI ();
356
+ new InlineModelResolver ().flatten (openAPI );
401
357
402
- new InlineModelResolver ().flatten(openapi );
358
+ MediaType mediaType = openAPI . getPaths ().get ( "/non_model_request_body" ). getPost (). getRequestBody (). getContent (). get ( "multipart/form-data" );
403
359
404
- Operation operation = openapi.getPaths().get("/hello").getGet();
405
- BodyParameter bp = (BodyParameter)operation.getParameters().get(0);
406
- assertTrue(bp.getSchema() instanceof ObjectSchema);
407
- ObjectSchema m = (ObjectSchema) bp.getSchema();
408
- assertEquals("string", m.getType());
409
- assertEquals("binary", m.getFormat());
360
+ assertTrue (mediaType .getSchema () instanceof BinarySchema );
361
+ assertEquals ("string" , mediaType .getSchema ().getType ());
362
+ assertEquals ("binary" , mediaType .getSchema ().getFormat ());
410
363
}
411
364
365
+ /*
412
366
@Test
413
367
public void resolveInlineArrayBodyParameter() throws Exception {
414
368
OpenAPI openapi = new OpenAPI();
0 commit comments