Dr *_*izo 7 api-doc swashbuckle
我使用的是最新版本的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
}
Run Code Online (Sandbox Code Playgroud)
初始响应类记录正确,但在显示表的情况下进一步向下"Response Messages",响应模型为空(对于400 Bad Request).无法在屏幕上看到记录其他响应类型的任何位置.
xml <response>和[SwaggerResponse]不能同时使用。<response>标签将取消显示您的[SwaggerResponse]。尝试删除所有标签,您将在swagger ui中看到该模型。
| 归档时间: |
|
| 查看次数: |
4294 次 |
| 最近记录: |