@Test public void resolveInlineArrayModel() throws Exception { Swagger swagger = new Swagger(); swagger.addDefinition( "User", new ArrayModel() .items( new ObjectProperty() .title("title") ._default("default") .access("access") .readOnly(false) .required(true) .description("description") .name("name") .property("street", new StringProperty()) .property("city", new StringProperty()))); new InlineModelResolver().flatten(swagger); Model model = swagger.getDefinitions().get("User"); assertTrue(model instanceof ArrayModel); Model user = swagger.getDefinitions().get("User_inner"); assertNotNull(user); assertEquals("description", user.getDescription()); }
@Test public void resolveInlineModelTest() throws Exception { Swagger swagger = new Swagger(); swagger.addDefinition( "User", new ModelImpl() .name("user") .description("a common user") .property("name", new StringProperty()) .property( "address", new ObjectProperty() .title("title") ._default("default") .access("access") .readOnly(false) .required(true) .description("description") .name("name") .property("street", new StringProperty()) .property("city", new StringProperty()))); new InlineModelResolver().flatten(swagger); ModelImpl user = (ModelImpl) swagger.getDefinitions().get("User"); assertNotNull(user); assertTrue(user.getProperties().get("address") instanceof RefProperty); ModelImpl address = (ModelImpl) swagger.getDefinitions().get("User_address"); assertNotNull(address); assertNotNull(address.getProperties().get("city")); assertNotNull(address.getProperties().get("street")); }
@Test public void testBasicInput() { Swagger swagger = new Swagger(); ModelImpl user = new ModelImpl().property("name", new StringProperty()); swagger.path( "/foo/baz", new Path() .post( new Operation() .parameter(new BodyParameter().name("myBody").schema(new RefModel("User"))))); swagger.addDefinition("User", user); new InlineModelResolver().flatten(swagger); Json.prettyPrint(swagger); }