Logo: Relish

  1. Sign in

Project: Gavel 1.2.0

Body - JSON schema draft v4

  • @javascript
  • @stable
Background
Given
you define expected HTTP body using the following "JSON schema":
{
  "type":"object",
  "$schema": "http://json-schema.org/draft-04/schema",
  "required": ["string"],
  "properties":{
    "object": {
      "type":"object",
      "required": ["a", "c", "e"],
      "properties":{
        "a": {
          "type":"string"
        },
        "c": {
          "type":"string"
        },
        "e": {
          "type":"string"
        }
      }
    },
    "string": {
      "type":"string"
    }
  }
}
Scenarios
Payload body is valid against given schema
When
real HTTP body is following:
{
  "object": {
    "a": "b",
    "c": "d",
    "e": "f"
  },
  "string": "Hello World"
}
Then
Gavel will NOT set any errors for "body"
And
Request or Response is valid
Payload body not valid against schema
When
real HTTP body is following:
{
  "object": {
    "a": "b",
    "c": "d"
  },
  "string": "Hello World"
}
Then
Gavel will set some error for "body"
And
Request or Response is NOT valid

Last published over 3 years ago by honzajavorek.