Skip to content

Commit 401371e

Browse files
committed
Merge branch 'fix-2282' of github.com:NaccOll/springdoc-openapi into NaccOll-fix-2282
2 parents 8fd5685 + b7b2810 commit 401371e

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/extractor/DelegatingMethodParameter.java

+20-6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
import org.springframework.core.annotation.AnnotatedElementUtils;
5252
import org.springframework.lang.NonNull;
5353
import org.springframework.lang.Nullable;
54+
import org.springframework.web.bind.annotation.RequestBody;
55+
import org.springframework.web.bind.annotation.RequestPart;
5456

5557
/**
5658
* The type Delegating method parameter.
@@ -128,12 +130,24 @@ public static MethodParameter[] customize(String[] pNames, MethodParameter[] par
128130
explodedParameters.add(methodParameter);
129131
});
130132
}
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.getClass()))
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+
}
137151
}
138152
else {
139153
String name = pNames != null ? pNames[i] : p.getParameterName();

0 commit comments

Comments
 (0)