From 38dcd385ec88527be2ba28eaf6aa87e62847ee0c Mon Sep 17 00:00:00 2001 From: Gourab Sahu Date: Fri, 4 Sep 2026 10:07:54 +0200 Subject: [PATCH 1/2] Enhance X-Request-ID constraints with nativeType Added nativeType argument to constraints for X-Request-ID. --- core/filters.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/filters.md b/core/filters.md index d462693c0ce..8e5edfd0bee 100644 --- a/core/filters.md +++ b/core/filters.md @@ -498,6 +498,8 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\HeaderParameter; use ApiPlatform\Metadata\QueryParameter; use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\TypeInfo\Type\BuiltinType; +use Symfony\Component\TypeInfo\TypeIdentifier; #[ApiResource(operations: [ new GetCollection( @@ -510,7 +512,8 @@ use Symfony\Component\Validator\Constraints as Assert; 'X-Request-ID' => new HeaderParameter( description: 'A unique request identifier.', required: true, - constraints: [new Assert\Uuid()] + constraints: [new Assert\Uuid()], + nativeType: new BuiltinType(typeIdentifier: TypeIdentifier::STRING) ) ] ) @@ -521,6 +524,8 @@ class User {} > [!NOTE] When `castToNativeType` is enabled, API Platform infers type validation from the JSON > Schema. +If `constraints` are used then a valid type needs to be passed using `nativeType` named argument. + The `ApiPlatform\Validator\Util\ParameterValidationConstraints` trait can be used to automatically infer validation constraints from the JSON Schema and OpenAPI definitions of a parameter. From 268e8248d33c1702b8343889ef54b81d79355f32 Mon Sep 17 00:00:00 2001 From: Gourab Sahu Date: Fri, 4 Sep 2026 10:22:57 +0200 Subject: [PATCH 2/2] Update filters.md for nativeType clarification Clarify usage of nativeType argument with constraints. --- core/filters.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core/filters.md b/core/filters.md index 8e5edfd0bee..e807e165489 100644 --- a/core/filters.md +++ b/core/filters.md @@ -525,6 +525,7 @@ class User {} > Schema. If `constraints` are used then a valid type needs to be passed using `nativeType` named argument. +Otherwise, the values will be passed as an array to each constraints. The `ApiPlatform\Validator\Util\ParameterValidationConstraints` trait can be used to automatically infer validation constraints from the JSON Schema and OpenAPI definitions of a parameter.