2017-01-11 76 views
1

XML註釋沒有顯示出來包括XML註釋 - Swashbuckle

我下面的例子: https://github.com/domaindrivendev/Swashbuckle

我的代碼如下所示:

var baseDirectory = System.String.Format(@"{0}bin\", AppDomain.CurrentDomain.BaseDirectory); 
var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML"; 
var commentsFile = Path.Combine(baseDirectory, commentsFileName); 
c.SingleApiVersion("v1", "Documentação web Api"); 

在我DefaultController enter image description here

[RoutePrefix("api")] 
public class DefaultController : ApiController 
{ 
    /// <summary> 
    /// Register a new user on application 
    /// </summary> 
    /// <param name="user">New user to register</param> 
    /// <remarks>Adds new user to application and grant access</remarks> 
    /// <response code="400">Bad Request</response> 
    /// <response code="500">Internal Server Error</response> 

    [HttpGet] 
    [Route("consulta/BuscaProduto")] 
    //localhost:50907/api/consulta/BuscaProduto 
    public HttpResponseMessage BuscaProduto() 
    { 
     try 
     { 
      var tTabela = new ProdutoAplicacao(); 
      var listar = tTabela.ListaTodos(); 
      return Request.CreateResponse(HttpStatusCode.OK, listar, Configuration.Formatters.JsonFormatter); 
     } 
     catch (Exception ex) 
     { 

      return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); 
     } 
    } 

} 

enter image description here

回答

1

我只是這個問題的努力近日:)

Swashbuckle不會自動生成一個200個成功響應,其中包含了楷模和榜樣價值,如果沒有明確指定任何迴應。

對於您的情況,由於您指定了「400」和「500」響應,因此Swashbuckle希望您也指定「200」響應。我覺得你有2種選擇:

  1. 指定用於在其它響應在SwaggerConfig
使用操作過濾器中指定
  • Add the 200 responses programmatically每個端點的XML註釋的200響應