@@ -323,24 +323,24 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
323323 }
324324 }
325325
326- LinkedHashMap <String , Parameter > map = getParameterLinkedHashMap (components , methodAttributes , operationParameters , parametersDocMap );
326+ LinkedHashMap <ParameterId , Parameter > map = getParameterLinkedHashMap (components , methodAttributes , operationParameters , parametersDocMap );
327327 RequestBody requestBody = requestBodyInfo .getRequestBody ();
328328 // support form-data
329329 if (defaultSupportFormData && requestBody != null
330330 && requestBody .getContent () != null
331331 && requestBody .getContent ().containsKey (org .springframework .http .MediaType .MULTIPART_FORM_DATA_VALUE )) {
332- Iterator <Entry <String , Parameter >> it = map .entrySet ().iterator ();
332+ Iterator <Entry <ParameterId , Parameter >> it = map .entrySet ().iterator ();
333333 while (it .hasNext ()) {
334- Entry <String , Parameter > entry = it .next ();
334+ Entry <ParameterId , Parameter > entry = it .next ();
335335 Parameter parameter = entry .getValue ();
336336 if (!ParameterIn .PATH .toString ().equals (parameter .getIn ())) {
337337 io .swagger .v3 .oas .models .media .Schema <?> itemSchema = new io .swagger .v3 .oas .models .media .Schema <>();
338- itemSchema .setName (entry .getKey ());
338+ itemSchema .setName (entry .getKey (). getpName () );
339339 itemSchema .setDescription (parameter .getDescription ());
340340 itemSchema .setDeprecated (parameter .getDeprecated ());
341341 if (parameter .getExample () != null )
342342 itemSchema .setExample (parameter .getExample ());
343- requestBodyInfo .addProperties (entry .getKey (), itemSchema );
343+ requestBodyInfo .addProperties (entry .getKey (). getpName () , itemSchema );
344344 it .remove ();
345345 }
346346 }
@@ -358,27 +358,32 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
358358 * @param parametersDocMap the parameters doc map
359359 * @return the parameter linked hash map
360360 */
361- private LinkedHashMap <String , Parameter > getParameterLinkedHashMap (Components components , MethodAttributes methodAttributes , List <Parameter > operationParameters , Map <String , io .swagger .v3 .oas .annotations .Parameter > parametersDocMap ) {
362- LinkedHashMap <String , Parameter > map = operationParameters .stream ()
361+ private LinkedHashMap <ParameterId , Parameter > getParameterLinkedHashMap (Components components , MethodAttributes methodAttributes , List <Parameter > operationParameters , Map <String , io .swagger .v3 .oas .annotations .Parameter > parametersDocMap ) {
362+ LinkedHashMap <ParameterId , Parameter > map = operationParameters .stream ()
363363 .collect (Collectors .toMap (
364- parameter -> parameter . getName () != null ? parameter . getName () : Integer . toString ( parameter . hashCode ()) ,
365- parameter -> parameter ,
364+ ParameterId :: new ,
365+ parameter -> parameter ,
366366 (u , v ) -> {
367367 throw new IllegalStateException (String .format ("Duplicate key %s" , u ));
368368 },
369369 LinkedHashMap ::new
370370 ));
371371
372372 for (Map .Entry <String , io .swagger .v3 .oas .annotations .Parameter > entry : parametersDocMap .entrySet ()) {
373- if (entry .getKey () != null && !map .containsKey (entry .getKey ()) && !entry .getValue ().hidden ()) {
373+ ParameterId parameterId = new ParameterId (entry .getValue ());
374+ if (entry .getKey () != null && !map .containsKey (parameterId ) && !entry .getValue ().hidden ()) {
374375 //Convert
375376 Parameter parameter = parameterBuilder .buildParameterFromDoc (entry .getValue (), components ,
376377 methodAttributes .getJsonViewAnnotation (), methodAttributes .getLocale ());
377- map .put (entry . getKey () , parameter );
378+ map .put (parameterId , parameter );
378379 }
379380 }
380381
381382 getHeaders (methodAttributes , map );
383+ map .forEach ((parameterId , parameter ) -> {
384+ if (StringUtils .isBlank (parameter .getIn ()) && StringUtils .isBlank (parameter .get$ref ()))
385+ parameter .setIn (ParameterIn .QUERY .toString ());
386+ });
382387 return map ;
383388 }
384389
@@ -390,22 +395,23 @@ private LinkedHashMap<String, Parameter> getParameterLinkedHashMap(Components co
390395 * @return the headers
391396 */
392397 @ SuppressWarnings ("unchecked" )
393- public static Collection <Parameter > getHeaders (MethodAttributes methodAttributes , Map <String , Parameter > map ) {
398+ public static Collection <Parameter > getHeaders (MethodAttributes methodAttributes , Map <ParameterId , Parameter > map ) {
394399 for (Map .Entry <String , String > entry : methodAttributes .getHeaders ().entrySet ()) {
395400 StringSchema schema = new StringSchema ();
396401 if (StringUtils .isNotEmpty (entry .getValue ()))
397402 schema .addEnumItem (entry .getValue ());
398403 Parameter parameter = new Parameter ().in (ParameterIn .HEADER .toString ()).name (entry .getKey ()).schema (schema );
399- if (map .containsKey (entry .getKey ())) {
400- parameter = map .get (entry .getKey ());
404+ ParameterId parameterId = new ParameterId (parameter );
405+ if (map .containsKey (parameterId )) {
406+ parameter = map .get (parameterId );
401407 List existingEnum = null ;
402408 if (parameter .getSchema () != null && !CollectionUtils .isEmpty (parameter .getSchema ().getEnum ()))
403409 existingEnum = parameter .getSchema ().getEnum ();
404- if (StringUtils .isNotEmpty (entry .getValue ()) && (existingEnum == null || !existingEnum .contains (entry .getValue ())))
410+ if (StringUtils .isNotEmpty (entry .getValue ()) && (existingEnum == null || !existingEnum .contains (entry .getValue ())))
405411 parameter .getSchema ().addEnumItemObject (entry .getValue ());
406412 parameter .setSchema (parameter .getSchema ());
407413 }
408- map .put (entry . getKey () , parameter );
414+ map .put (parameterId , parameter );
409415 }
410416 return map .values ();
411417 }
@@ -503,7 +509,7 @@ public Parameter buildParams(ParameterInfo parameterInfo, Components components,
503509 // By default
504510 if (!isRequestBodyParam (requestMethod , parameterInfo )) {
505511 parameterInfo .setRequired (!((DelegatingMethodParameter ) methodParameter ).isNotRequired () && !methodParameter .isOptional ());
506- parameterInfo .setParamType (QUERY_PARAM );
512+ // parameterInfo.setParamType(QUERY_PARAM);
507513 parameterInfo .setDefaultValue (null );
508514 return this .buildParam (parameterInfo , components , jsonView );
509515 }
0 commit comments