Xml评论未显示
我正在效仿: 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");
[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);
}
}
}
答案 0 :(得分:1)
我最近一直在努力解决这个问题:)
如果明确指定了任何响应,Swashbuckle将不会自动生成200个成功响应,其中包含模型和示例值。
在您的情况下,因为您指定了&#34; 400&#34;和&#34; 500&#34;回复,Swashbuckle希望你也指定&#34; 200&#34;响应。我认为你有两个选择: