{
  "apiVersion": "v1",
  "kind": "JSONSchema",
  "metadata": {
    "generated": "2026-08-22T14:14:13Z",
    "language": "en"
  },
  "data": {
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api.wheelofheaven.world/v1/schema/book/",
  "title": "Book",
  "description": "A library book — primary or comparative text. Returned by /v1/library/books/{slug}/ (and the historical alias /v1/books/{slug}/).",
  "type": "object",
  "required": [
    "slug",
    "code",
    "primaryLang"
  ],
  "properties": {
    "slug": {
      "type": "string",
      "description": "URL-safe identifier; matches data-library directory name."
    },
    "code": {
      "type": "string",
      "description": "Short code (e.g. 'GEN', '1ENO', 'TBWTT')."
    },
    "refId": {
      "type": "string",
      "description": "Stable reference ID."
    },
    "titles": {
      "type": "object",
      "description": "Map of language code → title.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "subtitles": {
      "type": "object"
    },
    "descriptions": {
      "type": "object"
    },
    "tradition": {
      "type": "string"
    },
    "collection": {
      "type": "string"
    },
    "primaryLang": {
      "type": "string"
    },
    "originalLang": {
      "type": "string"
    },
    "availableLangs": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "chapterCount": {
      "type": "integer"
    },
    "chapters": {
      "type": "integer"
    },
    "paragraphCount": {
      "type": "integer"
    },
    "paragraphs": {
      "type": "integer"
    },
    "publicationYear": {
      "type": [
        "integer",
        "string"
      ]
    },
    "schema": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Structure schema (e.g. ['book', 'chapters', 'verses'])."
    },
    "chapterIndex": {
      "type": "array",
      "description": "Per-chapter navigation data. Paragraph books populate `paragraphs`; line/segment texts populate `lines` and `segments`.",
      "items": {
        "type": "object",
        "properties": {
          "n": {
            "type": "integer"
          },
          "title": {
            "type": "string"
          },
          "paragraphs": {
            "type": "integer"
          },
          "lines": {
            "type": "integer"
          },
          "segments": {
            "type": "integer"
          },
          "url": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "status": {
      "type": "string",
      "description": "Editorial status (stable, draft, planned, etc.)."
    },
    "licensing_status": {
      "type": "string",
      "enum": [
        "public_domain",
        "licensed",
        "fair_use_excerpt",
        "metadata_only",
        "unknown"
      ]
    },
    "version": {
      "type": [
        "object",
        "null"
      ],
      "description": "Structured version and provenance metadata exported from data-library `_meta.json` when available.",
      "properties": {
        "schemaVersion": {
          "type": "integer"
        },
        "title": {
          "type": "string"
        },
        "shortTitle": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "source-text",
            "translation",
            "curated-translation",
            "edition",
            "adaptation",
            "composite"
          ]
        },
        "language": {
          "type": "string"
        },
        "sourceLanguage": {
          "type": "string"
        },
        "refSystem": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "license": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "project-cc0",
                "public-domain",
                "licensed",
                "source-restricted",
                "mixed",
                "unknown"
              ]
            },
            "spdx": {
              "type": "string"
            },
            "url": {
              "type": "string"
            },
            "detail": {
              "type": "string"
            }
          },
          "additionalProperties": true
        },
        "provenance": {
          "type": "object",
          "properties": {
            "sourceRecordId": {
              "type": "string"
            },
            "sourceUrl": {
              "type": "string"
            },
            "baseText": {
              "type": "string"
            },
            "method": {
              "type": "string"
            },
            "citation": {
              "type": "string"
            },
            "witnesses": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          },
          "additionalProperties": true
        },
        "responsibility": {
          "type": "object"
        }
      },
      "additionalProperties": true
    },
    "translation": {
      "type": "object",
      "description": "For -woh translations: track, version, sourceText, glossaryVersion, modelDrafts, reviewer, divergencesFromBase."
    }
  }
},
  "links": {
    "self": "/v1/schema/book/",
    "index": "/v1/schema/"
  }
}
