use of io.swagger.v3.oas.models.media.StringSchema 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 Schema p = m.readValue(json, Schema.class);
assertEquals(p.getType(), "string");
List<String> _enum = ((StringSchema) p).getEnum();
assertNotNull(_enum);
assertEquals(_enum, Arrays.asList("a", "b"));
assertEquals(p.getClass(), StringSchema.class);
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.v3.oas.models.media.StringSchema in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeObjectPropertyWithRequiredProperties.
@Test(description = "it should deserialize an object property with required set")
public void deserializeObjectPropertyWithRequiredProperties() throws IOException {
final Schema p = new ObjectSchema().addProperties("stringProperty", new StringSchema());
p.required(Arrays.asList("stringProperty"));
final String json = "{\"type\":\"object\",\"properties\":{\"stringProperty\":{\"type\":\"string\"}},\"required\":[\"stringProperty\"]}";
assertEquals(p, m.readValue(json, Schema.class));
}
use of io.swagger.v3.oas.models.media.StringSchema in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeNotReadOnlyStringProperty.
@Test(description = "it should serialize a string property with readOnly unset")
public void deserializeNotReadOnlyStringProperty() throws IOException {
final StringSchema p = new StringSchema();
p.setReadOnly(false);
final String json = "{\"type\":\"string\",\"readOnly\":false}";
assertEquals(m.writeValueAsString(p), json);
}
Aggregations