Search in sources :

Example 21 with IntegerProperty

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

the class SimpleReaderTest method scanResourceWithParamRange.

@Test(description = "scan a resource with param range")
public void scanResourceWithParamRange() {
    Swagger swagger = getSwagger(ResourceWithRanges.class);
    List<Parameter> params = getGetParameters(swagger, "/{id}");
    PathParameter param0 = (PathParameter) params.get(0);
    assertEquals(param0.getName(), "id");
    assertEquals(param0.getDefaultValue(), 5);
    assertEquals(param0.getMinimum(), new BigDecimal(0.0));
    assertEquals(param0.getMaximum(), new BigDecimal(10.0));
    PathParameter param1 = (PathParameter) params.get(1);
    assertEquals(param1.getName(), "minValue");
    assertEquals(param1.getMinimum(), new BigDecimal(0.0));
    assertNull(param1.getMaximum(), null);
    PathParameter param2 = (PathParameter) params.get(2);
    assertEquals(param2.getName(), "maxValue");
    assertNull(param2.getMinimum());
    assertEquals(param2.getMaximum(), new BigDecimal(100.0));
    PathParameter param3 = (PathParameter) params.get(3);
    assertEquals(param3.getName(), "values");
    IntegerProperty items = (IntegerProperty) param3.getItems();
    assertEquals(items.getMinimum(), new BigDecimal(0.0));
    assertEquals(items.getMaximum(), new BigDecimal(5.0));
    assertEquals(items.getExclusiveMinimum(), Boolean.TRUE);
    assertEquals(items.getExclusiveMaximum(), Boolean.TRUE);
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) Swagger(io.swagger.models.Swagger) SerializableParameter(io.swagger.models.parameters.SerializableParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 22 with IntegerProperty

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

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

the class IntegerPropertyTest method testEquals.

@Test
public void testEquals() {
    final IntegerProperty prop1 = new IntegerProperty();
    prop1.setName(PROP_1);
    prop1.setRequired(true);
    final IntegerProperty prop2 = new IntegerProperty();
    prop2.setName(PROP_2);
    assertNotEquals(prop1, prop2);
    prop2.setName(PROP_1);
    prop2.setRequired(true);
    assertEquals(prop1, prop2);
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) 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