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


C# IApplicationBuilder.UseSwagger方法代码示例

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


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

示例1: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseMvc();
     app.UseSwagger();
     app.UseSwaggerUi();
     app.UseWelcomePage();
 }
开发者ID:herecydev,项目名称:WeatherTest,代码行数:7,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
		{
            loggerFactory.AddConsole(Configuration.GetSection("ConsoleLogging"));
            loggerFactory.AddDebug(LogLevel.Debug);
            
			// CORS
            app.UseCors((policy) => {
                policy.AllowAnyHeader();
                policy.AllowAnyMethod();
                policy.AllowAnyOrigin();
                policy.AllowCredentials();
            });

            app.UseExceptionHandling(option =>
           {
               // add your custom exception mappings here
           });
            
            // static files en wwwroot
			app.UseFileServer(new FileServerOptions() { EnableDirectoryBrowsing = false, FileProvider = env.WebRootFileProvider });
			app.UseStaticFiles(new StaticFileOptions { FileProvider = env.WebRootFileProvider });

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

            app.UseSwagger();
            app.UseSwaggerUi();  
		}
开发者ID:digipolisantwerp,项目名称:generator-dgp-web-aspnetcore_yeoman,代码行数:35,代码来源:Startup.cs

示例3: 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.UseSwagger();
            app.UseSwaggerUi();

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

示例4: Configure

 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     app.UseStaticFiles();
     app.UseMvc();
     app.UseSwagger();
     app.UseSwaggerUi();
 }
开发者ID:lavbox,项目名称:TaskAPI.AspNet5,代码行数:7,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("ConsoleLogging"));
            loggerFactory.AddDebug(LogLevel.Debug);
                       
			// CORS
            app.UseCors((policy) => {
                policy.AllowAnyHeader();
                policy.AllowAnyMethod();
                policy.AllowAnyOrigin();
                policy.AllowCredentials();
            });
            
            app.UseApiExtensions();

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

            app.UseSwagger();
            app.UseSwaggerUi();
            app.UseSwaggerUiRedirect();
        }
开发者ID:digipolisantwerp,项目名称:generator-dgp-api-aspnetcore_yeoman,代码行数:26,代码来源:Startup.cs

示例6: ConfigureSwagger

        /// <summary>
        /// 
        /// </summary>
        /// <param name="application">The application.</param>
        private static void ConfigureSwagger(IApplicationBuilder application)
        {
            // Adds the swagger/{apiVersion}/swagger.json route.
            application.UseSwagger();

            // Adds the swagger/ui route.
            application.UseSwaggerUi();
        }
开发者ID:fmoliveira,项目名称:ASP.NET-MVC-Boilerplate,代码行数:12,代码来源:Startup.Swagger.cs

示例7: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseCors("AllowAll");
     app.UseMvc();
     app.UseSwaggerUi("api");
     app.UseSwagger("{apiVersion}");
     app.UseWelcomePage();
 }
开发者ID:rzachariah,项目名称:hello-aspnet5,代码行数:8,代码来源: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.UseMvc();
            app.UseSwagger();
            app.UseSwaggerUi();
        }
开发者ID:CNinnovation,项目名称:WindowsApps,代码行数:10,代码来源:Startup.cs

示例9: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseDefaultFiles();
            app.UseStaticFiles();
            //app.UseIISPlatformHandler();
            //app.UseDefaultFiles();

            app.UseMvc();

            app.UseSwagger();
            app.UseSwaggerUi();
        }
开发者ID:Twiinlab,项目名称:FavoriteMoviesAngular,代码行数:12,代码来源:Startup.cs

示例10: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // 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.UseSwagger();
            app.UseSwaggerUi();
        }
开发者ID:BartDeVries,项目名称:RESTGateway,代码行数:14,代码来源:Startup.cs

示例11: 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)
        {
            app.UseStaticFiles();

            app.UseMvcWithDefaultRoute();

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUi();
            
        }
开发者ID:MaherJendoubi,项目名称:Docs,代码行数:14,代码来源:Startup.cs

示例12: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "default", template: "api/{controller}/{action}/");
            });

            //if (bool.Parse(Configuration["Data:SeedDataOnStartup"]))
            //{
            //    app.UseStaticFiles();  // Serve the SampleData.csv file
            //}

            app.UseSwagger();
            app.UseSwaggerUi();
        }
开发者ID:anderssonfilip,项目名称:CustomerManagement,代码行数:16,代码来源:Startup.cs

示例13: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app,ILoggerFactory loggerFactory, IHostingEnvironment env,IRuntimeEnvironment runtimeEnv,IConnectionManager connectionManager)
        {
            app.UseStaticFiles();
            app.UseIISPlatformHandler();
            app.UseCors("OpenBookAPI");
            app.UseSwagger();
            app.UseSwaggerUi();
            app.UseSignalR();
            var hubContext = connectionManager.GetHubContext<OpenBookAPI.SignalR.Hubs.LogHub>();
            app.UseJwtBearerAuthentication(options =>
            {
                options.Audience = Configuration["Auth:ClientId"];
                options.Authority = Configuration["Auth:Domain"];
                options.AuthenticationScheme = "Automatic";
                options.RequireHttpsMetadata = false;
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateLifetime = true
                };
            });
            var localLogger = new LoggerConfiguration()
                .WriteTo.Trace()
                .WriteTo.Console().CreateLogger();

            var signalRlogger = new LoggerConfiguration()
                .WriteTo.Sink(new SignalRSink(hubContext, 10))
                .MinimumLevel.Warning()
                .CreateLogger();

            var azureLogger = new LoggerConfiguration()
                .WriteTo.AzureDocumentDB(new System.Uri("https://openbook.documents.azure.com:443/"), "j4Hzifc5HL6z4uNt152t6ECrI5J7peGpSJDlwfkEzn5Vs94pAxf71N3sw3iQS6YneXC0CvxA+MdQjP/GKVbo6A==")
                .MinimumLevel.Warning()
                .CreateLogger();

            if (runtimeEnv.OperatingSystem.Equals("Windows", StringComparison.OrdinalIgnoreCase))
            {
                loggerFactory.AddSerilog(azureLogger);
            }
            if (env.IsDevelopment())
            {
                loggerFactory.AddSerilog(localLogger);
            }

            loggerFactory.AddSerilog(signalRlogger);

            //should go at the end
            app.UseMvc();
        }
开发者ID:reeseoo,项目名称:OpenBookAPI,代码行数:49,代码来源:Startup.cs

示例14: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            // Add the platform handler to the request pipeline.
            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            app.UseMvc();

            app.UseSwagger();
            app.UseSwaggerUi();

            app.Run(async context =>
            {
                context.Response.Redirect("/swagger/ui/index.html");
            });
        }
开发者ID:jruckert,项目名称:ignitedemo2015,代码行数:17,代码来源:Startup.cs

示例15: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // https://github.com/leastprivilege/AspNet5TemplateCookieAuthentication
            app.UseCookieAuthentication(options =>
            {
                options.LoginPath = "/account/login";
                options.AuthenticationScheme = "Cookies";
                options.AutomaticAuthentication = true;
            });

            // 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.UseSwagger();
            app.UseSwaggerUi();
        }
开发者ID:aguldstrand,项目名称:Tasky,代码行数:22,代码来源:Startup.cs


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