Skip to content

Commit 0f0322f

Browse files
feat: remove hydra prefix
Fixes #449 # Conflicts: # api/src/Entity/Book.php # api/src/Entity/Review.php # api/tests/Api/Admin/BookTest.php
1 parent 97a01aa commit 0f0322f

26 files changed

Lines changed: 309 additions & 216 deletions

api/config/packages/api_platform.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ api_platform:
2626
extra_properties:
2727
standard_put: true
2828
rfc_7807_compliant_errors: true
29-
serializer:
30-
hydra_prefix: true
3129
oauth:
3230
enabled: true
3331
clientId: '%env(OIDC_SWAGGER_CLIENT_ID)%'

api/src/Entity/Book.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
*/
4242
#[ApiResource(
4343
uriTemplate: '/admin/books{._format}',
44+
shortName: 'Book',
4445
types: [
4546
'https://schema.org/Book',
4647
'https://schema.org/Offer',
@@ -83,6 +84,7 @@
8384
security: 'is_granted("OIDC_ADMIN")',
8485
)]
8586
#[ApiResource(
87+
shortName: 'Book',
8688
types: ['https://schema.org/Book', 'https://schema.org/Offer'],
8789
operations: [
8890
new GetCollection(

api/src/Entity/Bookmark.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @see https://schema.org/BookmarkAction
3232
*/
3333
#[ApiResource(
34+
shortName: 'Bookmark',
3435
types: ['https://schema.org/BookmarkAction'],
3536
operations: [
3637
new GetCollection(),

api/src/Entity/Review.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* @see https://schema.org/Review
3939
*/
4040
#[ApiResource(
41+
shortName: 'Review',
4142
types: ['https://schema.org/Review'],
4243
operations: [
4344
new GetCollection(
@@ -88,6 +89,7 @@
8889
)]
8990
#[ApiResource(
9091
uriTemplate: '/books/{bookId}/reviews{._format}',
92+
shortName: 'Review',
9193
types: ['https://schema.org/Review'],
9294
operations: [
9395
new GetCollection(

api/src/Entity/User.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @see https://schema.org/Person
2626
*/
2727
#[ApiResource(
28+
shortName: 'User',
2829
types: ['https://schema.org/Person'],
2930
operations: [
3031
new GetCollection(

api/tests/Api/Admin/BookTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function asNonAdminUserICannotGetACollectionOfBooks(int $expectedCode, st
5555
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
5656
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"');
5757
self::assertJsonContains([
58-
'@type' => 'hydra:Error',
59-
'hydra:title' => 'An error occurred',
60-
'hydra:description' => $hydraDescription,
58+
'@type' => 'Error',
59+
'title' => 'An error occurred',
60+
'description' => $hydraDescription,
6161
]);
6262
}
6363

@@ -78,9 +78,9 @@ public function asAdminUserICanGetACollectionOfBooks(FactoryCollection $factory,
7878
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
7979
self::assertEquals('<https://localhost:443/.well-known/mercure>; rel="mercure"', $response->getHeaders()['link'][1]);
8080
self::assertJsonContains([
81-
'hydra:totalItems' => $hydraTotalItems,
81+
'totalItems' => $hydraTotalItems,
8282
]);
83-
self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['hydra:member']);
83+
self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['member']);
8484
self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Book/collection.json'));
8585
}
8686

@@ -145,9 +145,9 @@ public function asAdminUserICanGetACollectionOfBooksOrderedByTitle(): void
145145
self::assertResponseIsSuccessful();
146146
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
147147
self::assertEquals('<https://localhost:443/.well-known/mercure>; rel="mercure"', $response->getHeaders()['link'][1]);
148-
self::assertEquals('Ball Lightning', $response->toArray()['hydra:member'][0]['title']);
149-
self::assertEquals('Hyperion', $response->toArray()['hydra:member'][1]['title']);
150-
self::assertEquals('The Wandering Earth', $response->toArray()['hydra:member'][2]['title']);
148+
self::assertEquals('Ball Lightning', $response->toArray()['member'][0]['title']);
149+
self::assertEquals('Hyperion', $response->toArray()['member'][1]['title']);
150+
self::assertEquals('The Wandering Earth', $response->toArray()['member'][2]['title']);
151151
self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Book/collection.json'));
152152
}
153153

@@ -197,9 +197,9 @@ public function asNonAdminUserICannotGetABook(int $expectedCode, string $hydraDe
197197
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
198198
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"');
199199
self::assertJsonContains([
200-
'@type' => 'hydra:Error',
201-
'hydra:title' => 'An error occurred',
202-
'hydra:description' => $hydraDescription,
200+
'@type' => 'Error',
201+
'title' => 'An error occurred',
202+
'description' => $hydraDescription,
203203
]);
204204
}
205205

@@ -254,9 +254,9 @@ public function asNonAdminUserICannotCreateABook(int $expectedCode, string $hydr
254254
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
255255
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"');
256256
self::assertJsonContains([
257-
'@type' => 'hydra:Error',
258-
'hydra:title' => 'An error occurred',
259-
'hydra:description' => $hydraDescription,
257+
'@type' => 'Error',
258+
'title' => 'An error occurred',
259+
'description' => $hydraDescription,
260260
]);
261261
}
262262

@@ -290,7 +290,7 @@ public static function getInvalidDataOnCreate(): iterable
290290
Response::HTTP_UNPROCESSABLE_ENTITY,
291291
[
292292
'@type' => 'ConstraintViolation',
293-
'hydra:title' => 'An error occurred',
293+
'title' => 'An error occurred',
294294
'violations' => [
295295
[
296296
'propertyPath' => 'book',
@@ -316,8 +316,8 @@ public static function getInvalidData(): iterable
316316
Response::HTTP_UNPROCESSABLE_ENTITY,
317317
[
318318
'@type' => 'ConstraintViolation',
319-
'hydra:title' => 'An error occurred',
320-
'hydra:description' => 'condition: This value should be of type int|string.',
319+
'title' => 'An error occurred',
320+
'description' => 'condition: This value should be of type int|string.',
321321
'violations' => [
322322
[
323323
'propertyPath' => 'condition',
@@ -334,8 +334,8 @@ public static function getInvalidData(): iterable
334334
Response::HTTP_UNPROCESSABLE_ENTITY,
335335
[
336336
'@type' => 'ConstraintViolation',
337-
'hydra:title' => 'An error occurred',
338-
'hydra:description' => 'condition: This value should be of type int|string.',
337+
'title' => 'An error occurred',
338+
'description' => 'condition: This value should be of type int|string.',
339339
'violations' => [
340340
[
341341
'propertyPath' => 'condition',
@@ -352,7 +352,7 @@ public static function getInvalidData(): iterable
352352
Response::HTTP_UNPROCESSABLE_ENTITY,
353353
[
354354
'@type' => 'ConstraintViolation',
355-
'hydra:title' => 'An error occurred',
355+
'title' => 'An error occurred',
356356
'violations' => [
357357
[
358358
'propertyPath' => 'book',
@@ -440,9 +440,9 @@ public function asNonAdminUserICannotUpdateBook(int $expectedCode, string $hydra
440440
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
441441
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"');
442442
self::assertJsonContains([
443-
'@type' => 'hydra:Error',
444-
'hydra:title' => 'An error occurred',
445-
'hydra:description' => $hydraDescription,
443+
'@type' => 'Error',
444+
'title' => 'An error occurred',
445+
'description' => $hydraDescription,
446446
]);
447447
}
448448

@@ -564,9 +564,9 @@ public function asNonAdminUserICannotDeleteABook(int $expectedCode, string $hydr
564564
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
565565
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"');
566566
self::assertJsonContains([
567-
'@type' => 'hydra:Error',
568-
'hydra:title' => 'An error occurred',
569-
'hydra:description' => $hydraDescription,
567+
'@type' => 'Error',
568+
'title' => 'An error occurred',
569+
'description' => $hydraDescription,
570570
]);
571571
}
572572

api/tests/Api/Admin/ReviewTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public function asNonAdminUserICannotGetACollectionOfReviews(int $expectedCode,
5656
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
5757
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"');
5858
self::assertJsonContains([
59-
'@type' => 'hydra:Error',
60-
'hydra:title' => 'An error occurred',
61-
'hydra:description' => $hydraDescription,
59+
'@type' => 'Error',
60+
'title' => 'An error occurred',
61+
'description' => $hydraDescription,
6262
]);
6363
}
6464

@@ -82,9 +82,9 @@ public function asAdminUserICanGetACollectionOfReviews(FactoryCollection $factor
8282
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
8383
self::assertEquals('<https://localhost:443/.well-known/mercure>; rel="mercure"', $response->getHeaders()['link'][1]);
8484
self::assertJsonContains([
85-
'hydra:totalItems' => $hydraTotalItems,
85+
'totalItems' => $hydraTotalItems,
8686
]);
87-
self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['hydra:member']);
87+
self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['member']);
8888
self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/Review/collection.json'));
8989
}
9090

@@ -164,9 +164,9 @@ public function asNonAdminUserICannotGetAReview(int $expectedCode, string $hydra
164164
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
165165
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"');
166166
self::assertJsonContains([
167-
'@type' => 'hydra:Error',
168-
'hydra:title' => 'An error occurred',
169-
'hydra:description' => $hydraDescription,
167+
'@type' => 'Error',
168+
'title' => 'An error occurred',
169+
'description' => $hydraDescription,
170170
]);
171171
}
172172

@@ -228,9 +228,9 @@ public function asNonAdminUserICannotUpdateAReview(int $expectedCode, string $hy
228228
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
229229
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"');
230230
self::assertJsonContains([
231-
'@type' => 'hydra:Error',
232-
'hydra:title' => 'An error occurred',
233-
'hydra:description' => $hydraDescription,
231+
'@type' => 'Error',
232+
'title' => 'An error occurred',
233+
'description' => $hydraDescription,
234234
]);
235235
}
236236

@@ -334,9 +334,9 @@ public function asNonAdminUserICannotDeleteAReview(int $expectedCode, string $hy
334334
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
335335
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"');
336336
self::assertJsonContains([
337-
'@type' => 'hydra:Error',
338-
'hydra:title' => 'An error occurred',
339-
'hydra:description' => $hydraDescription,
337+
'@type' => 'Error',
338+
'title' => 'An error occurred',
339+
'description' => $hydraDescription,
340340
]);
341341
}
342342

api/tests/Api/Admin/UserTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function asNonAdminUserICannotGetACollectionOfUsers(int $expectedCode, st
4747
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
4848
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"');
4949
self::assertJsonContains([
50-
'@type' => 'hydra:Error',
51-
'hydra:title' => 'An error occurred',
52-
'hydra:description' => $hydraDescription,
50+
'@type' => 'Error',
51+
'title' => 'An error occurred',
52+
'description' => $hydraDescription,
5353
]);
5454
}
5555

@@ -72,9 +72,9 @@ public function asAdminUserICanGetACollectionOfUsers(FactoryCollection $factory,
7272
self::assertResponseIsSuccessful();
7373
self::assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8');
7474
self::assertJsonContains([
75-
'hydra:totalItems' => $hydraTotalItems,
75+
'totalItems' => $hydraTotalItems,
7676
]);
77-
self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['hydra:member']);
77+
self::assertCount(min($itemsPerPage ?? $hydraTotalItems, 30), $response->toArray()['member']);
7878
self::assertMatchesJsonSchema(file_get_contents(__DIR__ . '/schemas/User/collection.json'));
7979
}
8080

@@ -123,9 +123,9 @@ public function asNonAdminUserICannotGetAUser(int $expectedCode, string $hydraDe
123123
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
124124
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"');
125125
self::assertJsonContains([
126-
'@type' => 'hydra:Error',
127-
'hydra:title' => 'An error occurred',
128-
'hydra:description' => $hydraDescription,
126+
'@type' => 'Error',
127+
'title' => 'An error occurred',
128+
'description' => $hydraDescription,
129129
]);
130130
}
131131

api/tests/Api/Admin/schemas/Book/collection.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,24 @@
7878
"@type": {
7979
"readOnly": true,
8080
"type": "string",
81-
"pattern": "^hydra:Collection$"
81+
"pattern": "^Collection$"
8282
},
8383
"@id": {
8484
"readOnly": true,
8585
"type": "string",
8686
"pattern": "^/admin/books$"
8787
},
88-
"hydra:member": {
88+
"member": {
8989
"type": "array",
9090
"items": {
9191
"$ref": "#\/definitions\/Book:jsonld"
9292
}
9393
},
94-
"hydra:totalItems": {
94+
"totalItems": {
9595
"type": "integer",
9696
"minimum": 0
9797
},
98-
"hydra:view": {
98+
"view": {
9999
"type": "object",
100100
"properties": {
101101
"@id": {
@@ -105,33 +105,33 @@
105105
"@type": {
106106
"type": "string"
107107
},
108-
"hydra:first": {
108+
"first": {
109109
"type": "string",
110110
"format": "iri-reference"
111111
},
112-
"hydra:last": {
112+
"last": {
113113
"type": "string",
114114
"format": "iri-reference"
115115
},
116-
"hydra:next": {
116+
"next": {
117117
"type": "string",
118118
"format": "iri-reference"
119119
}
120120
}
121121
},
122-
"hydra:search": {
122+
"search": {
123123
"type": "object",
124124
"properties": {
125125
"@type": {
126126
"type": "string"
127127
},
128-
"hydra:template": {
128+
"template": {
129129
"type": "string"
130130
},
131-
"hydra:variableRepresentation": {
131+
"variableRepresentation": {
132132
"type": "string"
133133
},
134-
"hydra:mapping": {
134+
"mapping": {
135135
"type": "array",
136136
"items": {
137137
"type": "object",
@@ -161,9 +161,9 @@
161161
"@context",
162162
"@type",
163163
"@id",
164-
"hydra:member",
165-
"hydra:totalItems",
166-
"hydra:view",
167-
"hydra:search"
164+
"member",
165+
"totalItems",
166+
"view",
167+
"search"
168168
]
169169
}

0 commit comments

Comments
 (0)