use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class InheritedBeanTest method testHierarchy.
@Test
public void testHierarchy() throws Exception {
final Schema baseModel = context.resolve(new AnnotatedType(BaseBean3.class));
assertNotNull(baseModel);
assertBasePropertiesValid(baseModel.getProperties());
assertEquals(baseModel.getDiscriminator().getPropertyName(), "type");
assertEquals(baseModel.getDiscriminator().getMapping().get("ChildBean3Mapped"), "#/components/schemas/ChildBean3");
final Schema subModel = context.getDefinedModels().get("ChildBean3");
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/BaseBean3");
// make sure parent properties are filtered out of subclass
assertSub1PropertiesValid(cm.getAllOf().get(1).getProperties());
// assert grandchild
final Schema subSubModel = context.getDefinedModels().get("GrandChildBean3");
assertNotNull(subSubModel);
// make sure child points at parent
assertTrue(subSubModel instanceof ComposedSchema);
cm = (ComposedSchema) subSubModel;
assertEquals(cm.getAllOf().get(0).get$ref(), "#/components/schemas/ChildBean3");
// make sure parent properties are filtered out of subclass
assertSub2PropertiesValid(cm.getAllOf().get(1).getProperties());
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class InheritedBeanTest method testInheritedBean.
@Test
public void testInheritedBean() throws Exception {
final Schema baseModel = context.resolve(new AnnotatedType(BaseBean.class));
assertNotNull(baseModel);
assertBasePropertiesValid(baseModel.getProperties());
assertEquals(baseModel.getDiscriminator().getPropertyName(), "type");
assertEquals(baseModel.getDiscriminator().getMapping().get("Sub1BeanMapped"), "#/components/schemas/Sub1Bean");
final Schema subModel = context.getDefinedModels().get("Sub1Bean");
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());
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class InheritedBeanTest method testComposedChildBean.
@Test
public void testComposedChildBean() throws Exception {
final Schema subModel = context.resolve(new AnnotatedType(Sub2Bean.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/BaseBean2");
// make sure parent properties are filtered out of subclass
assertSub1PropertiesValid(cm.getAllOf().get(1).getProperties());
final Schema baseModel = context.getDefinedModels().get("BaseBean2");
assertNotNull(baseModel);
assertBase2PropertiesValid(baseModel.getProperties());
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class SimpleGenerationTest method testComplex.
@Test
public void testComplex() throws Exception {
final Schema model = context.resolve(new AnnotatedType(ComplexBean.class));
assertNotNull(model);
final Map<String, Schema> props = model.getProperties();
assertEquals(props.size(), 6);
}
use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.
the class SimpleGenerationTest method testIntArray.
@Test
public void testIntArray() throws Exception {
final Schema model = context.resolve(new AnnotatedType(IntArrayBean.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, "b");
assertEquals(prop.getType(), "array");
}
Aggregations