use of io.swagger.converter.ModelConverter 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.ModelConverter 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.ModelConverter 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.converter.ModelConverter in project swagger-core by swagger-api.
the class XMLInfoTest method testSimple.
@Test
public void testSimple() throws Exception {
final ModelConverter mr = modelResolver();
final Model model = mr.resolve(XmlDecoratedBean.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");
// Cast it to an array property
final ArrayProperty property = (ArrayProperty) impl.getProperties().get("elements");
assertNotNull(property);
final Xml propertyXml = property.getXml();
assertNotNull(propertyXml);
assertNull(propertyXml.getName());
assertTrue(propertyXml.getWrapped());
// Get the xml for items for the array property
final Xml itemsXml = property.getItems().getXml();
assertNotNull(itemsXml);
// Check the name of item name
assertEquals(itemsXml.getName(), "element");
assertNotNull(impl.getProperties().get("elementC"));
}
Aggregations