zoukankan      html  css  js  c++  java
  • asp.net webapi 生成在线文档--Swagger

    第一步:使用nuget包获取Swashbule、swagger.net.ui的包并安装。

    安装成功后

    打开App_Start->SwaggerNet.cs

    注释掉一下两行

    //[assembly: WebActivator.PreApplicationStartMethod(typeof(ApiInterface.App_Start.SwaggerNet), "PreStart")]
    //[assembly: WebActivator.PostApplicationStartMethod(typeof(ApiInterface.App_Start.SwaggerNet), "PostStart")]

    第二步

    打开App_Start->SwaggerConfig.cs

    增加一个GetXmlCommentsPath()的方法,具体内容如下:

    private static string GetXmlCommentsPath()
    {
      return string.Format("{0}/bin/ApiInterface.xml", System.AppDomain.CurrentDomain.BaseDirectory);
    }

    同时将此页面中“c.IncludeXmlComments(GetXmlCommentsPath());”去掉注释。

    第三部

    启用生成xml文档,右击项目文件属性

    第四步

    运行程序http://localhost:XXX/swagger/ui/index

    显示界面:

  • 相关阅读:
    PG-日常管理
    PG-高可用(pgpool-Ⅱ)
    PG-基准测试
    PG-备份恢复
    PG-并发问题
    Go-常量
    Go-变量
    Oracle-11g升级PSU补丁
    Oracle-`sqlplus`工具使用技巧
    [CF1051F] The Shortest Statement
  • 原文地址:https://www.cnblogs.com/gskstudy/p/8329277.html
Copyright © 2011-2022 走看看