|
63 | 63 | import jakarta.validation.constraints.Min;
|
64 | 64 | import jakarta.validation.constraints.Pattern;
|
65 | 65 | import jakarta.validation.constraints.Size;
|
66 |
| -import org.apache.commons.lang3.ArrayUtils; |
67 | 66 | import org.apache.commons.lang3.StringUtils;
|
68 |
| -import org.jetbrains.annotations.NotNull; |
69 | 67 | import org.springdoc.core.customizers.ParameterCustomizer;
|
70 | 68 | import org.springdoc.core.discoverer.SpringDocParameterNameDiscoverer;
|
71 | 69 | import org.springdoc.core.extractor.DelegatingMethodParameter;
|
|
98 | 96 | import static org.springdoc.core.service.GenericParameterService.isFile;
|
99 | 97 | import static org.springdoc.core.utils.Constants.OPENAPI_ARRAY_TYPE;
|
100 | 98 | import static org.springdoc.core.utils.Constants.OPENAPI_STRING_TYPE;
|
| 99 | +import static org.springdoc.core.utils.SpringDocUtils.getParameterAnnotations; |
101 | 100 | import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
|
102 | 101 |
|
103 | 102 | /**
|
@@ -325,7 +324,7 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
|
325 | 324 | // Merge with the operation parameters
|
326 | 325 | parameter = GenericParameterService.mergeParameter(operationParameters, parameter);
|
327 | 326 |
|
328 |
| - List<Annotation> parameterAnnotations = getParameterAnnotations(methodParameter); |
| 327 | + List<Annotation> parameterAnnotations = List.of(getParameterAnnotations(methodParameter)); |
329 | 328 |
|
330 | 329 | if (isValidParameter(parameter)) {
|
331 | 330 | // Add param javadoc
|
@@ -375,35 +374,6 @@ else if (!RequestMethod.GET.equals(requestMethod) || OpenApiVersion.OPENAPI_3_1.
|
375 | 374 | return operation;
|
376 | 375 | }
|
377 | 376 |
|
378 |
| - /** |
379 |
| - * Gets parameter annotations. |
380 |
| - * |
381 |
| - * @param methodParameter the method parameter |
382 |
| - * @return the parameter annotations |
383 |
| - */ |
384 |
| - @NotNull |
385 |
| - private static List<Annotation> getParameterAnnotations(MethodParameter methodParameter) { |
386 |
| - // Initialize the list for parameter annotations |
387 |
| - List<Annotation> parameterAnnotations = new ArrayList<>(); |
388 |
| - // Add the parameter annotations (direct annotations) |
389 |
| - if (ArrayUtils.isNotEmpty(methodParameter.getParameterAnnotations())) { |
390 |
| - parameterAnnotations.addAll(Arrays.asList(methodParameter.getParameterAnnotations())); |
391 |
| - } |
392 |
| - // Separate list to store meta-annotations |
393 |
| - List<Annotation> metaAnnotationsList = new ArrayList<>(); |
394 |
| - // Iterate over the direct annotations and collect meta-annotations |
395 |
| - for (Annotation parameterAnnotation : parameterAnnotations) { |
396 |
| - Annotation[] metaAnnotations = parameterAnnotation.annotationType().getAnnotations(); |
397 |
| - |
398 |
| - if (ArrayUtils.isNotEmpty(metaAnnotations)) { |
399 |
| - metaAnnotationsList.addAll(Arrays.asList(metaAnnotations)); |
400 |
| - } |
401 |
| - } |
402 |
| - // Add all the collected meta-annotations to the main list |
403 |
| - parameterAnnotations.addAll(metaAnnotationsList); |
404 |
| - return parameterAnnotations; |
405 |
| - } |
406 |
| - |
407 | 377 | /**
|
408 | 378 | * Gets parameter linked hash map.
|
409 | 379 | *
|
|
0 commit comments