当前位置: 首页>>代码示例>>C#>>正文


C# IApplicationBuilder.UseSwaggerGen方法代码示例

本文整理汇总了C#中IApplicationBuilder.UseSwaggerGen方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseSwaggerGen方法的具体用法?C# IApplicationBuilder.UseSwaggerGen怎么用?C# IApplicationBuilder.UseSwaggerGen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IApplicationBuilder的用法示例。


在下文中一共展示了IApplicationBuilder.UseSwaggerGen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
     app.UseDefaultConfiguration();
     app.UseStaticFiles();
     app.UseSwaggerGen();
     app.UseSwaggerUi();
 }
开发者ID:MarcusParkkinen,项目名称:artist-lookup-service,代码行数:7,代码来源:Startup.cs

示例2: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            // Add the platform handler to the request pipeline.
            app.UseIISPlatformHandler();

            // Configure the HTTP request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc();
            // Add the following route for porting Web API 2 controllers.
            // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");

            app.UseSwaggerGen();
            app.UseSwaggerUi();

            // TOOD: Figure out oauth middleware to validate token
            //app.UseOAuthBearerAuthentication(opts =>
            //{
            //});
        }
开发者ID:andycmaj,项目名称:Ahoy,代码行数:26,代码来源:Startup.cs

示例3: Configure

        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="loggerFactory"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            var log = loggerFactory.CreateLogger<Startup>();
            try
            {
                loggerFactory.AddConsole(Configuration.GetSection("Logging"));
                loggerFactory.AddDebug();
                app.UseDeveloperExceptionPage();
                app.UseIISPlatformHandler();
                CheckAuthorization(app);
                app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
                app.UseMvc();
                app.UseSwaggerGen();
                app.UseSwaggerUi();
            }
            catch (Exception ex)
            {
                app.Run(
                        async context => {
                            log.LogError($"{ex.Message}");
                            context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                            context.Response.ContentType = "text/plain";
                            await context.Response.WriteAsync(ex.Message).ConfigureAwait(false);
                            await context.Response.WriteAsync(ex.StackTrace).ConfigureAwait(false);
                        });

            }
        }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:34,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseMvc();
            app.UseSwaggerGen();
            app.UseSwaggerUi();

            SampleData.Initialize(app.ApplicationServices);
        }
开发者ID:paulopez78,项目名称:voting,代码行数:8,代码来源:StartUp.cs

示例5: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();

            app.UseMvcWithDefaultRoute();

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:shirhatti,项目名称:MeetupDemo,代码行数:11,代码来源:Startup.cs

示例6: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseIISPlatformHandler();
			
			app.UseSwaggerGen();
			app.UseSwaggerUi();
			app.UseMvcWithDefaultRoute();

			app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
开发者ID:mattridgway,项目名称:ASPNET5-SwaggerUI,代码行数:13,代码来源:Startup.cs

示例7: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            app.UseMvc();

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:CedricLeblond,项目名称:MultiChannelTodo,代码行数:15,代码来源:Startup.cs

示例8: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();

            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.UseMvc();

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:jimschubert,项目名称:webapi-swagger-samples,代码行数:16,代码来源:Startup.cs

示例9: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            //TODO: Add OAuth

            app.Map("/health", subApp =>
            {
                subApp.Use(async (context, next) =>
                {
                    IEnumerable<Type> healthTypes =
                                     AppDomain
                                    .CurrentDomain
                                    .GetAssemblies()
                                    .SelectMany(assembly => assembly.GetTypes())
                                    .Where(type => typeof(IHealth).IsAssignableFrom(type)
                                     && type.IsAbstract == false
                                     && type.IsInterface == false
                                     && type.IsGenericTypeDefinition == false);

                    var servicesHealth = new Dictionary<string, string>();

                    foreach (var healthType in healthTypes)
                    {
                        var healthService = (IHealth)Activator.CreateInstance(healthType);
                        var serviceHealth = await healthService.Check();
                        servicesHealth.Add(healthType.ToString(), serviceHealth);
                    }

                    var jsonResponse = JsonConvert.SerializeObject(servicesHealth, Formatting.Indented);
                    await context.Response.WriteAsync(jsonResponse);
                });
            });

            app.UseSwaggerGen();
            app.UseSwaggerUi();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                
            });
        }
开发者ID:jjcollinge,项目名称:blanky,代码行数:43,代码来源:Startup.cs

