Shalvin Interests

Sunday, February 1, 2026

Web API 10 Configure Swagger

Web API 10 doesn't come with default swagger support. It can be added by adding a reference to Swashbuckle.AspNetCode, registering the service, adding to middleware and making alterations to launchSettings.json.

 

image 

Program.cs
builder.Services.AddControllers();

builder.Services.AddOpenApi();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
}
appsettings.json
"profiles": {
  "http": {
    ..
    "launchBrowser": true,
    "launchUrl": "swagger",
    "applicationUrl": "http://localhost:5172",
   ..
    }
  },

No comments:

Post a Comment