From af5478d2ccb2fd4f8ce5fcb39ad12149c389b9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Glatter-G=C3=B6tz?= Date: Thu, 10 Oct 2013 20:21:52 +0200 Subject: [PATCH 1/2] Add *Of properties to RefResolver The RefResolver currently skips any part of the schema that contains 'allOf', 'anyOf' or 'oneOf'. This prevents proper resolving of references ($ref) that are inside of an array that is part of the above mentioned properties. Add the three property names to the array that is used to execute resolveArrayOfSchemas(). --- src/JsonSchema/RefResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonSchema/RefResolver.php b/src/JsonSchema/RefResolver.php index bf9d3848..afe0b741 100644 --- a/src/JsonSchema/RefResolver.php +++ b/src/JsonSchema/RefResolver.php @@ -116,7 +116,7 @@ public function resolve($schema, $sourceUri = null) // These are all potentially arrays that contain schema objects // eg. type can be a value or an array of values/schemas // eg. items can be a schema or an array of schemas - foreach (array('disallow', 'extends', 'items', 'type') as $propertyName) { + foreach (array('disallow', 'extends', 'items', 'type', 'allOf', 'anyOf', 'oneOf') as $propertyName) { $this->resolveArrayOfSchemas($schema, $propertyName, $sourceUri); } From 6d8dbed8e132ecd3758e6fb75e10e8cae0046443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20Glatter-G=C3=B6tz?= Date: Thu, 10 Oct 2013 22:43:47 +0200 Subject: [PATCH 2/2] Update test case to account for 3 additional parameters In JsonSchema\Tests\RefResolverTest::testResolve the JsonSchema\RefResolver::resolveArrayOfSchemas method is now called 7 instead of 4 times due to the addition of 'oneOf', 'allOf' and 'anyOf'. Change expected count from 4 to 7 in resolveProvider. --- tests/JsonSchema/Tests/RefResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/JsonSchema/Tests/RefResolverTest.php b/tests/JsonSchema/Tests/RefResolverTest.php index 0d1dbde5..dd2793fc 100644 --- a/tests/JsonSchema/Tests/RefResolverTest.php +++ b/tests/JsonSchema/Tests/RefResolverTest.php @@ -43,7 +43,7 @@ public function resolveProvider() { array( 'resolveRef' => 1, 'resolveProperty' => 4, - 'resolveArrayOfSchemas' => 4, + 'resolveArrayOfSchemas' => 7, 'resolveObjectOfSchemas' => 3 ) )