web api 配置

一 安装 Swashbuckle

Swashbuckle 是通过生成的XML文件来读取注释的

https://www.cnblogs.com/hhhh2010/p/5234016.html

  1. 通过 Nuget 管理工具安装Swashbuckle 
  2. 修改 App_Start 下的SwaggerConfig
  • 将配置文件大概99行注释去掉并修改为
c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name))

并在当前类中添加一个方法
/// <summary>

/// </summary>

/// <param name="name"></param>

/// <returns></returns>

protected static string GetXmlCommentsPath(string name)

{

     return string.Format(@"{0}in{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);

}
  • 紧接着你在此Web项目属性生成选卡中勾选 “XML 文档文件”,编译过程中生成类库的注释文件
  1. 安装完后如果不加注释,会有绿色波浪线提示,如图:

 

 

二 ,Web api分区路由的配置

三 ,web api 路由重新定位

原文地址:https://www.cnblogs.com/haigui-zx/p/15129107.html