Skip to content

Commit de808dd

Browse files
committed
Merge 3.4
2 parents 1b7fd9c + 717c7e5 commit de808dd

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ Notes:
199199

200200
* [0d5f35683](https://github.com/api-platform/core/commit/0d5f356839eb6aa9f536044abe4affa736553e76) feat(laravel): laravel component (#5882)
201201

202+
## v3.4.7
203+
204+
### Bug fixes
205+
206+
* [2d25e79e0](https://github.com/api-platform/core/commit/2d25e79e0e04ce549fb67ecc2017798a8deb7458) fix(symfony): unset item_uri_template when serializing an error (#6816)
207+
202208
## v3.4.6
203209

204210
### Bug fixes

src/Metadata/ApiResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function __construct(
106106
* 'jsonapi' => ['application/vnd.api+json'],
107107
* 'json' => ['application/json'],
108108
* 'xml' => ['application/xml', 'text/xml'],
109-
* 'yaml' => ['application/x-yaml'],
109+
* 'yaml' => ['application/yaml'],
110110
* 'csv' => ['text/csv'],
111111
* 'html' => ['text/html'],
112112
* 'myformat' =>['application/vnd.myformat'],

src/Symfony/EventListener/ErrorListener.php

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ protected function duplicateRequest(\Throwable $exception, Request $request): Re
9999
$normalizationContext += ['api_error_resource' => true];
100100
}
101101

102+
if (isset($normalizationContext['item_uri_template'])) {
103+
unset($normalizationContext['item_uri_template']);
104+
}
105+
102106
if (!isset($normalizationContext[AbstractObjectNormalizer::IGNORED_ATTRIBUTES])) {
103107
$normalizationContext[AbstractObjectNormalizer::IGNORED_ATTRIBUTES] = ['trace', 'file', 'line', 'code', 'message', 'traceAsString'];
104108
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6718;
15+
16+
use ApiPlatform\Metadata\ApiResource;
17+
use ApiPlatform\Metadata\Get;
18+
use ApiPlatform\Metadata\Operation;
19+
20+
#[ApiResource(
21+
shortName: 'OrganisationIssue6718',
22+
extraProperties: ['rfc_7807_compliant_errors' => true],
23+
operations: [
24+
new Get(
25+
uriTemplate: '/6718_organisations/{id}',
26+
provider: [self::class, 'itemProvider'],
27+
),
28+
new Get(
29+
uriTemplate: '/6718_users/{userId}/organisation',
30+
uriVariables: [
31+
'userId',
32+
],
33+
normalizationContext: [
34+
'item_uri_template' => '/6718_organisations/{id}',
35+
'hydra_prefix' => false,
36+
],
37+
provider: [self::class, 'userOrganizationItemProvider']
38+
),
39+
],
40+
)]
41+
class Organization
42+
{
43+
public function __construct(public readonly string $id)
44+
{
45+
}
46+
47+
public static function itemProvider(Operation $operation, array $uriVariables = []): ?self
48+
{
49+
return new self($uriVariables['id']);
50+
}
51+
52+
public static function userOrganizationItemProvider(): ?self
53+
{
54+
return null;
55+
}
56+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <dunglas@gmail.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Tests\Functional;
15+
16+
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
17+
18+
class ItemUriTemplateTest extends ApiTestCase
19+
{
20+
public function testIssue6718(): void
21+
{
22+
self::createClient()->request('GET', '/6718_users/1/organisation', [
23+
'headers' => ['accept' => 'application/ld+json'],
24+
]);
25+
$this->assertResponseStatusCodeSame(404);
26+
$this->assertJsonContains(['description' => 'Not Found']);
27+
}
28+
}

0 commit comments

Comments
 (0)