# Swagger/Open API 3 Import
In vREST NG, Importing the Swagger spec file in order to generate test cases is pretty easy. All you need is the .json file for your Swagger Spec.
# Importing Swagger / Open API 3 Spec into vREST
- Open vREST NG application.
- Go to the Test Cases Tab.
- Click on on the top left side of the application. (A window will pop up)
- Select Swagger or Open API 3 for Import Source depending upon which type of specification file you have.
- Click on
- Find and select the Swagger Spec .json file.
- Now click on
Voila! Your Swagger Spec file is imported into vREST and test cases are created for all the requests from your Spec file, respectively.
Now let's see, what the import process has done:
- It has generated a test case for each API spec available in the swagger file.
- It has generated the test suites for each tag available in the swagger file.
- It will add the test case in the first tag (test suite in vREST NG) available in the API spec.
- It will import all the definitions in the Configuration >> Schemas section.
- Additionally, it will generate the sample test data CSV files with all the necessary information to fill if Generate Data Driven Tests option is ticked.
- And it will also generate the templates with all the necessary information to fill if Template Driven Tests option is ticked.
Now let's look at three additional options provided by the swagger import process:
Update Schema Only: If this option is ticked, then test cases will not be generated when you import the swagger files. Instead, this option will only update the swagger schema definitions available in the Configuration >> Schemas section of the vREST NG application.
Generate Data Driven Tests: If this option is ticked, then the import process will do the following:
- It will generate a sample test data CSV file for each API spec available in the swagger file.
- It will do all the necessary bindings between the test data file and the generated test case.
- Further it also provides an option
Generate multiple columns for JSON request body for data-driven tests
. If this option is ticked then vREST will try to generate multiple CSV columns if the request body is of JSON format, otherwise vREST will create a single column namedrequestBody
for the request body if applicable for the API test.
You will only need to fill the test data in the generated CSV file for the tests and you are ready to go. You may also need to execute a command to set up the initial state of the application.
Generate Template Driven Tests: If this option is ticked, then the import process will do the following:
- It will generate a template file for each API spec available in the swagger file.
- It will do all the necessary bindings between the template file and the generated test case.
You will only need to fill the test data in the tests for the templates and you are ready to go.