分享

Swagger 生成API文档

 邵飞翔 2017-03-14

1.打开程序包管理控制台输入:

Install-Package Swashbuckle

2.打开App_Start文件夹下的SwaggerConfig.cs文件找到

c.IncludeXmlComments 

替换为

c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name));

3.添加方法

protected static string GetXmlCommentsPath(string name)
{
      return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);
}

4.右键项目->属性->生成->勾选(XML文档文件)->保存

5.访问地址

http://localhost:15416/swagger/ui/index

 

如下图:

官方地址: Swagger1.打开程序包管理控制台输入:

Install-Package Swashbuckle

2.打开App_Start文件夹下的SwaggerConfig.cs文件找到

c.IncludeXmlComments 

替换为

c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name));

3.添加方法

protected static string GetXmlCommentsPath(string name)
{
      return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);
}

4.右键项目->属性->生成->勾选(XML文档文件)->保存

5.访问地址

http://localhost:15416/swagger/ui/index

 

如下图:

官方地址: Swagger

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多