{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://emendatio.reverdin.eu/api/v1/schema/bible-index.json",
  "title": "bible-index",
  "type": "object",
  "required": [
    "id",
    "language",
    "title",
    "translator",
    "printed_edition",
    "scans",
    "licence",
    "canon",
    "versification",
    "status",
    "books",
    "corrections",
    "variants",
    "version",
    "date_modified"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "language": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "translator": {
      "type": "string"
    },
    "licence": {
      "type": "string"
    },
    "canon": {
      "type": "string"
    },
    "versification": {
      "type": "string"
    },
    "status": {
      "enum": [
        "collated",
        "partial"
      ]
    },
    "printed_edition": {
      "type": "object",
      "required": [
        "publisher"
      ],
      "properties": {
        "publisher": {
          "type": "string",
          "pattern": "\\S"
        }
      }
    },
    "scans": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "source"
          ],
          "properties": {
            "source": {
              "type": "string"
            },
            "url": {
              "type": "string"
            },
            "details": {
              "type": "string"
            },
            "iiif": {
              "type": "string"
            }
          },
          "anyOf": [
            {
              "required": [
                "url"
              ]
            },
            {
              "required": [
                "details"
              ]
            },
            {
              "required": [
                "iiif"
              ]
            }
          ]
        },
        {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "source"
            ],
            "properties": {
              "source": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "details": {
                "type": "string"
              },
              "iiif": {
                "type": "string"
              }
            },
            "anyOf": [
              {
                "required": [
                  "url"
                ]
              },
              {
                "required": [
                  "details"
                ]
              },
              {
                "required": [
                  "iiif"
                ]
              }
            ]
          }
        }
      ]
    },
    "corrections": {
      "type": "integer",
      "minimum": 0
    },
    "variants": {
      "type": "integer",
      "minimum": 0
    },
    "transcription_notes": {
      "type": "integer",
      "minimum": 0
    },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][A-Za-z0-9.-]+)?$"
    },
    "date_modified": {
      "type": "string",
      "format": "date"
    },
    "doi": {
      "type": [
        "string",
        "null"
      ]
    },
    "books": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "code",
          "name",
          "chapters",
          "chapter_numbers",
          "corrections_count",
          "variants_count"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[A-Z0-9]{3}$"
          },
          "name": {
            "type": "string"
          },
          "chapters": {
            "type": "integer",
            "minimum": 0
          },
          "complete": {
            "type": "boolean"
          },
          "chapter_numbers": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[1-9][0-9]*$"
            }
          },
          "corrections_count": {
            "type": "integer",
            "minimum": 0
          },
          "variants_count": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    }
  }
}
