6. {
"listen": "test",
"script": {
"id": "0b950846-9920-4059-a605-
4796f79dcc30",
"type": "text/javascript",
"exec": [
""
]
}
}
]
},
{
"name": "4 - Fundamental - Contract Tests",
"description": "**10 minutes**rnrnContract tests verify
that what you send back in your response matches what you told users would come
back in your response.rnrnOne way of doing this in Postman is throught a
schema validation.rnrnA schema defines the data structure of the response,
and the rules around the structure. Rules meaning like what is required, what
values can be null, what the max or min length of a string can be, and so
on.rnrnWe have rules around specifying this data structure, or schema, in
json, so that we can all understand what is expected.rnrnPostman has a
built-in schema validator that we can use - we just need to specify the schema
that we want our response validated against.rnrnjsonschema.net is a sweet
tool for doing this.",
"item": [
{
"name": "Response json schema should match
expected schema",
"event": [
{
"listen": "test",
"script": {
"id": "6b9b095b-6026-4a1c-98e2-
59c7655c92fb",
"type": "text/javascript",
"exec": [
"var data =
JSON.parse(responseBody);",
"var schema = {",
" "$id": "http://exampl
e.com/example.json",",
" "type": "object",",
" "definitions": {},",
" "$schema": "http://js
on-schema.org/draft-07/schema#",",
" "additionalProperties"
: false,",
" "properties": {",
" "latitude": {",
" "$id": "/properti
es/latitude",",
" "type": "number"
",
" },",
" "longitude": {",
" "$id": "/properti
es/longitude",",
" "type": "number"
",
" },",
" "timezone": {",
" "$id": "/properti