diff --git a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java index 7f8a925d15..4ea4c93dd7 100644 --- a/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java +++ b/modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java @@ -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(); @@ -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 referencedObjectProperties = referencedObjectModel.getProperties(); + assertTrue(referencedObjectProperties.containsKey("hello")); + final Schema fooModel = definitions.get("foo"); assertEquals(fooModel.getDescription(), "Just another model"); expectedPropertiesInModel(fooModel, "hello", "world"); @@ -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(); diff --git a/modules/swagger-parser-v3/src/test/resources/ref-problem/ref-problem.yaml b/modules/swagger-parser-v3/src/test/resources/issue-1889/issue1889.yaml similarity index 100% rename from modules/swagger-parser-v3/src/test/resources/ref-problem/ref-problem.yaml rename to modules/swagger-parser-v3/src/test/resources/issue-1889/issue1889.yaml