use of io.swagger.models.properties.IntegerProperty in project swagger-core by swagger-api.
the class ModelSerializerTest method testIssue2064Ip.
@Test
public void testIssue2064Ip() throws Exception {
String json = "{\n" + " \"type\": \"object\",\n" + " \"properties\": {\n" + " \"id\": {\n" + " \"type\": \"integer\",\n" + " \"format\": \"int32\",\n" + " \"multipleOf\": 3.0\n" + " }\n" + " }\n" + "}";
final ModelImpl model = Json.mapper().readValue(json, ModelImpl.class);
IntegerProperty ip = (IntegerProperty) model.getProperties().get("id");
assertEquals(ip.getMultipleOf(), new BigDecimal("3.0"));
}
use of io.swagger.models.properties.IntegerProperty in project swagger-core by swagger-api.
the class HibernateBeanValidationsTest method readHibernateValidations.
@Test(description = "it should read hibernate validations")
public void readHibernateValidations() {
final Map<String, Model> schemas = ModelConverters.getInstance().readAll(HibernateBeanValidationsModel.class);
final Map<String, Property> properties = schemas.get("HibernateBeanValidationsModel").getProperties();
final IntegerProperty age = (IntegerProperty) properties.get("age");
assertEquals(age.getMinimum().doubleValue(), 13.0, 0.01);
assertEquals(age.getMaximum().doubleValue(), 99.0, 0.01);
final StringProperty password = (StringProperty) properties.get("password");
assertEquals((int) password.getMinLength(), 6);
assertEquals((int) password.getMaxLength(), 20);
assertTrue(((DoubleProperty) properties.get("minBalance")).getExclusiveMinimum());
assertTrue(((DoubleProperty) properties.get("maxBalance")).getExclusiveMaximum());
}
use of io.swagger.models.properties.IntegerProperty in project swagger-core by swagger-api.
the class PropertyDeserializerTest method deserializePropertyWithMinimumMaximumValues.
@Test
public void deserializePropertyWithMinimumMaximumValues() throws Exception {
String json = "{\n" + " \"type\": \"integer\",\n" + " \"format\": \"int32\",\n" + " \"minimum\": 32,\n" + " \"maximum\": 100\n" + "}";
Property param = Json.mapper().readValue(json, Property.class);
IntegerProperty ip = (IntegerProperty) param;
assertEquals(ip.getMinimum(), new BigDecimal("32"));
assertEquals(ip.getMaximum(), new BigDecimal("100"));
}
use of io.swagger.models.properties.IntegerProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeIntegerMapProperty.
@Test(description = "it should serialize a integer MapProperty")
public void serializeIntegerMapProperty() throws IOException {
final MapProperty p = new MapProperty(new IntegerProperty());
final String json = "{\"type\":\"object\",\"additionalProperties\":{\"type\":\"integer\",\"format\":\"int32\"}}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.IntegerProperty in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeIntegerArrayPathParameter.
@Test(description = "it should serialize a PathParameter with integer array")
public void serializeIntegerArrayPathParameter() {
final PathParameter p = new PathParameter().type(ArrayProperty.TYPE).items(new IntegerProperty()).collectionFormat("multi");
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"integer\"," + " \"format\":\"int32\"" + " }," + " \"collectionFormat\":\"multi\"" + "}";
SerializationMatchers.assertEqualsToJson(p, json);
}
Aggregations