Skip to content

Commit a259d46

Browse files
committed
Merge branch '3.4' into 4.0
2 parents 025f63e + f932699 commit a259d46

File tree

12 files changed

+37
-54
lines changed

12 files changed

+37
-54
lines changed

features/hydra/error.feature

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ Feature: Error handling
1717
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
1818
And the JSON node "type" should exist
1919
And the JSON node "title" should be equal to "An error occurred"
20-
And the JSON node "hydra:title" should be equal to "An error occurred"
2120
And the JSON node "detail" should exist
22-
And the JSON node "hydra:description" should exist
21+
And the JSON node "description" should exist
2322
And the JSON node "trace" should exist
2423
And the JSON node "status" should exist
2524
And the JSON node "@context" should exist
@@ -48,10 +47,9 @@ Feature: Error handling
4847
}
4948
],
5049
"detail": "name: This value should not be blank.",
51-
"hydra:title": "An error occurred",
52-
"hydra:description": "name: This value should not be blank.",
53-
"type": "/validation_errors/c1051bb4-d103-4f74-8988-acbcafc7fdc3",
54-
"title": "An error occurred"
50+
"title": "An error occurred",
51+
"description": "name: This value should not be blank.",
52+
"type": "/validation_errors/c1051bb4-d103-4f74-8988-acbcafc7fdc3"
5553
}
5654
"""
5755

@@ -83,9 +81,8 @@ Feature: Error handling
8381
And the JSON node "@context" should exist
8482
And the JSON node "type" should exist
8583
And the JSON node "title" should be equal to "An error occurred"
86-
And the JSON node "hydra:title" should be equal to "An error occurred"
8784
And the JSON node "detail" should exist
88-
And the JSON node "hydra:description" should exist
85+
And the JSON node "description" should exist
8986

9087
Scenario: Get an rfc 7807 bad method error
9188
When I add "Content-Type" header equal to "application/ld+json"
@@ -101,9 +98,8 @@ Feature: Error handling
10198
And the JSON node "@context" should exist
10299
And the JSON node "type" should exist
103100
And the JSON node "title" should be equal to "An error occurred"
104-
And the JSON node "hydra:title" should be equal to "An error occurred"
105101
And the JSON node "detail" should exist
106-
And the JSON node "hydra:description" should exist
102+
And the JSON node "description" should exist
107103

108104
Scenario: Get an rfc 7807 validation error
109105
When I add "Content-Type" header equal to "application/ld+json"

features/jsonld/input_output.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ Feature: JSON-LD DTO input and output
309309
"""
310310
Then the response status code should be 400
311311
And the response should be in JSON
312-
And the JSON node "hydra:description" should be equal to "The input data is misformatted."
312+
And the JSON node "description" should be equal to "The input data is misformatted."
313313

314314
@!mongodb
315315
Scenario: Reset password through an input DTO without DataTransformer

features/main/attribute_resource.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Feature: Resource attributes
100100
And the response should be in JSON
101101
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
102102
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
103-
And the JSON node "hydra:description" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"'
103+
And the JSON node "description" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"'
104104

105105
Scenario: Uri variables with Post operation
106106
When I add "Content-Type" header equal to "application/ld+json"

features/main/not_exposed.feature

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,22 @@ Feature: Expose only a collection of objects
171171
When I send a "GET" request to "<uri>"
172172
Then the response status code should be 404
173173
And the response should be in JSON
174-
And the JSON node "hydra:description" should be equal to "<hydra:description>"
174+
And the JSON node "hydra:description" should be equal to "<description>"
175175
Examples:
176-
| uri | hydra:description |
177-
| /.well-known/genid/12345 | This route is not exposed on purpose. It generates an IRI for a collection resource without identifier nor item operation. |
176+
| uri | description |
178177
| /tables/12345 | This route does not aim to be called. |
179178
| /forks/12345 | This route does not aim to be called. |
180179

180+
Scenario Outline: Get a not exposed route returns a 404 with an explanation
181+
When I send a "GET" request to "<uri>"
182+
Then the response status code should be 404
183+
And the response should be in JSON
184+
And the JSON node "description" should be equal to "<description>"
185+
Examples:
186+
| uri | description |
187+
| /.well-known/genid/12345 | This route is not exposed on purpose. It generates an IRI for a collection resource without identifier nor item operation. |
188+
189+
181190
Scenario: Get a single item still works
182191
When I send a "GET" request to "/cuillers/12345"
183192
Then the response status code should be 200

features/main/relation.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ Feature: Relations support
472472
Then the response status code should be 400
473473
And the response should be in JSON
474474
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
475-
And the JSON node "hydra:description" should contain 'Invalid IRI "certainly not an IRI".'
475+
And the JSON node "description" should contain 'Invalid IRI "certainly not an IRI".'
476476

