Skip to content

Instantly share code, notes, and snippets.

@johnsheehan
Created October 14, 2016 21:25
Show Gist options
  • Save johnsheehan/32c68d520a5d7dee1dff3031531da630 to your computer and use it in GitHub Desktop.
Save johnsheehan/32c68d520a5d7dee1dff3031531da630 to your computer and use it in GitHub Desktop.
// The JSON Schema that we place into the Initial Script
// section of the Runscope API test.
var rosterResponse = {
"definitions": {
"player": {
"id": "player",
"type": "object",
"required": ["player_number","guid","name"],
"properties": {
"player_number": { "type": "integer" },
"guid": { "type": "string" },
"name": { "type": "string" }
}
}
},
"title": "roster schema v1",
"type": "object",
"required": ["roster"],
"properties": {
"roster": {
"type": "array",
"items": { "$ref": "#/definitions/player" }
}
}
};
variables.set("rosterResponse",rosterResponse);
// The JavaScript assertion that picks up the rosterResponse
// global variable from above, and the Chai-JSON assertion..
// This we paste into the Scripts section of the request
// step.
var rosterResponse = variables.get("rosterResponse");
var data = JSON.parse(response.body);
assert.jsonSchema(data, rosterResponse);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment