From 54bf2e8fcb26900acebce09eb1737a2ca5a5935f Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:33:24 +0200 Subject: [PATCH] chore: remove hydra prefix --- api/config/packages/api_platform.yaml | 2 +- api/tests/Api/Admin/BookTest.php | 52 ++++++++--------- api/tests/Api/Admin/ReviewTest.php | 28 ++++----- api/tests/Api/Admin/UserTest.php | 16 ++--- .../Api/Admin/schemas/Book/collection.json | 30 +++++----- .../Api/Admin/schemas/Review/collection.json | 30 +++++----- .../Api/Admin/schemas/User/collection.json | 30 +++++----- api/tests/Api/BookTest.php | 10 ++-- api/tests/Api/BookmarkTest.php | 36 ++++++------ api/tests/Api/ReviewTest.php | 58 +++++++++---------- api/tests/Api/schemas/Book/collection.json | 30 +++++----- .../Api/schemas/Bookmark/collection.json | 30 +++++----- api/tests/Api/schemas/Review/collection.json | 20 +++---- pwa/components/book/List.tsx | 6 +- pwa/components/book/Show.tsx | 4 +- pwa/components/bookmark/List.tsx | 6 +- pwa/components/common/Pagination.tsx | 6 +- pwa/components/review/List.tsx | 4 +- pwa/types/collection.ts | 18 +++--- pwa/utils/dataAccess.ts | 4 +- pwa/utils/mercure.ts | 10 ++-- 21 files changed, 215 insertions(+), 215 deletions(-) diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index 17798882c..6c49a4592 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -32,7 +32,7 @@ api_platform: event_listeners_backward_compatibility_layer: false keep_legacy_inflector: false serializer: - hydra_prefix: true + hydra_prefix: false oauth: enabled: true clientId: '%env(OIDC_SWAGGER_CLIENT_ID)%' diff --git a/api/tests/Api/Admin/BookTest.php b/api/tests/Api/Admin/BookTest.php index 74a605a12..45f5f06f3 100644 --- a/api/tests/Api/Admin/BookTest.php +++ b/api/tests/Api/Admin/BookTest.php @@ -54,9 +54,9 @@ public function asNonAdminUserICannotGetACollectionOfBooks(int $expectedCode, st self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -77,9 +77,9 @@ public function asAdminUserICanGetACollectionOfBooks(FactoryCollection $factory, self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders()['link'][1]); self::assertJsonContains([ - 'hydra:totalItems' => $hydraTotalItems, + 'totalItems' => $hydraTotalItems, ]); - self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['hydra:member']); + self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['member']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Book/collection.json')); } @@ -144,9 +144,9 @@ public function asAdminUserICanGetACollectionOfBooksOrderedByTitle(): void self::assertResponseIsSuccessful(); self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders()['link'][1]); - self::assertEquals('Ball Lightning', $response->toArray()['hydra:member'][0]['title']); - self::assertEquals('Hyperion', $response->toArray()['hydra:member'][1]['title']); - self::assertEquals('The Wandering Earth', $response->toArray()['hydra:member'][2]['title']); + self::assertEquals('Ball Lightning', $response->toArray()['member'][0]['title']); + self::assertEquals('Hyperion', $response->toArray()['member'][1]['title']); + self::assertEquals('The Wandering Earth', $response->toArray()['member'][2]['title']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Book/collection.json')); } @@ -196,9 +196,9 @@ public function asNonAdminUserICannotGetABook(int $expectedCode, string $hydraDe self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -254,9 +254,9 @@ public function asNonAdminUserICannotCreateABook(int $expectedCode, string $hydr self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -290,7 +290,7 @@ public static function getInvalidDataOnCreate(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', + 'title' => 'An error occurred', 'violations' => [ [ 'propertyPath' => 'book', @@ -316,8 +316,8 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'condition: This value should be of type ' . BookCondition::class . '.', + 'title' => 'An error occurred', + 'description' => 'condition: This value should be of type ' . BookCondition::class . '.', 'violations' => [ [ 'propertyPath' => 'condition', @@ -334,8 +334,8 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'condition: This value should be of type ' . BookCondition::class . '.', + 'title' => 'An error occurred', + 'description' => 'condition: This value should be of type ' . BookCondition::class . '.', 'violations' => [ [ 'propertyPath' => 'condition', @@ -352,7 +352,7 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', + 'title' => 'An error occurred', 'violations' => [ [ 'propertyPath' => 'book', @@ -442,9 +442,9 @@ public function asNonAdminUserICannotUpdateBook(int $expectedCode, string $hydra self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -570,9 +570,9 @@ public function asNonAdminUserICannotDeleteABook(int $expectedCode, string $hydr self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } diff --git a/api/tests/Api/Admin/ReviewTest.php b/api/tests/Api/Admin/ReviewTest.php index b8b87ec3d..4d5664891 100644 --- a/api/tests/Api/Admin/ReviewTest.php +++ b/api/tests/Api/Admin/ReviewTest.php @@ -55,9 +55,9 @@ public function asNonAdminUserICannotGetACollectionOfReviews(int $expectedCode, self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -81,9 +81,9 @@ public function asAdminUserICanGetACollectionOfReviews(FactoryCollection $factor self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders()['link'][1]); self::assertJsonContains([ - 'hydra:totalItems' => $hydraTotalItems, + 'totalItems' => $hydraTotalItems, ]); - self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['hydra:member']); + self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['member']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Review/collection.json')); } @@ -163,9 +163,9 @@ public function asNonAdminUserICannotGetAReview(int $expectedCode, string $hydra self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -227,9 +227,9 @@ public function asNonAdminUserICannotUpdateAReview(int $expectedCode, string $hy self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -334,9 +334,9 @@ public function asNonAdminUserICannotDeleteAReview(int $expectedCode, string $hy self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } diff --git a/api/tests/Api/Admin/UserTest.php b/api/tests/Api/Admin/UserTest.php index cc5825d53..b56874d2b 100644 --- a/api/tests/Api/Admin/UserTest.php +++ b/api/tests/Api/Admin/UserTest.php @@ -47,9 +47,9 @@ public function asNonAdminUserICannotGetACollectionOfUsers(int $expectedCode, st self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -72,9 +72,9 @@ public function asAdminUserICanGetACollectionOfUsers(FactoryCollection $factory, self::assertResponseIsSuccessful(); self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertJsonContains([ - 'hydra:totalItems' => $hydraTotalItems, + 'totalItems' => $hydraTotalItems, ]); - self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['hydra:member']); + self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['member']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/User/collection.json')); } @@ -123,9 +123,9 @@ public function asNonAdminUserICannotGetAUser(int $expectedCode, string $hydraDe self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } diff --git a/api/tests/Api/Admin/schemas/Book/collection.json b/api/tests/Api/Admin/schemas/Book/collection.json index eb02f1a8f..2ed63ae71 100644 --- a/api/tests/Api/Admin/schemas/Book/collection.json +++ b/api/tests/Api/Admin/schemas/Book/collection.json @@ -78,24 +78,24 @@ "@type": { "readOnly": true, "type": "string", - "pattern": "^hydra:Collection$" + "pattern": "^Collection$" }, "@id": { "readOnly": true, "type": "string", "pattern": "^/admin/books$" }, - "hydra:member": { + "member": { "type": "array", "items": { "$ref": "#\/definitions\/Book:jsonld" } }, - "hydra:totalItems": { + "totalItems": { "type": "integer", "minimum": 0 }, - "hydra:view": { + "view": { "type": "object", "properties": { "@id": { @@ -105,33 +105,33 @@ "@type": { "type": "string" }, - "hydra:first": { + "first": { "type": "string", "format": "iri-reference" }, - "hydra:last": { + "last": { "type": "string", "format": "iri-reference" }, - "hydra:next": { + "next": { "type": "string", "format": "iri-reference" } } }, - "hydra:search": { + "search": { "type": "object", "properties": { "@type": { "type": "string" }, - "hydra:template": { + "template": { "type": "string" }, - "hydra:variableRepresentation": { + "variableRepresentation": { "type": "string" }, - "hydra:mapping": { + "mapping": { "type": "array", "items": { "type": "object", @@ -161,9 +161,9 @@ "@context", "@type", "@id", - "hydra:member", - "hydra:totalItems", - "hydra:view", - "hydra:search" + "member", + "totalItems", + "view", + "search" ] } diff --git a/api/tests/Api/Admin/schemas/Review/collection.json b/api/tests/Api/Admin/schemas/Review/collection.json index 6a1f327d4..259161a1a 100644 --- a/api/tests/Api/Admin/schemas/Review/collection.json +++ b/api/tests/Api/Admin/schemas/Review/collection.json @@ -171,24 +171,24 @@ "@type": { "readOnly": true, "type": "string", - "pattern": "^hydra:Collection$" + "pattern": "^Collection$" }, "@id": { "readOnly": true, "type": "string", "pattern": "^/admin/reviews$" }, - "hydra:member": { + "member": { "type": "array", "items": { "$ref": "#\/definitions\/Review:jsonld" } }, - "hydra:totalItems": { + "totalItems": { "type": "integer", "minimum": 0 }, - "hydra:view": { + "view": { "type": "object", "properties": { "@id": { @@ -198,33 +198,33 @@ "@type": { "type": "string" }, - "hydra:first": { + "first": { "type": "string", "format": "iri-reference" }, - "hydra:last": { + "last": { "type": "string", "format": "iri-reference" }, - "hydra:next": { + "next": { "type": "string", "format": "iri-reference" } } }, - "hydra:search": { + "search": { "type": "object", "properties": { "@type": { "type": "string" }, - "hydra:template": { + "template": { "type": "string" }, - "hydra:variableRepresentation": { + "variableRepresentation": { "type": "string" }, - "hydra:mapping": { + "mapping": { "type": "array", "items": { "type": "object", @@ -254,9 +254,9 @@ "@context", "@type", "@id", - "hydra:member", - "hydra:totalItems", - "hydra:view", - "hydra:search" + "member", + "totalItems", + "view", + "search" ] } diff --git a/api/tests/Api/Admin/schemas/User/collection.json b/api/tests/Api/Admin/schemas/User/collection.json index f94e49ad0..96e521d4d 100644 --- a/api/tests/Api/Admin/schemas/User/collection.json +++ b/api/tests/Api/Admin/schemas/User/collection.json @@ -57,24 +57,24 @@ "@type": { "readOnly": true, "type": "string", - "pattern": "^hydra:Collection$" + "pattern": "^Collection$" }, "@id": { "readOnly": true, "type": "string", "pattern": "^/admin/users$" }, - "hydra:member": { + "member": { "type": "array", "items": { "$ref": "#\/definitions\/User:jsonld" } }, - "hydra:totalItems": { + "totalItems": { "type": "integer", "minimum": 0 }, - "hydra:view": { + "view": { "type": "object", "properties": { "@id": { @@ -84,33 +84,33 @@ "@type": { "type": "string" }, - "hydra:first": { + "first": { "type": "string", "format": "iri-reference" }, - "hydra:last": { + "last": { "type": "string", "format": "iri-reference" }, - "hydra:next": { + "next": { "type": "string", "format": "iri-reference" } } }, - "hydra:search": { + "search": { "type": "object", "properties": { "@type": { "type": "string" }, - "hydra:template": { + "template": { "type": "string" }, - "hydra:variableRepresentation": { + "variableRepresentation": { "type": "string" }, - "hydra:mapping": { + "mapping": { "type": "array", "items": { "type": "object", @@ -140,9 +140,9 @@ "@context", "@type", "@id", - "hydra:member", - "hydra:totalItems", - "hydra:view", - "hydra:search" + "member", + "totalItems", + "view", + "search" ] } diff --git a/api/tests/Api/BookTest.php b/api/tests/Api/BookTest.php index 584f27879..3c2d3218a 100644 --- a/api/tests/Api/BookTest.php +++ b/api/tests/Api/BookTest.php @@ -41,9 +41,9 @@ public function asAnonymousICanGetACollectionOfBooks(FactoryCollection $factory, self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders()['link'][1]); self::assertJsonContains([ - 'hydra:totalItems' => $hydraTotalItems, + 'totalItems' => $hydraTotalItems, ]); - self::assertCount(min($hydraTotalItems, 30), $response->toArray()['hydra:member']); + self::assertCount(min($hydraTotalItems, 30), $response->toArray()['member']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Book/collection.json')); } @@ -98,9 +98,9 @@ public function asAdminUserICanGetACollectionOfBooksOrderedByTitle(): void self::assertResponseIsSuccessful(); self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders()['link'][1]); - self::assertEquals('Ball Lightning', $response->toArray()['hydra:member'][0]['title']); - self::assertEquals('Hyperion', $response->toArray()['hydra:member'][1]['title']); - self::assertEquals('The Wandering Earth', $response->toArray()['hydra:member'][2]['title']); + self::assertEquals('Ball Lightning', $response->toArray()['member'][0]['title']); + self::assertEquals('Hyperion', $response->toArray()['member'][1]['title']); + self::assertEquals('The Wandering Earth', $response->toArray()['member'][2]['title']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Book/collection.json')); } diff --git a/api/tests/Api/BookmarkTest.php b/api/tests/Api/BookmarkTest.php index f668dbd41..cc4aa0e68 100644 --- a/api/tests/Api/BookmarkTest.php +++ b/api/tests/Api/BookmarkTest.php @@ -45,9 +45,9 @@ public function asAnonymousICannotGetACollectionOfBookmarks(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -72,9 +72,9 @@ public function asAUserICanGetACollectionOfMyBookmarksWithoutFilters(): void self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders(false)['link'][1]); self::assertJsonContains([ - 'hydra:totalItems' => 35, + 'totalItems' => 35, ]); - self::assertCount(30, $response->toArray()['hydra:member']); + self::assertCount(30, $response->toArray()['member']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Bookmark/collection.json')); } @@ -97,9 +97,9 @@ public function asAnonymousICannotCreateABookmark(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -129,8 +129,8 @@ public function asAUserICannotCreateABookmarkWithInvalidData(): void self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'book: This value should be of type ' . Book::class . '.', + 'title' => 'An error occurred', + 'description' => 'book: This value should be of type ' . Book::class . '.', 'violations' => [ [ 'propertyPath' => 'book', @@ -219,8 +219,8 @@ public function asAUserICannotCreateADuplicateBookmark(): void self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'You have already bookmarked this book.', + 'title' => 'An error occurred', + 'description' => 'You have already bookmarked this book.', ]); } @@ -235,9 +235,9 @@ public function asAnonymousICannotDeleteABookmark(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -259,9 +259,9 @@ public function asAUserICannotDeleteABookmarkOfAnotherUser(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Access Denied.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Access Denied.', ]); } diff --git a/api/tests/Api/ReviewTest.php b/api/tests/Api/ReviewTest.php index 26dcc203b..390267d2e 100644 --- a/api/tests/Api/ReviewTest.php +++ b/api/tests/Api/ReviewTest.php @@ -55,9 +55,9 @@ public function asAnonymousICanGetACollectionOfBookReviewsWithoutFilters(Factory self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); self::assertEquals('; rel="mercure"', $response->getHeaders()['link'][1]); self::assertJsonContains([ - 'hydra:totalItems' => $hydraTotalItems, + 'totalItems' => $hydraTotalItems, ]); - self::assertCount(min($hydraTotalItems, $totalHydraMember), $response->toArray()['hydra:member']); + self::assertCount(min($hydraTotalItems, $totalHydraMember), $response->toArray()['member']); self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Review/collection.json')); } @@ -150,9 +150,9 @@ public function asAnonymousICannotAddAReviewOnABook(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -189,7 +189,7 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', + 'title' => 'An error occurred', 'violations' => [ [ 'propertyPath' => 'body', @@ -231,9 +231,9 @@ public function asAUserICannotAddAReviewWithValidDataOnAnInvalidBook(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Invalid uri variables.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Invalid uri variables.', ]); } @@ -326,8 +326,8 @@ public function asAUserICannotAddADuplicateReviewOnABook(): void self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'You have already reviewed this book.', + 'title' => 'An error occurred', + 'description' => 'You have already reviewed this book.', ]); } @@ -342,9 +342,9 @@ public function asAnonymousICannotGetAnInvalidReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'This route does not aim to be called.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'This route does not aim to be called.', ]); } @@ -359,9 +359,9 @@ public function asAnonymousICanGetABookReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'This route does not aim to be called.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'This route does not aim to be called.', ]); } @@ -384,9 +384,9 @@ public function asAnonymousICannotUpdateABookReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -415,9 +415,9 @@ public function asAUserICannotUpdateABookReviewOfAnotherUser(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Access Denied.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Access Denied.', ]); } @@ -501,9 +501,9 @@ public function asAnonymousICannotDeleteABookReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -525,9 +525,9 @@ public function asAUserICannotDeleteABookReviewOfAnotherUser(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Access Denied.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Access Denied.', ]); } diff --git a/api/tests/Api/schemas/Book/collection.json b/api/tests/Api/schemas/Book/collection.json index 3dbade24f..e04c98e51 100644 --- a/api/tests/Api/schemas/Book/collection.json +++ b/api/tests/Api/schemas/Book/collection.json @@ -95,24 +95,24 @@ "@type": { "readOnly": true, "type": "string", - "pattern": "^hydra:Collection$" + "pattern": "^Collection$" }, "@id": { "readOnly": true, "type": "string", "pattern": "^/books$" }, - "hydra:member": { + "member": { "type": "array", "items": { "$ref": "#\/definitions\/Book:jsonld" } }, - "hydra:totalItems": { + "totalItems": { "type": "integer", "minimum": 0 }, - "hydra:view": { + "view": { "type": "object", "properties": { "@id": { @@ -122,33 +122,33 @@ "@type": { "type": "string" }, - "hydra:first": { + "first": { "type": "string", "format": "iri-reference" }, - "hydra:last": { + "last": { "type": "string", "format": "iri-reference" }, - "hydra:next": { + "next": { "type": "string", "format": "iri-reference" } } }, - "hydra:search": { + "search": { "type": "object", "properties": { "@type": { "type": "string" }, - "hydra:template": { + "template": { "type": "string" }, - "hydra:variableRepresentation": { + "variableRepresentation": { "type": "string" }, - "hydra:mapping": { + "mapping": { "type": "array", "items": { "type": "object", @@ -178,9 +178,9 @@ "@context", "@type", "@id", - "hydra:member", - "hydra:totalItems", - "hydra:view", - "hydra:search" + "member", + "totalItems", + "view", + "search" ] } diff --git a/api/tests/Api/schemas/Bookmark/collection.json b/api/tests/Api/schemas/Bookmark/collection.json index fdd94265a..9944b5992 100644 --- a/api/tests/Api/schemas/Bookmark/collection.json +++ b/api/tests/Api/schemas/Bookmark/collection.json @@ -134,24 +134,24 @@ "@type": { "readOnly": true, "type": "string", - "pattern": "^hydra:Collection$" + "pattern": "^Collection$" }, "@id": { "readOnly": true, "type": "string", "pattern": "^/bookmarks$" }, - "hydra:member": { + "member": { "type": "array", "items": { "$ref": "#\/definitions\/Bookmark:jsonld" } }, - "hydra:totalItems": { + "totalItems": { "type": "integer", "minimum": 0 }, - "hydra:view": { + "view": { "type": "object", "properties": { "@id": { @@ -161,33 +161,33 @@ "@type": { "type": "string" }, - "hydra:first": { + "first": { "type": "string", "format": "iri-reference" }, - "hydra:last": { + "last": { "type": "string", "format": "iri-reference" }, - "hydra:next": { + "next": { "type": "string", "format": "iri-reference" } } }, - "hydra:search": { + "search": { "type": "object", "properties": { "@type": { "type": "string" }, - "hydra:template": { + "template": { "type": "string" }, - "hydra:variableRepresentation": { + "variableRepresentation": { "type": "string" }, - "hydra:mapping": { + "mapping": { "type": "array", "items": { "type": "object", @@ -217,9 +217,9 @@ "@context", "@type", "@id", - "hydra:member", - "hydra:totalItems", - "hydra:view", - "hydra:search" + "member", + "totalItems", + "view", + "search" ] } diff --git a/api/tests/Api/schemas/Review/collection.json b/api/tests/Api/schemas/Review/collection.json index cfe83e86c..bc737b8d5 100644 --- a/api/tests/Api/schemas/Review/collection.json +++ b/api/tests/Api/schemas/Review/collection.json @@ -128,24 +128,24 @@ "@type": { "readOnly": true, "type": "string", - "pattern": "^hydra:Collection$" + "pattern": "^Collection$" }, "@id": { "readOnly": true, "type": "string", "pattern": "^/books/.+/reviews$" }, - "hydra:member": { + "member": { "type": "array", "items": { "$ref": "#\/definitions\/Review:jsonld" } }, - "hydra:totalItems": { + "totalItems": { "type": "integer", "minimum": 0 }, - "hydra:view": { + "view": { "type": "object", "properties": { "@id": { @@ -155,15 +155,15 @@ "@type": { "type": "string" }, - "hydra:first": { + "first": { "type": "string", "format": "iri-reference" }, - "hydra:last": { + "last": { "type": "string", "format": "iri-reference" }, - "hydra:next": { + "next": { "type": "string", "format": "iri-reference" } @@ -174,8 +174,8 @@ "@context", "@type", "@id", - "hydra:member", - "hydra:totalItems", - "hydra:view" + "member", + "totalItems", + "view" ] } diff --git a/pwa/components/book/List.tsx b/pwa/components/book/List.tsx index 9c5fb97b9..d63d50e55 100644 --- a/pwa/components/book/List.tsx +++ b/pwa/components/book/List.tsx @@ -48,7 +48,7 @@ export const List: NextPage = ({ data, hubURL, filters, page }: Props) =>
- {!!collection && !!collection["hydra:member"] && ( + {!!collection && !!collection["member"] && ( <>
@@ -68,10 +68,10 @@ export const List: NextPage = ({ data, hubURL, filters, page }: Props) => Title DESC
- {collection["hydra:totalItems"]} book(s) found + {collection["totalItems"]} book(s) found
- {collection["hydra:member"].length !== 0 && collection["hydra:member"].map((book) => ( + {collection["member"].length !== 0 && collection["member"].map((book) => ( ))}
diff --git a/pwa/components/book/Show.tsx b/pwa/components/book/Show.tsx index 5314654cb..5436df1e8 100644 --- a/pwa/components/book/Show.tsx +++ b/pwa/components/book/Show.tsx @@ -81,8 +81,8 @@ export const Show: NextPage = ({ data, hubURL }) => { try { // @ts-ignore const response: FetchResponse> | undefined = await fetchApi(`/bookmarks?book=${data["@id"]}`, {}, session); - if (response && response?.data && response.data["hydra:member"]?.length) { - setBookmark(response.data["hydra:member"][0]); + if (response && response?.data && response.data["member"]?.length) { + setBookmark(response.data["member"][0]); } } catch (error) { console.error(error); diff --git a/pwa/components/bookmark/List.tsx b/pwa/components/bookmark/List.tsx index c383c5ec4..b6ff62d2a 100644 --- a/pwa/components/bookmark/List.tsx +++ b/pwa/components/bookmark/List.tsx @@ -21,13 +21,13 @@ export const List: NextPage = ({ data, hubURL, page }) => { return (
- {!!collection && !!collection["hydra:member"] && ( + {!!collection && !!collection["member"] && ( <>

- {collection["hydra:totalItems"]} book(s) bookmarked + {collection["totalItems"]} book(s) bookmarked

- {collection["hydra:member"].length !== 0 && collection["hydra:member"].map((bookmark) => ( + {collection["member"].length !== 0 && collection["member"].map((bookmark) => ( ))}
diff --git a/pwa/components/common/Pagination.tsx b/pwa/components/common/Pagination.tsx index a106f8856..c70afe67d 100644 --- a/pwa/components/common/Pagination.tsx +++ b/pwa/components/common/Pagination.tsx @@ -12,14 +12,14 @@ interface Props { } export const Pagination = ({ collection, getPagePath, currentPage }: Props) => { - const view = collection && collection["hydra:view"]; - if (!view || !view["hydra:last"]) return null; + const view = collection && collection["view"]; + if (!view || !view["last"]) return null; return (
- ( )} diff --git a/pwa/components/review/List.tsx b/pwa/components/review/List.tsx index d5ea97f6e..a462b4dda 100644 --- a/pwa/components/review/List.tsx +++ b/pwa/components/review/List.tsx @@ -81,9 +81,9 @@ export const List: FunctionComponent = ({ book }) => { )} {!!error && ( - ) || !!collection && !!collection["hydra:member"] && collection["hydra:member"]?.length > 0 && ( + ) || !!collection && !!collection["member"] && collection["member"]?.length > 0 && ( <> - {collection["hydra:member"].map((review) => ( + {collection["member"].map((review) => ( toggleReload(!reload)}/> ))} diff --git a/pwa/types/collection.ts b/pwa/types/collection.ts index 3b271a513..60f87f2c2 100644 --- a/pwa/types/collection.ts +++ b/pwa/types/collection.ts @@ -2,18 +2,18 @@ export interface PagedCollection { "@context"?: string; "@id"?: string; "@type"?: string; - "hydra:member"?: T[]; - "hydra:search"?: object; - "hydra:totalItems"?: number; - "hydra:view"?: { + "member"?: T[]; + "search"?: object; + "totalItems"?: number; + "view"?: { "@id": string; "@type": string; - "hydra:first"?: string; - "hydra:last"?: string; - "hydra:previous"?: string; - "hydra:next"?: string; + "first"?: string; + "last"?: string; + "previous"?: string; + "next"?: string; }; } export const isPagedCollection = (data: any): data is PagedCollection => - "hydra:member" in data && Array.isArray(data["hydra:member"]); + "member" in data && Array.isArray(data["member"]); diff --git a/pwa/utils/dataAccess.ts b/pwa/utils/dataAccess.ts index a963cb009..d8a48597c 100644 --- a/pwa/utils/dataAccess.ts +++ b/pwa/utils/dataAccess.ts @@ -67,8 +67,8 @@ export const fetchApi = async ( }; } - const errorMessage = json["hydra:title"]; - const status = json["hydra:description"] || resp.statusText; + const errorMessage = json["title"]; + const status = json["description"] || resp.statusText; if (!json.violations) throw Error(errorMessage); const fields: { [key: string]: string } = {}; json.violations.map( diff --git a/pwa/utils/mercure.ts b/pwa/utils/mercure.ts index 4da30acb6..682720cda 100644 --- a/pwa/utils/mercure.ts +++ b/pwa/utils/mercure.ts @@ -49,16 +49,16 @@ export const useMercure = < if ( isPagedCollection(data) && - data["hydra:member"] && - data["hydra:member"].length !== 0 + data["member"] && + data["member"].length !== 0 ) { const eventSources: EventSource[] = []; // It's a PagedCollection - data["hydra:member"].forEach((obj, pos) => { + data["member"].forEach((obj, pos) => { eventSources.push( mercureSubscribe(hubURL, obj, (datum) => { - if (data["hydra:member"]) { - data["hydra:member"][pos] = datum; + if (data["member"]) { + data["member"][pos] = datum; } setData({ ...data }); })