Skip to content
Open
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
2 changes: 0 additions & 2 deletions api/config/packages/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ api_platform:
extra_properties:
standard_put: true
rfc_7807_compliant_errors: true
serializer:
hydra_prefix: true
oauth:
enabled: true
clientId: '%env(OIDC_SWAGGER_CLIENT_ID)%'
Expand Down
2 changes: 2 additions & 0 deletions api/src/Entity/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
*/
#[ApiResource(
uriTemplate: '/admin/books{._format}',
shortName: 'Book',
types: ['https://schema.org/Book', 'https://schema.org/Offer'],
operations: [
new GetCollection(
Expand Down Expand Up @@ -80,6 +81,7 @@
]
)]
#[ApiResource(
shortName: 'Book',
types: ['https://schema.org/Book', 'https://schema.org/Offer'],
operations: [
new GetCollection(
Expand Down
1 change: 1 addition & 0 deletions api/src/Entity/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @see https://schema.org/BookmarkAction
*/
#[ApiResource(
shortName: 'Bookmark',
types: ['https://schema.org/BookmarkAction'],
order: ['bookmarkedAt' => 'DESC'],
operations: [
Expand Down
2 changes: 2 additions & 0 deletions api/src/Entity/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* @see https://schema.org/Review
*/
#[ApiResource(
shortName: 'Review',
types: ['https://schema.org/Review'],
order: ['publishedAt' => 'DESC'],
operations: [
Expand Down Expand Up @@ -87,6 +88,7 @@
]
)]
#[ApiResource(
shortName: 'Review',
types: ['https://schema.org/Review'],
order: ['publishedAt' => 'DESC'],
uriTemplate: '/books/{bookId}/reviews{._format}',
Expand Down
1 change: 1 addition & 0 deletions api/src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @see https://schema.org/Person
*/
#[ApiResource(
shortName: 'User',
types: ['https://schema.org/Person'],
operations: [
new GetCollection(
Expand Down
52 changes: 26 additions & 26 deletions api/tests/Api/Admin/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,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 All @@ -78,9 +78,9 @@ public function asAdminUserICanGetACollectionOfBooks(FactoryCollection $factory,
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
self::assertEquals('<https://localhost:443/.well-known/mercure>; 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'));
}

Expand Down Expand Up @@ -145,9 +145,9 @@ public function asAdminUserICanGetACollectionOfBooksOrderedByTitle(): void
self::assertResponseIsSuccessful();
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
self::assertEquals('<https://localhost:443/.well-known/mercure>; 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'));
}

Expand Down Expand Up @@ -197,9 +197,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' => 'ConstraintViolation',
'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' => 'ConstraintViolation',
'hydra:title' => 'An error occurred',
'hydra:description' => 'condition: This value should be of type BookCondition.',
'title' => 'An error occurred',
'description' => 'condition: This value should be of type BookCondition.',
'violations' => [
[
'propertyPath' => 'condition',
Expand All @@ -334,8 +334,8 @@ public static function getInvalidData(): iterable
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@type' => 'ConstraintViolation',
'hydra:title' => 'An error occurred',
'hydra:description' => 'condition: This value should be of type BookCondition.',
'title' => 'An error occurred',
'description' => 'condition: This value should be of type BookCondition.',
'violations' => [
[
'propertyPath' => 'condition',
Expand All @@ -352,7 +352,7 @@ public static function getInvalidData(): iterable
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@type' => 'ConstraintViolation',
'hydra:title' => 'An error occurred',
'title' => 'An error occurred',
'violations' => [
[
'propertyPath' => 'book',
Expand Down Expand Up @@ -440,9 +440,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 @@ -564,9 +564,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
28 changes: 14 additions & 14 deletions api/tests/Api/Admin/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,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 All @@ -82,9 +82,9 @@ public function asAdminUserICanGetACollectionOfReviews(FactoryCollection $factor
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
self::assertEquals('<https://localhost:443/.well-known/mercure>; 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'));
}

Expand Down Expand Up @@ -164,9 +164,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 @@ -228,9 +228,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
16 changes: 8 additions & 8 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 All @@ -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'));
}

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
30 changes: 15 additions & 15 deletions api/tests/Api/Admin/schemas/Book/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand Down Expand Up @@ -161,9 +161,9 @@
"@context",
"@type",
"@id",
"hydra:member",
"hydra:totalItems",
"hydra:view",
"hydra:search"
"member",
"totalItems",
"view",
"search"
]
}
Loading
Loading