0

I understand in postman we use test cases like status codes and response time to ensure API does not break but what is the necessity to validate the response body.

var schema
var jsonData = JSON.parse(responseBody);
tests["Verify that the Schema is Valid"] = tv4.validate(jsonData, schema);
Bill P
  • 3,622
  • 10
  • 20
  • 32
  • To verify a response body and the structure of it, against a known schema. You can check and confirm that each part of the response data is correct, compared to your model. It's worth researching JSON schemas first before attempting to do this within the application. Postman uses tv4 but also Ajv to help with this validation in the Tests sandbox. – Danny Dainton Oct 01 '19 at 13:01

1 Answers1

0

To answer your question, Why is JSON Schema Validation required?

  1. We monitor API responses and ensure that the format that we are getting is the same as the expected one.
  2. We get alerts whenever there is any breaking change in the JSON response.
  3. We use JSON Schema to construct a model of API response and it makes easier to validate that API is returning the valid data.
Nihir Kumar
  • 283
  • 1
  • 6
  • 19