Skip to content

Commit 545eb69

Browse files
fix(symfony): internal resources should not inherit global defaults (#7073)
1 parent 694681f commit 545eb69

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Metadata/Resource/Factory/OperationDefaultsTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use ApiPlatform\Metadata\ApiResource;
1717
use ApiPlatform\Metadata\CollectionOperationInterface;
1818
use ApiPlatform\Metadata\Delete;
19+
use ApiPlatform\Metadata\Error;
1920
use ApiPlatform\Metadata\Exception\RuntimeException;
2021
use ApiPlatform\Metadata\Get;
2122
use ApiPlatform\Metadata\GetCollection;
@@ -32,6 +33,7 @@
3233
use ApiPlatform\Metadata\Post;
3334
use ApiPlatform\Metadata\Util\CamelCaseToSnakeCaseNameConverter;
3435
use ApiPlatform\State\CreateProvider;
36+
use ApiPlatform\Validator\Exception\ValidationException;
3537
use Psr\Log\LoggerInterface;
3638

3739
trait OperationDefaultsTrait
@@ -42,6 +44,11 @@ trait OperationDefaultsTrait
4244

4345
private function addGlobalDefaults(ApiResource|Operation $operation): ApiResource|Operation
4446
{
47+
// Do not add global defaults for internal resources:
48+
if (\in_array($operation->getClass(), [Error::class, ValidationException::class], true)) {
49+
return $operation;
50+
}
51+
4552
$extraProperties = $this->defaults['extra_properties'] ?? [];
4653

4754
foreach ($this->defaults as $key => $value) {

0 commit comments

Comments
 (0)