Swashbuckle SwaggerResponse not showing response model

I am using the latest version of Swashbuckle 5.1.3 and notice that there is a new SwaggerResponse attribute that allows you to document the type of response for each response code. For instance:

( https://github.com/domaindrivendev/Swashbuckle/issues/175 <may be 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 original response class is documented, but further down, where it shows the "Response Messages" table, the response model is empty (for 400 Bad Request). It is impossible to see anywhere on the screen where a different type of response is documented.

+6
source share
1 answer

The xml <response> and [SwaggerResponse] parameters are not used simultaneously. The <response> tag will suppress your [SwaggerResponse]. Try to remove all tags and you should see the model in swagger ui.

+3
source

Source: https://habr.com/ru/post/985337/


All Articles