@@ -68,20 +68,22 @@ public function normalize(mixed $object, string $format = null, array $context =
68
68
$ template = 'This value should be of type {{ type }}. ' ;
69
69
$ data = [
70
70
self ::TYPE => 'https://symfony.com/errors/validation ' ,
71
+ self ::TITLE => 'Validation Failed ' ,
71
72
'violations ' => array_map (
72
73
fn ($ e ) => [
73
74
'propertyPath ' => $ e ->getPath (),
74
75
'title ' => $ trans ($ template , [
75
76
'{{ type }} ' => implode ('| ' , $ e ->getExpectedTypes () ?? ['? ' ]),
76
77
], 'validators ' ),
77
78
'template ' => $ template ,
78
- 'parameter ' => [
79
+ 'parameters ' => [
79
80
'{{ type }} ' => implode ('| ' , $ e ->getExpectedTypes () ?? ['? ' ]),
80
81
],
81
82
] + ($ debug || $ e ->canUseMessageForUser () ? ['hint ' => $ e ->getMessage ()] : []),
82
83
$ exception ->getErrors ()
83
84
),
84
85
];
86
+ $ data ['detail ' ] = implode ("\n" , array_map (fn ($ e ) => $ e ['propertyPath ' ].': ' .$ e ['title ' ], $ data ['violations ' ]));
85
87
} elseif ($ exception instanceof ValidationFailedException
86
88
&& $ this ->serializer instanceof NormalizerInterface
87
89
&& $ this ->serializer ->supportsNormalization ($ exception ->getViolations (), $ format , $ context )
@@ -94,7 +96,7 @@ public function normalize(mixed $object, string $format = null, array $context =
94
96
self ::TYPE => $ data [self ::TYPE ] ?? $ context [self ::TYPE ] ?? 'https://tools.ietf.org/html/rfc2616#section-10 ' ,
95
97
self ::TITLE => $ data [self ::TITLE ] ?? $ context [self ::TITLE ] ?? 'An error occurred ' ,
96
98
self ::STATUS => $ context [self ::STATUS ] ?? $ object ->getStatusCode (),
97
- 'detail ' => $ debug ? $ object ->getMessage () : $ object ->getStatusText (),
99
+ 'detail ' => $ data [ ' detail ' ] ?? ( $ debug ? $ object ->getMessage () : $ object ->getStatusText () ),
98
100
] + $ data ;
99
101
if ($ debug ) {
100
102
$ data ['class ' ] = $ object ->getClass ();
0 commit comments