Swagger is a language-agnostic specification for describing REST APIs. It lets computers and users understand what a REST API does without directly accessing the source code. The Swagger project was donated to the OpenAPI Initiative, and since then it has been known as the OpenAPI Specification.
Swashbuckle is an open-source project for .NET Core. It is a collection of OpenAPI tools used to generate OpenAPI specification documents. It can generate API documentation automatically, including API descriptions, request and response formats, parameter descriptions, and more.
Installing Swashbuckle.AspNetCore
In a .NET Core project, you can install the Swashbuckle.AspNetCore package via NuGet.
dotnet add package Swashbuckle.AspNetCore
Configuring Swashbuckle
In the Startup.cs file, you can configure Swagger as follows:
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}