7

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.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
Dr Schizo
  • 4,045
  • 7
  • 38
  • 77

1 Answers1

5

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.

Calvin
  • 1,153
  • 2
  • 14
  • 25