use of io.swagger.v3.oas.annotations.media.Schema 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());
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class PropertyDeserializerTest method deserializeParameterWithMinimumMaximumValues.
@Test
public void deserializeParameterWithMinimumMaximumValues() throws Exception {
String json = "{\n" + " \"in\": \"query\",\n" + " \"type\": \"integer\",\n" + " \"format\": \"int32\",\n" + " \"minimum\": 32,\n" + " \"maximum\": 100\n" + "}";
Schema property = Json.mapper().readValue(json, Schema.class);
assertTrue(property instanceof IntegerSchema);
IntegerSchema ip = (IntegerSchema) property;
assertEquals(ip.getMinimum(), new BigDecimal("32"));
assertEquals(ip.getMaximum(), new BigDecimal("100"));
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class ModelPropertyTest method extractProperties.
@Test
public void extractProperties() {
final Map<String, Schema> models = ModelConverters.getInstance().readAll(Family.class);
assertEquals(models.size(), 3);
final Schema person = models.get("Person");
final Schema employer = (Schema) person.getProperties().get("employer");
assertTrue(employer instanceof ArraySchema);
final ArraySchema employerProperty = (ArraySchema) employer;
final Schema items = employerProperty.getItems();
assertEquals(items.get$ref(), "#/components/schemas/Employer");
final Schema awards = (Schema) person.getProperties().get("awards");
assertTrue(awards instanceof ArraySchema);
assertTrue(((ArraySchema) awards).getItems() instanceof StringSchema);
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class ModelPropertyTest method modelAllowEmptyTest.
@Test
public void modelAllowEmptyTest() {
final Map<String, Schema> models = ModelConverters.getInstance().readAll(Model1979.class);
Schema model = models.get("Model1979");
assertTrue(((Schema) model.getProperties().get("id")).getNullable());
}
use of io.swagger.v3.oas.annotations.media.Schema in project swagger-core by swagger-api.
the class ModelPropertyTest method testIssue1743.
@Test
public void testIssue1743() {
final Map<String, Schema> models = ModelConverters.getInstance().readAll(ModelWithBooleanProperty.class);
final Schema model = models.get("ModelWithBooleanProperty");
assertNotNull(model);
BooleanSchema bp = (BooleanSchema) model.getProperties().get("isGreat");
assertTrue(bp.getEnum().size() == 1);
assertEquals(bp.getEnum().get(0), Boolean.TRUE);
IntegerSchema is = (IntegerSchema) model.getProperties().get("intValue");
assertTrue(is.getEnum().size() == 2);
assertEquals(is.getEnum().get(0), new Integer(1));
assertEquals(is.getEnum().get(1), new Integer(2));
}
Aggregations