2015-04-17 42 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中看到模型。