@@ -323,24 +323,24 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
323
323
}
324
324
}
325
325
326
- LinkedHashMap <String , Parameter > map = getParameterLinkedHashMap (components , methodAttributes , operationParameters , parametersDocMap );
326
+ LinkedHashMap <ParameterId , Parameter > map = getParameterLinkedHashMap (components , methodAttributes , operationParameters , parametersDocMap );
327
327
RequestBody requestBody = requestBodyInfo .getRequestBody ();
328
328
// support form-data
329
329
if (defaultSupportFormData && requestBody != null
330
330
&& requestBody .getContent () != null
331
331
&& 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 ();
333
333
while (it .hasNext ()) {
334
- Entry <String , Parameter > entry = it .next ();
334
+ Entry <ParameterId , Parameter > entry = it .next ();
335
335
Parameter parameter = entry .getValue ();
336
336
if (!ParameterIn .PATH .toString ().equals (parameter .getIn ())) {
337
337
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 () );
339
339
itemSchema .setDescription (parameter .getDescription ());
340
340
itemSchema .setDeprecated (parameter .getDeprecated ());
341
341
if (parameter .getExample () != null )
342
342
itemSchema .setExample (parameter .getExample ());
343
- requestBodyInfo .addProperties (entry .getKey (), itemSchema );
343
+ requestBodyInfo .addProperties (entry .getKey (). getpName () , itemSchema );
344
344
it .remove ();
345
345
}
346
346
}
@@ -358,27 +358,32 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
358
358
* @param parametersDocMap the parameters doc map
359
359
* @return the parameter linked hash map
360
360
*/
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 ()
363
363
.collect (Collectors .toMap (
364
- parameter -> parameter . getName () != null ? parameter . getName () : Integer . toString ( parameter . hashCode ()) ,
365
- parameter -> parameter ,
364
+ ParameterId :: new ,
365
+ parameter -> parameter ,
366
366
(u , v ) -> {
367
367
throw new IllegalStateException (String .format ("Duplicate key %s" , u ));
368
368
},
369
369
LinkedHashMap ::new
370
370
));
371
371
372
372
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 ()) {
374
375
//Convert
375
376
Parameter parameter = parameterBuilder .buildParameterFromDoc (entry .getValue (), components ,
376
377
methodAttributes .getJsonViewAnnotation (), methodAttributes .getLocale ());
377
- map .put (entry . getKey () , parameter );
378
+ map .put (parameterId , parameter );
378
379
}
379
380
}
380
381
381
382
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
+ });
382
387
return map ;
383
388
}
384
389
@@ -390,22 +395,23 @@ private LinkedHashMap<String, Parameter> getParameterLinkedHashMap(Components co
390
395
* @return the headers
391
396
*/
392
397
@ 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 ) {
394
399
for (Map .Entry <String , String > entry : methodAttributes .getHeaders ().entrySet ()) {
395
400
StringSchema schema = new StringSchema ();
396
401
if (StringUtils .isNotEmpty (entry .getValue ()))
397
402
schema .addEnumItem (entry .getValue ());
398
403
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 );
401
407
List existingEnum = null ;
402
408
if (parameter .getSchema () != null && !CollectionUtils .isEmpty (parameter .getSchema ().getEnum ()))
403
409
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 ())))
405
411
parameter .getSchema ().addEnumItemObject (entry .getValue ());
406
412
parameter .setSchema (parameter .getSchema ());
407
413
}
408
- map .put (entry . getKey () , parameter );
414
+ map .put (parameterId , parameter );
409
415
}
410
416
return map .values ();
411
417
}
@@ -503,7 +509,7 @@ public Parameter buildParams(ParameterInfo parameterInfo, Components components,
503
509
// By default
504
510
if (!isRequestBodyParam (requestMethod , parameterInfo )) {
505
511
parameterInfo .setRequired (!((DelegatingMethodParameter ) methodParameter ).isNotRequired () && !methodParameter .isOptional ());
506
- parameterInfo .setParamType (QUERY_PARAM );
512
+ // parameterInfo.setParamType(QUERY_PARAM);
507
513
parameterInfo .setDefaultValue (null );
508
514
return this .buildParam (parameterInfo , components , jsonView );
509
515
}
0 commit comments