Search in sources :

Example 11 with StringProperty

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

the class PostParamTest method findAPostOperationWithStringsCollection.

@Test(description = "find a Post operation with collection of strings")
public void findAPostOperationWithStringsCollection() {
    Path petPath = getPath("collectionOfStrings");
    assertNotNull(petPath);
    Operation petPost = petPath.getPost();
    assertNotNull(petPost);
    assertEquals(petPost.getParameters().size(), 1);
    BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
    assertEquals(petPostBodyParam.getName(), BODY);
    Model inputModel = petPostBodyParam.getSchema();
    assertTrue(inputModel instanceof ArrayModel);
    ArrayModel ap = (ArrayModel) inputModel;
    Property inputSchema = ap.getItems();
    assertTrue(inputSchema instanceof StringProperty);
}
Also used : Path(io.swagger.models.Path) Model(io.swagger.models.Model) ArrayModel(io.swagger.models.ArrayModel) StringProperty(io.swagger.models.properties.StringProperty) Operation(io.swagger.models.Operation) BodyParameter(io.swagger.models.parameters.BodyParameter) ArrayModel(io.swagger.models.ArrayModel) StringProperty(io.swagger.models.properties.StringProperty) RefProperty(io.swagger.models.properties.RefProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 12 with StringProperty

use of io.swagger.models.properties.StringProperty 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);
}
Also used : StringProperty(io.swagger.models.properties.StringProperty) 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 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 14 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 15 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)

Aggregations

StringProperty (io.swagger.models.properties.StringProperty)60 Test (org.testng.annotations.Test)47 Property (io.swagger.models.properties.Property)29 ArrayProperty (io.swagger.models.properties.ArrayProperty)21 Model (io.swagger.models.Model)20 IntegerProperty (io.swagger.models.properties.IntegerProperty)16 LongProperty (io.swagger.models.properties.LongProperty)16 RefProperty (io.swagger.models.properties.RefProperty)16 DoubleProperty (io.swagger.models.properties.DoubleProperty)14 ModelImpl (io.swagger.models.ModelImpl)9 FloatProperty (io.swagger.models.properties.FloatProperty)9 BooleanProperty (io.swagger.models.properties.BooleanProperty)8 ApiModelProperty (io.swagger.annotations.ApiModelProperty)7 BodyParameter (io.swagger.models.parameters.BodyParameter)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