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"));
}
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);
}
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);
}
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);
}
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);
}
Aggregations