I have the following java endpoint inside a Springboot RestController annotated with some Swagger annotations for 4 ApiResponses:
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successfully sign in"),
@ApiResponse(code = 400, message = "Missing request body"),
@ApiResponse(code = 404, message = "Schema not found"),
@ApiResponse(code = 500, message = "Internal error")
})
@PostMapping(
path = "/login",
produces = "application/json; charset=utf-8")
public LoginResponse login(
@ApiParam(
name="cred",
value="Credenciales de quien intenta ingresar al sistema")
@RequestBody CredencialesRequest cred
) throws ControllerException {
return accessService.login(cred.getUsuario(), cred.getClave());
}
As you can see, I have declared 4 response codes as a possible HTTP responses: 200, 400, 404 and 500
When I run the application and go to http://localhost:8080/swagger-ui.html the UI shows the 4 codes that I have described in the endpoint. However, it shows MORE http codes. Please take a look at this picture:
The extra codes are: 201 (created), 401 (unauthorized) & 403 (forbidden). Why? For my use case, the "login" endpoint should be always accessible to any user, so at least, 401 & 403 doesn't make sense at all, in this context.