Swagger (now known as OpenAPI) is a well-known framework for describing the rest API specifications. Swagger removes ambiguity among multiple teams (e.g. frontend team, backend team, testing team) by having the proper rest API specification. And development and testing teams can work in parallel by referring the same spec.
Today in this post, we will look at how the swagger spec also helps us in making the automated API validation process easier using APIs. We have developed a tool named as vREST NG for validating the REST APIs and it also imports the swagger specification and makes the validation process against the imported schema much easier.
Let us see how you may validate your REST APIs by using APIs swagger specification.
Use promo code LEBLACK50 for 50% off on Links Explorer Cloud Version.
Use promo code RRMOFRIDAY50 for 50% off on RMsis Cloud Version.
Use promo code PACMFRIDAY50 for 50% off on PACT Cloud Version.
Use promo code BXTIFRIDAY50 for 50% off on Baseline X.
Get a flat 50% discount on all Optimizory products, including RMsis, PACT, and Links Explorer, for Data Center through this Promo Code.
Download the vREST NG version. vREST NG provides the ability to import the swagger/OpenAPI specification to generate the test cases. If you download the Pro version for automated api testing then it will allow you to generate the data driven tests as well. Please click on the link below to download the vREST NG.
vREST NG Download Link
Write down your automated API testing specification in Swagger Editor and download the swagger specification file either in JSON or YAML format. I hope this step is pretty much clear. For this post, I will use the famous pet store swagger file.
To import swagger editor specifications in vREST NG, follow the steps below:
Now let us look at the data imported by vREST NG:
vREST generates the test cases automatically for each API. Tags are converted into the Test Suites automatically in the API development.
Figure: Test Cases generated from Swagger Specification
vREST also extracts the query or form parameters and even generates the sample request body from the schema available in the Swagger rest API specification.
Figure: Query Parameters extracted from Swagger Specification
vREST also generates the assertions for each swagger rest API spec. In the following screenshot, there are two assertions generated by vREST.
Figure: Assertions generated by vREST Swagger Importer
And the schema is imported in the “Expected Schema” tab. You may notice that references are still maintained and are referring to global schemas available under the Configuration tab.
Figure: Expected Schema imported from Swagger Specification
Swagger definitions are imported into the Configuration tab >> Schemas Section. Which test cases can reference as we have seen in the Assertions section above. So it improves the reusability because all the schema definitions in the rest API automation can be defined globally and you may reuse them in your test cases.
Figure: Schemas imported from Swagger Specification
Finally, We would like to have your feedback regarding the Swagger Import feature supported by vREST NG in agile development. To try out, just visit vREST NG website to download the rest API testing tool and let us know what you think about this. This API automation tool is designed to be enterprise-ready and after several years of experience and hard-learned lessons in the domain of API Testing. In future posts, I will discuss how you may incrementally update the tests for agile methodology and/or schemas whenever there is some change in swagger specification.