@@ -255,7 +255,7 @@ protected Parameter customiseParameter(Parameter parameter, ParameterInfo parame
255
255
protected boolean isParamToIgnore (MethodParameter parameter ) {
256
256
if (parameterBuilder .isAnnotationToIgnore (parameter ))
257
257
return true ;
258
- if ((parameter .getParameterAnnotation (PathVariable .class ) != null && parameter .getParameterAnnotation (PathVariable .class ) .required ())
258
+ if ((parameter .getParameterAnnotation (PathVariable .class ) != null && parameter .getParameterAnnotation (PathVariable .class ).required ())
259
259
|| (parameter .getParameterAnnotation (RequestParam .class ) != null && parameter .getParameterAnnotation (RequestParam .class ).required ())
260
260
|| (parameter .getParameterAnnotation (org .springframework .web .bind .annotation .RequestBody .class ) != null && parameter .getParameterAnnotation (org .springframework .web .bind .annotation .RequestBody .class ).required ()))
261
261
return false ;
@@ -374,14 +374,16 @@ private void applyBeanValidatorAnnotations(final Parameter parameter, final List
374
374
375
375
private void applyBeanValidatorAnnotations (final RequestBody requestBody , final List <Annotation > annotations , boolean isOptional ) {
376
376
Map <String , Annotation > annos = new HashMap <>();
377
- if (annotations != null )
377
+ boolean requestBodyRequired = false ;
378
+ if (annotations != null ) {
378
379
annotations .forEach (annotation -> annos .put (annotation .annotationType ().getName (), annotation ));
380
+ requestBodyRequired = annotations .stream ()
381
+ .filter (annotation -> org .springframework .web .bind .annotation .RequestBody .class .equals (annotation .annotationType ()))
382
+ .anyMatch (annotation -> ((org .springframework .web .bind .annotation .RequestBody ) annotation ).required ());
383
+ }
379
384
boolean validationExists = Arrays .stream (ANNOTATIONS_FOR_REQUIRED ).anyMatch (annos ::containsKey );
380
- boolean requestBodyRequired = annotations .stream ()
381
- .filter (annotation -> org .springframework .web .bind .annotation .RequestBody .class .equals (annotation .annotationType ()))
382
- .anyMatch (annotation -> ((org .springframework .web .bind .annotation .RequestBody ) annotation ).required ());
383
385
384
- if (validationExists || (!isOptional && requestBodyRequired ) )
386
+ if (validationExists || (!isOptional && requestBodyRequired ))
385
387
requestBody .setRequired (true );
386
388
Content content = requestBody .getContent ();
387
389
for (MediaType mediaType : content .values ()) {
0 commit comments