@@ -68,20 +68,22 @@ public function normalize(mixed $object, string $format = null, array $context =
6868 $ template = 'This value should be of type {{ type }}. ' ;
6969 $ data = [
7070 self ::TYPE => 'https://symfony.com/errors/validation ' ,
71+ self ::TITLE => 'Validation Failed ' ,
7172 'violations ' => array_map (
7273 fn ($ e ) => [
7374 'propertyPath ' => $ e ->getPath (),
7475 'title ' => $ trans ($ template , [
7576 '{{ type }} ' => implode ('| ' , $ e ->getExpectedTypes () ?? ['? ' ]),
7677 ], 'validators ' ),
7778 'template ' => $ template ,
78- 'parameter ' => [
79+ 'parameters ' => [
7980 '{{ type }} ' => implode ('| ' , $ e ->getExpectedTypes () ?? ['? ' ]),
8081 ],
8182 ] + ($ debug || $ e ->canUseMessageForUser () ? ['hint ' => $ e ->getMessage ()] : []),
8283 $ exception ->getErrors ()
8384 ),
8485 ];
86+ $ data ['detail ' ] = implode ("\n" , array_map (fn ($ e ) => $ e ['propertyPath ' ].': ' .$ e ['title ' ], $ data ['violations ' ]));
8587 } elseif ($ exception instanceof ValidationFailedException
8688 && $ this ->serializer instanceof NormalizerInterface
8789 && $ this ->serializer ->supportsNormalization ($ exception ->getViolations (), $ format , $ context )
@@ -94,7 +96,7 @@ public function normalize(mixed $object, string $format = null, array $context =
9496 self ::TYPE => $ data [self ::TYPE ] ?? $ context [self ::TYPE ] ?? 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
9597 self ::TITLE => $ data [self ::TITLE ] ?? $ context [self ::TITLE ] ?? 'An error occurred ' ,
9698 self ::STATUS => $ context [self ::STATUS ] ?? $ object ->getStatusCode (),
97- 'detail ' => $ debug ? $ object ->getMessage () : $ object ->getStatusText (),
99+ 'detail ' => $ data [ ' detail ' ] ?? ( $ debug ? $ object ->getMessage () : $ object ->getStatusText () ),
98100 ] + $ data ;
99101 if ($ debug ) {
100102 $ data ['class ' ] = $ object ->getClass ();
0 commit comments