I am using the latest version of Swashbuckle 5.1.3 and noticed there is a new attribute SwaggerResponse
which allows you to document a response type for each response code. For example:
(https://github.com/domaindrivendev/Swashbuckle/issues/175 < might prove useful).
/// <summary>
/// Lovely.
/// </summary>
/// <param name="blah">Blah blah blah.</param>
/// <returns>Something special.</returns>
/// <response code="200">OK very nice.</response>
/// <response code="400">Invalid request.</response>
[SwaggerResponse(HttpStatusCode.OK, "A", typeof(Foo))]
[SwaggerResponse(HttpStatusCode.BadRequest, "B", typeof(Bar))]
public IHttpActionResult Get(string blah)
{
// Some code
}
The initial response class is documented fine but further down where it shows a table of "Response Messages"
, the response model is empty (for 400 Bad Request). Can't see anywhere on screen where the other response type is documented.
The xml <response> and [SwaggerResponse] are not used at the same time. <response> tag will suppress your [SwaggerResponse]. Try remove all tag and you should see the model in swagger ui.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With