5353import io .swagger .v3 .oas .models .parameters .Parameter ;
5454import io .swagger .v3 .oas .models .parameters .RequestBody ;
5555import org .apache .commons .lang3 .StringUtils ;
56- import org .springdoc .api .annotations .ParameterObject ;
57- import org .springdoc .core .converters .AdditionalModelsConverter ;
5856import org .springdoc .core .customizers .OperationCustomizer ;
5957import org .springdoc .core .customizers .ParameterCustomizer ;
6058
@@ -162,24 +160,10 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
162160 // requests
163161 String [] pNames = this .localSpringDocParameterNameDiscoverer .getParameterNames (handlerMethod .getMethod ());
164162 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 );
183167 RequestBodyInfo requestBodyInfo = new RequestBodyInfo ();
184168 List <Parameter > operationParameters = (operation .getParameters () != null ) ? operation .getParameters () : new ArrayList <>();
185169 Map <String , io .swagger .v3 .oas .annotations .Parameter > parametersDocMap = getApiParameters (handlerMethod .getMethod ());
@@ -188,9 +172,10 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
188172 for (MethodParameter methodParameter : parameters ) {
189173 // check if query param
190174 Parameter parameter = null ;
175+ final String pName = methodParameter .getParameterName ();
191176 io .swagger .v3 .oas .annotations .Parameter parameterDoc = methodParameter .getParameterAnnotation (io .swagger .v3 .oas .annotations .Parameter .class );
192177 if (parameterDoc == null )
193- parameterDoc = parametersDocMap .get (methodParameter . getParameterName () );
178+ parameterDoc = parametersDocMap .get (pName );
194179 // use documentation as reference
195180 if (parameterDoc != null ) {
196181 if (parameterDoc .hidden ())
@@ -200,7 +185,7 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
200185 }
201186
202187 if (!isParamToIgnore (methodParameter )) {
203- ParameterInfo parameterInfo = new ParameterInfo (methodParameter . getParameterName () , methodParameter , parameter );
188+ ParameterInfo parameterInfo = new ParameterInfo (pName , methodParameter , parameter );
204189 parameter = buildParams (parameterInfo , components , requestMethod ,
205190 methodAttributes .getJsonViewAnnotation ());
206191 // Merge with the operation parameters
0 commit comments