Just start typing...

API Testing using the JSON Schema

Published August 22, 2016

Let’s go through the most important testing principles and tools for API development and testing, focusing on JSON Schema among them.

The API (Application Programming Interface) allows you to significantly reduce the amount of resources needed for development. In other words, the API provides you with ready code in the form of a library or service. In addition, the API can provide access to embedded services, and it allows you to request data from them at any time.

API testing is used to validate the transmission of information from the server and to find vulnerabilities. In this regard, we create queries that are designed to obtain specific data. If the API does not function correctly, some data may not be stored or updated on the server, which means that the expected result may not occur.

API Testing Using The JSON Schema

The most important testing principles

The following common methods are used to test the API:

  • Analysis of threshold values

The API queries transmit clear parameters. This makes it easy to note the threshold values of the maximum and minimum indicators and to subsequently verify them.

  • Division into areas of equivalence

Two classes of areas are formed: valid and invalid input and output data that have been placed in the appropriate class.

It is important to bear in mind that the API is developed primarily for interconnecting different services. That is why it should be considered in use cases that require the practical use of other software and rapid integration with these packages. In addition, no API is complete without detailed documentation.

Tools for working with the API

Queries for the content of this resource can be distributed using the browser. However, apart from this, there is a huge number of tools for API development and testing. They allow you to send different types of queries, save them, display the results as well as to act as proxy servers.

  • Postman. This is an extension for Chrome that allows you to send queries, save them, and show the history of queries.
  • jMeter. This is a tool that is popular for stress testing.
  • Runscope. You can use this tool to send queries to the server and check the received responses on the basis of criteria that are received in advance.
  • SoapUI. This is a perfect tool for developing and testing web applications.
  • Fiddler. This provides you with the ability to view sent HTTP queries.
  • Advanced REST Client. This is another add-on for Google Chrome, which creates a query structure and displays queries in a convenient way.
  • JSON Schema. This is a JSON analogue for the XML Schema format. It specifies the structure of the document in a declarative form.
API Testing using the JSON Schema

The JSON Schema is a description standard for data structures in the JSON format, which is developed on the basis of the XML Schema. JSON schemas are quite suitable for testing purposes.

Let's consider this format as a conventional example. Let's consider the following JSON object: {"title": "text"}

In order to define the structure and type of parameters, it is sufficient to substitute the parameter values for the special objects, after which we obtain the following:

      "title": {
        "type": "string"

The same JSON schemas are used both for testing purposes as well as for documentation. This means that schemas are always up-to-date and valid. Otherwise, the test will fail.

If there is more than one response for one field, such as the description field, for example, then it can either be filled or left blank. In response to the JSON query we receive a specific answer: "null" or "string." It is best to use "one of" in order to execute this script.

        "description": {
          "type": ["string", "null"]

If in one or several JSON scripts the verification of one type of data is performed multiple times, we can reduce the number of lines of code and also consolidate the verification process. To do this, we have to create a separate JSON file and write our verification script to it. In the API tests themselves a link is simply specified in the following format:

      "imageAnalysis": {
        "$ref": "commons.json#/definitions/imageAnalysis"

Where "$ref": "commons.json#/definitions/imageAnalysis" is the specification of the place for the test code, and imageAnalysis is what we are testing in the API.


The JSON Schema helps to significantly save time that is spent on API testing and documentation. It requires a minimum number of attempts in order to achieve high results.

In addition to the benefits listed above, the JSON Schema easily supports backward compatibility in the API, because the API format is clearly specified in the JSON Schema.

Related Services

Automated Functional Testing

How we process your personal data

When you submit the completed form, your personal data will be processed by WaveAccess USA. Due to our international presence, your data may be transferred and processed outside the country where you reside or are located. You have the right to withdraw your consent at any time.
Please read our Privacy Policy for more information.