use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ContainerTest method testArray.
@Test
public void testArray() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Model model = context.resolve(ArrayBean.class);
final Map<String, Property> props = model.getProperties();
assertEquals(1, props.size());
final Property prop = props.get("a");
assertNotNull(prop);
assertEquals(prop.getType(), "array");
final Property items = ((ArrayProperty) prop).getItems();
assertNotNull(items);
assertEquals(items.getType(), "integer");
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class EnumTest method testEnum.
@Test
public void testEnum() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Model model = context.resolve(Currency.class);
assertNull(model);
final Property property = context.resolveProperty(Currency.class, new Annotation[] {});
assertNotNull(property);
assertTrue(property instanceof StringProperty);
final StringProperty strProperty = (StringProperty) property;
assertNotNull(strProperty.getEnum());
final Collection<String> values = new ArrayList<String>(Collections2.transform(Arrays.asList(Currency.values()), Functions.toStringFunction()));
assertEquals(strProperty.getEnum(), values);
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class XMLInfoTest method testReadingXmlAccessorTypeNone.
@Test
public void testReadingXmlAccessorTypeNone() throws Exception {
final ModelConverter mr = modelResolver();
final Model model = mr.resolve(XmlDecoratedBeanXmlAccessorNone.class, new ModelConverterContextImpl(mr), null);
assertTrue(model instanceof ModelImpl);
final ModelImpl impl = (ModelImpl) model;
final Xml xml = impl.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "xmlDecoratedBean");
final Property property = impl.getProperties().get("a");
assertNotNull(property);
assertNull(impl.getProperties().get("b"));
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class XMLInfoTest method testReadingXmlAccessorTypePublic.
@Test
public void testReadingXmlAccessorTypePublic() throws Exception {
final ModelConverter mr = modelResolver();
final Model model = mr.resolve(XmlDecoratedBeanXmlAccessorPublic.class, new ModelConverterContextImpl(mr), null);
assertTrue(model instanceof ModelImpl);
final ModelImpl impl = (ModelImpl) model;
final Xml xml = impl.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "xmlDecoratedBean");
final Property propertyA = impl.getProperties().get("a");
assertNotNull(propertyA);
Property propertyB = impl.getProperties().get("b");
assertNotNull(propertyB);
}
use of io.swagger.converter.ModelConverterContextImpl 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));
}
}
}
Aggregations