我有一个 post 操作接收 Person 类型的 FromBody 参数。在 HelpPage 中,我获得了有关 Person 参数的信息。是否可以在 Person 中列出有关属性的信息,并使用 XML 文档文件中的文档来获取每个属性的描述?
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; }
}