本文整理汇总了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();
}
示例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();
}
示例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 =>
//{
//});
}
示例4: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStaticFiles();
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUi();
}
示例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();
}
示例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();
}
示例7: Configure
public void Configure(IApplicationBuilder app)
{
app.UseCors("AllowAll");
app.UseMvc();
app.UseSwaggerUi("api");
app.UseSwagger("{apiVersion}");
app.UseWelcomePage();
}
示例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();
}
示例9: Configure
public void Configure(IApplicationBuilder app)
{
app.UseDefaultFiles();
app.UseStaticFiles();
//app.UseIISPlatformHandler();
//app.UseDefaultFiles();
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUi();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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");
});
}
示例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();
}