OpenAPI information
Since there are many .NET versions, the Web API templates reference the Swashbuckle.AspNetCore
NuGet package to create an OpenAPI description. Over the years, with later .NET versions, more and more functionality from OpenAPI has been added to ASP.NET Core itself, such as the OpenApiInfo
class, which is now part of the Microsoft.OpenApis.Models
namespace. Swashbuckle was changed to use the new classes and was also changed to be based on the System.Text.Json
serializer instead of Newtonsoft.Json
.
Adding OpenAPI documentation
Next, let’s make use of classes from the Microsoft.OpenApis.Models
namespace together with Swashbuckle to configure the OpenAPI documentation:
Codebreaker.GameAPIs/Program.cs
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(options => { options.SwaggerDoc("v3", new OpenApiInfo { Version = "v3", Title = "...