Skip to content

override-with-generic-response not working from 1.6.8 onwards #1791

Closed
@ahopgood

Description

@ahopgood

Describe the bug
When using the springdoc.override-with-generic-response=true property after version 1.6.7 methods annotated with @ResponseStatus and @ExceptionHandler are no longer included in the swagger definition.

This applies for handler methods inside either the @RestController class or a @ControllerAdvice class for handling global exceptions.

To Reproduce
Steps to reproduce the behavior:

openapi: 3.0.1
info:
  title: Hello API
  description: An API for saying hello.
  version: 1.0-SNAPSHOT
servers:
- url: http://0.0.0.0:8080
  description: Generated server url
tags:
- name: Hello Api
paths:
  /api/hello:
    get:
      tags:
      - Hello Api
      summary: Says hello
      operationId: getHello
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string
components: {}

Expected behavior

  • It is expected that every @ExceptionHandler method that is annotated with @ResponseStatus should show as a response for every API path in the swagger doc when springdoc.override-with-generic-response=true
  • Expected output
openapi: 3.0.1
info:
  title: Hello API
  description: An API for saying hello.
  version: 1.0-SNAPSHOT
servers:
- url: http://0.0.0.0:8080
  description: Generated server url
tags:
- name: Hello Api
paths:
  /api/hello:
    get:
      tags:
      - Hello Api
      summary: Says hello
      operationId: getHello
      responses:
        "403":
          description: Forbidden
          content:
            '*/*':
              schema:
                type: string
        "500":
          description: Internal Server Error
          content:
            '*/*':
              schema:
                type: string
        "200":
          description: OK
          content:
            text/plain:
              schema:
                type: string
components: {}

Screenshots
Here is an example of the expected output where the errors are shown in the endpoint documentation:
swagger-error-statuses

When using 1.6.8 or above the error statuses are missing:
swagger-no-errors

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions