Advertisement
Guest User

Runscope JSON Schema v4 Validation Example

a guest
Jan 23rd, 2015
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The JSON Schema that we place into the Initial Script
  2. // section of the Runscope Radar test.
  3. var rosterResponse = {
  4.     "definitions": {
  5.         "player": {
  6.             "id": "player",
  7.             "type": "object",
  8.             "required": ["player_number","guid","name"],
  9.             "properties": {
  10.                 "player_number": { "type": "integer" },
  11.                 "guid": { "type": "string" },
  12.                 "name": { "type": "string" }
  13.             }
  14.         }
  15.     },
  16.     "title": "roster schema v1",
  17.     "type": "object",
  18.     "required": ["roster"],
  19.     "properties": {
  20.         "roster": {
  21.             "type": "array",
  22.             "items": { "$ref": "#/definitions/player" }
  23.         }
  24.     }
  25. };
  26.  
  27. variables.set("rosterResponse",rosterResponse);
  28.  
  29.  
  30.  
  31.  
  32. // The JavaScript assertion that picks up the rosterResponse
  33. // global variable from above, and the Chai-JSON assertion..
  34. // This we paste into the Scripts section of the request
  35. // step.
  36.  
  37. var rosterResponse = variables.get("rosterResponse");
  38. var data = JSON.parse(response.body);
  39. assert.jsonSchema(data, rosterResponse);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement