shlogg · Early preview
Olabamiji Oyetubo @bigboybamo

How To Add Swagger Configuration To .NET 9 Projects

Add Swagger config to .NET 9 projects: install Swashbuckle.AspNetCore, register SwaggerGen in Program.cs & modify app.Environment.IsDevelopment() condition. Run & access Swagger UI at /swagger/index.html

If you didn’t know, with the release of .NET 9, Swagger UI for Web API projects no longer comes out of the box. This tutorial will show you how to add Swagger configuration to .NET 9 projects.
First, create a new ASP .NET Core Web API project and set your target framework to .NET 9

Next, navigate to the package manager console.

Once there, use the Browse tab to search for Swashbuckle.AspNetCore, then click install to add it to your project

After the package has been successfully installed, navigate to your Program.cs class and just above the builder.Build() method, add this line of code;

b...