本文整理汇总了C#中IApplicationBuilder.UseSwaggerUi方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseSwaggerUi方法的具体用法?C# IApplicationBuilder.UseSwaggerUi怎么用?C# IApplicationBuilder.UseSwaggerUi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseSwaggerUi方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
});
}
}
示例2: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseStaticFiles();
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUi();
}
示例3: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseDefaultConfiguration();
app.UseStaticFiles();
app.UseSwaggerGen();
app.UseSwaggerUi();
}
示例4: Configure
public void Configure(IApplicationBuilder app)
{
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUi();
app.UseWelcomePage();
}
示例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.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();
}
示例6: 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 =>
//{
//});
}
示例7: 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();
}
示例8: Configure
public void Configure(IApplicationBuilder app)
{
app.UseMvc();
app.UseSwaggerGen();
app.UseSwaggerUi();
SampleData.Initialize(app.ApplicationServices);
}
示例9: Configure
public void Configure(IApplicationBuilder app)
{
app.UseCors("AllowAll");
app.UseMvc();
app.UseSwaggerUi("api");
app.UseSwagger("{apiVersion}");
app.UseWelcomePage();
}
示例10: 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();
}
示例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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUi();
}
示例12: 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();
}
示例13: Configure
public void Configure(IApplicationBuilder app)
{
app.UseDefaultFiles();
app.UseStaticFiles();
//app.UseIISPlatformHandler();
//app.UseDefaultFiles();
app.UseMvc();
app.UseSwagger();
app.UseSwaggerUi();
}
示例14: Configure
public void Configure(IApplicationBuilder app)
{
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseMvc();
app.UseSwaggerGen();
app.UseSwaggerUi();
}
示例15: Configure
public void Configure(IApplicationBuilder app)
{
app.UseIISPlatformHandler();
app.UseSwaggerGen();
app.UseSwaggerUi();
app.UseMvcWithDefaultRoute();
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}