use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeReadOnlyStringProperty.
@Test(description = "it should serialize a string property with readOnly set")
public void serializeReadOnlyStringProperty() throws IOException {
final Property p = new StringProperty().readOnly();
final String json = "{\"type\":\"string\",\"readOnly\":true}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class JsonDeserializationTest method shouldDeserializeArrayPropertyMinItems.
@Test
public void shouldDeserializeArrayPropertyMinItems() throws Exception {
String path = "json-schema-validation/array.json";
ArrayProperty property = (ArrayProperty) TestUtils.deserializeJsonFileFromClasspath(path, Property.class);
assertNotNull(property.getMinItems());
assertEquals(property.getMinItems().intValue(), 1);
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class GenericsTest method checkParametersOfGenericTypes.
@Test(description = "check parameters of generic types")
public void checkParametersOfGenericTypes() {
Set<String> genericTypes = new HashSet(Arrays.asList("GenericTypeString", "GenericTypeUUID", "GenericTypeGenericTypeString", "RenamedGenericTypeString", "RenamedGenericTypeRenamedGenericTypeString"));
assertTrue(swagger.getDefinitions().keySet().containsAll(genericTypes));
Operation opString = getOperation("testGenericType");
testGenericType(opString, "GenericTypeString");
Property strValue = getProperty("GenericTypeString", "value");
assertNotEquals(strValue, null);
assertEquals(strValue.getClass().getName(), StringProperty.class.getName());
Operation opUUID = getOperation("testStringBasedGenericType");
testGenericType(opUUID, "GenericTypeUUID");
Property uuidValue = getProperty("GenericTypeUUID", "value");
assertNotEquals(uuidValue, null);
assertEquals(uuidValue.getClass().getName(), UUIDProperty.class.getName());
Operation opComplex = getOperation("testComplexGenericType");
testGenericType(opComplex, "GenericTypeGenericTypeString");
Property complexValue = getProperty("GenericTypeGenericTypeString", "value");
assertNotEquals(complexValue, null);
assertEquals(complexValue.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) complexValue).getSimpleRef(), "GenericTypeString");
Operation opRenamed = getOperation("testRenamedGenericType");
testGenericType(opRenamed, "RenamedGenericTypeRenamedGenericTypeString");
Property renamedComplexValue = getProperty("RenamedGenericTypeRenamedGenericTypeString", "value");
assertNotEquals(renamedComplexValue, null);
assertTrue(renamedComplexValue instanceof RefProperty);
assertEquals(((RefProperty) renamedComplexValue).getSimpleRef(), "RenamedGenericTypeString");
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class GenericsTest method checkGenericResult.
@Test(description = "check generic result")
public void checkGenericResult() {
Operation op = swagger.getPath("/generics/testGenericResult").getGet();
Property schema = op.getResponses().get("200").getSchema();
assertEquals(schema.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) schema).getSimpleRef(), "GenericListWrapperTag");
Property entries = getProperty("GenericListWrapperTag", "entries");
assertNotEquals(entries, null);
assertEquals(entries.getClass().getName(), ArrayProperty.class.getName());
Property items = ((ArrayProperty) entries).getItems();
assertEquals(items.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) items).getSimpleRef(), "Tag");
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class MapPropertyDeserializerTest method testMapDeserialization.
@Test(description = "it should deserialize a response per #1349")
public void testMapDeserialization() throws Exception {
Operation operation = Json.mapper().readValue(json, Operation.class);
Response response = operation.getResponses().get("200");
assertNotNull(response);
Property responseSchema = response.getSchema();
assertNotNull(responseSchema);
assertTrue(responseSchema instanceof MapProperty);
MapProperty mp = (MapProperty) responseSchema;
assertTrue(mp.getAdditionalProperties() instanceof IntegerProperty);
}
Aggregations