{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "$ref": "#/types/URL"
    },
    "@context": {
      "$ref": "#/types/URL"
    },
    "document": {
      "items": {
        "$ref": "#/types/document"
      },
      "type": "array"
    },
    "institution": {
      "$ref": "#/types/entity"
    },
    "timestamp": {
      "$ref": "#/types/datetime"
    }
  },
  "required": [
    "document"
  ],
  "type": "object",
  "types": {
    "URI": {
      "format": "uri",
      "type": "string"
    },
    "URL": {
      "allOf": [
        {
          "format": "uri",
          "type": "string"
        },
        {
          "pattern": "^https?:",
          "type": "string"
        }
      ]
    },
    "anydate": {
      "anyOf": [
        {
          "pattern": "^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9](Z|[+-][0-9][0-9]:[0-9][0-9])?$",
          "type": "string"
        },
        {
          "enum": [
            "unknown"
          ]
        }
      ]
    },
    "available": {
      "additionalProperties": false,
      "properties": {
        "delay": {
          "$ref": "#/types/duration"
        },
        "href": {
          "$ref": "#/types/URL"
        },
        "limitation": {
          "items": {
            "$ref": "#/types/entity"
          },
          "type": "array"
        },
        "service": {
          "$ref": "#/types/service"
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "service"
      ],
      "type": "object"
    },
    "chronology": {
      "additionalProperties": true,
      "properties": {
        "about": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "count": {
      "minimum": 1,
      "type": "integer"
    },
    "datetime": {
      "format": "date-time",
      "type": "string"
    },
    "document": {
      "additionalProperties": false,
      "properties": {
        "about": {
          "type": "string"
        },
        "href": {
          "$ref": "#/types/URL"
        },
        "id": {
          "$ref": "#/types/URI"
        },
        "item": {
          "items": {
            "$ref": "#/types/item"
          },
          "type": "array"
        },
        "requested": {
          "type": "string"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "duration": {
      "anyOf": [
        {
          "pattern": "^-?P([0-9]+Y)?([0-9]+M)?([0-9]+D)?T?([0-9]+H)?([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?$",
          "type": "string"
        },
        {
          "enum": [
            "unknown"
          ]
        }
      ]
    },
    "entity": {
      "additionalProperties": false,
      "properties": {
        "content": {
          "type": "string"
        },
        "href": {
          "$ref": "#/types/URL"
        },
        "id": {
          "$ref": "#/types/URI"
        }
      },
      "type": "object"
    },
    "item": {
      "additionalProperties": false,
      "properties": {
        "about": {
          "type": "string"
        },
        "available": {
          "items": {
            "$ref": "#/types/available"
          },
          "type": "array"
        },
        "chronology": {
          "$ref": "#/types/chronology"
        },
        "department": {
          "$ref": "#/types/entity"
        },
        "href": {
          "$ref": "#/types/URL"
        },
        "id": {
          "$ref": "#/types/URI"
        },
        "label": {
          "type": "string"
        },
        "part": {
          "enum": [
            "broader",
            "narrower"
          ]
        },
        "storage": {
          "$ref": "#/types/entity"
        },
        "unavailable": {
          "items": {
            "$ref": "#/types/unavailable"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "service": {
      "anyOf": [
        {
          "$ref": "#/types/URI"
        },
        {
          "enum": [
            "presentation",
            "loan",
            "remote",
            "interloan",
            "openaccess"
          ]
        }
      ]
    },
    "unavailable": {
      "additionalProperties": false,
      "properties": {
        "expected": {
          "$ref": "#/types/anydate"
        },
        "href": {
          "$ref": "#/types/URL"
        },
        "limitation": {
          "items": {
            "$ref": "#/types/entity"
          },
          "type": "array"
        },
        "queue": {
          "$ref": "#/types/count"
        },
        "service": {
          "$ref": "#/types/service"
        },
        "title": {
          "type": "string"
        }
      },
      "required": [
        "service"
      ],
      "type": "object"
    }
  }
}
