{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.michaeldariuseastwood.com/schemas/citation-authority.schema.json",
  "title": "Citation authority register",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "registerId", "dateModified", "sourceDigests", "programme", "summary", "records"],
  "properties": {
    "schemaVersion": {"const": 1},
    "registerId": {"type": "string", "minLength": 1},
    "dateModified": {"type": "string", "format": "date"},
    "sourceDigests": {"type": "object", "additionalProperties": {"type": "string", "pattern": "^[a-f0-9]{64}$"}},
    "programme": {
      "type": "object",
      "additionalProperties": false,
      "required": ["resourceId", "doi", "url"],
      "properties": {
        "resourceId": {"type": "string", "minLength": 1},
        "doi": {"type": "string", "pattern": "^10\\."},
        "url": {"type": "string", "format": "uri"}
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["records", "papers", "papersWithIndividualDoi", "books", "datasets", "reports", "software"],
      "properties": {
        "records": {"type": "integer", "minimum": 1},
        "papers": {"type": "integer", "minimum": 1},
        "papersWithIndividualDoi": {"type": "integer", "minimum": 0},
        "books": {"type": "integer", "minimum": 0},
        "datasets": {"type": "integer", "minimum": 0},
        "reports": {"type": "integer", "minimum": 0},
        "software": {"type": "integer", "minimum": 0}
      }
    },
    "records": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/record"}
    }
  },
  "$defs": {
    "author": {
      "type": "object",
      "additionalProperties": false,
      "required": ["literal", "given", "family", "orcid"],
      "properties": {
        "literal": {"type": "string", "minLength": 1},
        "given": {"type": "string", "minLength": 1},
        "family": {"type": "string", "minLength": 1},
        "orcid": {"type": "string", "format": "uri"}
      }
    },
    "relation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["relationType", "relatedResourceId"],
      "properties": {
        "relationType": {"type": "string", "minLength": 1},
        "relatedResourceId": {"type": "string", "minLength": 1},
        "relatedIdentifier": {"type": "string", "minLength": 1},
        "relatedIdentifierType": {"type": "string", "minLength": 1},
        "reason": {"type": "string", "minLength": 1}
      }
    },
    "record": {
      "type": "object",
      "additionalProperties": false,
      "required": ["resourceId", "citationKey", "resourceType", "title", "authors", "url", "relations", "source"],
      "properties": {
        "resourceId": {"type": "string", "minLength": 1},
        "citationKey": {"type": "string", "minLength": 1},
        "resourceType": {"enum": ["programme", "paper", "book", "dataset", "software", "report"]},
        "title": {"type": "string", "minLength": 1},
        "authors": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/author"}},
        "datePublished": {"type": "string", "format": "date"},
        "dateModified": {"type": "string", "format": "date"},
        "url": {"type": "string", "format": "uri"},
        "doi": {"type": "string", "pattern": "^10\\."},
        "isbn": {"type": "string", "minLength": 1},
        "edition": {"type": "string", "minLength": 1},
        "status": {"type": "string", "minLength": 1},
        "repositoryCode": {"type": "string", "format": "uri"},
        "relations": {"type": "array", "items": {"$ref": "#/$defs/relation"}},
        "source": {"type": "string", "minLength": 1}
      }
    }
  }
}
