|
101 | 101 | /** |
102 | 102 | * The type Generic response builder. |
103 | 103 | * |
104 | | - * @author bnasslahsen |
| 104 | + * @author bnasslahsen, Max Freedom Pollard |
105 | 105 | */ |
106 | 106 | public class GenericResponseService implements ApplicationContextAware { |
107 | 107 |
|
@@ -450,7 +450,7 @@ private void buildGenericApiResponses(Components components, MethodParameter met |
450 | 450 | else { |
451 | 451 | // Use response parameters with no description filled - No documentation |
452 | 452 | // available |
453 | | - String httpCode = evaluateResponseStatus(methodParameter.getMethod(), Objects.requireNonNull(methodParameter.getMethod()).getClass(), true); |
| 453 | + String httpCode = evaluateResponseStatus(methodParameter.getMethod(), methodParameter.getContainingClass(), true); |
454 | 454 | if (Objects.nonNull(httpCode)) { |
455 | 455 | apiResponse = methodAttributes.getGenericMapResponse().containsKey(httpCode) ? methodAttributes.getGenericMapResponse().get(httpCode) |
456 | 456 | : new ApiResponse(); |
@@ -491,16 +491,17 @@ private void buildApiResponses(Components components, MethodParameter methodPara |
491 | 491 | buildApiResponses(components, methodParameter, apiResponsesOp, methodAttributes, httpCode, apiResponse, false); |
492 | 492 | } |
493 | 493 | } |
494 | | - if (AnnotatedElementUtils.hasAnnotation(methodParameter.getMethod(), ResponseStatus.class)) { |
| 494 | + if (AnnotatedElementUtils.hasAnnotation(methodParameter.getMethod(), ResponseStatus.class) |
| 495 | + || AnnotatedElementUtils.hasAnnotation(methodParameter.getContainingClass(), ResponseStatus.class)) { |
495 | 496 | // Handles the case with @ResponseStatus, if the specified response is not already handled explicitly |
496 | | - String httpCode = evaluateResponseStatus(methodParameter.getMethod(), Objects.requireNonNull(methodParameter.getMethod()).getClass(), false); |
| 497 | + String httpCode = evaluateResponseStatus(methodParameter.getMethod(), methodParameter.getContainingClass(), false); |
497 | 498 | if (Objects.nonNull(httpCode) && !apiResponsesOp.containsKey(httpCode) && !apiResponsesOp.containsKey(ApiResponses.DEFAULT)) { |
498 | 499 | buildApiResponses(components, methodParameter, apiResponsesOp, methodAttributes, httpCode, new ApiResponse(), false); |
499 | 500 | } |
500 | 501 | } |
501 | 502 | } |
502 | 503 | else { |
503 | | - String httpCode = evaluateResponseStatus(methodParameter.getMethod(), Objects.requireNonNull(methodParameter.getMethod()).getClass(), false); |
| 504 | + String httpCode = evaluateResponseStatus(methodParameter.getMethod(), methodParameter.getContainingClass(), false); |
504 | 505 | if (Objects.nonNull(httpCode)) |
505 | 506 | buildApiResponses(components, methodParameter, apiResponsesOp, methodAttributes, httpCode, new ApiResponse(), false); |
506 | 507 | } |
@@ -812,7 +813,7 @@ private boolean isValidHttpCode(String httpCode, MethodParameter methodParameter |
812 | 813 | if (isHttpCodePresent(httpCode, responseSet)) |
813 | 814 | result = true; |
814 | 815 | } |
815 | | - if (httpCode.equals(evaluateResponseStatus(method, method.getClass(), false))) |
| 816 | + if (httpCode.equals(evaluateResponseStatus(method, methodParameter.getContainingClass(), false))) |
816 | 817 | result = true; |
817 | 818 | } |
818 | 819 | } |
|
0 commit comments