You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating an @ExceptionHandler in a @RestController, similar to @RestControllerAdvice I expect the OpenAPI documentation to contain the response for this ExceptionHandler. I'm not sure if this is a bug of a missing feature and thus a feature request.
@RestControllerAdvicepublicclassExceptionControllerAdvice
{
// This is generated in OpenAPI documentation@ExceptionHandler(CustomException1.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
publicErrorMessagehandleException1(RuntimeExceptione)
{
returnnewErrorMessage(HttpStatus.NOT_FOUND, e.getMessage());
}
}
@RestControllerpublicclassClassExceptionHandlerController
{
// This is not generated in OpenAPI documentation@ExceptionHandler(CustomException2.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
publicErrorMessagehandleException(RuntimeExceptione)
{
returnnewErrorMessage(HttpStatus.BAD_REQUEST, e.getMessage());
}
@GetMapping("/classexceptionhandler/1")
publicvoidtest1() {
thrownewCustomException1();
}
@GetMapping("/classexceptionhandler/2")
publicvoidtest2() {
thrownewCustomException2();
}
}
Expected:
Both 400 (from @RestController) and 404 (from @RestControllerAdvice) as responses of mappings.
Actual:
Only 404 (from @RestControllerAdvice) as response of mappings.
bnasslahsen
changed the title
@RestController @ExceptionHandler not generated in OpenAPI
Add support for @ExceptionHandler inside @RestController
Jun 26, 2020
When creating an
@ExceptionHandler
in a@RestController
, similar to@RestControllerAdvice
I expect the OpenAPI documentation to contain the response for this ExceptionHandler. I'm not sure if this is a bug of a missing feature and thus a feature request.Expected:
@RestController
) and 404 (from@RestControllerAdvice
) as responses of mappings.Actual:
@RestControllerAdvice
) as response of mappings.Using springdoc-openapi 1.4.1. See attached project.
springdoc-bug-classexceptionhandler.zip
The text was updated successfully, but these errors were encountered: