use of io.swagger.models.Model in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithEmptyModel.
@Test(description = "correctly model an empty model per 499")
public void scanResourceWithEmptyModel() {
Map<String, Model> definitions = getSwagger(ResourceWithEmptyModel.class).getDefinitions();
assertEquals(definitions.size(), 1);
ModelImpl empty = (ModelImpl) definitions.get("EmptyModel");
assertEquals(empty.getType(), "object");
assertNull(empty.getProperties());
assertNull(empty.getAdditionalProperties(), null);
}
use of io.swagger.models.Model in project swagger-core by swagger-api.
the class GenericsTest method scanModelWithGenericType.
@Test(description = "scan model with Generic Type")
public void scanModelWithGenericType() {
final Swagger swagger = new Reader(new Swagger()).read(UserApiRoute.class);
assertNotNull(swagger);
final Model userEntity = swagger.getDefinitions().get("UserEntity");
assertNotNull(userEntity);
final Map<String, Property> properties = userEntity.getProperties();
assertEquals(properties.size(), 2);
assertNotNull(properties.get("id"));
assertNotNull(properties.get("name"));
}
use of io.swagger.models.Model in project swagger-core by swagger-api.
the class PostParamTest method findPostOperationWithObjectsCollection.
@Test(description = "find a Post operation with collection of objects")
public void findPostOperationWithObjectsCollection() {
Path petPath = getPath("collectionOfObjects");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof RefProperty);
RefProperty rm = (RefProperty) inputSchema;
assertEquals(rm.getSimpleRef(), PET);
}
use of io.swagger.models.Model in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithStringsList.
@Test(description = "find a Post operation with list of strings")
public void findAPostOperationWithStringsList() {
Path petPath = getPath("listOfStrings");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof StringProperty);
}
use of io.swagger.models.Model in project swagger-core by swagger-api.
the class SwaggerJersey2JaxrsTest method testJacksonFeatures.
@Test(description = "JsonUnwrapped, JsonIgnore, JsonValue should be honoured")
public void testJacksonFeatures() {
final Swagger swagger = new Reader(new Swagger()).read(ResourceWithJacksonBean.class);
Model o = swagger.getDefinitions().get("JacksonBean");
assertEquals(o.getProperties().keySet(), Sets.newHashSet("identity", "bean", "code", "message", "precodesuf", "premessagesuf"));
}
Aggregations