From 483719f116e9e10ab24c90f9784f51b384a29811 Mon Sep 17 00:00:00 2001 From: Eric GELOEN Date: Fri, 25 Oct 2024 16:09:06 +0200 Subject: [PATCH] fix(validator): Don't setup the parameter automatic validation if constraints are provided --- ...ParameterValidationResourceMetadataCollectionFactory.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Validator/Metadata/Resource/Factory/ParameterValidationResourceMetadataCollectionFactory.php b/src/Validator/Metadata/Resource/Factory/ParameterValidationResourceMetadataCollectionFactory.php index 1c16ed527e..f8bc274e78 100644 --- a/src/Validator/Metadata/Resource/Factory/ParameterValidationResourceMetadataCollectionFactory.php +++ b/src/Validator/Metadata/Resource/Factory/ParameterValidationResourceMetadataCollectionFactory.php @@ -91,6 +91,12 @@ public function create(string $resourceClass): ResourceMetadataCollection private function addSchemaValidation(Parameter $parameter, ?array $schema = null, ?bool $required = null, ?OpenApiParameter $openApi = null): Parameter { + $constraints = $parameter->getConstraints(); + + if (\is_array($constraints) && \count($constraints) > 0) { + return $parameter; + } + $schema ??= $parameter->getSchema(); $required ??= $parameter->getRequired() ?? false; $openApi ??= $parameter->getOpenApi();