2015-04-17 185 views
6

我使用的是最新版本的Swashbuckle 5.1.3,並且注意到有一個新的屬性SwaggerResponse允許您爲每個響應代碼記錄一個響應類型。例如:Swashbuckle 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錯誤的請求)。無法看到其他響應類型記錄在屏幕上的任何地方。

回答

3

xml < response>和[SwaggerResponse]不能同時使用。 <響應>標記會壓制你的[SwaggerResponse]。嘗試刪除所有標籤,你應該在swagger UI中看到模型。