6868import org .springdoc .core .customizers .ParameterCustomizer ;
6969import org .springdoc .core .extractor .DelegatingMethodParameter ;
7070import org .springdoc .core .models .MethodAttributes ;
71+ import org .springdoc .core .models .ParameterId ;
7172import org .springdoc .core .models .ParameterInfo ;
7273import org .springdoc .core .models .RequestBodyInfo ;
7374import org .springdoc .core .providers .JavadocProvider ;
@@ -328,24 +329,24 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
328329 }
329330 }
330331
331- LinkedHashMap <String , Parameter > map = getParameterLinkedHashMap (components , methodAttributes , operationParameters , parametersDocMap );
332+ LinkedHashMap <ParameterId , Parameter > map = getParameterLinkedHashMap (components , methodAttributes , operationParameters , parametersDocMap );
332333 RequestBody requestBody = requestBodyInfo .getRequestBody ();
333334 // support form-data
334335 if (defaultSupportFormData && requestBody != null
335336 && requestBody .getContent () != null
336337 && requestBody .getContent ().containsKey (org .springframework .http .MediaType .MULTIPART_FORM_DATA_VALUE )) {
337- Iterator <Entry <String , Parameter >> it = map .entrySet ().iterator ();
338+ Iterator <Entry <ParameterId , Parameter >> it = map .entrySet ().iterator ();
338339 while (it .hasNext ()) {
339- Entry <String , Parameter > entry = it .next ();
340+ Entry <ParameterId , Parameter > entry = it .next ();
340341 Parameter parameter = entry .getValue ();
341342 if (!ParameterIn .PATH .toString ().equals (parameter .getIn ())) {
342- io .swagger .v3 .oas .models .media .Schema <?> itemSchema = new io .swagger .v3 .oas .models .media .Schema () ;
343- itemSchema .setName (entry .getKey ());
343+ io .swagger .v3 .oas .models .media .Schema <?> itemSchema = new io .swagger .v3 .oas .models .media .Schema <>() ;
344+ itemSchema .setName (entry .getKey (). getpName () );
344345 itemSchema .setDescription (parameter .getDescription ());
345346 itemSchema .setDeprecated (parameter .getDeprecated ());
346347 if (parameter .getExample () != null )
347348 itemSchema .setExample (parameter .getExample ());
348- requestBodyInfo .addProperties (entry .getKey (), itemSchema );
349+ requestBodyInfo .addProperties (entry .getKey (). getpName () , itemSchema );
349350 it .remove ();
350351 }
351352 }
@@ -363,27 +364,32 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
363364 * @param parametersDocMap the parameters doc map
364365 * @return the parameter linked hash map
365366 */
366- private LinkedHashMap <String , Parameter > getParameterLinkedHashMap (Components components , MethodAttributes methodAttributes , List <Parameter > operationParameters , Map <String , io .swagger .v3 .oas .annotations .Parameter > parametersDocMap ) {
367- LinkedHashMap <String , Parameter > map = operationParameters .stream ()
367+ private LinkedHashMap <ParameterId , Parameter > getParameterLinkedHashMap (Components components , MethodAttributes methodAttributes , List <Parameter > operationParameters , Map <String , io .swagger .v3 .oas .annotations .Parameter > parametersDocMap ) {
368+ LinkedHashMap <ParameterId , Parameter > map = operationParameters .stream ()
368369 .collect (Collectors .toMap (
369- parameter -> parameter . getName () != null ? parameter . getName () : Integer . toString ( parameter . hashCode ()) ,
370- parameter -> parameter ,
370+ ParameterId :: new ,
371+ parameter -> parameter ,
371372 (u , v ) -> {
372373 throw new IllegalStateException (String .format ("Duplicate key %s" , u ));
373374 },
374375 LinkedHashMap ::new
375376 ));
376377
377378 for (Map .Entry <String , io .swagger .v3 .oas .annotations .Parameter > entry : parametersDocMap .entrySet ()) {
378- if (entry .getKey () != null && !map .containsKey (entry .getKey ()) && !entry .getValue ().hidden ()) {
379+ ParameterId parameterId = new ParameterId (entry .getValue ());
380+ if (entry .getKey () != null && !map .containsKey (parameterId ) && !entry .getValue ().hidden ()) {
379381 //Convert
380382 Parameter parameter = parameterBuilder .buildParameterFromDoc (entry .getValue (), components ,
381383 methodAttributes .getJsonViewAnnotation (), methodAttributes .getLocale ());
382- map .put (entry . getKey () , parameter );
384+ map .put (parameterId , parameter );
383385 }
384386 }
385387
386388 getHeaders (methodAttributes , map );
389+ map .forEach ((parameterId , parameter ) -> {
390+ if (StringUtils .isBlank (parameter .getIn ()) && StringUtils .isBlank (parameter .get$ref ()))
391+ parameter .setIn (ParameterIn .QUERY .toString ());
392+ });
387393 return map ;
388394 }
389395
@@ -395,22 +401,23 @@ private LinkedHashMap<String, Parameter> getParameterLinkedHashMap(Components co
395401 * @return the headers
396402 */
397403 @ SuppressWarnings ("unchecked" )
398- public static Collection <Parameter > getHeaders (MethodAttributes methodAttributes , Map <String , Parameter > map ) {
404+ public static Collection <Parameter > getHeaders (MethodAttributes methodAttributes , Map <ParameterId , Parameter > map ) {
399405 for (Map .Entry <String , String > entry : methodAttributes .getHeaders ().entrySet ()) {
400406 StringSchema schema = new StringSchema ();
401407 if (StringUtils .isNotEmpty (entry .getValue ()))
402408 schema .addEnumItem (entry .getValue ());
403409 Parameter parameter = new Parameter ().in (ParameterIn .HEADER .toString ()).name (entry .getKey ()).schema (schema );
404- if (map .containsKey (entry .getKey ())) {
405- parameter = map .get (entry .getKey ());
410+ ParameterId parameterId = new ParameterId (parameter );
411+ if (map .containsKey (parameterId )) {
412+ parameter = map .get (parameterId );
406413 List existingEnum = null ;
407414 if (parameter .getSchema () != null && !CollectionUtils .isEmpty (parameter .getSchema ().getEnum ()))
408415 existingEnum = parameter .getSchema ().getEnum ();
409- if (StringUtils .isNotEmpty (entry .getValue ()) && (existingEnum == null || !existingEnum .contains (entry .getValue ())))
416+ if (StringUtils .isNotEmpty (entry .getValue ()) && (existingEnum == null || !existingEnum .contains (entry .getValue ())))
410417 parameter .getSchema ().addEnumItemObject (entry .getValue ());
411418 parameter .setSchema (parameter .getSchema ());
412419 }
413- map .put (entry . getKey () , parameter );
420+ map .put (parameterId , parameter );
414421 }
415422 return map .values ();
416423 }
@@ -508,7 +515,7 @@ public Parameter buildParams(ParameterInfo parameterInfo, Components components,
508515 // By default
509516 if (!isRequestBodyParam (requestMethod , parameterInfo )) {
510517 parameterInfo .setRequired (!((DelegatingMethodParameter ) methodParameter ).isNotRequired () && !methodParameter .isOptional ());
511- parameterInfo .setParamType (QUERY_PARAM );
518+ // parameterInfo.setParamType(QUERY_PARAM);
512519 parameterInfo .setDefaultValue (null );
513520 return this .buildParam (parameterInfo , components , jsonView );
514521 }
0 commit comments