use of io.swagger.models.ArrayModel in project swagger-core by swagger-api.
the class ModelSerializerTest method deserializeArrayModel.
@Test(description = "it should deserialize an array model")
public void deserializeArrayModel() throws IOException {
final String json = "{\"type\":\"array\",\"items\":{\"$ref\":\"#/definitions/Pet\"}}";
final Model p = m.readValue(json, Model.class);
assertTrue(p instanceof ArrayModel);
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.ArrayModel in project swagger-core by swagger-api.
the class PropertyBuilderTest method testToModelWithArrayProperty.
@Test
public void testToModelWithArrayProperty() {
// given
EmailProperty emailProperty = new EmailProperty();
ArrayProperty arrayProperty = new ArrayProperty();
arrayProperty.setItems(emailProperty);
// when
Model model = PropertyBuilder.toModel(arrayProperty);
// then
assertEquals(((ArrayModel) model).getItems(), emailProperty, "Must contain the items value passed into the property");
}
use of io.swagger.models.ArrayModel in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithStringsArray.
@Test(description = "find a Post operation with an array of strings")
public void findAPostOperationWithStringsArray() {
Path petPath = getPath("arrayOfStrings");
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.ArrayModel in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithStringsCollection.
@Test(description = "find a Post operation with collection of strings")
public void findAPostOperationWithStringsCollection() {
Path petPath = getPath("collectionOfStrings");
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.ArrayModel in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithObjectsArray.
@Test(description = "find a Post operation with an array of objects")
public void findAPostOperationWithObjectsArray() {
Path petPath = getPath("arrayOfObjects");
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);
}
Aggregations