zoukankan      html  css  js  c++  java
  • swagger的配置

      // This method gets called by the runtime. Use this method to add services to the container.
            public void ConfigureServices(IServiceCollection services)
            {
                services.AddMvc();
                services.AddSwaggerGen(c =>
                {
                    c.SwaggerDoc("v1",
                        new Info
                        {
                            Title = "API接口文档",
                            Version = "v1",
                            Description = "开发接口调试.",
                            Contact = new Contact
                            {
                                Name = "ListXiong",
                                Email = "",
                            },
                            TermsOfService = "None"
                        }
                     );
                     //注释
                    c.IncludeXmlComments(GetXmlCommentsPath());
                });
    
                services.AddSupportServices();
              
            }
    
            // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app, IHostingEnvironment env)
            {
                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();
                }
               
                app.UseMvc();
                app.UseSwagger(c =>
                {
                    c.RouteTemplate = "doc/{documentName}/swagger.json";
                });
                app.UseSwaggerUI(c =>
                {
                    c.RoutePrefix = "doc";
                    c.SwaggerEndpoint("/doc/v1/swagger.json", "API v1");
                });
                app.UseStaticFiles();
            }
            /// <summary>
            /// 获取XML文档地址
            /// </summary>
            /// <returns></returns>
            private string GetXmlCommentsPath()
            {
                var app = PlatformServices.Default.Application;
                return Path.Combine(app.ApplicationBasePath, Path.ChangeExtension(app.ApplicationName, "xml"));
            }            
  • 相关阅读:
    假期实践
    每周更新学习进度表
    作业三
    作业一
    作业二
    真实感海洋的绘制(一):基于统计学模型的水面模拟方法
    递推方程的求解
    真实感海洋的绘制(二):使用快速傅里叶变换加速波形计算
    "Mathematical Analysis of Algorithms" 阅读心得
    HTML2
  • 原文地址:https://www.cnblogs.com/AnAng/p/9203782.html
Copyright © 2011-2022 走看看