{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://apologetics.wiki/schemas/connections.schema.json",
  "version": 1,
  "title": "Apologetics Wiki connections",
  "description": "A connection record on a verse, or the per-chapter explorer payload. version 1.",
  "oneOf": [{ "$ref": "#/$defs/connectionRecord" }, { "$ref": "#/$defs/chapterPayload" }],
  "$defs": {
    "connectionRecord": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "version": { "const": 1 },
        "reference": { "type": "string", "minLength": 1 },
        "path": { "type": "string", "pattern": "^/bible/" },
        "url": { "type": "string", "format": "uri" },
        "group": { "type": "string", "enum": ["quotes", "fulfilled", "alludes", "see-also"] },
        "formula": { "type": "string" },
        "theme": { "type": "string" },
        "source": { "type": "string" },
        "votes": { "type": "integer", "minimum": 0 },
        "snippet": { "type": "string" },
        "book": { "type": "string", "minLength": 1 },
        "chapter": { "type": "integer", "minimum": 1 },
        "verse": { "type": "integer", "minimum": 1 }
      },
      "required": ["reference", "path", "url", "group", "snippet", "book", "chapter", "verse"]
    },
    "chapterPayload": {
      "type": "object",
      "additionalProperties": false,
      "description": "Verse pairs for one chapter. v is the payload version. Group codes: 1 quotes, 2 fulfilled, 3 alludes, 4 see-also. otherIndex is the chapter index in chapter-index.json (0 is Genesis 1).",
      "properties": {
        "v": { "const": 1 },
        "pairs": {
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              { "title": "otherIndex", "type": "integer", "minimum": 0, "maximum": 1188 },
              { "title": "thisVerse", "type": "integer", "minimum": 1 },
              { "title": "otherVerse", "type": "integer", "minimum": 1 },
              { "title": "groupCode", "type": "integer", "minimum": 1, "maximum": 4 }
            ],
            "minItems": 4,
            "maxItems": 4,
            "items": false
          }
        }
      },
      "required": ["v", "pairs"]
    }
  }
}
