Created
July 27, 2017 19:21
-
-
Save JamesMessinger/fba37542221b2128603a480aa1100ad2 to your computer and use it in GitHub Desktop.
Using JSON Schema in Postman (via an environment variable)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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 -