diff --git a/src/Json/Json.php b/src/Json/Json.php index a95dacb6..8f7e6294 100644 --- a/src/Json/Json.php +++ b/src/Json/Json.php @@ -13,6 +13,11 @@ public function __construct($content) $this->content = $this->decode((string) $content); } + public function getContent() + { + return $this->content; + } + public function read($expression, PropertyAccessor $accessor) { if (is_array($this->content)) { diff --git a/src/Json/JsonSchema.php b/src/Json/JsonSchema.php index 32b9835f..659ada01 100644 --- a/src/Json/JsonSchema.php +++ b/src/Json/JsonSchema.php @@ -28,7 +28,7 @@ public function resolve(RefResolver $resolver) public function validate(Json $json, Validator $validator) { - $validator->check($json, $this); + $validator->check($json->getContent(), $this->getContent()); if (!$validator->isValid()) { $msg = "JSON does not validate. Violations:".PHP_EOL; diff --git a/tests/units/Json/JsonSchema.php b/tests/units/Json/JsonSchema.php index 80403777..02b97b18 100644 --- a/tests/units/Json/JsonSchema.php +++ b/tests/units/Json/JsonSchema.php @@ -60,7 +60,7 @@ public function test_should_validate_correct_json() ) ->mock($validator) ->call('check') - ->withArguments($json, $schema) + ->withArguments($json->getContent(), $schema->getContent()) ->once() ->boolean($result)