【问题标题】:Swashbuckle SwaggerResponse not showing response modelSwashbuckle SwaggerResponse 未显示响应模型
【发布时间】:2018-04-30 23:06:59
【问题描述】:

我正在使用最新版本的 Swashbuckle 5.1.3 并注意到有一个新属性 SwaggerResponse 允许您记录每个响应代码的响应类型。例如:

https://github.com/domaindrivendev/Swashbuckle/issues/175

/// <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
}

初始响应类记录良好,但在更下方显示"Response Messages" 表的位置,响应模型为空(对于 400 Bad Request)。在屏幕上看不到记录了其他响应类型的任何地方。

【问题讨论】:

    标签: api-doc swashbuckle


    【解决方案1】:

    xml 和 [SwaggerResponse] 不能同时使用。 标签会抑制你的 [SwaggerResponse]。尝试删除所有标签,您应该会在 swagger ui 中看到模型。

    【讨论】:

      猜你喜欢
      • 2018-08-24
      • 2019-08-04
      • 1970-01-01
      • 2017-11-23
      • 1970-01-01
      • 1970-01-01
      • 2017-08-16
      • 1970-01-01
      • 2018-02-01
      相关资源
      最近更新 更多