Search in sources :

Example 16 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 17 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)

Example 18 with StringProperty

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

the class PropertySerializationTest method deserializeStringProperty.

@Test(description = "it should deserialize a StringProperty")
public void deserializeStringProperty() throws IOException {
    final String json = "{\"type\":\"string\"}";
    final Property p = m.readValue(json, Property.class);
    assertEquals(p.getType(), "string");
    assertEquals(p.getClass(), StringProperty.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 19 with StringProperty

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

the class ParameterSerializationTest method serializeEnumPathParameter.

@Test(description = "it should serialize a path parameter with enum")
public void serializeEnumPathParameter() {
    PathParameter p = new PathParameter().items(new StringProperty())._enum(Arrays.asList("a", "b", "c"));
    final String json = "{" + "   \"in\":\"path\"," + "   \"required\":true," + "   \"items\":{" + "      \"type\":\"string\"" + "   }," + "   \"enum\":[\"a\",\"b\",\"c\"]" + "}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : StringProperty(io.swagger.models.properties.StringProperty) PathParameter(io.swagger.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 20 with StringProperty

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

the class StringPropertyTest method testEquals.

@Test
public void testEquals() {
    final StringProperty prop1 = new StringProperty();
    prop1.setName(PROP_1);
    prop1.setRequired(true);
    final StringProperty prop2 = new StringProperty();
    prop2.setName(PROP_2);
    assertNotEquals(prop1, prop2);
    prop2.setName(PROP_1);
    prop2.setRequired(true);
    assertEquals(prop1, prop2);
}
Also used : StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

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