use of io.swagger.v3.core.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 Schema model = mr.resolve(new AnnotatedType(XmlDecoratedBeanXmlAccessorNone.class), new ModelConverterContextImpl(mr), null);
final XML xml = model.getXml();
assertNotNull(xml);
assertEquals(xml.getName(), "xmlDecoratedBean");
final Schema property = (Schema) model.getProperties().get("a");
assertNotNull(property);
assertNull(model.getProperties().get("b"));
assertNotNull(model.getProperties().get("c"));
assertNotNull(model.getProperties().get("d"));
assertNotNull(model.getProperties().get("e"));
assertNotNull(model.getProperties().get("f"));
}
use of io.swagger.v3.core.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 Schema model = context.resolve(new AnnotatedType(OuterBean.class));
assertNotNull(model);
}
use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ModelConverters method read.
public Map<String, Schema> read(AnnotatedType type) {
Map<String, Schema> modelMap = new HashMap<>();
if (shouldProcess(type.getType())) {
ModelConverterContextImpl context = new ModelConverterContextImpl(converters);
Schema resolve = context.resolve(type);
for (Entry<String, Schema> entry : context.getDefinedModels().entrySet()) {
if (entry.getValue().equals(resolve)) {
modelMap.put(entry.getKey(), entry.getValue());
}
}
}
return modelMap;
}
use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class ReaderTest method resolveJaxb.
private Map<String, Schema> resolveJaxb(Type type) {
List<ModelConverter> converters = new CopyOnWriteArrayList<ModelConverter>();
ObjectMapper mapper = JaxbObjectMapperFactory.getMapper();
converters.add(new ModelResolver(mapper));
ModelConverterContextImpl context = new ModelConverterContextImpl(converters);
Schema resolve = context.resolve(new AnnotatedType().type(type));
Map<String, Schema> schemas = new HashMap<String, Schema>();
for (Map.Entry<String, Schema> entry : context.getDefinedModels().entrySet()) {
if (entry.getValue().equals(resolve)) {
schemas.put(entry.getKey(), entry.getValue());
}
}
return schemas;
}
use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.
the class PatternAndSchemaPropertiesTest method testSinglePatternAndSchemaProperties.
@Test
public void testSinglePatternAndSchemaProperties() throws Exception {
final ModelResolver modelResolver = new ModelResolver(mapper());
ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
Schema model = context.resolve(new AnnotatedType(AnnotatedPetSinglePatternProperty.class));
assertEquals(((Schema) model.getPatternProperties().get("what.*ever")).getFormat(), "int32");
assertEquals(((Schema) model.getProperties().get("anotherCategory")).get$ref(), "#/components/schemas/Category");
}
Aggregations