{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opencertificatestandard.org/v1/record.schema.json",
  "title": "Open Certificate Standard record, version 1",
  "description": "The shape of a certificate record. STRUCTURE ONLY. It deliberately permits null, empty strings and empty arrays, because under section 3 of the specification those are legal ways of saying a field was not answered, and they normalise away before hashing. A schema that demanded non-empty values would reject records that are perfectly valid. It also cannot express the canonicalisation rules, and passing it is not conformance: conformance is decided by the criteria in section 4, against a record whose hash has been checked.",
  "type": "object",
  "required": [
    "spec",
    "rules",
    "issuedAt",
    "recordVersion"
  ],
  "additionalProperties": true,
  "properties": {
    "spec": {
      "description": "The version of the standard this record claims. A URI so it can be resolved.",
      "type": "string",
      "format": "uri",
      "pattern": "^https://opencertificatestandard\\.org/v[0-9]+$"
    },
    "subject": {
      "description": "The premises inspected.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "address": {
          "type": [
            "string",
            "null"
          ]
        },
        "postcode": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "dutyHolder": {
      "description": "The landlord or managing agent, where the certificate is issued in respect of let premises.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "address": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "issuer": {
      "description": "The competent person who certified the work.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "registration": {
          "type": [
            "string",
            "null"
          ]
        },
        "scheme": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "inspection": {
      "description": "What was inspected, when, and under which certificate type.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "date": {
          "description": "The local calendar day the work was carried out, or empty if unanswered. Never re-zoned: see specification section 3, rule 8.",
          "type": [
            "string",
            "null"
          ],
          "pattern": "^([0-9]{4}-[0-9]{2}-[0-9]{2})?$"
        },
        "type": {
          "type": [
            "string",
            "null"
          ]
        },
        "typeName": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "items": {
      "description": "Per-item findings, in the order the engineer recorded them. Order is meaningful: appliance 1 is not appliance 2, and a blank entry keeps its place rather than being removed. An empty array means no items were recorded.",
      "type": "array",
      "items": {
        "type": [
          "object",
          "null"
        ],
        "additionalProperties": false,
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "location": {
            "type": [
              "string",
              "null"
            ]
          },
          "outcome": {
            "type": [
              "string",
              "null"
            ]
          },
          "defects": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "rules": {
      "description": "The rules the certificate was made under, so it can be read years later against the edition it was issued against.",
      "type": "object",
      "required": [
        "schemaId"
      ],
      "additionalProperties": false,
      "properties": {
        "schemaId": {
          "description": "Country-scoped, because type codes repeat across countries.",
          "type": "string",
          "minLength": 1
        },
        "version": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "issuedAt": {
      "description": "RFC 3339 instant in UTC at millisecond precision. See specification section 3, rule 9.",
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    },
    "recordVersion": {
      "description": "Revision of this record. 1 unless it has been reissued.",
      "type": "integer",
      "minimum": 1
    },
    "supersedes": {
      "description": "Lowercase hex hash of the record this one replaces. A correction is a new record, never an edit.",
      "type": [
        "string",
        "null"
      ],
      "pattern": "^([0-9a-f]{64})?$"
    }
  }
}
