在 .NET 项目中集成 SwaggerUI(2018.9.30)

  不多说,直接上教程!

1. 打开NuGet管理器搜索并安装 Swashbuckle和Swagger.Net两项

  

2. 修改生成设置

  

3. 修改SwaggerConfig文件

  (1)去除注释

  c.IncludeXmlComments(GetXmlCommentsPath());

    如图:

    

  (2)添加方法

      private static string GetXmlCommentsPath()
        {
            return String.Format(@"{0}inxxxxxxxxxxx.XML", System.AppDomain.CurrentDomain.BaseDirectory);    //将里面的“xxx……xxx”替换成你的(第2步中的那个)
        }

4. 修改SwaggetNet文件

  如图,注释掉这两行:

  

5. 启动项目打开地址即可看到结果

  http://localhost:1254/swagger/ui/index

  

结语:

  此教程是本人亲自在 VS2017 中实验成功的,如果实践过程中遇到任何问题,还是自行百度吧。

  最后,附上一些别人的教程:

    https://www.cnblogs.com/youngh/p/5462537.html

    https://blog.csdn.net/small_kidy/article/details/81384177

    https://www.cnblogs.com/tdws/p/6103289.html

    https://www.cnblogs.com/dukang1991/p/5627673.html

    https://www.cnblogs.com/SzeCheng/p/4990079.html

    https://www.cnblogs.com/Rexcnblog/p/6420425.html

原文地址:https://www.cnblogs.com/zhangchaoran/p/9729755.html