use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class InheritedBeanTest method testComposedUberObject.
@Test
public void testComposedUberObject() throws Exception {
final Schema uberModel = context.resolve(new AnnotatedType(UberObject.class));
assertNotNull(uberModel);
// make sure child points at parent
assertTrue(uberModel instanceof ComposedSchema);
ComposedSchema cm = (ComposedSchema) uberModel;
assertEquals(cm.getAnyOf().size(), 2);
assertEquals(cm.getAnyOf().get(0).get$ref(), "#/components/schemas/UserObject");
// parent properties are filtered out of subclass when parent doesn't define subtypes
assertNotNull(cm.getProperties());
assertEquals(cm.getProperties().size(), 3);
final Schema interfaceModel = context.getDefinedModels().get("UserObject");
assertNotNull(interfaceModel);
assertUserObjectPropertiesValid(interfaceModel.getProperties());
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class InheritedBeanTest method testInheritedChildBean.
@Test
public void testInheritedChildBean() throws Exception {
final Schema subModel = context.resolve(new AnnotatedType(Sub1Bean.class));
assertNotNull(subModel);
// make sure child points at parent
assertTrue(subModel instanceof ComposedSchema);
ComposedSchema cm = (ComposedSchema) subModel;
assertEquals(cm.getAllOf().get(0).get$ref(), "#/components/schemas/BaseBean");
// make sure parent properties are filtered out of subclass
assertSub1PropertiesValid(cm.getAllOf().get(1).getProperties());
final Schema baseModel = context.getDefinedModels().get("BaseBean");
assertNotNull(baseModel);
assertBasePropertiesValid(baseModel.getProperties());
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class InheritedBeanTest method testMultipleInheritedBean.
@Test
public void testMultipleInheritedBean() throws Exception {
final Schema baseModel = context.resolve(new AnnotatedType(MultipleBaseBean.class));
assertNotNull(baseModel);
assertBasePropertiesValid(baseModel.getProperties());
final Schema sub1Model = context.getDefinedModels().get("MultipleSub1Bean");
assertNotNull(sub1Model);
// make sure child points at parent
assertTrue(sub1Model instanceof ComposedSchema);
ComposedSchema cm1 = (ComposedSchema) sub1Model;
assertEquals(cm1.getAllOf().get(0).get$ref(), "#/components/schemas/MultipleBaseBean");
// make sure parent properties are filtered out of subclass
assertSub1PropertiesValid(cm1.getAllOf().get(1).getProperties());
final Schema sub2Model = context.getDefinedModels().get("MultipleSub2Bean");
assertNotNull(sub2Model);
assertTrue(sub2Model instanceof ComposedSchema);
ComposedSchema cm2 = (ComposedSchema) sub2Model;
assertEquals(cm2.getAllOf().get(0).get$ref(), "#/components/schemas/MultipleBaseBean");
// make sure parent properties are filtered out of subclass
assertSub2PropertiesValid(cm2.getAllOf().get(1).getProperties());
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class JodaTest method testSimple.
@Test
public void testSimple() throws Exception {
final ModelConverter mr = modelResolver();
final Schema model = mr.resolve(new AnnotatedType(ModelWithJodaDateTime.class), new ModelConverterContextImpl(mr), null);
assertNotNull(model);
final Map<String, Schema> props = model.getProperties();
assertEquals(props.size(), 2);
for (Map.Entry<String, Schema> entry : props.entrySet()) {
final String name = entry.getKey();
final Schema 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.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class SimpleGenerationTest method testTheCountBean.
@Test
public void testTheCountBean() throws Exception {
final Schema model = context.resolve(new AnnotatedType(TheCount.class));
final Map<String, Schema> props = model.getProperties();
assertEquals(props.size(), 1);
String key = props.keySet().iterator().next();
final Schema prop = props.get(key);
assertEquals(key, "theCount");
}
Aggregations