From 59adca2c6934a0d2a656521eed45381e41617fef Mon Sep 17 00:00:00 2001 From: soyuka Date: Wed, 30 Oct 2024 15:38:41 +0100 Subject: [PATCH] fix(metadata): name convert parameter property --- .../Factory/ParameterResourceMetadataCollectionFactory.php | 7 ++++++- src/Symfony/Bundle/Resources/config/metadata/resource.xml | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php index 12a89a50fb..e815d603ee 100644 --- a/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/ParameterResourceMetadataCollectionFactory.php @@ -25,6 +25,7 @@ use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter; use ApiPlatform\Serializer\Filter\FilterInterface as SerializerFilterInterface; use Psr\Container\ContainerInterface; +use Symfony\Component\Serializer\NameConverter\NameConverterInterface; use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Count; use Symfony\Component\Validator\Constraints\DivisibleBy; @@ -47,7 +48,7 @@ */ final class ParameterResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface { - public function __construct(private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null, private readonly ?ContainerInterface $filterLocator = null) + public function __construct(private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null, private readonly ?ContainerInterface $filterLocator = null, private readonly ?NameConverterInterface $nameConverter = null) { } @@ -136,6 +137,10 @@ private function setDefaults(string $key, Parameter $parameter, string $resource $parameter = $this->addSchemaValidation($parameter, $schema, $parameter->getRequired() ?? $description['required'] ?? false, $parameter->getOpenApi() ?: null); } + if ($this->nameConverter && $property = $parameter->getProperty()) { + $parameter = $parameter->withProperty($this->nameConverter->normalize($property)); + } + return $parameter; } diff --git a/src/Symfony/Bundle/Resources/config/metadata/resource.xml b/src/Symfony/Bundle/Resources/config/metadata/resource.xml index c1181121e0..f3607b9a54 100644 --- a/src/Symfony/Bundle/Resources/config/metadata/resource.xml +++ b/src/Symfony/Bundle/Resources/config/metadata/resource.xml @@ -84,7 +84,8 @@ - + +