zoukankan      html  css  js  c++  java
  • Swagger自定义默认首页

    1、添加资源文件夹

        ①创建wwwroot->html->index.html文件

        

       ②、文件属性【生成操作】设置成【嵌入的资源】

        

       ③、配置Swagger管道

     app.UseSwaggerUI(option =>
                { 
            option.IndexStream
    = (Func<Stream>) (() => Assembly.GetExecutingAssembly()         .GetManifestResourceStream("GreenUnity.GuangMing.WebApi.wwwroot.html.index.html")); });

      ④、获取Swagger默认index.html替换资源文件【官网地址:https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html

    Stream _stream=  (Func<Stream>) (() => typeof (SwaggerUIOptions).GetTypeInfo().Assembly.GetManifestResourceStream("Swashbuckle.AspNetCore.SwaggerUI.index.html"));
    byte[] _byte=new byte[_stream.Length];
    _stream.Read(_byte,0,_byte.Length);
    string _html=Encoding.UTF8.GetString(_byte);
  • 相关阅读:
    centos5&6的启动过程
    linux之目录知识
    js动画
    js操作高级
    js操作
    JS基础
    跨域问题
    MySQL存储引擎
    MySQL索引管理
    MySQL操作命令
  • 原文地址:https://www.cnblogs.com/study10000/p/12809128.html
Copyright © 2011-2022 走看看