Skip to content

Commit

Permalink
Merge branch 'fix-2282' of github.com:NaccOll/springdoc-openapi into …
Browse files Browse the repository at this point in the history
…NaccOll-fix-2282
  • Loading branch information
bnasslahsen committed Jul 10, 2023
2 parents 8fd5685 + b7b2810 commit 401371e
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;

/**
* The type Delegating method parameter.
Expand Down Expand Up @@ -128,12 +130,24 @@ public static MethodParameter[] customize(String[] pNames, MethodParameter[] par
explodedParameters.add(methodParameter);
});
}
else if (defaultFlatParamObject && !MethodParameterPojoExtractor.isSimpleType(paramClass) && !AbstractRequestService.isRequestTypeToIgnore(paramClass)) {
MethodParameterPojoExtractor.extractFrom(paramClass).forEach(methodParameter -> {
optionalDelegatingMethodParameterCustomizer
.ifPresent(customizer -> customizer.customize(p, methodParameter));
explodedParameters.add(methodParameter);
});
else if (defaultFlatParamObject) {
boolean isSimpleType = MethodParameterPojoExtractor.isSimpleType(paramClass);
List<Annotation> annotations = Arrays.stream(p.getParameterAnnotations())
.filter(annotation -> Arrays.asList(RequestBody.class, RequestPart.class).contains(annotation.getClass()))
.toList();
boolean hasAnnotation = !annotations.isEmpty();
boolean shouldFlat = !isSimpleType && !hasAnnotation;
if (shouldFlat && !AbstractRequestService.isRequestTypeToIgnore(paramClass)) {
MethodParameterPojoExtractor.extractFrom(paramClass).forEach(methodParameter -> {
optionalDelegatingMethodParameterCustomizer
.ifPresent(customizer -> customizer.customize(p, methodParameter));
explodedParameters.add(methodParameter);
});
}
else {
String name = pNames != null ? pNames[i] : p.getParameterName();
explodedParameters.add(new DelegatingMethodParameter(p, name, null, false, false));
}
}
else {
String name = pNames != null ? pNames[i] : p.getParameterName();
Expand Down

0 comments on commit 401371e

Please sign in to comment.