Skip to content

Commit

Permalink
fix: remove hydra prefix from error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Oct 4, 2024
1 parent 61a75af commit 8efcb2f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 82 deletions.
42 changes: 21 additions & 21 deletions api/tests/Api/Admin/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function asNonAdminUserICannotGetACollectionOfBooks(int $expectedCode, st
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -196,9 +196,9 @@ public function asNonAdminUserICannotGetABook(int $expectedCode, string $hydraDe
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -254,9 +254,9 @@ public function asNonAdminUserICannotCreateABook(int $expectedCode, string $hydr
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -442,9 +442,9 @@ public function asNonAdminUserICannotUpdateBook(int $expectedCode, string $hydra
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -570,9 +570,9 @@ public function asNonAdminUserICannotDeleteABook(int $expectedCode, string $hydr
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down
24 changes: 12 additions & 12 deletions api/tests/Api/Admin/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function asNonAdminUserICannotGetACollectionOfReviews(int $expectedCode,
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -163,9 +163,9 @@ public function asNonAdminUserICannotGetAReview(int $expectedCode, string $hydra
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -227,9 +227,9 @@ public function asNonAdminUserICannotUpdateAReview(int $expectedCode, string $hy
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -334,9 +334,9 @@ public function asNonAdminUserICannotDeleteAReview(int $expectedCode, string $hy
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down
12 changes: 6 additions & 6 deletions api/tests/Api/Admin/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function asNonAdminUserICannotGetACollectionOfUsers(int $expectedCode, st
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down Expand Up @@ -123,9 +123,9 @@ public function asNonAdminUserICannotGetAUser(int $expectedCode, string $hydraDe
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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,
]);
}

Expand Down
32 changes: 16 additions & 16 deletions api/tests/Api/BookmarkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function asAnonymousICannotGetACollectionOfBookmarks(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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.',
]);
}

Expand Down Expand Up @@ -97,9 +97,9 @@ public function asAnonymousICannotCreateABookmark(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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.',
]);
}

Expand Down Expand Up @@ -129,8 +129,8 @@ public function asAUserICannotCreateABookmarkWithInvalidData(): void
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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',
Expand Down Expand Up @@ -219,8 +219,8 @@ public function asAUserICannotCreateADuplicateBookmark(): void
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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.',
]);
}

Expand All @@ -235,9 +235,9 @@ public function asAnonymousICannotDeleteABookmark(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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.',
]);
}

Expand All @@ -259,9 +259,9 @@ public function asAUserICannotDeleteABookmarkOfAnotherUser(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; 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.',
]);
}

Expand Down
Loading

0 comments on commit 8efcb2f

Please sign in to comment.