diff --git a/CHANGELOG.md b/CHANGELOG.md index 104dbe5e..123bb9b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), For a full diff see [`2.0.0...main`][2.0.0...main]. +## [`2.0.1`][2.0.1] + +For a full diff see [`2.0.0...2.0.1`][2.0.0...2.0.1]. + +### Fixed + +- Started throwing an `Exception\CanNotResolve` exception instead of an `Exception\ResolvedToRootSchema` when the `JsonPointer` is not a valid URI fragment identifier representation of a JSON pointer ([#201]), by [@localheinz] ### Changed - Required [`ergebnis/json-pointer`](https://github.com/ergebnis/json-pointer) ([#195]), by [@localheinz] @@ -51,7 +58,8 @@ For a full diff see [`dcd4cfb...1.0.0`][dcd4cfb...1.0.0]. [dcd4cfb...1.0.0]: https://github.com/ergebnis/json-schema-validator/compare/dcd4cfb...1.0.0 [1.0.0...2.0.0]: https://github.com/ergebnis/json-schema-validator/compare/1.0.0...2.0.0 -[2.0.0...main]: https://github.com/ergebnis/json-schema-validator/compare/2.0.0...main +[2.0.0...2.0.1]: https://github.com/ergebnis/json-schema-validator/compare/2.0.0...2.0.1 +[2.0.1...main]: https://github.com/ergebnis/json-schema-validator/compare/2.0.1...main [#2]: https://github.com/ergebnis/json-schema-validator/pull/2 [#3]: https://github.com/ergebnis/json-schema-validator/pull/3 @@ -71,5 +79,6 @@ For a full diff see [`dcd4cfb...1.0.0`][dcd4cfb...1.0.0]. [#169]: https://github.com/ergebnis/json-schema-validator/pull/169 [#172]: https://github.com/ergebnis/json-schema-validator/pull/172 [#195]: https://github.com/ergebnis/json-schema-validator/pull/195 +[#201]: https://github.com/ergebnis/json-schema-validator/pull/201 [@localheinz]: https://github.com/localheinz diff --git a/src/SchemaValidator.php b/src/SchemaValidator.php index 7f987533..87853134 100644 --- a/src/SchemaValidator.php +++ b/src/SchemaValidator.php @@ -50,7 +50,7 @@ public function validate( } if ($schemaDecoded === $subSchemaDecoded) { - throw ResolvedToRootSchema::jsonPointer($jsonPointer); + throw CanNotResolve::jsonPointer($jsonPointer); } $schemaDecoded = $subSchemaDecoded; diff --git a/test/Unit/Exception/CanNotResolveTest.php b/test/Unit/Exception/CanNotResolveTest.php index 28571c84..7f8ce12d 100644 --- a/test/Unit/Exception/CanNotResolveTest.php +++ b/test/Unit/Exception/CanNotResolveTest.php @@ -28,7 +28,7 @@ final class CanNotResolveTest extends Framework\TestCase { public function testJsonPointerReturnsException(): void { - $jsonPointer = JsonPointer::fromString('/foo/bar'); + $jsonPointer = JsonPointer::fromString('#/foo/bar'); $exception = Exception\CanNotResolve::jsonPointer($jsonPointer); diff --git a/test/Unit/Exception/ResolvedToRootSchemaTest.php b/test/Unit/Exception/ResolvedToRootSchemaTest.php index 0e9955a8..2990d458 100644 --- a/test/Unit/Exception/ResolvedToRootSchemaTest.php +++ b/test/Unit/Exception/ResolvedToRootSchemaTest.php @@ -28,7 +28,7 @@ final class ResolvedToRootSchemaTest extends Framework\TestCase { public function testJsonPointerReturnsException(): void { - $jsonPointer = JsonPointer::fromString('/foo/bar'); + $jsonPointer = JsonPointer::fromString('#/foo/bar'); $exception = Exception\ResolvedToRootSchema::jsonPointer($jsonPointer); diff --git a/test/Unit/SchemaValidatorTest.php b/test/Unit/SchemaValidatorTest.php index 8fe55a53..caad34e5 100644 --- a/test/Unit/SchemaValidatorTest.php +++ b/test/Unit/SchemaValidatorTest.php @@ -253,7 +253,7 @@ public function testValidateThrowsCanNotResolveWhenJsonPointerIsNotEmptyAndSubSc ); } - public function testValidateThrowsResolvedToRootSchemaWhenJsonPointerIsNotEmptyAndSubSchemaWasResolvedToRootSchema(): void + public function testValidateThrowsCanNotResolveWhenJsonPointerIsNotEmptyButCouldNotBeParsedAsUriFragmentIdentifierString(): void { $faker = self::faker(); @@ -288,11 +288,11 @@ public function testValidateThrowsResolvedToRootSchemaWhenJsonPointerIsNotEmptyA 'type' => 'object', ])); - $jsonPointer = JsonPointer::fromString('/properties/qux'); + $jsonPointer = JsonPointer::fromString('#/properties/qux'); $schemaValidator = new SchemaValidator(); - $this->expectException(Exception\ResolvedToRootSchema::class); + $this->expectException(Exception\CanNotResolve::class); $schemaValidator->validate( $data,