Skip to content

Commit

Permalink
Bump justinrainbow/json-schema to 2.0 (#13)
Browse files Browse the repository at this point in the history
Bump justinrainbow/json-schema to 2.0
  • Loading branch information
estahn authored Aug 3, 2016
1 parent 403e92a commit 11fd0e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"email": "enrico.stahn@gmail.com"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"require": {
"php": "^5.4 || ^7.0",
"justinrainbow/json-schema": "^1.6",
"justinrainbow/json-schema": "^2.0",
"mtdowling/jmespath.php": "^2.3"
},
"require-dev": {
Expand Down
10 changes: 4 additions & 6 deletions src/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace EnricoStahn\JsonAssert;

use JsonSchema\RefResolver;
use JsonSchema\Uri\UriResolver;
use JsonSchema\Uri\UriRetriever;
use JsonSchema\Validator;

Expand All @@ -36,16 +37,13 @@ trait Assert
*/
public static function assertJsonMatchesSchema($schema, $content)
{
$retriever = new UriRetriever();
$schema = $retriever->retrieve('file://'.realpath($schema));

// Assume references are relative to the current file
// Create an issue or pull request if you need more complex use cases
$refResolver = new RefResolver($retriever);
$refResolver->resolve($schema, $schema->id);
$refResolver = new RefResolver(new UriRetriever(), new UriResolver());
$schemaObj = $refResolver->resolve('file://'.realpath($schema));

$validator = new Validator();
$validator->check($content, $schema);
$validator->check($content, $schemaObj);

$message = '- Property: %s, Contraint: %s, Message: %s';
$messages = array_map(function ($exception) use ($message) {
Expand Down

0 comments on commit 11fd0e8

Please sign in to comment.