示例10: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            // Add the platform handler to the request pipeline.
            app.UseIISPlatformHandler();

            // Configure the HTTP request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseDeveloperExceptionPage();
            app.UseMvc();
            // Add the following route for porting Web API 2 controllers.
            // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:ChrisOMetz,项目名称:Ahoy,代码行数:22,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app)
        {
            // Use IIS platform handle to run ASP.NET in IIS
            app.UseIISPlatformHandler();

            // Use file server to serve static files
            app.UseDefaultFiles();
            app.UseFileServer();

            // Use AI request telemetry
            app.UseApplicationInsightsRequestTelemetry();
            app.UseApplicationInsightsExceptionTelemetry();

            // Add middlewares (CORS and MVC)
            app.UseCors(builder => builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
            app.UseMvc();

            // Configure swagger. For more details see e.g.
            // http://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/
            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:BarfieldMV,项目名称:Samples,代码行数:22,代码来源:Startup.cs

示例12: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            //loggerFactory.AddDebug();

            

            // ES6 Imports always pull from a .js file however signalr doesn't support the call with an extensions so remap it.
            app.Rewrite("/signalr/hubs.js", "/signalr/hubs");
            //app.UseSignalR();
            app.UseStaticFiles();
            
            // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:Jackett,项目名称:Jackett2,代码行数:24,代码来源:Startup.cs

示例13: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseApplicationInsightsRequestTelemetry();

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseCors(builder =>
            {
                builder
                    .WithMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
                    .AllowAnyHeader()
                    .AllowAnyOrigin();
            });

            app.UseCookieAuthentication(options =>
            {
                options.AuthenticationScheme = "Cookie";
                options.AutomaticAuthenticate = true;
                options.AutomaticChallenge = false;
            });

            app.UseMvc();

            app.UseSwaggerUi();
            app.UseSwaggerGen();
        }
开发者ID:MightyDevelopers,项目名称:solutions,代码行数:39,代码来源:Startup.cs

示例14: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var authLogger = loggerFactory.CreateLogger("Auth");
            var settings = app.ApplicationServices.GetService<IOptions<AuthSettings>>();

            app.UseJwtBearerAuthentication(options =>
            {
                options.Audience = settings.Value.ClientId;
                options.Authority = $"https://{settings.Value.Domain}/{settings.Value.TennantId}/{settings.Value.Version}";
                
                options.Events = new JwtBearerEvents
                {
                    OnAuthenticationFailed = context =>
                    {
                        authLogger.LogError("Authentication failed.", context.Exception);
                        return Task.FromResult(0);
                    },
                    OnValidatedToken = context =>
                    {
                        var claimsIdentity = context.AuthenticationTicket.Principal.Identity as ClaimsIdentity;
                        if (claimsIdentity == null) return null; // ??

                        claimsIdentity.AddClaim(new Claim("id_token",
                            context.Request.Headers["Authorization"][0].Substring(context.AuthenticationTicket.AuthenticationScheme.Length + 1)));

                        // OPTIONAL: you can read/modify the claims that are populated based on the JWT
                        claimsIdentity.AddClaim(new Claim(ClaimTypes.Name, claimsIdentity.FindFirst("name").Value));
                        claimsIdentity.AddClaim(new Claim(ClaimTypes.GivenName, claimsIdentity.FindFirst("preferred_username").Value));
                        
                        return Task.FromResult(0);
                    }
                };
            });

            app.UseApplicationInsightsRequestTelemetry();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                        .CreateScope())
                    {
                        serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
                             .Database.Migrate();
                    }
                }
                catch { }
            }

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            //app.UseIdentity();
          
            // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:tinodu,项目名称:Dite,代码行数:83,代码来源:Startup.cs

示例15: Configure

        public void Configure(
            IApplicationBuilder app
            , IHostingEnvironment env
            , ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                //app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage(o => o.EnableAll());
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // sends the request to the following path or controller action.
                app.UseExceptionHandler("/Home/Error");
            }

            // Add the platform handler to the request pipeline.
            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline.
            app.UseIdentity();

            //app.UseCookieAuthentication(options =>
            //{
            //    //options.AutomaticAuthenticate = true;
            //    options.AccessDeniedPath = new PathString("/Account/AccessDenied");
            //    options.LoginPath = new PathString("/Account/Login");
            //    options.LogoutPath = new PathString("/Account/Logout");
            //});

            app.UseSession();

            app.UseMvc(routes =>
            {
                routes.MapRoute("subarearoute", "{area:exists}/{subarea:exists}/{controller=Home}/{action=Index}");
                routes.MapRoute("areaRoute", "{area:exists}/{controller=Home}/{action=Index}");
                routes.MapRoute("controllerActionRoute", "{controller=Home}/{action=Index}");
            });

            app.UseSwaggerGen();
            app.UseSwaggerUi();
        }
开发者ID:CWISoftware,项目名称:accounts,代码行数:51,代码来源:Startup.cs


注:本文中的IApplicationBuilder.UseSwaggerGen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。