To generate the Swagger file automatically in your project, I recommend using the popular Swashbuckle (https://github.com/domaindrivendev/Swashbuckle.AspNetCore) NuGet package.
Swashbuckle uses the metadata of your API to build the OpenAPI file. The metadata is automatically created by ASP.NET Core, based on the routing attributes, and the method's signature of the action in your controllers.
To use Swashbuckle, do the following:
- Install the Swashbuckle.AspNetCore NuGet package.
- Register the Swagger generator in the ConfigureServices method of your Startup class. In the registration process, specify the details of the API and its Version (note that you can define more than one ...