practical-api-guidelines
practical-api-guidelines copied to clipboard
Include validation errors in swagger documentation?
Each controller can also return a validation error, status code 400. Should we also include this in the swagger documentation, for completeness? In a similar way that the OK200 and ERROR500 status codes are documented here below.
[HttpGet(Name = Constants.RouteNames.v1.GetCustomizations)]
[SwaggerResponse((int)HttpStatusCode.OK, "List of players")]
[SwaggerResponse((int)HttpStatusCode.InternalServerError, "API is not available")]
public async Task<IActionResult> GetCustomizations()
Imo, yes.
probably we should update the guidance of the Level 1 saying that for every implemented status code, a swagger response attribute should be added.
Agreed