use of io.swagger.models.properties.RefProperty 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.RefProperty 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.RefProperty in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeArrayBodyParameter.
@Test(description = "it should serialize an array BodyParameter")
public void serializeArrayBodyParameter() {
final ArrayModel model = new ArrayModel().items(new RefProperty("Cat"));
final BodyParameter p = new BodyParameter().schema(model);
final String json = "{" + " \"in\":\"body\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"array\"," + " \"items\":{" + " \"$ref\":\"#/definitions/Cat\"" + " }" + " }" + "}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.properties.RefProperty in project swagger-parser by swagger-api.
the class ModelPropertyConverterTest method convertRefModelProperty.
@Test
public void convertRefModelProperty() throws Exception {
ModelProperty property = new ModelProperty();
property.setRef("Pet");
Property converted = converter.convertProperty(property);
assertEquals(converted.getClass(), RefProperty.class);
RefProperty ref = (RefProperty) converted;
assertEquals(ref.getSimpleRef(), "Pet");
}
use of io.swagger.models.properties.RefProperty in project swagger-parser by swagger-api.
the class ResolverCache method updateLocalRefs.
protected <T> void updateLocalRefs(String file, T result) {
if (result instanceof Response) {
Response response = (Response) result;
updateLocalRefs(file, response.getSchema());
} else if (result instanceof RefProperty) {
RefProperty prop = (RefProperty) result;
updateLocalRefs(file, prop);
} else if (result instanceof Model) {
Model model = (Model) result;
updateLocalRefs(file, model);
}
}
Aggregations