AspNetCore.Docs/aspnetcore/release-notes/sample/StartupSwagger.cs

57 lines
1.5 KiB
C#
Raw Normal View History

What's new in ASP.NET Core 5 (#20140) * What's new in ASP.NET Core 5 * What's new in ASP.NET Core 5 * Work * Work * Work * work * work * work * work * work * work * work * work * GuardRex feedback * work * work * work * work * work * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * react to feedback * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Daniel Roth <daroth@microsoft.com> * Apply suggestions from code review Co-authored-by: Daniel Roth <daroth@microsoft.com> * Apply suggestions from code review Co-authored-by: Stephen Halter <halter73@gmail.com> * react to feedback * react to feedback * React to feedback * Nit ..... *almost done* lol * A few final nits ... *I'm done!* * Update aspnetcore/release-notes/aspnetcore-5.0.md Co-authored-by: Brennan <brecon@microsoft.com> * React to feedback * Update * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Protected Browser Support API updates * Update aspnetcore/release-notes/aspnetcore-5.0.md Co-authored-by: Daniel Roth <daroth@microsoft.com> * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Stephen Halter <halter73@gmail.com> * react to feedback * react to feedback Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Daniel Roth <daroth@microsoft.com> Co-authored-by: Stephen Halter <halter73@gmail.com> Co-authored-by: Luke Latham <llatham@aquent.com> Co-authored-by: Brennan <brecon@microsoft.com>
2020-10-30 08:20:42 +08:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
namespace WebApp1
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
#region snippet
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebApp1", Version = "v1" });
});
}
#endregion
#region snippet2
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
2024-04-28 11:18:54 +08:00
app.UseSwagger(); // UseSwaggerUI Protected by if (env.IsDevelopment())
What's new in ASP.NET Core 5 (#20140) * What's new in ASP.NET Core 5 * What's new in ASP.NET Core 5 * Work * Work * Work * work * work * work * work * work * work * work * work * GuardRex feedback * work * work * work * work * work * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * react to feedback * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Daniel Roth <daroth@microsoft.com> * Apply suggestions from code review Co-authored-by: Daniel Roth <daroth@microsoft.com> * Apply suggestions from code review Co-authored-by: Stephen Halter <halter73@gmail.com> * react to feedback * react to feedback * React to feedback * Nit ..... *almost done* lol * A few final nits ... *I'm done!* * Update aspnetcore/release-notes/aspnetcore-5.0.md Co-authored-by: Brennan <brecon@microsoft.com> * React to feedback * Update * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Protected Browser Support API updates * Update aspnetcore/release-notes/aspnetcore-5.0.md Co-authored-by: Daniel Roth <daroth@microsoft.com> * Apply suggestions from code review Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Stephen Halter <halter73@gmail.com> * react to feedback * react to feedback Co-authored-by: Scott Addie <10702007+scottaddie@users.noreply.github.com> Co-authored-by: Daniel Roth <daroth@microsoft.com> Co-authored-by: Stephen Halter <halter73@gmail.com> Co-authored-by: Luke Latham <llatham@aquent.com> Co-authored-by: Brennan <brecon@microsoft.com>
2020-10-30 08:20:42 +08:00
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
"WebApp1 v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
#endregion
}
}