51
51
import org .springframework .core .annotation .AnnotatedElementUtils ;
52
52
import org .springframework .lang .NonNull ;
53
53
import org .springframework .lang .Nullable ;
54
+ import org .springframework .web .bind .annotation .RequestBody ;
55
+ import org .springframework .web .bind .annotation .RequestPart ;
54
56
55
57
/**
56
58
* The type Delegating method parameter.
@@ -128,12 +130,24 @@ public static MethodParameter[] customize(String[] pNames, MethodParameter[] par
128
130
explodedParameters .add (methodParameter );
129
131
});
130
132
}
131
- else if (defaultFlatParamObject && !MethodParameterPojoExtractor .isSimpleType (paramClass ) && !AbstractRequestService .isRequestTypeToIgnore (paramClass )) {
132
- MethodParameterPojoExtractor .extractFrom (paramClass ).forEach (methodParameter -> {
133
- optionalDelegatingMethodParameterCustomizer
134
- .ifPresent (customizer -> customizer .customize (p , methodParameter ));
135
- explodedParameters .add (methodParameter );
136
- });
133
+ else if (defaultFlatParamObject ) {
134
+ boolean isSimpleType = MethodParameterPojoExtractor .isSimpleType (paramClass );
135
+ List <Annotation > annotations = Arrays .stream (p .getParameterAnnotations ())
136
+ .filter (annotation -> Arrays .asList (RequestBody .class , RequestPart .class ).contains (annotation .annotationType ()))
137
+ .toList ();
138
+ boolean hasAnnotation = !annotations .isEmpty ();
139
+ boolean shouldFlat = !isSimpleType && !hasAnnotation ;
140
+ if (shouldFlat && !AbstractRequestService .isRequestTypeToIgnore (paramClass )) {
141
+ MethodParameterPojoExtractor .extractFrom (paramClass ).forEach (methodParameter -> {
142
+ optionalDelegatingMethodParameterCustomizer
143
+ .ifPresent (customizer -> customizer .customize (p , methodParameter ));
144
+ explodedParameters .add (methodParameter );
145
+ });
146
+ }
147
+ else {
148
+ String name = pNames != null ? pNames [i ] : p .getParameterName ();
149
+ explodedParameters .add (new DelegatingMethodParameter (p , name , null , false , false ));
150
+ }
137
151
}
138
152
else {
139
153
String name = pNames != null ? pNames [i ] : p .getParameterName ();
@@ -286,4 +300,4 @@ public boolean isParameterObject() {
286
300
return isParameterObject ;
287
301
}
288
302
289
- }
303
+ }
0 commit comments