use of io.swagger.models.properties.MapProperty in project swagger-core by swagger-api.
the class JsonDeserializationTest method givenMapProperty_shouldDeserializeMinProperties.
@Test
public void givenMapProperty_shouldDeserializeMinProperties() {
String path = "json-schema-validation/map.json";
MapProperty property = (MapProperty) TestUtils.deserializeJsonFileFromClasspath(path, Property.class);
assertNotNull(property.getMinProperties());
assertEquals(property.getMinProperties().intValue(), 1);
}
use of io.swagger.models.properties.MapProperty in project swagger-core by swagger-api.
the class MapPropertyDeserializerTest method testMapDeserializationVendorExtensions.
@Test(description = "vendor extensions should be included with object type")
public void testMapDeserializationVendorExtensions() throws Exception {
Operation operation = Json.mapper().readValue(json, Operation.class);
Response response = operation.getResponses().get("200");
assertNotNull(response);
Property responseSchema = response.getSchema();
assertNotNull(responseSchema);
MapProperty mp = (MapProperty) responseSchema;
assertTrue(mp.getVendorExtensions().size() > 0);
assertNotNull(mp.getVendorExtensions().get("x-foo"));
assertEquals(mp.getVendorExtensions().get("x-foo"), "vendor x");
}
use of io.swagger.models.properties.MapProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeLongMapProperty.
@Test(description = "it should deserialize a long MapProperty")
public void deserializeLongMapProperty() throws IOException {
final String json = "{\"type\":\"object\",\"additionalProperties\":{\"type\":\"integer\",\"format\":\"int64\"}}";
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.MapProperty in project swagger-core by swagger-api.
the class ContainerTest method testMap.
@Test
public void testMap() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Model model = context.resolve(MapBean.class);
final Map<String, Property> props = model.getProperties();
assertEquals(1, props.size());
final Property prop = props.get("stuff");
assertNotNull(prop);
assertEquals(prop.getType(), "object");
final Property items = ((MapProperty) prop).getAdditionalProperties();
assertNotNull(items);
assertEquals(items.getType(), "string");
assertEquals(items.getFormat(), "date-time");
}
use of io.swagger.models.properties.MapProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeIntegerMapProperty.
@Test(description = "it should deserialize a integer MapProperty")
public void deserializeIntegerMapProperty() throws IOException {
final String json = "{\"type\":\"object\",\"additionalProperties\":{\"type\":\"integer\",\"format\":\"int32\"}}";
final Property p = m.readValue(json, Property.class);
assertEquals(p.getType(), "object");
assertEquals(p.getClass(), MapProperty.class);
assertEquals(m.writeValueAsString(p), json);
}
Aggregations