How to create multiple 404 responses (or more broadly, multiple same HTTP code responses) using java annotations.
I've tried:
@ApiResponse(
responseCode = "404",
description = "Not Found 1"
)
@ApiResponse(
responseCode = "404",
description = "Not Found 2"
)
And also mulitple @Content
:
@ApiResponse(
responseCode = "404",
content = {
@Content(schema = @Schema(name = "404-1", description = "404-1")),
@Content(schema = @Schema(name = "404-2", description = "404-2"))
}
)
The only way I can get something similar to multiple is by using @ExampleObject[]
:
@ApiResponse(
responseCode = "404",
content = @Content(
mediaType = "application/json",
examples = {
@ExampleObject(name = "404-1", description = "Not Found 1 desc"),
@ExampleObject(name = "404-2", description = "Not Found 2 desc")
}
)
)
This is not ideal because it requires human interaction to view all of them and is just not wanted; the expectation is to have:
- 200
- 404 Description 1
- 404 Description 2
- 404 Description 3
or even better:
- 200
- 404 Description 1
Description 2
Description 3
I'm using springdoc and the following dep:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.3</version>
</dependency>