Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swashbuckle SwaggerResponse not showing response model

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.

like image 411
Dr Schizo Avatar asked Apr 17 '15 10:04

Dr Schizo


1 Answers

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.

like image 85
Calvin Avatar answered Oct 11 '22 05:10

Calvin