1
A
回答
1
好了,所以我想通了這一點,希望這可以幫助遇到此問題的其他人。您要做的第一件事是按照link爲ApiExplorer啓用XML文檔。啓用後要添加
/// <summary>Description</summary>
你上面的控制器名稱(您可以在XML中添加PARAM名稱,以及通過增加另一行<param name="model">A Test Model</param>
)
然後前往您的模型和內部的每個參數您的模型再次添加摘要標籤,如下所示:
public class TestModel()
{
/// <summary>This is your IdNumber you received earlier</summary>
public string IdNumber {get;set;}
}
1
您可以添加一個Description屬性:
[Description("Get the data from our service. It will requires a key.")]
public ActionResult GetData(string key)
{
//Do something here...
return Json(new{Success=true, Data = data});
}
或爲參數
public ActionResult GetData([Description("A valid key should be formated as xxx-xxx-xx")]string key)
{
//Do something here...
return Json(new{Success=true, Data = data});
}
1
我在這裏找到了答案,令人困惑,因此這裏是我的完整解決方案。
首先打開XMLDocumentation的區域 - > HelpPage - > App_Start - > HelpPageConfig.cs並取消註釋以下兩行。
// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
然後,對於要爲以下格式創建xml註釋提供文檔的方法。這通常會自動完成,但我打開了resharper,因此可能不是默認設置。
/// <summary>
/// An example method description
/// </summary>
/// <param name="id">An example parameter description</param>
/// <returns>An example return value description</returns>
// GET: api/Products/5
public string Get(int id)
{
return "value";
}
如果您運行該應用程序並轉到您的api幫助頁面,則文檔應該可見。
相關問題
- 1. 爲什麼ProtocolBuffers生成描述符?
- 2. 缺少的字段在NetBeans中生成的javadocs中的描述
- 3. Mono中的字體描述
- 4. 如何獲取WADL生成的文檔中的參數描述
- 5. 存儲字段描述
- 6. 新標準字段「描述」
- 7. Rails:Formtastic字段與描述
- 8. MySql「註釋」參數作爲描述符?
- 9. 段描述符與門描述符
- 10. customvalidator servervalidate參數描述
- 11. FREAK描述符參數
- 12. plone靈活性注入行爲字段後描述字段
- 13. 描述函數參數以類爲打字稿
- 14. Django使用描述生成RSS提要
- 15. 未生成maven插件描述符
- 16. 顯示僞影生成描述
- 17. 在僕人中生成端點描述
- 18. git-diff如何生成大塊描述?
- 19. 無法生成部署描述符
- 20. matchingFontDescriptorsWithMandatoryKeys如何匹配字體描述符?
- 21. 字體描述符和符號特徵
- 22. 隱藏描述字段與敏捷
- 23. 描述文本在文本字段中?
- 24. mysql描述表 - 連接字段?
- 25. 在Slick中描述可選字段
- 26. SQLite的:擴展字段描述
- 27. Object [] []的Java字段描述符
- 28. 刪除woocommerce簡短描述字段
- 29. RecordEditor - 字段描述該行的佈局
- 30. Spring中每個字段的描述
不幸的是,這沒有奏效。我仍留有「主體說明說明」的空白區域和主幫助頁面 – Kyle