Overview of the JSON schema format

The following code defines a basic JSON file.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {
    "Contact" : {
      "type" : "object",
      "properties" : {
        "FirstName":
          "type": "string"
        },
        "Addresses" : {
          "type" : "array",
          "items" : {
            "type" : "object",
            "$ref" : "#/definitions/Address"
          }
        }
      }
    },
    "Address" : {
      "type" : "object",
      "properties" : {
        "AddressLine1" : {
          "type" : "string"
        },
        "State" : {
          "type" : "string",
          "x-gw-type" : "typekey.State"
        }
      }
    }
  }
}
In this example, the various JSON property have the following meanings.
definitions
The definitions section is itself an object that contains keys for each type that it defines. Each definition has a properties property that contains keys for each allowed property.
properties
Each property defines its own type. The type must be one of the following:
  • array
  • boolean
  • integer
  • number
  • object
  • string
If the type is array, there must be an items property that defines the types of items. Items can be any of the above types except for array, as Guidewire does not permit schemas with nested arrays.
If the type is object (for both properties or items), the $ref property defines the schema of the referenced object. A reference to a definition within the same file starts with #/definitions/.
If the type is a scalar type, it is possible to define an additional format and x-gw-type property.
Using the example JSON schema, a Contact definition looks similar to the following JSON code.
{
  "FirstName" : "Homer",
  "Addresses" : [
    {
      "AddressLine1" : "100 Evergreen Terrace",
      "State" : "MI"
    }
  ]
}