Testing controllers with Swagger UI
We've built controllers and run the application, but we haven't tested it yet, right? In this section, we will send GET, POST, PUT, and DELETE requests to TourList
controller.
First of all, make sure that you are running the application by going to the Web Api
project and running this command:
dotnet run
Now check your Swagger UI by going to the link https://localhost:5001/swagger/index.html while the application is running.
You will see the TourLists and TourPackages endpoints. The Swagger UI is showing you the documentation of the HTTP methods for each controller. There are GET, POST, DELETE, and PUT methods ready to be tried out:
The following screenshot shows the schemas of the application, which are also generated for you by Swagger UI:
Now let's try the GET method of the TourLists
controller....