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

  • 相关阅读:
    asp.net 通过js调用webService注意
    身份证号码验证 类
    char值码对应大全
    C# 让textbox 只能输入数字的方法
    table嵌套循环数据
    拆分字符串
    angular的路由配置
    js对象数组(JSON) 根据某个共同字段 分组
    当前时间的后七天
    ajax提交时“加载中”提示的处理方法
  • 原文地址:https://www.cnblogs.com/zhangchaoran/p/9729755.html
Copyright © 2011-2022 走看看