{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ioce.alkhemy.com/schemas/ioce-schema-v0.1.json",
  "title": "IOCE Core Ontology v0.1 — plain-JSON document schema",
  "description": "Validates /ontology/ioce-core-v0.1.json. Licence: CC0 1.0.",
  "type": "object",
  "required": [
    "ontology",
    "terms",
    "properties",
    "assertions",
    "statusVocabulary"
  ],
  "properties": {
    "ontology": {
      "type": "object",
      "required": [
        "id",
        "versionIRI",
        "version",
        "title",
        "licence"
      ],
      "properties": {
        "version": {
          "const": "0.1"
        }
      }
    },
    "statusVocabulary": {
      "type": "object"
    },
    "terms": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/term"
      }
    },
    "properties": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/property"
      }
    },
    "annotationProperties": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/property"
      }
    },
    "assertions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/assertion"
      }
    },
    "excludedRelations": {
      "type": "object"
    }
  },
  "$defs": {
    "iri": {
      "type": "string",
      "pattern": "^https?://[^\\s<>\"{}|\\\\^`]+$"
    },
    "status": {
      "enum": [
        "documented",
        "externally-sourced",
        "inferred",
        "proposed",
        "unknown"
      ]
    },
    "classification": {
      "enum": [
        "ESTABLISHED",
        "EXTERNAL",
        "INFERRED",
        "PROPOSED",
        "UNKNOWN"
      ]
    },
    "term": {
      "type": "object",
      "required": [
        "id",
        "notation",
        "preferredLabel",
        "status",
        "classification",
        "version",
        "provenance",
        "definition",
        "sourceURL",
        "broaderTerm",
        "narrowerTerms",
        "relatedTerms",
        "dateCreated",
        "dateModified"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/iri"
        },
        "notation": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9]*$"
        },
        "type": {
          "enum": [
            "concept",
            "class",
            "measure",
            "value"
          ]
        },
        "preferredLabel": {
          "type": "object",
          "required": [
            "en"
          ],
          "additionalProperties": {
            "type": "string"
          }
        },
        "altLabels": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "definition": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "$ref": "#/$defs/status"
        },
        "classification": {
          "$ref": "#/$defs/classification"
        },
        "sourceURL": {
          "oneOf": [
            {
              "$ref": "#/$defs/iri"
            },
            {
              "type": "null"
            }
          ]
        },
        "broaderTerm": {
          "oneOf": [
            {
              "$ref": "#/$defs/iri"
            },
            {
              "type": "null"
            }
          ]
        },
        "narrowerTerms": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/iri"
          }
        },
        "relatedTerms": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/iri"
          }
        },
        "version": {
          "const": "0.1"
        },
        "dateCreated": {
          "type": "string",
          "format": "date"
        },
        "dateModified": {
          "type": "string",
          "format": "date"
        },
        "provenance": {
          "$ref": "#/$defs/iri"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "documented"
              }
            }
          },
          "then": {
            "required": [
              "evidenceQuote"
            ],
            "properties": {
              "evidenceQuote": {
                "type": "string"
              },
              "sourceURL": {
                "$ref": "#/$defs/iri"
              }
            }
          }
        }
      ]
    },
    "property": {
      "type": "object",
      "required": [
        "id",
        "label",
        "status",
        "classification",
        "provenance"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/iri"
        },
        "status": {
          "$ref": "#/$defs/status"
        },
        "classification": {
          "$ref": "#/$defs/classification"
        }
      }
    },
    "assertion": {
      "type": "object",
      "required": [
        "id",
        "subject",
        "predicate",
        "status",
        "source",
        "provenance"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/iri"
        },
        "subject": {
          "$ref": "#/$defs/iri"
        },
        "predicate": {
          "$ref": "#/$defs/iri"
        },
        "status": {
          "$ref": "#/$defs/status"
        }
      },
      "oneOf": [
        {
          "required": [
            "object"
          ]
        },
        {
          "required": [
            "objectLiteral"
          ]
        }
      ]
    }
  }
}
