{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://thewarrecord.com/api/v1/schema/source.json",
 "title": "source",
 "type": "object",
 "required": [
  "id",
  "type",
  "name",
  "kind",
  "affiliations",
  "record_state",
  "schema_version"
 ],
 "properties": {
  "record_state": {
   "enum": [
    "active",
    "merged",
    "withdrawn"
   ]
  },
  "merged_into": {
   "type": "string"
  },
  "withdrawn_reason": {
   "type": "string"
  },
  "schema_version": {
   "const": 1
  },
  "created_at": {
   "type": "string",
   "format": "date-time"
  },
  "last_changed": {
   "type": "string",
   "format": "date-time"
  },
  "id": {
   "type": "string",
   "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
  },
  "type": {
   "const": "source"
  },
  "name": {
   "type": "string"
  },
  "home_url": {
   "type": "string",
   "format": "uri"
  },
  "language": {
   "type": "array",
   "items": {
    "type": "string"
   }
  },
  "kind": {
   "enum": [
    "official_party",
    "official_third_state",
    "un",
    "ngo_monitor",
    "counting_body",
    "wire",
    "media",
    "osint",
    "academic",
    "assessment",
    "market_data",
    "technical_monitor"
   ]
  },
  "affiliations": {
   "type": "array",
   "description": "Dated. A source with no classed entry is \"unknown\" and never counts as unaffiliated.",
   "items": {
    "type": "object",
    "required": [
     "from",
     "actor"
    ],
    "properties": {
     "from": {
      "type": "string",
      "format": "date"
     },
     "to": {
      "type": "string",
      "format": "date"
     },
     "actor": {
      "anyOf": [
       {
        "type": "string",
        "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
       },
       {
        "const": null
       }
      ]
     },
     "conflict": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$",
      "description": "This entry applies to one war only; it beats an entry without a conflict."
     }
    },
    "additionalProperties": false
   }
  },
  "licence": {
   "enum": [
    "open",
    "cite_only",
    "ask_first",
    "never_ingest"
   ]
  },
  "licence_note": {
   "type": "string"
  },
  "sanctioned": {
   "type": "boolean",
   "description": "Designated or sanctioned outlet: cite and quote briefly only; never embed, host, mirror or archive."
  }
 },
 "additionalProperties": false
}
