2222/**
2323 * @internal
2424 */
25- class SymfonyConstraintAnnotationReader
25+ class SymfonyAnnotationReader
2626{
2727 use SetsContextTrait;
2828
@@ -39,27 +39,37 @@ public function __construct(bool $useValidationGroups = false)
3939 }
4040
4141 /**
42- * Update the given property and schema with defined Symfony constraints .
42+ * Update the given property and schema with defined Symfony attributes .
4343 *
4444 * @param \ReflectionProperty|\ReflectionMethod $reflection
4545 * @param string[]|null $validationGroups
4646 */
4747 public function updateProperty ($ reflection , OA \Property $ property , ?array $ validationGroups = null ): void
4848 {
49- foreach ($ this ->getAttributes ($ property ->_context , $ reflection , $ validationGroups ) as $ outerAttribute ) {
49+ // Handle constraints
50+ foreach ($ this ->getConstraintAttributes ($ property ->_context , $ reflection , $ validationGroups ) as $ outerAttribute ) {
5051 $ innerAttributes = $ outerAttribute instanceof Assert \Compound || $ outerAttribute instanceof Assert \Sequentially
5152 ? $ outerAttribute ->constraints
5253 : [$ outerAttribute ];
5354
54- $ this ->processPropertyAttributes ($ reflection , $ property , $ innerAttributes );
55+ $ this ->processConstraintPropertyAttributes ($ reflection , $ property , $ innerAttributes );
56+ }
57+
58+ // Handle context
59+ $ context = $ reflection ->getAttributes (\Symfony \Component \Serializer \Attribute \Context::class);
60+ if (1 === \count ($ context )) {
61+ $ contextArgs = $ context [0 ]->getArguments ()[0 ];
62+ if ('Y-m-d ' === ($ contextArgs ['datetime_format ' ] ?? null )) {
63+ $ property ->format = 'date ' ;
64+ }
5565 }
5666 }
5767
5868 /**
5969 * @param \ReflectionProperty|\ReflectionMethod $reflection
6070 * @param Constraint[] $attributes
6171 */
62- private function processPropertyAttributes ($ reflection , OA \Property $ property , array $ attributes ): void
72+ private function processConstraintPropertyAttributes ($ reflection , OA \Property $ property , array $ attributes ): void
6373 {
6474 foreach ($ attributes as $ attribute ) {
6575 if ($ attribute instanceof Assert \NotBlank || $ attribute instanceof Assert \NotNull) {
@@ -179,7 +189,7 @@ private function applyEnumFromChoiceConstraint(OA\Schema $property, Assert\Choic
179189 *
180190 * @return iterable<Constraint>
181191 */
182- private function getAttributes (Context $ parentContext , $ reflection , ?array $ validationGroups ): iterable
192+ private function getConstraintAttributes (Context $ parentContext , $ reflection , ?array $ validationGroups ): iterable
183193 {
184194 // To correctly load OA attributes
185195 $ this ->setContextFromReflection ($ parentContext , $ reflection );
0 commit comments