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");
}
}
}
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));
}
}
}
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");
}
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);
}
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));
}
}
}
Aggregations