Skip to content

Commit

Permalink
Add test for allOf without object type (OpenAPITools#6042)
Browse files Browse the repository at this point in the history
* add test for allof without object type

* add comments to test cases
  • Loading branch information
wing328 authored and MikailBag committed May 31, 2020
1 parent b32c715 commit 179cc09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,23 @@ public void testAllOfSingleAndDoubleRefWithOwnPropsNoDiscriminator() {

codegen.setOpenAPI(openAPI);

// to test allOf with double refs
Schema supermanSchema = openAPI.getComponents().getSchemas().get("SuperMan");
CodegenModel supermanModel = codegen.fromModel("SuperMan", supermanSchema);
Assert.assertEquals(supermanModel.parent, null);
Assert.assertEquals(supermanModel.allParents, null);

// to test allOf with single ref
Schema superboySchema = openAPI.getComponents().getSchemas().get("SuperBoy");
CodegenModel superboyModel = codegen.fromModel("SuperBoy", superboySchema);
Assert.assertEquals(superboyModel.parent, null);
Assert.assertEquals(superboyModel.allParents, null);

// to test allOf with single ref and no "type: object" in the (last) inline schema
Schema superbabySchema = openAPI.getComponents().getSchemas().get("SuperBaby");
CodegenModel superbabyModel = codegen.fromModel("SuperBaby", superbabySchema);
Assert.assertEquals(superbabyModel.parent, null);
Assert.assertEquals(superbabyModel.allParents, null);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ paths:
$ref: "#/components/schemas/SuperMan"
components:
schemas:
SuperBaby: # to test single ref (Human) only
allOf:
- $ref: '#/components/schemas/Human'
- required: # without type: object
- level
properties:
gender:
type: string
age:
type: integer
SuperBoy: # to test single ref (Human) only
allOf:
- $ref: '#/components/schemas/Human'
Expand Down

0 comments on commit 179cc09

Please sign in to comment.