Skip to content

Commit

Permalink
Format refactoring for test. Fixed of the test where the refernce to …
Browse files Browse the repository at this point in the history
…the file was not taken into account earlier
  • Loading branch information
Yehor Kovalchuk committed Mar 29, 2023
1 parent 1d9af14 commit 7e3dd07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,11 @@ public void testIssue1658() throws Exception {
}

@Test
public void testRefParseProblem() {
public void testIssue1889_ArrayReferenceNull() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("src/test/resources/ref-problem/ref-problem.yaml", null, options);
SwaggerParseResult result = new OpenAPIV3Parser()
.readLocation("src/test/resources/issue-1889/issue1889.yaml", null, options);
Assert.assertNotNull(result);
Assert.assertNotNull(result.getOpenAPI());
OpenAPI openAPI = result.getOpenAPI();
Expand Down Expand Up @@ -2291,6 +2292,10 @@ private OpenAPI doRelativeFileTest(String location) {
assertEquals(refInDefinitions.getDescription(), "The example model");
expectedPropertiesInModel(refInDefinitions, "foo", "bar");

final ObjectSchema referencedObjectModel = (ObjectSchema) definitions.get("arrayModel");
final Map<String, Schema> referencedObjectProperties = referencedObjectModel.getProperties();
assertTrue(referencedObjectProperties.containsKey("hello"));

final Schema fooModel = definitions.get("foo");
assertEquals(fooModel.getDescription(), "Just another model");
expectedPropertiesInModel(fooModel, "hello", "world");
Expand All @@ -2299,6 +2304,9 @@ private OpenAPI doRelativeFileTest(String location) {
final Schema child = composedCat.getAllOf().get(2);
expectedPropertiesInModel(child, "huntingSkill", "prop2", "reflexes", "reflexMap");
final ArraySchema reflexes = (ArraySchema) child.getProperties().get("reflexes");
final Schema reflexItems = reflexes.getItems();
assertEquals(reflexItems.get$ref(), "#/components/schemas/reflex");
assertTrue(definitions.containsKey(reflexItems.get$ref().substring(reflexItems.get$ref().lastIndexOf("/")+1)));

final Schema reflexMap = (Schema) child.getProperties().get("reflexMap");
final Schema reflexMapAdditionalProperties = (Schema) reflexMap.getAdditionalProperties();
Expand Down

0 comments on commit 7e3dd07

Please sign in to comment.