{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://emendatio.reverdin.eu/api/v1/schema/summa-question.json",
  "title": "Summa Theologiae Question",
  "type": "object",
  "required": [
    "work",
    "part",
    "part_number",
    "part_name",
    "question",
    "title",
    "prooemium",
    "articles",
    "source",
    "license",
    "corrections"
  ],
  "additionalProperties": false,
  "properties": {
    "work": {
      "type": "string",
      "const": "summa"
    },
    "part": {
      "type": "string",
      "enum": [
        "prima",
        "prima-secundae",
        "secunda-secundae",
        "tertia",
        "supplementum"
      ]
    },
    "part_number": {
      "type": "integer",
      "minimum": 1,
      "maximum": 5
    },
    "part_name": {
      "type": "string"
    },
    "question": {
      "type": "integer",
      "minimum": 1
    },
    "title": {
      "type": "object",
      "required": [
        "la",
        "fr",
        "en"
      ],
      "additionalProperties": false,
      "properties": {
        "la": {
          "type": [
            "string",
            "null"
          ]
        },
        "fr": {
          "type": "string"
        },
        "en": {
          "type": "string"
        }
      }
    },
    "prooemium": {
      "type": "string"
    },
    "articles": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "n",
          "title",
          "paragraphs"
        ],
        "additionalProperties": false,
        "properties": {
          "n": {
            "type": "integer",
            "minimum": 1
          },
          "title": {
            "type": "string"
          },
          "paragraphs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    },
    "source": {
      "type": "object",
      "required": [
        "name",
        "url"
      ],
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "enum": [
            "wikisource",
            "leonina"
          ]
        },
        "url": {
          "type": "string"
        }
      }
    },
    "license": {
      "type": "string"
    },
    "corrections": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "a",
          "corrections"
        ],
        "properties": {
          "a": {
            "type": "integer",
            "minimum": 0
          },
          "corrections": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "part",
                "q",
                "a",
                "occ",
                "from",
                "to",
                "type",
                "page",
                "leaf",
                "bbox",
                "tome",
                "source",
                "image",
                "viewer"
              ],
              "properties": {
                "part": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 5
                },
                "q": {
                  "type": "integer",
                  "minimum": 1
                },
                "a": {
                  "type": "integer",
                  "minimum": 0
                },
                "occ": {
                  "type": "integer",
                  "minimum": 1
                },
                "from": {
                  "type": "string"
                },
                "to": {
                  "type": "string",
                  "minLength": 1
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "lettre",
                    "soudure",
                    "coupure",
                    "omission",
                    "ajout",
                    "ponctuation",
                    "casse",
                    "autre"
                  ]
                },
                "page": {
                  "type": [
                    "integer",
                    "null"
                  ]
                },
                "leaf": {
                  "type": "integer",
                  "minimum": 0
                },
                "bbox": {
                  "type": "array",
                  "minItems": 4,
                  "maxItems": 4,
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "bbox2": {
                  "type": "array",
                  "minItems": 4,
                  "maxItems": 4,
                  "items": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "tome": {
                  "type": "integer",
                  "minimum": 7,
                  "maximum": 12
                },
                "source": {
                  "type": "object",
                  "required": [
                    "archive_id",
                    "url",
                    "ocr"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "archive_id": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "ocr": {
                      "type": "string"
                    }
                  }
                },
                "image": {
                  "type": "string",
                  "pattern": "^https://iiif\\.archive\\.org/iiif/"
                },
                "image2": {
                  "type": "string",
                  "pattern": "^https://iiif\\.archive\\.org/iiif/"
                },
                "viewer": {
                  "type": "string",
                  "pattern": "^https://archive\\.org/details/"
                }
              },
              "dependentRequired": {
                "bbox2": [
                  "image2"
                ],
                "image2": [
                  "bbox2"
                ]
              }
            }
          }
        }
      }
    }
  }
}
