Search in sources :

Example 26 with StringProperty

use of io.swagger.models.properties.StringProperty 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 StringProperty p = new StringProperty();
    p.setReadOnly(false);
    final String json = "{\"type\":\"string\"}";
    assertEquals(m.writeValueAsString(p), json);
}
Also used : StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

Example 27 with StringProperty

use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.

the class DefaultParameterExtension method enforcePrimitive.

private Property enforcePrimitive(Property in, int level) {
    if (in instanceof RefProperty) {
        return new StringProperty();
    }
    if (in instanceof ArrayProperty) {
        if (level == 0) {
            final ArrayProperty array = (ArrayProperty) in;
            array.setItems(enforcePrimitive(array.getItems(), level + 1));
        } else {
            return new StringProperty();
        }
    }
    return in;
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) StringProperty(io.swagger.models.properties.StringProperty) RefProperty(io.swagger.models.properties.RefProperty)

Example 28 with StringProperty

use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.

the class GenericsTest method testEnumCollection.

private void testEnumCollection(QueryParameter p, String name) {
    testCollection(p, name, "string", null);
    StringProperty schema = (StringProperty) p.getItems();
    assertEquals(schema.getEnum(), enumValues);
}
Also used : StringProperty(io.swagger.models.properties.StringProperty)

Example 29 with StringProperty

use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.

the class PropertySerializationTest method serializeArrayStringProperty.

@Test(description = "it should serialize a string array property")
public void serializeArrayStringProperty() throws IOException {
    final ArrayProperty p = new ArrayProperty().items(new StringProperty());
    final String json = "{\"type\":\"array\",\"items\":{\"type\":\"string\"}}";
    assertEquals(m.writeValueAsString(p), json);
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

Example 30 with StringProperty

use of io.swagger.models.properties.StringProperty 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 ObjectProperty p = new ObjectProperty().property("stringProperty", new StringProperty().required(true));
    final String json = "{\"type\":\"object\",\"properties\":{\"stringProperty\":{\"type\":\"string\"}},\"required\":[\"stringProperty\"]}";
    assertEquals(p, m.readValue(json, ObjectProperty.class));
}
Also used : ObjectProperty(io.swagger.models.properties.ObjectProperty) StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

Aggregations

StringProperty (io.swagger.models.properties.StringProperty)62 Test (org.testng.annotations.Test)47 Property (io.swagger.models.properties.Property)30 ArrayProperty (io.swagger.models.properties.ArrayProperty)22 Model (io.swagger.models.Model)21 RefProperty (io.swagger.models.properties.RefProperty)17 IntegerProperty (io.swagger.models.properties.IntegerProperty)16 LongProperty (io.swagger.models.properties.LongProperty)16 DoubleProperty (io.swagger.models.properties.DoubleProperty)14 ModelImpl (io.swagger.models.ModelImpl)10 FloatProperty (io.swagger.models.properties.FloatProperty)9 BodyParameter (io.swagger.models.parameters.BodyParameter)8 BooleanProperty (io.swagger.models.properties.BooleanProperty)8 ApiModelProperty (io.swagger.annotations.ApiModelProperty)7 MapProperty (io.swagger.models.properties.MapProperty)7 Operation (io.swagger.models.Operation)6 Path (io.swagger.models.Path)6 PathParameter (io.swagger.models.parameters.PathParameter)6 ObjectProperty (io.swagger.models.properties.ObjectProperty)6 QueryParameter (io.swagger.models.parameters.QueryParameter)5