Search in sources :

Example 11 with RefProperty

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");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) Operation(io.swagger.models.Operation) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) RefProperty(io.swagger.models.properties.RefProperty) Property(io.swagger.models.properties.Property) UUIDProperty(io.swagger.models.properties.UUIDProperty) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 12 with RefProperty

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);
}
Also used : DoubleProperty(io.swagger.models.properties.DoubleProperty) MapProperty(io.swagger.models.properties.MapProperty) FloatProperty(io.swagger.models.properties.FloatProperty) DateProperty(io.swagger.models.properties.DateProperty) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) DateTimeProperty(io.swagger.models.properties.DateTimeProperty) ObjectProperty(io.swagger.models.properties.ObjectProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) BooleanProperty(io.swagger.models.properties.BooleanProperty) LongProperty(io.swagger.models.properties.LongProperty) RefProperty(io.swagger.models.properties.RefProperty) FileProperty(io.swagger.models.properties.FileProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 13 with RefProperty

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);
}
Also used : BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 14 with RefProperty

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");
}
Also used : ModelProperty(io.swagger.models.apideclaration.ModelProperty) DoubleProperty(io.swagger.models.properties.DoubleProperty) FloatProperty(io.swagger.models.properties.FloatProperty) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) DateTimeProperty(io.swagger.models.properties.DateTimeProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) ModelProperty(io.swagger.models.apideclaration.ModelProperty) LongProperty(io.swagger.models.properties.LongProperty) RefProperty(io.swagger.models.properties.RefProperty) Property(io.swagger.models.properties.Property) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Example 15 with RefProperty

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);
    }
}
Also used : Response(io.swagger.models.Response) Model(io.swagger.models.Model) RefModel(io.swagger.models.RefModel) RefProperty(io.swagger.models.properties.RefProperty)

Aggregations

RefProperty (io.swagger.models.properties.RefProperty)74 Property (io.swagger.models.properties.Property)50 ArrayProperty (io.swagger.models.properties.ArrayProperty)46 StringProperty (io.swagger.models.properties.StringProperty)35 Test (org.testng.annotations.Test)35 Model (io.swagger.models.Model)23 MapProperty (io.swagger.models.properties.MapProperty)20 ModelImpl (io.swagger.models.ModelImpl)18 Response (io.swagger.models.Response)18 IntegerProperty (io.swagger.models.properties.IntegerProperty)18 Operation (io.swagger.models.Operation)17 RefModel (io.swagger.models.RefModel)17 LongProperty (io.swagger.models.properties.LongProperty)14 Path (io.swagger.models.Path)12 Swagger (io.swagger.models.Swagger)12 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 ArrayModel (io.swagger.models.ArrayModel)11 BodyParameter (io.swagger.models.parameters.BodyParameter)11 Map (java.util.Map)11