JSON Schema Validation In Rest Assured

This entry is part 12 of 14 in the series REST Assured Tutorial

To learn about JSON schema validation we will learn what is a Schema:

Schema is the structure behind data organization. It is a visual representation of how different fields, values are organized in a JSON/XML file.

JSON schema describes your existing data format, clear, human and machine readable documentation, complete structural validation, useful for automated testing ad validating client-submitted data.

Lets say we have below JSON data and we want to perform schema validation on it.

we received this response from URI : https://jsonplaceholder.typicode.com/posts/1

JSON schema for above file will look like below :

By just looking at it you can quickly understand what is schema and how it is written.

Now what does it mean to validate a JSON schema ?

We are not dealing with validation of data here, validation of schema means, checking whether our JSON response is in its standard structure or not, all the required fields are there or not, with the required data types.

With below code we can validate the JSON Schema

Series Navigation<< REST-Assured Extracting values from the response.Send Query Parameter using REST-Assured >>