diff --git a/CHANGELOG.md b/CHANGELOG.md index d565111..3f4bc42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [2.1.2] - 2020-03-16 +### Fixed +- Related links must be allowed inside relationship documents (#104) + ## [2.1.1] - 2019-12-19 ### Fixed - ResourceIdentifier does not allow multiple meta members (#99) @@ -22,7 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - v2 initial release -[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.1...HEAD -[2.2.0]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1 +[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.2...HEAD +[2.1.2]: https://github.com/json-api-php/json-api/compare/2.1.1...2.1.2 +[2.1.1]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1 [2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0 [2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1 diff --git a/composer.json b/composer.json index 76bbb66..ffcd77e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "require": { "php": ">=7.1", "ext-json": "*" - }, "require-dev": { "phpunit/phpunit": "^7.0||^8.0", diff --git a/src/Internal/Identifier.php b/src/Internal/Identifier.php index fa435a1..f8f9e47 100644 --- a/src/Internal/Identifier.php +++ b/src/Internal/Identifier.php @@ -8,8 +8,8 @@ interface Identifier { /** - * @internal * @param array $registry + * @internal */ public function registerIn(array &$registry): void; } diff --git a/src/Link/RelatedLink.php b/src/Link/RelatedLink.php index c1924ee..1def33c 100644 --- a/src/Link/RelatedLink.php +++ b/src/Link/RelatedLink.php @@ -3,10 +3,11 @@ namespace JsonApiPhp\JsonApi\Link; use function JsonApiPhp\JsonApi\child; +use JsonApiPhp\JsonApi\Internal\DataDocumentMember; use JsonApiPhp\JsonApi\Internal\LinkTrait; use JsonApiPhp\JsonApi\Internal\RelationshipMember; -final class RelatedLink implements RelationshipMember +final class RelatedLink implements RelationshipMember, DataDocumentMember { use LinkTrait; diff --git a/src/PaginatedCollection.php b/src/PaginatedCollection.php index 15e3cc7..e59c66f 100644 --- a/src/PaginatedCollection.php +++ b/src/PaginatedCollection.php @@ -33,8 +33,8 @@ public function attachTo($o): void } /** - * @internal * @param array $registry + * @internal */ public function registerIn(array &$registry): void { diff --git a/test/DataDocument/ManyResourceObjectsTest.php b/test/DataDocument/ManyResourceObjectsTest.php index 3a2be82..54736e2 100644 --- a/test/DataDocument/ManyResourceObjectsTest.php +++ b/test/DataDocument/ManyResourceObjectsTest.php @@ -5,6 +5,7 @@ use JsonApiPhp\JsonApi\Attribute; use JsonApiPhp\JsonApi\DataDocument; use JsonApiPhp\JsonApi\JsonApi; +use JsonApiPhp\JsonApi\Link\RelatedLink; use JsonApiPhp\JsonApi\Link\SelfLink; use JsonApiPhp\JsonApi\Meta; use JsonApiPhp\JsonApi\ResourceCollection; @@ -33,24 +34,23 @@ public function testExtendedDocument() ' { "data": [{ - "type": "apples", + "type": "people", "id": "1", "attributes": { - "color": "red", - "sort": "Fuji" + "name": "Martin Fowler" }, "meta": {"apple_meta": "foo"} },{ - "type": "apples", + "type": "people", "id": "2", "attributes": { - "color": "yellow", - "sort": "Gala" + "name": "Kent Beck" }, "meta": {"apple_meta": "foo"} }], "links": { - "self": "/apples" + "self": "/books/123/relationships/authors", + "related": "/books/123/authors" }, "jsonapi": { "version": "1.0" @@ -61,21 +61,20 @@ public function testExtendedDocument() new DataDocument( new ResourceCollection( new ResourceObject( - 'apples', + 'people', '1', - new Attribute('color', 'red'), - new Attribute('sort', 'Fuji'), + new Attribute('name', 'Martin Fowler'), new Meta('apple_meta', 'foo') ), new ResourceObject( - 'apples', + 'people', '2', - new Attribute('color', 'yellow'), - new Attribute('sort', 'Gala'), + new Attribute('name', 'Kent Beck'), new Meta('apple_meta', 'foo') ) ), - new SelfLink('/apples'), + new SelfLink('/books/123/relationships/authors'), + new RelatedLink('/books/123/authors'), new JsonApi(), new Meta('document_meta', 'bar') ) diff --git a/test/DataDocument/SingleResourceIdentifierTest.php b/test/DataDocument/SingleResourceIdentifierTest.php index 1d12a77..165a625 100644 --- a/test/DataDocument/SingleResourceIdentifierTest.php +++ b/test/DataDocument/SingleResourceIdentifierTest.php @@ -4,6 +4,7 @@ use JsonApiPhp\JsonApi\DataDocument; use JsonApiPhp\JsonApi\JsonApi; +use JsonApiPhp\JsonApi\Link\RelatedLink; use JsonApiPhp\JsonApi\Link\SelfLink; use JsonApiPhp\JsonApi\Meta; use JsonApiPhp\JsonApi\ResourceIdentifier; @@ -17,13 +18,13 @@ public function testMinimalDocument() ' { "data": { - "type": "apples", + "type": "companies", "id": "1" } } ', new DataDocument( - new ResourceIdentifier('apples', '1') + new ResourceIdentifier('companies', '1') ) ); } @@ -34,7 +35,7 @@ public function testExtendedDocument() ' { "data": { - "type": "apples", + "type": "companies", "id": "1", "meta": { "apple_meta": "foo", @@ -42,7 +43,8 @@ public function testExtendedDocument() } }, "links": { - "self": "/apples/1" + "self": "/books/123/relationships/publisher", + "related": "/books/123/publisher" }, "jsonapi": { "version": "1.0" @@ -52,12 +54,13 @@ public function testExtendedDocument() ', new DataDocument( new ResourceIdentifier( - 'apples', + 'companies', '1', new Meta('apple_meta', 'foo'), new Meta('bar', [42]) ), - new SelfLink('/apples/1'), + new SelfLink('/books/123/relationships/publisher'), + new RelatedLink('/books/123/publisher'), new JsonApi(), new Meta('document_meta', 'bar') )