Skip to content

Response schema for overridden methods of ResponseEntityExceptionHandler is not generated  #1208

Closed
@Oguzhan1942

Description

@Oguzhan1942

Describe the feature
For generating documentation using @ResponseStatus on methods of my @ControllerAdvice class I have overridden a method named handleMethodArgumentNotValid of ResponseEntityExceptionHandler I expect the response code will be generated as it does for @ExceptionHandler methods.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    2.4.2
  • What modules and versions of springdoc-openapi are you using?
    org.springdoc:springdoc-openapi-kotlin:1.5.9
    org.springdoc:springdoc-openapi-ui:1.5.9
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
    json
  • Provide with a sample code (HelloController) or Test that reproduces the problem
@ControllerAdvice
class CustomResponseEntityHandler : ResponseEntityExceptionHandler() {
  @org.springframework.web.bind.annotation.ResponseStatus(HttpStatus.BAD_REQUEST)
   override fun handleMethodArgumentNotValid(.....) : ResponseEntity<Any> -> **NO response code generated**

   @org.springframework.web.bind.annotation.ResponseStatus(HttpStatus.REQUEST_TIMEOUT)
   @ExceptionHandler(TransactionTimedOutException::class)
    fun handleTransactionTimeout(....): ResponseEntity<ResponseStatus> -> **Response code generated**

Expected behavior

  • A clear and concise description of what you expected to happen.
    At least a response code json object 400 Bad Request generated in my api.json file as following.
 "400": {
            "description": "Bad Request",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseStatus"
                }
              }
            }
          },

If this is not the way it suppose to work, I appreciate any kind of help.

Thanks & Best Regards,
Oguzhan

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions