Reputation: 12063
I am using Spring Boot and Spring Rest Application. In this example I am migrating from Swagger2 to Open API 3.
I've below @APiResponse
which returns 500 errors code and I define the ErrorResource Object for the same. I am not sure how to define error schema in this annatation for the same ?
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "For Success"),
@ApiResponse(responseCode = "500", description = "Internal Server Error") })
Upvotes: 2
Views: 8456
Reputation: 71
In case you are using the SpringFox dependency:
@ApiResponses(value = {
@ApiResponse(code = "200", message = "For Success"),
@ApiResponse(code = "500", message = "Internal Server Error", response = MyErrorResponse.class)
})
Upvotes: 0
Reputation:
You add the schema implementation of your ErrorDetails on the content attribute. For exampel:
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ErrorDetails.class)))
You can have a look at the swagger documentation:
Upvotes: 4