我有一個接收來自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