@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 resolveInlineBodyParameter() throws Exception {
    Swagger swagger = new Swagger();

    swagger.path(
        "/hello",
        new Path()
            .get(
                new Operation()
                    .parameter(
                        new BodyParameter()
                            .name("body")
                            .schema(
                                new ModelImpl()
                                    .property(
                                        "address",
                                        new ObjectProperty()
                                            .property("street", new StringProperty()))
                                    .property("name", new StringProperty())))));

    new InlineModelResolver().flatten(swagger);

    Operation operation = swagger.getPaths().get("/hello").getGet();
    BodyParameter bp = (BodyParameter) operation.getParameters().get(0);
    assertTrue(bp.getSchema() instanceof RefModel);

    Model body = swagger.getDefinitions().get("body");
    assertTrue(body instanceof ModelImpl);

    ModelImpl impl = (ModelImpl) body;
    assertNotNull(impl.getProperties().get("address"));
  }
  @Test
  public void testInlineResponseModel() throws Exception {
    Swagger swagger = new Swagger();

    swagger
        .path(
            "/foo/bar",
            new Path()
                .get(
                    new Operation()
                        .response(
                            200,
                            new Response()
                                .description("it works!")
                                .schema(
                                    new ObjectProperty().property("name", new StringProperty())))))
        .path(
            "/foo/baz",
            new Path()
                .get(
                    new Operation()
                        .response(
                            200,
                            new Response()
                                .vendorExtension("x-foo", "bar")
                                .description("it works!")
                                .schema(
                                    new ObjectProperty().property("name", new StringProperty())))));
    new InlineModelResolver().flatten(swagger);

    Map<String, Response> responses = swagger.getPaths().get("/foo/bar").getGet().getResponses();

    Response response = responses.get("200");
    assertNotNull(response);
    assertTrue(response.getSchema() instanceof RefProperty);

    ModelImpl model = (ModelImpl) swagger.getDefinitions().get("inline_response_200");
    assertTrue(model.getProperties().size() == 1);
    assertNotNull(model.getProperties().get("name"));
  }