Skip to content

Instantly share code, notes, and snippets.

@JamesMessinger
Created July 27, 2017 19:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JamesMessinger/fba37542221b2128603a480aa1100ad2 to your computer and use it in GitHub Desktop.
Save JamesMessinger/fba37542221b2128603a480aa1100ad2 to your computer and use it in GitHub Desktop.
Using JSON Schema in Postman (via an environment variable)
// 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);
@AdditionAddict
Copy link

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.

https://www.youtube.com/watch?v=haDQBmQii2g

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