Search in sources :

Example 51 with Property

use of io.swagger.models.properties.Property 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" + "}";
    Property property = Json.mapper().readValue(json, Property.class);
    assertTrue(property instanceof IntegerProperty);
    IntegerProperty ip = (IntegerProperty) property;
    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 52 with Property

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

the class PropertySerializationTest method deserializeRefProperty.

@Test(description = "it should deserialize a RefProperty")
public void deserializeRefProperty() throws IOException {
    final String json = "{\"$ref\":\"#/definitions/Dog\"}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getClass(), RefProperty.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 53 with Property

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

the class PropertySerializationTest method deserializeStringMapProperty.

@Test(description = "it should deserialize a string MapProperty")
public void deserializeStringMapProperty() throws IOException {
    final String json = "{\"type\":\"object\",\"additionalProperties\":{\"type\":\"string\"}}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getType(), "object");
    assertEquals(p.getClass(), MapProperty.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 54 with Property

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

the class PropertySerializationTest method deserializeEnumIntegerProperty.

@Test(description = "it should deserialize an IntegerProperty with enums")
public void deserializeEnumIntegerProperty() throws IOException {
    final String json = "{\"type\":\"integer\",\"format\":\"int32\",\"enum\":[1,2]}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getType(), "integer");
    List<Integer> _enum = ((IntegerProperty) p).getEnum();
    assertNotNull(_enum);
    assertEquals(_enum, Arrays.asList(1, 2));
    assertEquals(p.getClass(), IntegerProperty.class);
    assertEquals(m.writeValueAsString(p), json);
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) 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 55 with Property

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

the class PropertySerializationTest method deserializeBooleanProperty.

@Test(description = "it should deserialize a BooleanProperty")
public void deserializeBooleanProperty() throws IOException {
    final String json = "{\"type\":\"boolean\",\"default\":false}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getType(), "boolean");
    assertNull(p.getFormat());
    assertEquals(p.getClass(), BooleanProperty.class);
    assertEquals(((BooleanProperty) p).getDefault(), Boolean.FALSE);
    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)

Aggregations

Property (io.swagger.models.properties.Property)145 Test (org.testng.annotations.Test)96 ArrayProperty (io.swagger.models.properties.ArrayProperty)86 StringProperty (io.swagger.models.properties.StringProperty)75 RefProperty (io.swagger.models.properties.RefProperty)65 MapProperty (io.swagger.models.properties.MapProperty)59 Model (io.swagger.models.Model)52 IntegerProperty (io.swagger.models.properties.IntegerProperty)48 LongProperty (io.swagger.models.properties.LongProperty)35 DoubleProperty (io.swagger.models.properties.DoubleProperty)32 FloatProperty (io.swagger.models.properties.FloatProperty)27 BooleanProperty (io.swagger.models.properties.BooleanProperty)25 ObjectProperty (io.swagger.models.properties.ObjectProperty)25 Operation (io.swagger.models.Operation)24 DateTimeProperty (io.swagger.models.properties.DateTimeProperty)23 DateProperty (io.swagger.models.properties.DateProperty)22 ApiModelProperty (io.swagger.annotations.ApiModelProperty)20 FileProperty (io.swagger.models.properties.FileProperty)18 ModelImpl (io.swagger.models.ModelImpl)17 Response (io.swagger.models.Response)16