|
21 | 21 | */
|
22 | 22 | package org.springdoc.core;
|
23 | 23 |
|
24 |
| -import java.lang.annotation.Annotation; |
25 |
| -import java.lang.reflect.AnnotatedElement; |
26 |
| -import java.lang.reflect.Constructor; |
27 |
| -import java.lang.reflect.Executable; |
28 |
| -import java.lang.reflect.Field; |
29 |
| -import java.lang.reflect.Member; |
30 |
| -import java.lang.reflect.Method; |
31 |
| -import java.lang.reflect.Type; |
32 |
| -import java.util.ArrayList; |
33 |
| -import java.util.Arrays; |
34 |
| -import java.util.List; |
35 |
| -import java.util.Objects; |
36 |
| -import java.util.Optional; |
37 |
| - |
38 | 24 | import org.apache.commons.lang3.ArrayUtils;
|
39 | 25 | import org.apache.commons.lang3.reflect.FieldUtils;
|
40 | 26 | import org.slf4j.Logger;
|
41 | 27 | import org.slf4j.LoggerFactory;
|
42 | 28 | import org.springdoc.api.annotations.ParameterObject;
|
43 | 29 | import org.springdoc.core.converters.AdditionalModelsConverter;
|
44 | 30 | import org.springdoc.core.customizers.DelegatingMethodParameterCustomizer;
|
45 |
| - |
46 | 31 | import org.springframework.core.MethodParameter;
|
47 | 32 | import org.springframework.core.ParameterNameDiscoverer;
|
48 | 33 | import org.springframework.core.annotation.AnnotatedElementUtils;
|
49 | 34 | import org.springframework.lang.NonNull;
|
50 | 35 | import org.springframework.lang.Nullable;
|
| 36 | +import org.springframework.web.bind.annotation.RequestBody; |
| 37 | +import org.springframework.web.bind.annotation.RequestPart; |
| 38 | + |
| 39 | +import java.lang.annotation.Annotation; |
| 40 | +import java.lang.reflect.*; |
| 41 | +import java.util.*; |
51 | 42 |
|
52 | 43 | /**
|
53 | 44 | * The type Delegating method parameter.
|
@@ -119,19 +110,16 @@ public static MethodParameter[] customize(String[] pNames, MethodParameter[] par
|
119 | 110 | MethodParameter p = parameters[i];
|
120 | 111 | Class<?> paramClass = AdditionalModelsConverter.getParameterObjectReplacement(p.getParameterType());
|
121 | 112 |
|
122 |
| - if (!MethodParameterPojoExtractor.isSimpleType(paramClass) && (p.hasParameterAnnotation(ParameterObject.class) || AnnotatedElementUtils.isAnnotated(paramClass, ParameterObject.class))) { |
| 113 | + boolean hasFlatAnnotation = p.hasParameterAnnotation(ParameterObject.class) || AnnotatedElementUtils.isAnnotated(paramClass, ParameterObject.class); |
| 114 | + boolean hasNotFlatAnnotation = Arrays.stream(p.getParameterAnnotations()) |
| 115 | + .anyMatch(annotation -> Arrays.asList(RequestBody.class, RequestPart.class).contains(annotation.annotationType())); |
| 116 | + if (!MethodParameterPojoExtractor.isSimpleType(paramClass) |
| 117 | + && (hasFlatAnnotation || (defaultFlatParamObject && !hasNotFlatAnnotation && !AbstractRequestService.isRequestTypeToIgnore(paramClass)))) { |
123 | 118 | MethodParameterPojoExtractor.extractFrom(paramClass).forEach(methodParameter -> {
|
124 | 119 | optionalDelegatingMethodParameterCustomizer.ifPresent(customizer -> customizer.customize(p, methodParameter));
|
125 | 120 | explodedParameters.add(methodParameter);
|
126 | 121 | });
|
127 | 122 | }
|
128 |
| - else if (defaultFlatParamObject && !MethodParameterPojoExtractor.isSimpleType(paramClass) && !AbstractRequestService.isRequestTypeToIgnore(paramClass)) { |
129 |
| - MethodParameterPojoExtractor.extractFrom(paramClass).forEach(methodParameter -> { |
130 |
| - optionalDelegatingMethodParameterCustomizer |
131 |
| - .ifPresent(customizer -> customizer.customize(p, methodParameter)); |
132 |
| - explodedParameters.add(methodParameter); |
133 |
| - }); |
134 |
| - } |
135 | 123 | else {
|
136 | 124 | String name = pNames != null ? pNames[i] : p.getParameterName();
|
137 | 125 | explodedParameters.add(new DelegatingMethodParameter(p, name, null, false, false));
|
|
0 commit comments