зеркало из https://github.com/dotnet/aspnetcore.git
[main] Use Swagger defaults in web API controllers template (#36826)
* Use Swagger defaults in web API controllers template * Add comment pointing at aspnetcore swagger docs to web api template Co-authored-by: DamianEdwards <damian@damianedwards.com>
This commit is contained in:
Родитель
f4ee794adf
Коммит
076605d908
|
@ -41,6 +41,7 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|||
builder.Services.AddAuthorization();
|
||||
|
||||
#if (EnableOpenAPI)
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
|
||||
// Add services to the container.
|
||||
#if (EnableOpenAPI)
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
#endif
|
||||
|
|
|
@ -43,11 +43,9 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|||
|
||||
builder.Services.AddControllers();
|
||||
#if (EnableOpenAPI)
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new() { Title = "Company.WebApplication1", Version = "v1" });
|
||||
});
|
||||
builder.Services.AddSwaggerGen();
|
||||
#endif
|
||||
|
||||
var app = builder.Build();
|
||||
|
@ -57,7 +55,7 @@ var app = builder.Build();
|
|||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Company.WebApplication1 v1"));
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
#endif
|
||||
#if (RequiresHttps)
|
||||
|
|
Загрузка…
Ссылка в новой задаче