|
35 | 35 | import org.apache.commons.lang3.reflect.FieldUtils;
|
36 | 36 | import org.slf4j.Logger;
|
37 | 37 | import org.slf4j.LoggerFactory;
|
| 38 | +import org.springdoc.core.GenericParameterService; |
38 | 39 | import org.springdoc.core.MethodAttributes;
|
39 | 40 | import org.springdoc.core.OperationService;
|
40 | 41 | import org.springdoc.core.SpringDocAnnotationsUtils;
|
@@ -205,12 +206,17 @@ private Operation buildSearchOperation(HandlerMethod handlerMethod, DataRestRepo
|
205 | 206 | String pName = parameterMetadatum.getName();
|
206 | 207 | ResourceDescription description = parameterMetadatum.getDescription();
|
207 | 208 | if (description instanceof TypedResourceDescription) {
|
208 |
| - Type type = getParameterType(pName,method,description); |
| 209 | + Type type = getParameterType(pName, method, description); |
209 | 210 | Schema<?> schema = SpringDocAnnotationsUtils.extractSchema(openAPI.getComponents(), type, null, null);
|
210 | 211 | Parameter parameter = getParameterFromAnnotations(openAPI, methodAttributes, method, pName);
|
211 |
| - if (parameter == null) |
| 212 | + if (parameter == null) { |
212 | 213 | parameter = new Parameter().name(pName).in(ParameterIn.QUERY.toString()).schema(schema);
|
213 |
| - operation.addParametersItem(parameter); |
| 214 | + operation.addParametersItem(parameter); |
| 215 | + } |
| 216 | + else if (CollectionUtils.isEmpty(operation.getParameters())) |
| 217 | + operation.addParametersItem(parameter); |
| 218 | + else |
| 219 | + GenericParameterService.mergeParameter(operation.getParameters(), parameter); |
214 | 220 | }
|
215 | 221 | }
|
216 | 222 |
|
@@ -238,7 +244,7 @@ private Type getParameterType(String pName, Method method, ResourceDescription d
|
238 | 244 | java.lang.reflect.Parameter[] parameters = method.getParameters();
|
239 | 245 | for (int i = 0; i < parameters.length; i++) {
|
240 | 246 | java.lang.reflect.Parameter parameter = parameters[i];
|
241 |
| - if (pName.equals(parameter.getName()) || (parameter.getAnnotation(Param.class)!=null && pName.equals(parameter.getAnnotation(Param.class).value()))) { |
| 247 | + if (pName.equals(parameter.getName()) || (parameter.getAnnotation(Param.class) != null && pName.equals(parameter.getAnnotation(Param.class).value()))) { |
242 | 248 | ResolvableType resolvableType = ResolvableType.forMethodParameter(method, i);
|
243 | 249 | type = resolvableType.getType();
|
244 | 250 | break;
|
|
0 commit comments