use of io.swagger.converter.ModelConverterContextImpl 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"));
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ATMTest method testATMModel.
@Test
public void testATMModel() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Model model = context.resolve(ATM.class);
assertNotNull(model);
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ComplexPropertyTest method testOuterBean.
@Test
public void testOuterBean() throws Exception {
final ModelResolver modelResolver = modelResolver();
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Model model = context.resolve(OuterBean.class);
assertNotNull(model);
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ContainerTest method testMap.
@Test
public void testMap() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
final Model model = context.resolve(MapBean.class);
final Map<String, Property> props = model.getProperties();
assertEquals(1, props.size());
final Property prop = props.get("stuff");
assertNotNull(prop);
assertEquals(prop.getType(), "object");
final Property items = ((MapProperty) prop).getAdditionalProperties();
assertNotNull(items);
assertEquals(items.getType(), "string");
assertEquals(items.getFormat(), "date-time");
}
use of io.swagger.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ContainerTest method testComplexMap.
@Test
public void testComplexMap() throws Exception {
ModelResolver resolver = new ModelResolver(mapper());
final ModelConverterContextImpl context = new ModelConverterContextImpl(resolver);
context.resolve(WrapperType.class);
final Map<String, Model> models = context.getDefinedModels();
final Model innerType = models.get("InnerType");
assertNotNull(innerType);
final Map<String, Property> innerProps = innerType.getProperties();
assertEquals(innerProps.size(), 2);
final Property foo = innerProps.get("foo");
assertEquals(foo.getType(), "integer");
assertEquals(foo.getFormat(), "int32");
final Property name = innerProps.get("name");
assertEquals(name.getType(), "string");
final Model wrapperType = models.get("WrapperType");
assertNotNull(wrapperType);
assertEquals(wrapperType.getProperties().get("innerType").getType(), "object");
}
Aggregations