【发布时间】:2016-09-19 14:54:37
【问题描述】:
想来想去,this 不一样。
我认为这应该是不言自明的。我想在 Swagger 文档中包含类描述。我的Swagger 配置如下所示:
config.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "My Api Name");
c.OperationFilter<AddAuthorizationHeaderParameterOperationFilter>();
c.IncludeXmlComments(GetXmlCommentsPath());
}).EnableSwaggerUi(c => { });
而MyAwesomeController 看起来像这样:
/// <summary>
/// Controller description (is included by Swashbuckle)
/// </summary>
public class MyAwesomeController : ApiController
{
/// <summary>
/// Method description (is included by Swashbuckle)
/// </summary>
public IHttpActionResult Get()
{
return Ok("hello... from the other side");
}
public IHttpActionResult Post([FromBody]MyAwesomeModel model)
{
return Ok("hello... from the other side");
}
}
而我的MyAwesomeModel 看起来像这样:
/// <summary>
/// **I would like this to be included in the Swagger description of the parameter**
/// </summary>
public class MyAwesomeModel
{
/// <summary>
/// **I would like this to be included in the Swagger description of the parameter**
/// </summary>
public string MyProperty { get; set; }
}
如果不雇用 Skeet 先生,这可能吗?
【问题讨论】:
标签: asp.net-web-api owin swagger swashbuckle