Instalar el paquete siguiente:
Install-Package Swashbuckle.AspNetCore -Version 6.6.2
Habilitar esto en program:
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}