Merge pull request #152 from alecsammon/refArrayJson

Fetching JSON Array from URI
This commit is contained in:
David Porter 2015-06-12 22:59:41 -05:00
commit c76301b61e
2 changed files with 23 additions and 1 deletions

View File

@ -150,7 +150,10 @@ class UriRetriever
// Use the JSON pointer if specified
$jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
if ($jsonSchema instanceof \stdClass) {
$jsonSchema->id = $resolvedUri;
}
return $jsonSchema;
}

View File

@ -287,6 +287,25 @@ JSN
);
}
public function testFetchRefArray()
{
$retr = new \JsonSchema\Uri\Retrievers\PredefinedArray(
array(
'http://example.org/array' => <<<JSN
[1,2,3]
JSN
)
);
$res = new \JsonSchema\RefResolver();
$res->getUriRetriever()->setUriRetriever($retr);
$this->assertEquals(
array(1, 2, 3),
$res->fetchRef('http://example.org/array', 'http://example.org/array')
);
}
public function testSetGetUriRetriever()
{
$retriever = new \JsonSchema\Uri\UriRetriever;