use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeEnumStringProperty.
@Test(description = "it should deserialize a StringProperty with enums")
public void deserializeEnumStringProperty() throws IOException {
final String json = "{\"type\":\"string\",\"enum\":[\"a\",\"b\"]}";
final Property p = m.readValue(json, Property.class);
assertEquals(p.getType(), "string");
List<String> _enum = ((StringProperty) p).getEnum();
assertNotNull(_enum);
assertEquals(_enum, Arrays.asList("a", "b"));
assertEquals(p.getClass(), StringProperty.class);
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeStringProperty.
@Test(description = "it should serialize a StringProperty")
public void serializeStringProperty() throws IOException {
final StringProperty p = new StringProperty()._default("Bob");
final String json = "{\"type\":\"string\",\"default\":\"Bob\"}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeStringMapProperty.
@Test(description = "it should serialize a string MapProperty")
public void serializeStringMapProperty() throws IOException {
final MapProperty p = new MapProperty(new StringProperty());
final String json = "{\"type\":\"object\",\"additionalProperties\":{\"type\":\"string\"}}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeArrayQueryParameter.
@Test(description = "it should serialize a QueryParameter with array")
public void serializeArrayQueryParameter() {
final QueryParameter p = new QueryParameter().type(ArrayProperty.TYPE).items(new StringProperty()).collectionFormat("multi");
final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"" + " }," + " \"collectionFormat\":\"multi\"" + "}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializePathParameter.
@Test(description = "it should serialize a PathParameter")
public void serializePathParameter() {
final PathParameter p = new PathParameter().property(new StringProperty());
final String json = "{\"in\":\"path\",\"required\":true,\"type\":\"string\"}";
SerializationMatchers.assertEqualsToJson(p, json);
}
Aggregations