Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configuration #330

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ api_platform:
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true
rfc_7807_compliant_errors: true
oauth:
enabled: true
clientId: '%env(OIDC_SWAGGER_CLIENT_ID)%'
Expand Down
2 changes: 0 additions & 2 deletions api/src/Entity/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#[ApiResource(
uriTemplate: '/admin/books{._format}',
types: ['https://schema.org/Book', 'https://schema.org/Offer'],
extraProperties: ['rfc_7807_compliant_errors' => true],
operations: [
new GetCollection(
itemUriTemplate: '/admin/books/{id}{._format}',
Expand Down Expand Up @@ -74,7 +73,6 @@
)]
#[ApiResource(
types: ['https://schema.org/Book', 'https://schema.org/Offer'],
extraProperties: ['rfc_7807_compliant_errors' => true],
operations: [
new GetCollection(
itemUriTemplate: '/books/{id}{._format}'
Expand Down
1 change: 0 additions & 1 deletion api/src/Entity/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#[ApiResource(
types: ['https://schema.org/BookmarkAction'],
order: ['bookmarkedAt' => 'DESC'],
extraProperties: ['rfc_7807_compliant_errors' => true],
operations: [
new GetCollection(),
new Delete(
Expand Down
2 changes: 0 additions & 2 deletions api/src/Entity/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#[ApiResource(
types: ['https://schema.org/Review'],
order: ['publishedAt' => 'DESC'],
extraProperties: ['rfc_7807_compliant_errors' => true],
operations: [
new GetCollection(
uriTemplate: '/admin/reviews{._format}',
Expand Down Expand Up @@ -80,7 +79,6 @@
#[ApiResource(
types: ['https://schema.org/Review'],
order: ['publishedAt' => 'DESC'],
extraProperties: ['rfc_7807_compliant_errors' => true],
uriTemplate: '/books/{bookId}/reviews{._format}',
uriVariables: [
'bookId' => new Link(toProperty: 'book', fromClass: Book::class),
Expand Down
1 change: 0 additions & 1 deletion api/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
#[ApiResource(
types: ['https://schema.org/Person'],
extraProperties: ['rfc_7807_compliant_errors' => true],
operations: [
new GetCollection(
uriTemplate: '/admin/users{._format}',
Expand Down
11 changes: 0 additions & 11 deletions api/tests/Api/Admin/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function testAsNonAdminUserICannotGetACollectionOfBooks(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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -197,7 +196,6 @@ public function testAsNonAdminUserICannotGetABook(int $expectedCode, string $hyd
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -253,7 +251,6 @@ public function testAsNonAdminUserICannotCreateABook(int $expectedCode, string $
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -286,7 +283,6 @@ public function getInvalidDataOnCreate(): iterable
[],
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'violations' => [
Expand Down Expand Up @@ -315,12 +311,10 @@ public function getInvalidData(): iterable
// todo waiting for https://github.com/api-platform/core/pull/5844
// Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'The data must belong to a backed enumeration of type '.BookCondition::class,
// todo waiting for https://github.com/api-platform/core/pull/5844[
// '@context' => '/contexts/ConstraintViolationList',
// '@type' => 'ConstraintViolationList',
// 'hydra:title' => 'An error occurred',
// 'hydra:description' => 'book: This value should not be blank.\ncondition: This value should be of type '.BookCondition::class.'.',
Expand All @@ -345,12 +339,10 @@ public function getInvalidData(): iterable
// todo waiting for https://github.com/api-platform/core/pull/5844
// Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'The data must belong to a backed enumeration of type '.BookCondition::class,
// todo waiting for https://github.com/api-platform/core/pull/5844
// '@context' => '/contexts/ConstraintViolationList',
// '@type' => 'ConstraintViolationList',
// 'hydra:title' => 'An error occurred',
// 'hydra:description' => 'condition: This value should be of type '.BookCondition::class.'.',
Expand All @@ -369,7 +361,6 @@ public function getInvalidData(): iterable
],
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'violations' => [
Expand Down Expand Up @@ -463,7 +454,6 @@ public function testAsNonAdminUserICannotUpdateBook(int $expectedCode, string $h
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -591,7 +581,6 @@ public function testAsNonAdminUserICannotDeleteABook(int $expectedCode, string $
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down
4 changes: 0 additions & 4 deletions api/tests/Api/Admin/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function testAsNonAdminUserICannotGetACollectionOfReviews(int $expectedCo
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -165,7 +164,6 @@ public function testAsNonAdminUserICannotGetAReview(int $expectedCode, string $h
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -224,7 +222,6 @@ public function testAsNonAdminUserICannotUpdateAReview(int $expectedCode, string
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -327,7 +324,6 @@ public function testAsNonAdminUserICannotDeleteAReview(int $expectedCode, string
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down
2 changes: 0 additions & 2 deletions api/tests/Api/Admin/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function testAsNonAdminUserICannotGetACollectionOfUsers(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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -127,7 +126,6 @@ public function testAsNonAdminUserICannotGetAUser(int $expectedCode, string $hyd
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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down
7 changes: 0 additions & 7 deletions api/tests/Api/BookmarkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function testAsAnonymousICannotGetACollectionOfBookmarks(): 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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand Down Expand Up @@ -88,7 +87,6 @@ public function testAsAnonymousICannotCreateABookmark(): 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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand Down Expand Up @@ -116,14 +114,12 @@ public function testAsAUserICannotCreateABookmarkWithInvalidData(): 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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Item not found for "/books/'.$uuid.'".',
]);
// todo waiting for https://github.com/api-platform/core/pull/5844
// self::assertJsonContains([
// '@context' => '/contexts/ConstraintViolationList',
// '@type' => 'ConstraintViolationList',
// 'hydra:title' => 'An error occurred',
// 'hydra:description' => 'book: This value should be of type '.Book::class.'.',
Expand Down Expand Up @@ -201,7 +197,6 @@ public function testAsAUserICannotCreateADuplicateBookmark(): 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([
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'hydra:description' => 'You have already bookmarked this book.',
Expand All @@ -218,7 +213,6 @@ public function testAsAnonymousICannotDeleteABookmark(): 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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand All @@ -241,7 +235,6 @@ public function testAsAUserICannotDeleteABookmarkOfAnotherUser(): 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([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Access Denied.',
Expand Down
Loading
Loading