[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:
github-actions[bot] 2021-09-22 10:54:40 -07:00 коммит произвёл GitHub
Родитель f4ee794adf
Коммит 076605d908
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -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)