-
-
Notifications
You must be signed in to change notification settings - Fork 589
override-with-generic-response not working from 1.6.8 onwards #1791
Copy link
Copy link
Closed
Description
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:
- Spring Boot Version:
2.7.2 springdoc-openapi-uiVersions:1.6.8, 1.6.9, 1.6.10- Error statuses are not shown as responses on the API endpoint path.
- Example minimal spring project https://github.com/ahopgood/springdoc-override-with-generic-response-regression where the version can be changed to view the different behaviour
- Actual response:
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
@ExceptionHandlermethod that is annotated with@ResponseStatusshould show as a response for every API path in the swagger doc whenspringdoc.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:

When using 1.6.8 or above the error statuses are missing:

Additional context
Add any other context about the problem here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels