@@ -92,7 +92,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
92
92
}
93
93
94
94
if (null !== $ payload ) {
95
- $ violations ->addAll ($ this ->validator ->validate ($ payload , null , $ attributes [0 ]->groups ?? null ));
95
+ $ violations ->addAll ($ this ->validator ->validate ($ payload , null , $ attributes [0 ]->validationGroups ?? null ));
96
96
}
97
97
98
98
if (\count ($ violations )) {
@@ -125,29 +125,29 @@ private function mapQueryString(Request $request, ArgumentMetadata $argument, Ma
125
125
126
126
private function mapRequestPayload (Request $ request , ArgumentMetadata $ argument , MapRequestPayload $ attribute ): ?object
127
127
{
128
- if ($ data = $ request ->request -> all ()) {
129
- return $ this -> serializer -> denormalize ( $ data , $ argument -> getType (), null , self :: CONTEXT_DENORMALIZE + $ attribute -> context );
128
+ if (null === $ format = $ request ->getContentTypeFormat ()) {
129
+ throw new HttpException (Response:: HTTP_UNSUPPORTED_MEDIA_TYPE , ' Unsupported format. ' );
130
130
}
131
131
132
- if ('' === $ data = $ request ->getContent ()) {
133
- return null ;
132
+ $ acceptedFormats = \is_string ($ attribute ->acceptedFormats ) ? [$ attribute ->acceptedFormats ] : $ attribute ->acceptedFormats ;
133
+ if (\is_array ($ attribute ->acceptedFormats ) && !\in_array ($ format , $ acceptedFormats , true )) {
134
+ throw new HttpException (Response::HTTP_UNSUPPORTED_MEDIA_TYPE , sprintf ('Unsupported format, expects "%s", but "%s" given. ' , implode ('", " ' , $ acceptedFormats ), $ format ));
134
135
}
135
136
136
- if (null === $ format = $ request ->getContentTypeFormat ()) {
137
- throw new HttpException (Response:: HTTP_UNSUPPORTED_MEDIA_TYPE , ' Unsupported format. ' );
137
+ if ($ data = $ request ->request -> all ()) {
138
+ return $ this -> serializer -> denormalize ( $ data , $ argument -> getType (), null , self :: CONTEXT_DENORMALIZE + $ attribute -> deserializationContext );
138
139
}
139
140
140
- $ acceptedFormats = \is_string ($ attribute ->format ) ? [$ attribute ->format ] : $ attribute ->format ;
141
- if (\is_array ($ attribute ->format ) && !\in_array ($ format , $ acceptedFormats , true )) {
142
- throw new HttpException (Response::HTTP_UNSUPPORTED_MEDIA_TYPE , sprintf ('Unsupported format, expects "%s", but "%s" given. ' , implode ('", " ' , $ acceptedFormats ), $ format ));
141
+ if ('' === $ data = $ request ->getContent ()) {
142
+ return null ;
143
143
}
144
144
145
145
if ('form ' === $ format ) {
146
146
throw new HttpException (Response::HTTP_BAD_REQUEST , 'Request payload contains invalid "form" data. ' );
147
147
}
148
148
149
149
try {
150
- return $ this ->serializer ->deserialize ($ data , $ argument ->getType (), $ format , self ::CONTEXT_DESERIALIZE + $ attribute ->context );
150
+ return $ this ->serializer ->deserialize ($ data , $ argument ->getType (), $ format , self ::CONTEXT_DESERIALIZE + $ attribute ->deserializationContext );
151
151
} catch (UnsupportedFormatException $ e ) {
152
152
throw new HttpException (Response::HTTP_UNSUPPORTED_MEDIA_TYPE , sprintf ('Unsupported format: "%s". ' , $ format ), $ e );
153
153
} catch (NotEncodableValueException $ e ) {
0 commit comments