From a6896c54a4b89adce16aa8d730326d264037c09d Mon Sep 17 00:00:00 2001 From: Enrico Stahn Date: Mon, 1 Aug 2016 15:22:55 +1000 Subject: [PATCH 1/3] Bump justinrainbow/json-schema to 2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9981069..52ea5db 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "minimum-stability": "dev", "require": { "php": "^5.4 || ^7.0", - "justinrainbow/json-schema": "^1.6", + "justinrainbow/json-schema": "^2.0", "mtdowling/jmespath.php": "^2.3" }, "require-dev": { From 938b5cd75729bed14fd5e7884338fdd1f0fd90d1 Mon Sep 17 00:00:00 2001 From: Enrico Stahn Date: Tue, 2 Aug 2016 01:52:23 -0400 Subject: [PATCH 2/3] Applied fixes from StyleCI --- src/Assert.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Assert.php b/src/Assert.php index 6062478..97ae9fb 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -40,7 +40,7 @@ public static function assertJsonMatchesSchema($schema, $content) // Assume references are relative to the current file // Create an issue or pull request if you need more complex use cases $refResolver = new RefResolver(new UriRetriever(), new UriResolver()); - $schemaObj = $refResolver->resolve('file://' . realpath($schema)); + $schemaObj = $refResolver->resolve('file://'.realpath($schema)); $validator = new Validator(); $validator->check($content, $schemaObj); From b214caef9470e7a30600dd23985df8316069ce56 Mon Sep 17 00:00:00 2001 From: Enrico Stahn Date: Tue, 2 Aug 2016 15:53:41 +1000 Subject: [PATCH 3/3] Adjust Assert to new json-schema API --- composer.json | 2 +- src/Assert.php | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 52ea5db..490e63c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "email": "enrico.stahn@gmail.com" } ], - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": "^5.4 || ^7.0", "justinrainbow/json-schema": "^2.0", diff --git a/src/Assert.php b/src/Assert.php index 2abd8d6..6062478 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -12,6 +12,7 @@ namespace EnricoStahn\JsonAssert; use JsonSchema\RefResolver; +use JsonSchema\Uri\UriResolver; use JsonSchema\Uri\UriRetriever; use JsonSchema\Validator; @@ -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) {