我有一个接收来自Person类型的FromBody参数的发布操作。在HelpPage中,我得到关于Person参数的信息。是否可以在Person中列出有关属性的信息,并使用XML文档文件中的文档来获取每个属性的描述?ASP.Net Web API帮助页面:文档复杂类型属性
public class PersonController : ApiController
{
/// <summary>
/// Add a person
/// </summary>
/// <param name="person">Person to add</param>
/// <returns></returns>
[HttpPost]
public HttpResponseMessage Add([FromBody] Person person)
{
// ...
return Request.CreateResponse(HttpStatusCode.Created);
}
}
/// <summary>
/// A person
/// </summary>
public class Person
{
/// <summary>
/// The name of the person
/// </summary>
public String Name { get; set; }
/// <summary>
/// The age of the person
/// </summary>
public Int32 Age { get; set; }
}
目前这不支持开箱即用。有一个相关工作项目要求为模型上使用的数据注释属性提供帮助页面生成。您的方案应该在修复后修复:http://aspnetwebstack.codeplex.com/workitem/877 –
谢谢!在这里作出答复,我会将其标记为答案! –
你有没有用'///'评论来处理这个问题?通过@KiranChalla链接到的工作项目似乎已经实现了注释支持,但截至2015年10月,文档仍然没有显示在帮助页面上。 – Mendhak