新建webApi的帮助文档
来源:互联网 发布:docker github 源码 编辑:程序博客网 时间:2024/06/07 04:57
1.新建一个WebApi项目
2.用Nuget添加Microsoft ASP.NET Web API Help Page包
3.修改HelpPageConfig文件
public static void Register(HttpConfiguration config)
{
// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/PatientView.Service.WebAPI.xml")));
...
}
4.API方法上写三斜杠的注释
/// <summary>
/// 病区列表
/// </summary>
/// <returns></returns>
[Route("GetLocationUnits")]
public Response<List<LocationUnitModel>> GetLocationUnits()
{
return TryResponse(() => _operatorBll.GetLocationUnits(),
method: "GetLocationUnits");
}
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") 如下
@using System.Web.Http
@using MyApi.Areas.HelpPage.Models
@model HelpPageApiModel
@{
var description = Model.ApiDescription;
ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath;
}
<div id="body" class="help-page">
<section class="featured">
<div class="content-wrapper">
<p>
@Html.ActionLink("Help Page Home", "Index")
</p>
</div>
</section>
<section class="content-wrapper main-content clear-fix">
@Html.DisplayForModel()
</section>
</div>
@Html.DisplayForModel("TestClientDialogs")
@section Scripts{
@Html.DisplayForModel("TestClientReferences")
<link type="text/css" href="~/Areas/HelpPage/HelpPage.css" rel="stylesheet" />
}
8.添加以下文件修改样式
- jQuery 1.7.1
- jQuery.UI.Combined 1.8.20
- knockoutjs 2.1.0
效果:
阅读全文
0 0
- 新建webApi的帮助文档
- webAPI 自动生成帮助文档
- webAPI 自动生成帮助文档
- WebAPI——自动生成帮助文档
- webApi——自动生成帮助文档
- webApi 接口帮助调试文档(Swagger UI)
- 困惑的新建文档
- SVN的帮助文档
- epoll的帮助文档
- JDK的帮助文档
- okhttp的帮助文档
- Java的帮助文档
- MFC 多文档的新建
- QUB的中文帮助文档
- jxl的帮助文档a
- GnuCash的在线帮助文档
- windbg的中文帮助文档
- box2d的api帮助文档
- SpringMVC 学习笔记5
- windows核心编程---windows线程池
- SpringMVC 学习笔记6
- 常用排序算法代码兑现
- Spring 学习笔记1
- 新建webApi的帮助文档
- Spring 学习笔记2
- Spring 学习笔记3
- Spring 学习笔记4
- Spring 学习笔记6
- UVa10618
- Runtime详解二
- 完美世界校招算法题2017
- Blog15@linux介绍kickstart、dhcp