You will often want to create documentation for your API. To create this documentation, you can take advantage of Swagger – a tool that can be used to provide a UI representation of your API with ease. Once you have generated Swagger documentation for your API, you can view the signature of your API methods and even test your API methods as well.
Swashbuckle is an open source project for generating Swagger documents. This article presents a discussion of how we can take advantage of Swashbuckle to generate interactive documentation for our RESTful API.
Create an ASP.Net Core project
First off, let’s create an ASP.Net Core project in Visual Studio. Assuming Visual Studio 2017 or Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.Net Core project in Visual Studio.
- Launch the Visual Studio IDE.
- Click on “Create new project.”
- In the “Create new project” window, select “ASP.Net Core Web Application” from the list of templates displayed.
- Click Next.
- In the “Configure your new project” window that is shown next, specify the name and location for the new project.
- Click Create.
- In the “Create New ASP.Net Core Web Application” window, select .Net Core as the runtime and ASP.Net Core 2.2 (or later) from the drop-down list at the top.
- Select “API” as the project template to create a new ASP.Net Core Web API project.
- Ensure that the check boxes “Enable Docker Support” and “Configure for HTTPS” are unchecked as we won’t be using those features here.
- Ensure that Authentication is set as “No Authentication” as we won’t be using authentication either.
- Click Create.
Following these steps will create a new ASP.Net Core project in Visual Studio. We’ll use this project in the subsequent sections of this article to examine how we can generate Swagger documentation for the ValuesController.