# Specifications functionality
This feature is available as part of vREST NG Pro/Enterprise version.
Specifications functionality allows you to drive your entire API Testing through API specification files. It provides the following set of functions:
You may generate API Test for a specific API Spec operation at any point in time.
It allows you to validate the API response through dynamic schema id. e.g.
$operationis a special variable and contains the information about operation associated with the test. So you may change the schema definitions and changes will be automatically reflected in your API tests.
It provides the API Coverage Report that will give you insights like how many tests you have written for an API and for which APIs, you have not written any tests at all.
In this guide, we will look at how you may use the specifications function in vREST NG Application. We will cover the following points in detail.
- Defining your API Specification file
- Creating a test case from the API specification
- Validating API response through API Specification schema references
- API Coverage Report
Few points before using this feature,
- It is necessary that you define the
operationIdfield for each operation in your API specification file. Also please don't update the
operationIdin your API specification file after that, otherwise, you will need to update the
operationIdin your tests manually.
- If you have modular specification files in your project then combine those files in a single file before entering them in vREST NG Application. vREST NG doesn't maintain any cross-references among specification files.
Now let's see the Specification feature in detail:
Defining your API Specification file
To define the API specification, simply visit the
Specificationssection. And now click on the
New Specificationbutton and provide the following information:
- Specification Type: You may provide either Swagger 2.0 or OpenAPI 3.0 type specifications. So select the appropriate value from the dropdown.
- Specification Name: Provide a suitable name for this specification.
- Specification Content: In the code editor, provide the API specification file content.
Creating a test case from the API Specification
Once you have defined the API specification file as shown in the previous step. Now let's try to create a test from the specification. To create a test, simply visit the
Test casestab and click on the
+icon in the toolbar to create your test.
A dialog window will appear. In the dialog window, simply select the
from Specification. And now the system asks for
Test Suite Name,
Simply select the Spec Name from the list and then select the desired Operation for which you would like to generate the test. Further, the system will ask you the following test case type:
- Normal Test Case
- Data Driven Test Case
Select a Data-driven test case if you would like to generate a data-driven API test, otherwise select the normal test case option.
Now click on the
Confirmbutton to generate the test. Now, let's look at some of the information generated in the API test.
The following screenshot illustrates the generated API test. The Operation Id field binds the test case with the specific API specification operation.
The following screenshot illustrates the request parameters generated from API specification:
The following screenshot illustrates the validation logic generated from API specification:
And the following screenshot illustrates the generated Expected Schema Tab content:
Validating API response through API Specification schema references
Now, let's see how you may validate your API response through the schema references defined in the API specification file. For that purpose, simply open the
Assertionstab. Now add a
Text Bodyassertion that calls the
Default Schema Validator. And in the
Expected Valuecolumn, you may select the desired schema reference. You may even define this reference in the
Please note that if you define the value in the
Expected Valuecolumn of the Assertions tab, then the
Expected Schematab content will be ignored.
API Coverage Report
API coverage report will help you in identifying the APIs available, their associated tests. The coverage report can be accessed using the More options available in the left pane.
The coverage report will look like this:
Similarly, we may add other tests as well. API Coverage report will provide the complete status of your API tests against each API operation in the API Specification file, as shown below: