use of io.swagger.v3.oas.annotations.media.ArraySchema in project swagger-core by swagger-api.
the class ByteConverterTest method testReadOnlyByteArray.
@Test
public void testReadOnlyByteArray() {
Schema model = new Schema().addProperties("byteArray", new ArraySchema().items(new BinarySchema()).readOnly(true));
assertEquals(Json.pretty(model), "{" + NEWLINE + " \"properties\" : {" + NEWLINE + " \"byteArray\" : {" + NEWLINE + " \"type\" : \"array\"," + NEWLINE + " \"readOnly\" : true," + NEWLINE + " \"items\" : {" + NEWLINE + " \"type\" : \"string\"," + NEWLINE + " \"format\" : \"binary\"" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + "}");
}
use of io.swagger.v3.oas.annotations.media.ArraySchema in project swagger-core by swagger-api.
the class ByteConverterTest method testByteArray.
@Test
public void testByteArray() {
Schema model = new Schema().addProperties("byteArray", new ArraySchema().items(new BinarySchema()));
assertEquals(Json.pretty(model), "{" + NEWLINE + " \"properties\" : {" + NEWLINE + " \"byteArray\" : {" + NEWLINE + " \"type\" : \"array\"," + NEWLINE + " \"items\" : {" + NEWLINE + " \"type\" : \"string\"," + NEWLINE + " \"format\" : \"binary\"" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + " }" + NEWLINE + "}");
}
use of io.swagger.v3.oas.annotations.media.ArraySchema in project swagger-core by swagger-api.
the class JsonPropertiesDeserializationTest method testDeserializeConstrainedArrayProperties.
@Test(description = "should deserialize an array property with constraints")
public void testDeserializeConstrainedArrayProperties() throws Exception {
OpenAPI oas = TestUtils.deserializeJsonFileFromClasspath("specFiles/propertiesWithConstraints.json", OpenAPI.class);
Map<String, Schema> properties = oas.getComponents().getSchemas().get("Health").getProperties();
ArraySchema withMin = (ArraySchema) properties.get("array_with_min");
assertEquals(withMin.getMinItems(), Integer.valueOf(5));
assertNull(withMin.getMaxItems());
assertNull(withMin.getUniqueItems());
ArraySchema withMax = (ArraySchema) properties.get("array_with_max");
assertNull(withMax.getMinItems());
assertEquals(withMax.getMaxItems(), Integer.valueOf(10));
assertNull(withMax.getUniqueItems());
ArraySchema withUnique = (ArraySchema) properties.get("array_with_unique");
assertNull(withUnique.getMinItems());
assertNull(withUnique.getMaxItems());
assertEquals(withUnique.getUniqueItems(), Boolean.TRUE);
ArraySchema withAll = (ArraySchema) properties.get("array_with_all");
assertEquals(withAll.getMinItems(), Integer.valueOf(1));
assertEquals(withAll.getMaxItems(), Integer.valueOf(10));
assertEquals(withAll.getUniqueItems(), Boolean.TRUE);
}
use of io.swagger.v3.oas.annotations.media.ArraySchema in project swagger-core by swagger-api.
the class JsonPropertiesDeserializationTest method shouldDeserializeArrayPropertyMaxItems.
@Test
public void shouldDeserializeArrayPropertyMaxItems() throws Exception {
String path = "json-schema-validation/array.json";
ArraySchema property = (ArraySchema) TestUtils.deserializeJsonFileFromClasspath(path, Schema.class);
assertNotNull(property.getMaxItems());
assertEquals(property.getMaxItems().intValue(), 10);
}
use of io.swagger.v3.oas.annotations.media.ArraySchema in project swagger-core by swagger-api.
the class JsonPropertiesDeserializationTest method shouldDeserializeArrayPropertyUniqueItems.
@Test
public void shouldDeserializeArrayPropertyUniqueItems() throws Exception {
String path = "json-schema-validation/array.json";
ArraySchema property = (ArraySchema) TestUtils.deserializeJsonFileFromClasspath(path, Schema.class);
assertNotNull(property.getUniqueItems());
assertTrue(property.getUniqueItems());
}
Aggregations