Search in sources :

Example 16 with IntegerProperty

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"));
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) ModelImpl(io.swagger.models.ModelImpl) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 17 with IntegerProperty

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());
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) HibernateBeanValidationsModel(io.swagger.models.HibernateBeanValidationsModel) Model(io.swagger.models.Model) StringProperty(io.swagger.models.properties.StringProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) DoubleProperty(io.swagger.models.properties.DoubleProperty) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 18 with IntegerProperty

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"));
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) Property(io.swagger.models.properties.Property) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 19 with IntegerProperty

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);
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) MapProperty(io.swagger.models.properties.MapProperty) Test(org.testng.annotations.Test)

Example 20 with IntegerProperty

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);
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Aggregations

IntegerProperty (io.swagger.models.properties.IntegerProperty)23 Test (org.testng.annotations.Test)20 Property (io.swagger.models.properties.Property)13 StringProperty (io.swagger.models.properties.StringProperty)11 ArrayProperty (io.swagger.models.properties.ArrayProperty)9 DoubleProperty (io.swagger.models.properties.DoubleProperty)9 LongProperty (io.swagger.models.properties.LongProperty)8 RefProperty (io.swagger.models.properties.RefProperty)7 BigDecimal (java.math.BigDecimal)7 FloatProperty (io.swagger.models.properties.FloatProperty)6 PathParameter (io.swagger.models.parameters.PathParameter)5 BooleanProperty (io.swagger.models.properties.BooleanProperty)5 MapProperty (io.swagger.models.properties.MapProperty)5 Model (io.swagger.models.Model)4 ModelImpl (io.swagger.models.ModelImpl)4 Response (io.swagger.models.Response)3 BodyParameter (io.swagger.models.parameters.BodyParameter)3 Parameter (io.swagger.models.parameters.Parameter)3 QueryParameter (io.swagger.models.parameters.QueryParameter)3 DateProperty (io.swagger.models.properties.DateProperty)3