{
  "openapi": "3.1.0",
  "info": {
    "title": "BibleAwesome Scripture Reader API",
    "description": "Public read-only access to available Old Testament books in AWE draft English and Biblical Hebrew, and the New Testament in AWE draft English and Koine Greek. See the chapter catalog for coverage. No credentials required.",
    "version": "1.0.0"
  },
  "servers": [{ "url": "https://bibleawesome.com" }],
  "externalDocs": { "url": "https://bibleawesome.com/developers" },
  "paths": {
    "/api/v1/catalog.json": {
      "get": {
        "operationId": "getCatalog",
        "summary": "List available books, editions, and chapter URLs",
        "parameters": [
          {
            "name": "If-None-Match",
            "in": "header",
            "description": "ETag from a previous response; omit on the first request.",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog of public chapters",
            "content": {
              "application/json": {
                "schema": { "type": "object", "$ref": "#/components/schemas/Catalog" }
              }
            }
          },
          "304": { "description": "Catalog has not changed since the supplied ETag" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/v1/{edition}/{book}/{chapter}.json": {
      "get": {
        "operationId": "getChapter",
        "summary": "Retrieve a chapter with its paragraphs, verse numbers, and attribution",
        "parameters": [
          {
            "name": "edition",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "enum": ["awe", "sblgnt", "wlc"] }
          },
          {
            "name": "book",
            "in": "path",
            "required": true,
            "description": "Book ID from the chapter catalog (for example, genesis or matthew).",
            "schema": { "type": "string", "pattern": "^[a-z0-9-]+$" }
          },
          {
            "name": "chapter",
            "in": "path",
            "required": true,
            "schema": { "$ref": "#/components/schemas/ChapterNumber" }
          }
        ],
        "responses": {
          "200": {
            "description": "Chapter text and source attribution",
            "content": {
              "application/json": {
                "schema": { "type": "object", "$ref": "#/components/schemas/Chapter" }
              }
            }
          },
          "404": {
            "description": "Chapter not found; follow the included catalog URL",
            "content": {
              "application/problem+json": { "schema": { "$ref": "#/components/schemas/Problem" } }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    }
  },
  "components": {
    "responses": {
      "RateLimited": {
        "description": "The shared request limit was exceeded",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying",
            "schema": { "type": "integer" }
          }
        },
        "content": {
          "application/problem+json": { "schema": { "$ref": "#/components/schemas/Problem" } }
        }
      }
    },
    "schemas": {
      "ChapterNumber": { "type": "integer", "minimum": 1 },
      "ChapterLink": {
        "type": "object",
        "required": ["chapter", "url", "json"],
        "properties": {
          "chapter": { "$ref": "#/components/schemas/ChapterNumber" },
          "url": { "type": "string", "format": "uri" },
          "json": { "type": "string", "format": "uri" }
        }
      },
      "Catalog": {
        "type": "object",
        "required": ["books"],
        "properties": {
          "books": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "name", "chapterCount", "editions"],
              "properties": {
                "id": { "type": "string" },
                "name": { "type": "string" },
                "chapterCount": { "type": "integer" },
                "editions": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": ["id", "language", "draft", "chapters"],
                    "properties": {
                      "id": { "type": "string" },
                      "language": { "type": "string" },
                      "draft": { "type": "boolean" },
                      "chapters": {
                        "type": "array",
                        "items": { "$ref": "#/components/schemas/ChapterLink" }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Chapter": {
        "type": "object",
        "required": [
          "book",
          "chapter",
          "edition",
          "language",
          "draft",
          "url",
          "source",
          "paragraphs"
        ],
        "properties": {
          "book": { "type": "string" },
          "chapter": { "$ref": "#/components/schemas/ChapterNumber" },
          "edition": { "type": "string" },
          "language": { "type": "string" },
          "draft": { "type": "boolean" },
          "url": { "type": "string", "format": "uri" },
          "source": {
            "type": "object",
            "required": ["name", "url", "license", "licenseUrl"],
            "properties": {
              "name": { "type": "string" },
              "url": { "type": "string", "format": "uri" },
              "copyright": { "type": "string" },
              "license": { "type": "string" },
              "licenseUrl": { "type": "string", "format": "uri" }
            }
          },
          "paragraphs": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["verse", "text"],
                "properties": {
                  "verse": {
                    "type": ["integer", "null"],
                    "description": "Null continues the preceding verse."
                  },
                  "text": { "type": "string" }
                }
              }
            }
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": ["type", "title", "status", "code", "detail", "catalog"],
        "properties": {
          "type": { "type": "string" },
          "title": { "type": "string" },
          "status": { "type": "integer", "enum": [404, 405, 429] },
          "code": {
            "type": "string",
            "enum": ["not_found", "method_not_allowed", "rate_limit_exceeded"]
          },
          "detail": { "type": "string" },
          "catalog": { "type": "string", "format": "uri" }
        }
      }
    }
  }
}
