diff --git a/src/State/Processor/ObjectMapperInputProcessor.php b/src/State/Processor/ObjectMapperInputProcessor.php index a99128e9ac..845be27e09 100644 --- a/src/State/Processor/ObjectMapperInputProcessor.php +++ b/src/State/Processor/ObjectMapperInputProcessor.php @@ -15,6 +15,7 @@ use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProcessorInterface; +use ApiPlatform\State\Util\StateOptionsTrait; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\ObjectMapper\ObjectMapperInterface; @@ -25,6 +26,8 @@ */ final class ObjectMapperInputProcessor implements ProcessorInterface { + use StateOptionsTrait; + /** * @param ProcessorInterface|null $decorated */ @@ -51,7 +54,8 @@ public function process(mixed $data, Operation $operation, array $uriVariables = } $request = $context['request'] ?? null; - $mapped = $this->objectMapper->map($data, $request?->attributes->get('mapped_data')); + $mapped = $this->objectMapper->map($data, $request?->attributes->get('mapped_data') ?? $this->getStateOptionsClass($operation, $operation->getClass())); + $request?->attributes->set('mapped_data', $mapped); return $this->decorated ? $this->decorated->process($mapped, $operation, $uriVariables, $context) : $mapped; }