ASP.NET Core Web API 的默認模板如下。
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
// Why are the following two statements not enabled only in development?
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
// Others are removed for the sake of simplicity.
app.Run();
如您所見,UseSwagger()并且UseSwaggerUI()僅在開發中被激活。
問題
我很好奇為什么AddEndpointsApiExplorer()并且AddSwaggerGen()不只在開發中被激活。
uj5u.com熱心網友回復:
在
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/485183.html
標籤:C# asp.net 核心 asp.net-web-api
