use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class JsonDeserializationTest method shouldDeserializeArrayPropertyMinItems.
@Test
public void shouldDeserializeArrayPropertyMinItems() throws Exception {
String path = "json-schema-validation/array.json";
ArrayProperty property = (ArrayProperty) TestUtils.deserializeJsonFileFromClasspath(path, Property.class);
assertNotNull(property.getMinItems());
assertEquals(property.getMinItems().intValue(), 1);
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class DefaultParameterExtension method enforcePrimitive.
private Property enforcePrimitive(Property in, int level) {
if (in instanceof RefProperty) {
return new StringProperty();
}
if (in instanceof ArrayProperty) {
if (level == 0) {
final ArrayProperty array = (ArrayProperty) in;
array.setItems(enforcePrimitive(array.getItems(), level + 1));
} else {
return new StringProperty();
}
}
return in;
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class GenericsTest method check2DArrayAsBodyParameter.
@Test(description = "check 2D array as body parameter")
public void check2DArrayAsBodyParameter() {
Operation op = getOperation("test2DInBody");
assertEquals(op.getParameters().size(), 1);
BodyParameter p = getBodyParameter(op, 0);
ArrayModel ddArray = (ArrayModel) p.getSchema();
assertEquals(((RefProperty) ((ArrayProperty) ddArray.getItems()).getItems()).getSimpleRef(), "Tag");
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class GenericsTest method checkGenericResult.
@Test(description = "check generic result")
public void checkGenericResult() {
Operation op = swagger.getPath("/generics/testGenericResult").getGet();
Property schema = op.getResponses().get("200").getSchema();
assertEquals(schema.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) schema).getSimpleRef(), "GenericListWrapperTag");
Property entries = getProperty("GenericListWrapperTag", "entries");
assertNotEquals(entries, null);
assertEquals(entries.getClass().getName(), ArrayProperty.class.getName());
Property items = ((ArrayProperty) entries).getItems();
assertEquals(items.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) items).getSimpleRef(), "Tag");
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeArrayStringProperty.
@Test(description = "it should serialize a string array property")
public void serializeArrayStringProperty() throws IOException {
final ArrayProperty p = new ArrayProperty().items(new StringProperty());
final String json = "{\"type\":\"array\",\"items\":{\"type\":\"string\"}}";
assertEquals(m.writeValueAsString(p), json);
}
Aggregations