Search in sources :

Example 1 with ModelProperty

use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.

the class ModelPropertyConverterTest method convertStringArrayModelProperty.

@Test
public void convertStringArrayModelProperty() throws Exception {
    ModelProperty property = new ModelProperty();
    property.setType("array");
    Items items = new Items();
    items.setType("string");
    property.setItems(items);
    Property converted = converter.convertProperty(property);
    assertEquals(converted.getClass(), ArrayProperty.class);
    ArrayProperty prop = (ArrayProperty) converted;
    Property innerType = prop.getItems();
    assertEquals(innerType.getType(), "string");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) ModelProperty(io.swagger.models.apideclaration.ModelProperty) Items(io.swagger.models.apideclaration.Items) 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) Test(org.testng.annotations.Test)

Example 2 with ModelProperty

use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.

the class ModelPropertyConverterTest method convertDateTimeModelProperty.

@Test
public void convertDateTimeModelProperty() throws Exception {
    ModelProperty property = new ModelProperty();
    property.setType("string");
    property.setFormat(Format.DATE_TIME);
    property.setDescription("a simple date-time");
    Property converted = converter.convertProperty(property);
    assertEquals(converted.getClass(), DateTimeProperty.class);
    assertEquals(converted.getDescription(), property.getDescription());
    assertEquals(converted.getType(), "string");
    assertEquals(converted.getFormat(), "date-time");
}
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) Test(org.testng.annotations.Test)

Example 3 with ModelProperty

use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.

the class ModelPropertyConverterTest method convertIntegerModelProperty.

@Test
public void convertIntegerModelProperty() throws Exception {
    ModelProperty property = new ModelProperty();
    property.setType("integer");
    property.setFormat(Format.INT32);
    property.setDescription("a simple int32 property");
    property.setMinimum("1");
    property.setMaximum("4");
    Property converted = converter.convertProperty(property);
    assertEquals(converted.getClass(), IntegerProperty.class);
    assertEquals(converted.getType(), "integer");
    assertEquals(converted.getFormat(), "int32");
    IntegerProperty prop = (IntegerProperty) converted;
    assertEquals(prop.getMinimum(), new BigDecimal("1"));
    assertEquals(prop.getMaximum(), new BigDecimal("4"));
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) 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) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 4 with ModelProperty

use of io.swagger.models.apideclaration.ModelProperty 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 5 with ModelProperty

use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.

the class ModelPropertyConverterTest method convertStringModelProperty.

@Test
public void convertStringModelProperty() throws Exception {
    ModelProperty property = new ModelProperty();
    property.setType("string");
    property.setDescription("a simple string");
    Property converted = converter.convertProperty(property);
    assertEquals(converted.getClass(), StringProperty.class);
    assertEquals(converted.getType(), "string");
    assertEquals(converted.getDescription(), property.getDescription());
}
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) Test(org.testng.annotations.Test)

Aggregations

ModelProperty (io.swagger.models.apideclaration.ModelProperty)14 Property (io.swagger.models.properties.Property)12 Test (org.testng.annotations.Test)12 ArrayProperty (io.swagger.models.properties.ArrayProperty)11 RefProperty (io.swagger.models.properties.RefProperty)11 StringProperty (io.swagger.models.properties.StringProperty)11 DateTimeProperty (io.swagger.models.properties.DateTimeProperty)10 DoubleProperty (io.swagger.models.properties.DoubleProperty)10 FloatProperty (io.swagger.models.properties.FloatProperty)10 IntegerProperty (io.swagger.models.properties.IntegerProperty)10 LongProperty (io.swagger.models.properties.LongProperty)10 BigDecimal (java.math.BigDecimal)4 ArrayList (java.util.ArrayList)4 Model (io.swagger.models.Model)2 Items (io.swagger.models.apideclaration.Items)2 LinkedHashMap (java.util.LinkedHashMap)2 UntypedProperty (io.swagger.models.properties.UntypedProperty)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1