// Load the JSON Schema | |
const customerSchema = JSON.parse(environment.customerSchema); | |
// Test whether the response matches the schema | |
var customer = JSON.parse(responseBody); | |
tests["Customer is valid"] = tv4.validate(customer, customerSchema); |
Im getting "AssertionError: expected false to be truthy" error, when i use this method to validate schema
@apoo51 - did you ever figure out a solution for this issue?
Postman just published a video showing how to validate JSON schemas. I recommend watching it, since it goes into far more detail than my little code snippet does.
@JamesMessinger thanks so much!!! You have no idea how much this code snippet has helped me and other co-workers of mine... I was able to solve this 'false to be truthy' error by adding in 'false, true' in the .validate function ... the failed test passed after this addition -
var customer = JSON.parse(responseBody);
tests["Customer is valid"] = tv4.validate(customer, false, true, customerSchema);
Postman just published a video showing how to validate JSON schemas. I recommend watching it, since it goes into far more detail than my little code snippet does.
Comment for purposes of finding this again.
In my api response the size of response is very large so the length of schema will be large. Is there any way to verify schema with swagger file