Swagger UI is a browser-based interface for exploring and calling a web API. In an ASP.NET Core project, Swashbuckle generates an OpenAPI description, usually served at /swagger/v1/swagger.json; Swagger UI reads that file and presents the endpoints, their return types, and interactive controls at /swagger. Controller and Minimal API endpoints added to the board-game API appear there automatically. section 3.2.2
// ...
builder.Services.AddSwaggerGen(); #1
// ...
if (app.Environment.IsDevelopment())
{
app.UseSwagger(); #2
app.UseSwaggerUI(); #3
}
Register the Swagger generator with AddSwaggerGen, then enable the description endpoint and UI with UseSwagger and UseSwaggerUI. Here, both middleware calls run only in the Development environment. section 3.2.2
Run an endpoint without typing its URI
Open /swagger/index.html, expand PUT /Seed, select Try It Out, and click Execute. Swagger UI sends the PUT request and displays the response. If seeding fails with HTTP 500, inspect the response body: one failure revealed a SQL Server identity-column error. This makes the UI useful for testing requests that cannot be made by simply visiting a URL. section 5.3.6
Swagger UI can also help test authenticated requests. Configure an OpenAPI bearer security definition and a global security requirement in AddSwaggerGen. The resulting Authorize button accepts a JWT and places it in the Authorization HTTP header before requests are sent. This is a testing convenience; an application client would normally attach its token through an HTTP interceptor. section 9.3.1
For request DTOs, the Example Value and Schema tabs show sample JSON and field information. Response examples may need help when an action has multiple return types. Add [ProducesResponseType] attributes for the relevant types and status codes so the configured documentation can display them. Before sharing the UI with testers, check its environment-based availability separately from the developer exception page. section 11.2.6 section 2.5


