53
53
import io .swagger .v3 .oas .models .parameters .Parameter ;
54
54
import io .swagger .v3 .oas .models .parameters .RequestBody ;
55
55
import org .apache .commons .lang3 .StringUtils ;
56
- import org .springdoc .api .annotations .ParameterObject ;
57
- import org .springdoc .core .converters .AdditionalModelsConverter ;
58
56
import org .springdoc .core .customizers .OperationCustomizer ;
59
57
import org .springdoc .core .customizers .ParameterCustomizer ;
60
58
@@ -162,24 +160,10 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
162
160
// requests
163
161
String [] pNames = this .localSpringDocParameterNameDiscoverer .getParameterNames (handlerMethod .getMethod ());
164
162
MethodParameter [] parameters = handlerMethod .getMethodParameters ();
165
-
166
- List <MethodParameter > explodedParameters = new ArrayList <>();
167
- for (int i = 0 ; i < parameters .length ; ++i ) {
168
- MethodParameter p = parameters [i ];
169
- if (p .hasParameterAnnotation (ParameterObject .class )) {
170
- Class <?> paramClass = AdditionalModelsConverter .getReplacement (p .getParameterType ());
171
- Stream .of (paramClass .getDeclaredFields ())
172
- .map (f -> DelegatingMethodParameter .fromGetterOfField (paramClass , f ))
173
- .filter (Objects ::nonNull )
174
- .forEach (explodedParameters ::add );
175
- }
176
- else {
177
- String name = pNames != null ? pNames [i ] : p .getParameterName ();
178
- explodedParameters .add (new DelegatingMethodParameter (p , name , null ));
179
- }
180
- }
181
- parameters = explodedParameters .toArray (new MethodParameter [0 ]);
182
-
163
+ String [] reflectionParametersNames = Arrays .stream (parameters ).map (MethodParameter ::getParameterName ).toArray (String []::new );
164
+ if (pNames == null )
165
+ pNames = reflectionParametersNames ;
166
+ parameters = DelegatingMethodParameter .customize (pNames , parameters );
183
167
RequestBodyInfo requestBodyInfo = new RequestBodyInfo ();
184
168
List <Parameter > operationParameters = (operation .getParameters () != null ) ? operation .getParameters () : new ArrayList <>();
185
169
Map <String , io .swagger .v3 .oas .annotations .Parameter > parametersDocMap = getApiParameters (handlerMethod .getMethod ());
@@ -188,9 +172,10 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
188
172
for (MethodParameter methodParameter : parameters ) {
189
173
// check if query param
190
174
Parameter parameter = null ;
175
+ final String pName = methodParameter .getParameterName ();
191
176
io .swagger .v3 .oas .annotations .Parameter parameterDoc = methodParameter .getParameterAnnotation (io .swagger .v3 .oas .annotations .Parameter .class );
192
177
if (parameterDoc == null )
193
- parameterDoc = parametersDocMap .get (methodParameter . getParameterName () );
178
+ parameterDoc = parametersDocMap .get (pName );
194
179
// use documentation as reference
195
180
if (parameterDoc != null ) {
196
181
if (parameterDoc .hidden ())
@@ -200,7 +185,7 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
200
185
}
201
186
202
187
if (!isParamToIgnore (methodParameter )) {
203
- ParameterInfo parameterInfo = new ParameterInfo (methodParameter . getParameterName () , methodParameter , parameter );
188
+ ParameterInfo parameterInfo = new ParameterInfo (pName , methodParameter , parameter );
204
189
parameter = buildParams (parameterInfo , components , requestMethod ,
205
190
methodAttributes .getJsonViewAnnotation ());
206
191
// Merge with the operation parameters
0 commit comments