新建webApi的帮助文档

1.新建一个WebApi项目
2.用Nuget添加 Microsoft ASP.NET Web API Help Page包
3.修改 HelpPageConfig文件
   
   
  1. public static void Register(HttpConfiguration config)
  2. {
  3. // Uncomment the following to use the documentation from XML documentation file.
  4. config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/PatientView.Service.WebAPI.xml")));
  5. ...
  6. }
4. API方法上写三斜杠的注释
    
    
  1. /// <summary>
  2. /// 病区列表
  3. /// </summary>
  4. /// <returns></returns>
  5. [Route("GetLocationUnits")]
  6. public Response<List<LocationUnitModel>> GetLocationUnits()
  7. {
  8. return TryResponse(() => _operatorBll.GetLocationUnits(),
  9. method: "GetLocationUnits");
  10. }
5.打开项目属性,在Build页面里,勾选XML documentation file
App_Data\PatientView.Service.WebAPI.xml
6.用Nuget添加 Install the WebApiTestClient package (可以搜索yaohuang)
7.修改文件 under Areas\HelpPage\Views\Help 下的Api.cshtml
添加
  • @Html.DisplayForModel("TestClientDialogs")
  • @Html.DisplayForModel("TestClientReferences") 如下
     
     
  1. @using System.Web.Http
  2. @using MyApi.Areas.HelpPage.Models
  3. @model HelpPageApiModel
  4. @{
  5. var description = Model.ApiDescription;
  6. ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath;
  7. }
  8. <div id="body" class="help-page">
  9. <section class="featured">
  10. <div class="content-wrapper">
  11. <p>
  12. @Html.ActionLink("Help Page Home", "Index")
  13. </p>
  14. </div>
  15. </section>
  16. <section class="content-wrapper main-content clear-fix">
  17. @Html.DisplayForModel()
  18. </section>
  19. </div>
  20. @Html.DisplayForModel("TestClientDialogs")
  21. @section Scripts{
  22. @Html.DisplayForModel("TestClientReferences")
  23. <link type="text/css" href="~/Areas/HelpPage/HelpPage.css" rel="stylesheet" />
  24. }
8.添加以下文件修改样式
  • jQuery 1.7.1
  • jQuery.UI.Combined 1.8.20
  • knockoutjs 2.1.0
效果:

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值