Search in sources :

Example 51 with StringProperty

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

the class PropertySerializationTest method deserializeEnumStringProperty.

@Test(description = "it should deserialize a StringProperty with enums")
public void deserializeEnumStringProperty() throws IOException {
    final String json = "{\"type\":\"string\",\"enum\":[\"a\",\"b\"]}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getType(), "string");
    List<String> _enum = ((StringProperty) p).getEnum();
    assertNotNull(_enum);
    assertEquals(_enum, Arrays.asList("a", "b"));
    assertEquals(p.getClass(), StringProperty.class);
    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 52 with StringProperty

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

the class PropertySerializationTest method serializeStringProperty.

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

Example 53 with StringProperty

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

the class PropertySerializationTest method serializeStringMapProperty.

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

Example 54 with StringProperty

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

the class ParameterSerializationTest method serializeArrayQueryParameter.

@Test(description = "it should serialize a QueryParameter with array")
public void serializeArrayQueryParameter() {
    final QueryParameter p = new QueryParameter().type(ArrayProperty.TYPE).items(new StringProperty()).collectionFormat("multi");
    final String json = "{" + "   \"in\":\"query\"," + "   \"required\":false," + "   \"type\":\"array\"," + "   \"items\":{" + "      \"type\":\"string\"" + "   }," + "   \"collectionFormat\":\"multi\"" + "}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

Example 55 with StringProperty

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

the class ParameterSerializationTest method serializePathParameter.

@Test(description = "it should serialize a PathParameter")
public void serializePathParameter() {
    final PathParameter p = new PathParameter().property(new StringProperty());
    final String json = "{\"in\":\"path\",\"required\":true,\"type\":\"string\"}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : StringProperty(io.swagger.models.properties.StringProperty) PathParameter(io.swagger.models.parameters.PathParameter) 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