477477
Scenario: Passing an invalid type to a relation
478478
When I add "Content-Type" header equal to "application/ld+json"
@@ -493,20 +493,20 @@ Feature: Relations support
493493
"properties": {
494494
"@type": {
495495
"type": "string",
496-
"pattern": "^hydra:Error$"
496+
"pattern": "^Error$"
497497
},
498-
"hydra:title": {
498+
"title": {
499499
"type": "string",
500500
"pattern": "^An error occurred$"
501501
},
502-
"hydra:description": {
502+
"description": {
503503
"pattern": "^The type of the \"ApiPlatform\\\\Tests\\\\Fixtures\\\\TestBundle\\\\(Document|Entity)\\\\RelatedDummy\" resource must be \"array\" \\(nested document\\) or \"string\" \\(IRI\\), \"integer\" given.$"
504504
}
505505
},
506506
"required": [
507507
"@type",
508-
"hydra:title",
509-
"hydra:description"
508+
"title",
509+
"description"
510510
]
511511
}
512512
"""

features/main/union_intersect_types.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ Feature: Union/Intersect types
118118
Then the response status code should be 400
119119
And the response should be in JSON
120120
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
121-
And the JSON node "hydra:description" should be equal to 'Could not denormalize object of type "ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5452\ActivableInterface", no supporting normalizer found.'
121+
And the JSON node "description" should be equal to 'Could not denormalize object of type "ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5452\ActivableInterface", no supporting normalizer found.'

features/main/validation.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Feature: Using validations groups
8787
And the JSON node "violations[0].message" should be equal to "This value should not be null."
8888
And the JSON node "violations[0].propertyPath" should be equal to "test"
8989
And the JSON node "detail" should be equal to "test: This value should not be null."
90-
And the JSON node "hydra:description" should be equal to "test: This value should not be null."
90+
And the JSON node "description" should be equal to "test: This value should not be null."
9191
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
9292

9393
@!mongodb

features/serializer/vo_relations.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,20 @@ Feature: Value object as ApiResource
148148
"properties": {
149149
"@type": {
150150
"type": "string",
151-
"pattern": "^hydra:Error$"
151+
"pattern": "^Error$"
152152
},
153-
"hydra:title": {
153+
"title": {
154154
"type": "string",
155155
"pattern": "^An error occurred$"
156156
},
157-
"hydra:description": {
157+
"description": {
158158
"pattern": "^Cannot create an instance of \"ApiPlatform\\\\Tests\\\\Fixtures\\\\TestBundle\\\\(Document|Entity)\\\\VoDummyCar\" from serialized data because its constructor requires the following parameters to be present : \"\\$drivers\".$"
159159
}
160160
},
161161
"required": [
162162
"@type",
163-
"hydra:title",
164-
"hydra:description"
163+
"title",
164+
"description"
165165
]
166166
}
167167
"""

src/JsonLd/ContextBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace ApiPlatform\JsonLd;
1515

1616
use ApiPlatform\JsonLd\Serializer\HydraPrefixTrait;
17+
use ApiPlatform\Metadata\Error;
1718
use ApiPlatform\Metadata\Get;
1819
use ApiPlatform\Metadata\HttpOperation;
1920
use ApiPlatform\Metadata\IriConverterInterface;
@@ -184,7 +185,7 @@ private function getResourceContextWithShortname(string $resourceClass, int $ref
184185
}
185186
}
186187

187-
if (false === ($this->defaultContext[self::HYDRA_CONTEXT_HAS_PREFIX] ?? true)) {
188+
if (false === ($this->defaultContext[self::HYDRA_CONTEXT_HAS_PREFIX] ?? true) || $operation instanceof Error) {
188189
return ['http://www.w3.org/ns/hydra/context.jsonld', $context];
189190
}
190191

src/State/ApiResource/Error.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Symfony\Component\WebLink\Link;
2626

2727
#[ErrorResource(
28-
types: ['hydra:Error'],
2928
openapi: false,
3029
uriVariables: ['status'],
3130
uriTemplate: '/errors/{status}',
@@ -95,21 +94,7 @@ public function __construct(
9594
#[Groups(['trace'])]
9695
public ?array $originalTrace = null;
9796

98-
#[SerializedName('hydra:title')]
9997
#[Groups(['jsonld'])]
100-
public function getHydraTitle(): ?string
101-
{
102-
return $this->title;
103-
}
104-
105-
#[SerializedName('hydra:description')]
106-
#[Groups(['jsonld'])]
107-
public function getHydraDescription(): ?string
108-
{
109-
return $this->detail;
110-
}
111-
112-
#[SerializedName('description')]
11398
public function getDescription(): ?string
11499
{
115100
return $this->detail;

src/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function getConfigTreeBuilder(): TreeBuilder
117117
->scalarNode('exists_parameter_name')->defaultValue('exists')->cannotBeEmpty()->info('The name of the query parameter to filter on nullable field values.')->end()
118118
->scalarNode('order')->defaultValue('ASC')->info('The default order of results.')->end() // Default ORDER is required for postgresql and mysql >= 5.7 when using LIMIT/OFFSET request
119119
->scalarNode('order_parameter_name')->defaultValue('order')->cannotBeEmpty()->info('The name of the query parameter to order results.')->end()
120-
->enumNode('order_nulls_comparison')->defaultNull()->values(array_merge(array_keys(OrderFilterInterface::NULLS_DIRECTION_MAP), [null]))->info('The nulls comparison strategy.')->end()
120+
->enumNode('order_nulls_comparison')->defaultNull()->values(interface_exists(OrderFilterInterface::class) ? array_merge(array_keys(OrderFilterInterface::NULLS_DIRECTION_MAP), [null]) : [null])->info('The nulls comparison strategy.')->end()
121121
->arrayNode('pagination')
122122
->canBeDisabled()
123123
->addDefaultsIfNotSet()

src/Validator/Exception/ValidationException.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,8 @@ public function getId(): string
106106
return $id;
107107
}
108108

109-
#[SerializedName('hydra:title')]
110109
#[Groups(['jsonld'])]
111-
public function getHydraTitle(): string
112-
{
113-
return $this->errorTitle ?? 'An error occurred';
114-
}
115-
116-
#[Groups(['jsonld'])]
117-
#[SerializedName('hydra:description')]
118-
public function getHydraDescription(): string
110+
public function getDescription(): string
119111
{
120112
return $this->detail;
121113
}

0 commit comments

Comments
 (0)