Add Swagger/OpenAPI support (development only)
Add Swashbuckle.AspNetCore (v6.6.2) to API project and register Swagger services (AddEndpointsApiExplorer, AddSwaggerGen). Enable UseSwagger/UseSwaggerUI only in Development to expose /swagger for API exploration without affecting production behavior. Update codexInfo.md to document the dev-only Swagger endpoint.
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
var webRootPath = app.Environment.WebRootPath ?? Path.Combine(app.Environment.ContentRootPath, "wwwroot");
|
||||
var indexFilePath = Path.Combine(webRootPath, "index.html");
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user