Search in sources :

Example 6 with DoubleProperty

use of io.swagger.models.properties.DoubleProperty 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 7 with DoubleProperty

use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.

the class PropertySerializationTest method serializeDoubleProperty.

@Test(description = "it should serialize a DoubleProperty")
public void serializeDoubleProperty() throws IOException {
    final DoubleProperty p = new DoubleProperty()._default(3.14159);
    final String json = "{\"type\":\"number\",\"format\":\"double\",\"default\":3.14159}";
    assertEquals(m.writeValueAsString(p), json);
}
Also used : DoubleProperty(io.swagger.models.properties.DoubleProperty) Test(org.testng.annotations.Test)

Example 8 with DoubleProperty

use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.

the class PropertySerializationTest method deserializeDoubleProperty.

@Test(description = "it should deserialize a DoubleProperty")
public void deserializeDoubleProperty() throws IOException {
    final String json = "{\"type\":\"number\",\"format\":\"double\"}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getType(), "number");
    assertEquals(p.getFormat(), "double");
    assertEquals(p.getClass(), DoubleProperty.class);
    assertEquals(m.writeValueAsString(p), json);
}
Also used : DoubleProperty(io.swagger.models.properties.DoubleProperty) MapProperty(io.swagger.models.properties.MapProperty) FloatProperty(io.swagger.models.properties.FloatProperty) DateProperty(io.swagger.models.properties.DateProperty) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) DateTimeProperty(io.swagger.models.properties.DateTimeProperty) ObjectProperty(io.swagger.models.properties.ObjectProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) BooleanProperty(io.swagger.models.properties.BooleanProperty) LongProperty(io.swagger.models.properties.LongProperty) RefProperty(io.swagger.models.properties.RefProperty) FileProperty(io.swagger.models.properties.FileProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 9 with DoubleProperty

use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.

the class AbstractSerializableParameter method setProperty.

public void setProperty(Property property) {
    setType(property.getType());
    this.format = property.getFormat();
    if (property instanceof StringProperty) {
        final StringProperty string = (StringProperty) property;
        setEnum(string.getEnum());
    } else if (property instanceof IntegerProperty) {
        setEnumValue(((IntegerProperty) property).getEnum());
    } else if (property instanceof LongProperty) {
        setEnumValue(((LongProperty) property).getEnum());
    } else if (property instanceof FloatProperty) {
        setEnumValue(((FloatProperty) property).getEnum());
    } else if (property instanceof DoubleProperty) {
        setEnumValue(((DoubleProperty) property).getEnum());
    } else if (property instanceof ArrayProperty) {
        final ArrayProperty array = (ArrayProperty) property;
        setItems(array.getItems());
    }
}
Also used : BaseIntegerProperty(io.swagger.models.properties.BaseIntegerProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) LongProperty(io.swagger.models.properties.LongProperty) StringProperty(io.swagger.models.properties.StringProperty) FloatProperty(io.swagger.models.properties.FloatProperty) DoubleProperty(io.swagger.models.properties.DoubleProperty)

Example 10 with DoubleProperty

use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.

the class DoublePropertyTest method testEquals.

@Test
public void testEquals() {
    final DoubleProperty prop1 = new DoubleProperty();
    prop1.setName(PROP_1);
    prop1.setRequired(true);
    final DoubleProperty prop2 = new DoubleProperty();
    prop2.setName(PROP_2);
    assertNotEquals(prop1, prop2);
    prop2.setName(PROP_1);
    prop2.setRequired(true);
    assertEquals(prop1, prop2);
}
Also used : DoubleProperty(io.swagger.models.properties.DoubleProperty) Test(org.testng.annotations.Test)

Aggregations

DoubleProperty (io.swagger.models.properties.DoubleProperty)10 IntegerProperty (io.swagger.models.properties.IntegerProperty)8 StringProperty (io.swagger.models.properties.StringProperty)8 ArrayProperty (io.swagger.models.properties.ArrayProperty)7 Property (io.swagger.models.properties.Property)7 Test (org.testng.annotations.Test)7 LongProperty (io.swagger.models.properties.LongProperty)5 FloatProperty (io.swagger.models.properties.FloatProperty)4 BooleanProperty (io.swagger.models.properties.BooleanProperty)3 RefProperty (io.swagger.models.properties.RefProperty)3 BigDecimal (java.math.BigDecimal)3 Model (io.swagger.models.Model)2 Response (io.swagger.models.Response)2 HeaderParameter (io.swagger.models.parameters.HeaderParameter)2 ArrayList (java.util.ArrayList)2 ArrayModel (io.swagger.models.ArrayModel)1 BeanValidationsModel (io.swagger.models.BeanValidationsModel)1 HibernateBeanValidationsModel (io.swagger.models.HibernateBeanValidationsModel)1 Operation (io.swagger.models.Operation)1 Path (io.swagger.models.Path)1