How to use Swagger for API testing
Posted By : Amol Sangal | 04-Sep-2018
Swagger is a software framework, in which so many tools are available to build, design the APIs. Using swagger we can add the
Basically, using swagger we can perform following operations on APIs -
1. Fetch the data from the backend using the GET method.
2. Insert new data into the database using
3. Update the already saved data using
4. Kill any operation using
5. Status Code & the response codes for each and every API according to their working.
6. Perform end to end testing on the set of APIs.
1. GET method – GET method is to get the data from the backend which is already saved inside the database.
Here is an example -
If we want to get the list of all the countries and that is saved inside the database then we’ll use
2. POST method – POST method is to add/insert new data in the database.
Like – If we want to successfully log in to any platform then, to test the functionality of the developed API from the developers, we will use
3. PUT method – PUT method is to update the already saved data inside the database.
Like – If any user wants to update his / her Password then, an API which is having PUT method will be developed by the developers.
4. DELETE method – DELETE method is to kill an operation and user won’t be able to go ahead of the current situation.
Like – If we want to perform LOGOUT operation then, developers will develop an API using DELETE method because it kills the entire operation which is running inside the backend.
5. Status and response Code – It is a very important part of every API that how that is working when it will be uploaded on the HTTP server.
Few basic and most useful status codes are -
100 – Continue
200 – OK
202 – Accepted
301 – Moved Permanently
400 – Bad Request
401 – Unauthorised
403 – Forbidden
404 – Content Not Found
500 – Internal Server Error (ISE)
501 – Not Implemented
502 – Bad Request
6. End to End testing – When a developer writes a code for any operation then he/she write the code for all the possible scenario related to
To test all the functionalities, Test engineer test all the APIs of the developed controller
(Controller is a set of APIs where we can store the APIs separately according to their working).
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Amol Sangal
Amol is very disciplined, passionate, and serious for his work. Apart from willing to do learning in new and different domains.