I want to implement/configure Swagger in my project.
I have installed (Swashbuckle) package which is necessary for swagger implementation.
Where should I need to add the swagger configuration or which file should I have to include.
I want to implement/configure Swagger in my project.
I have installed (Swashbuckle) package which is necessary for swagger implementation.
Where should I need to add the swagger configuration or which file should I have to include.
2
Answers
If you will create an project from correct template it already comes with Swagger pre-setup. For example you can use the ASP.NET Core web API template (via your IDE or using
dotnet new
command withwebapi
template name). It includes (for .NET 7):Preinstalled packages:
Swagger set up (in
Program.cs
):Read also:
Swashbuckle.AspNetCore
: Getting Started.NET 7 WebAPI project you need to configure it on
Program.cs
file.You need to add Swagger generator to the services collection.
Example to configure Swagger with JWT Authorization is as follows: