zoukankan      html  css  js  c++  java
  • 在 .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

  • 相关阅读:
    docker知识3---镜像
    docker知识2---docker简介
    docker知识1---容器背景
    docker故障排查
    linux故障处理--ssh故障
    sqlalchemy的一行代码更新数据库
    Python内置函数和高阶函数(map,filter,reduce, sorted,enumerate, zip,单行条件语句 )
    Mysql略复杂命令总结
    pip的使用
    Linux的基础命令
  • 原文地址:https://www.cnblogs.com/zhangchaoran/p/9729755.html
Copyright © 2011-2022 走看看