{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agrodt.github.io/agrotool-knowledge-portal/schemas/v1/persons.schema.json",
  "title": "PublicPersons",
  "type": "array",
  "items": {
    "type": "object",
    "allOf": [
      { "$ref": "common.schema.json#/$defs/recordMetadata" },
      {
        "type": "object",
        "required": [
          "person_id",
          "display_name",
          "aliases",
          "identity_status",
          "roles",
          "work_ids",
          "group_ids",
          "topic_ids",
          "organization_ids",
          "source_ids"
        ],
        "properties": {
          "person_id": { "type": "string", "pattern": "^P[A-Z0-9_-]{3,63}$" },
          "display_name": { "type": "string", "minLength": 1 },
          "aliases": {
            "type": "array",
            "items": { "type": "string" },
            "uniqueItems": true
          },
          "identity_status": { "enum": ["verified", "provisional"] },
          "roles": {
            "type": "array",
            "items": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
            "uniqueItems": true
          },
          "orcid": {
            "type": ["string", "null"],
            "pattern": "^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9X]{4}$"
          },
          "openalex_id": { "type": ["string", "null"], "pattern": "^A[0-9]+$" },
          "work_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^W[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "group_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^G[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "topic_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^T[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "organization_ids": {
            "type": "array",
            "items": { "type": "string", "pattern": "^O[A-Z0-9_-]{3,63}$" },
            "uniqueItems": true
          },
          "source_ids": { "$ref": "common.schema.json#/$defs/sourceIds" },
          "warning": { "type": "string", "minLength": 1 }
        }
      }
    ],
    "unevaluatedProperties": false
  }
}
