Search in sources :

Example 96 with Property

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

the class InheritedBeanTest method assertSub2PropertiesValid.

private void assertSub2PropertiesValid(Map<String, Property> subProperties) {
    assertEquals(subProperties.size(), 1);
    for (Map.Entry<String, Property> entry : subProperties.entrySet()) {
        final String name = entry.getKey();
        final Property prop = entry.getValue();
        if ("d".equals(name)) {
            assertEquals(prop.getType(), "integer");
            assertEquals(prop.getFormat(), "int32");
        }
    }
}
Also used : Map(java.util.Map) Property(io.swagger.models.properties.Property)

Example 97 with Property

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

the class JodaTest method testSimple.

@Test
public void testSimple() throws Exception {
    final ModelConverter mr = modelResolver();
    final Model model = mr.resolve(ModelWithJodaDateTime.class, new ModelConverterContextImpl(mr), null);
    assertNotNull(model);
    final Map<String, Property> props = model.getProperties();
    assertEquals(props.size(), 2);
    for (Map.Entry<String, Property> entry : props.entrySet()) {
        final String name = entry.getKey();
        final Property prop = entry.getValue();
        if ("name".equals(name)) {
            assertEquals(prop.getType(), "string");
        } else if ("createdAt".equals(name)) {
            assertEquals(prop.getType(), "string");
            assertEquals(prop.getFormat(), "date-time");
        } else {
            fail(String.format("Unknown property '%s'", name));
        }
    }
}
Also used : Model(io.swagger.models.Model) ApiModelProperty(io.swagger.annotations.ApiModelProperty) Property(io.swagger.models.properties.Property) Map(java.util.Map) ModelConverter(io.swagger.converter.ModelConverter) ModelConverterContextImpl(io.swagger.converter.ModelConverterContextImpl) Test(org.testng.annotations.Test)

Example 98 with Property

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

the class SimpleGenerationTest method testTheCountBean.

@Test
public void testTheCountBean() throws Exception {
    final Model model = context.resolve(TheCount.class);
    final Map<String, Property> props = model.getProperties();
    assertEquals(props.size(), 1);
    final Property prop = props.values().iterator().next();
    assertEquals(prop.getName(), "theCount");
}
Also used : Model(io.swagger.models.Model) ApiModel(io.swagger.annotations.ApiModel) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ApiModelProperty(io.swagger.annotations.ApiModelProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 99 with Property

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

the class SimpleGenerationTest method testOrdering.

@Test
public void testOrdering() throws Exception {
    final Model jsonOrderBean = context.resolve(JsonOrderBean.class);
    final Map<String, Property> props = jsonOrderBean.getProperties();
    assertEquals(new ArrayList<String>(props.keySet()), Arrays.asList("a", "b", "c", "d"));
    final Model positionBean = context.resolve(PositionBean.class);
    final Map<String, Property> positionBeanProps = positionBean.getProperties();
    assertEquals(positionBeanProps.size(), 4);
    final Property prop = positionBeanProps.get("c");
    assertNotNull(prop);
    assertEquals((int) prop.getPosition(), 3);
}
Also used : Model(io.swagger.models.Model) ApiModel(io.swagger.annotations.ApiModel) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ApiModelProperty(io.swagger.annotations.ApiModelProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 100 with Property

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

the class SimpleGenerationTest method testSimple.

@Test
public void testSimple() throws Exception {
    final Model model = context.resolve(SimpleBean.class);
    assertNotNull(model);
    assertEquals(model.getDescription(), "DESC");
    final Map<String, Property> props = model.getProperties();
    assertEquals(props.size(), 6);
    for (Map.Entry<String, Property> entry : props.entrySet()) {
        final String name = entry.getKey();
        final Property prop = entry.getValue();
        if ("a".equals(name)) {
            assertEquals(prop.getType(), "string");
        } else if ("b".equals(name)) {
            assertEquals(prop.getType(), "integer");
            assertEquals(prop.getFormat(), "int32");
        } else if ("c".equals(name)) {
            assertEquals(prop.getType(), "integer");
            assertEquals(prop.getFormat(), "int64");
        } else if ("d".equals(name)) {
            assertEquals(prop.getType(), "number");
            assertEquals(prop.getFormat(), "float");
        } else if ("e".equals(name)) {
            assertEquals(prop.getType(), "number");
            assertEquals(prop.getFormat(), "double");
        } else if ("f".equals(name)) {
            assertEquals(prop.getType(), "string");
            assertEquals(prop.getFormat(), "date-time");
        } else {
            fail(String.format("Unknown property '%s'", name));
        }
    }
}
Also used : Model(io.swagger.models.Model) ApiModel(io.swagger.annotations.ApiModel) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ApiModelProperty(io.swagger.annotations.ApiModelProperty) Property(io.swagger.models.properties.Property) Map(java.util.Map) Test(org.testng.annotations.Test)

Aggregations

Property (io.swagger.models.properties.Property)145 Test (org.testng.annotations.Test)96 ArrayProperty (io.swagger.models.properties.ArrayProperty)86 StringProperty (io.swagger.models.properties.StringProperty)75 RefProperty (io.swagger.models.properties.RefProperty)65 MapProperty (io.swagger.models.properties.MapProperty)59 Model (io.swagger.models.Model)52 IntegerProperty (io.swagger.models.properties.IntegerProperty)48 LongProperty (io.swagger.models.properties.LongProperty)35 DoubleProperty (io.swagger.models.properties.DoubleProperty)32 FloatProperty (io.swagger.models.properties.FloatProperty)27 BooleanProperty (io.swagger.models.properties.BooleanProperty)25 ObjectProperty (io.swagger.models.properties.ObjectProperty)25 Operation (io.swagger.models.Operation)24 DateTimeProperty (io.swagger.models.properties.DateTimeProperty)23 DateProperty (io.swagger.models.properties.DateProperty)22 ApiModelProperty (io.swagger.annotations.ApiModelProperty)20 FileProperty (io.swagger.models.properties.FileProperty)18 ModelImpl (io.swagger.models.ModelImpl)17 Response (io.swagger.models.Response)16