|
21 | 21 | * * * * |
22 | 22 | * * * |
23 | 23 | * * |
24 | | - * |
| 24 | + * |
25 | 25 | */ |
26 | 26 |
|
27 | 27 | package org.springdoc.core.service; |
@@ -333,7 +333,7 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod, |
333 | 333 | if (!isParamToIgnore(methodParameter)) { |
334 | 334 | parameter = buildParams(parameterInfo, components, requestMethod, methodAttributes, openAPI.getOpenapi()); |
335 | 335 | List<Annotation> parameterAnnotations = List.of(getParameterAnnotations(methodParameter)); |
336 | | - if (isValidParameter(parameter,methodAttributes)) { |
| 336 | + if (isValidParameter(parameter, methodAttributes)) { |
337 | 337 | // Merge with the operation parameters |
338 | 338 | parameter = GenericParameterService.mergeParameter(operationParameters, parameter); |
339 | 339 | // Add param javadoc |
@@ -368,12 +368,20 @@ else if (!RequestMethod.GET.equals(requestMethod) || OpenApiVersion.OPENAPI_3_1. |
368 | 368 | Parameter parameter = entry.getValue(); |
369 | 369 | if (!ParameterIn.PATH.toString().equals(parameter.getIn()) && !ParameterIn.HEADER.toString().equals(parameter.getIn()) |
370 | 370 | && !ParameterIn.COOKIE.toString().equals(parameter.getIn())) { |
371 | | - Schema<?> itemSchema = new Schema<>(); |
372 | | - itemSchema.setName(entry.getKey().getpName()); |
373 | | - itemSchema.setDescription(parameter.getDescription()); |
374 | | - itemSchema.setDeprecated(parameter.getDeprecated()); |
| 371 | + Schema<?> itemSchema; |
| 372 | + if (parameter.getSchema() != null) { |
| 373 | + itemSchema = parameter.getSchema(); |
| 374 | + } |
| 375 | + else { |
| 376 | + itemSchema = new Schema<>(); |
| 377 | + itemSchema.setName(entry.getKey().getpName()); |
| 378 | + } |
| 379 | + if (StringUtils.isNotEmpty(parameter.getDescription())) |
| 380 | + itemSchema.setDescription(parameter.getDescription()); |
375 | 381 | if (parameter.getExample() != null) |
376 | 382 | itemSchema.setExample(parameter.getExample()); |
| 383 | + if (parameter.getDeprecated() != null) |
| 384 | + itemSchema.setDeprecated(parameter.getDeprecated()); |
377 | 385 | requestBodyInfo.addProperties(entry.getKey().getpName(), itemSchema); |
378 | 386 | it.remove(); |
379 | 387 | } |
@@ -525,7 +533,7 @@ private void setParams(Operation operation, List<Parameter> operationParameters, |
525 | 533 | * @param methodAttributes the method attributes |
526 | 534 | * @return the boolean |
527 | 535 | */ |
528 | | - public boolean isValidParameter(Parameter parameter, MethodAttributes methodAttributes ) { |
| 536 | + public boolean isValidParameter(Parameter parameter, MethodAttributes methodAttributes) { |
529 | 537 | return parameter != null && (parameter.getName() != null || parameter.get$ref() != null) && !(Arrays.asList(methodAttributes.getMethodConsumes()).contains(APPLICATION_FORM_URLENCODED_VALUE) && ParameterIn.QUERY.toString().equals(parameter.getIn())); |
530 | 538 | } |
531 | 539 |
|
@@ -842,14 +850,14 @@ else if (requestBody.content().length > 0) |
842 | 850 | return false; |
843 | 851 | } |
844 | 852 |
|
845 | | - /** |
846 | | - * Check if the parameter has any of the annotations that make it non-optional |
847 | | - * |
848 | | - * @param annotationSimpleNames the annotation simple class named, e.g. NotNull |
849 | | - * @return whether any of the known NotNull annotations are present |
850 | | - */ |
851 | | - public static boolean hasNotNullAnnotation(Collection<String> annotationSimpleNames) { |
852 | | - return Arrays.stream(ANNOTATIONS_FOR_REQUIRED).anyMatch(annotationSimpleNames::contains); |
853 | | - } |
854 | | - |
| 853 | + /** |
| 854 | + * Check if the parameter has any of the annotations that make it non-optional |
| 855 | + * |
| 856 | + * @param annotationSimpleNames the annotation simple class named, e.g. NotNull |
| 857 | + * @return whether any of the known NotNull annotations are present |
| 858 | + */ |
| 859 | + public static boolean hasNotNullAnnotation(Collection<String> annotationSimpleNames) { |
| 860 | + return Arrays.stream(ANNOTATIONS_FOR_REQUIRED).anyMatch(annotationSimpleNames::contains); |
| 861 | + } |
| 862 | + |
855 | 863 | } |
0 commit comments