{
  "openapi": "3.1.1",
  "info": {
    "title": "Daily Read Bytes API",
    "version": "1.0.0",
    "description": "Read-only access to Daily Read Bytes news summaries. Responses contain Daily Read Bytes summaries and source attribution, not republished source articles."
  },
  "servers": [
    {
      "url": "https://dailyreadbytes.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Check API availability",
        "responses": {
          "200": {
            "description": "The API is available",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Health" }
              }
            }
          }
        }
      }
    },
    "/api/feed": {
      "get": {
        "operationId": "getFeed",
        "summary": "List news cards",
        "parameters": [
          { "name": "locale", "in": "query", "description": "Content locale. English (`en`) is currently supported.", "schema": { "type": "string", "default": "en" } },
          { "name": "offset", "in": "query", "description": "Zero-based feed offset, from 0 to 500.", "schema": { "type": "integer", "minimum": 0, "maximum": 500, "default": 0 } },
          { "name": "topic", "in": "query", "description": "Optional topic key.", "schema": { "type": "string" } },
          { "name": "region", "in": "query", "description": "Optional region key; `auto` uses the Cloudflare request country.", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "News cards",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Feed" }
              }
            }
          },
          "400": { "description": "Invalid locale" }
        }
      }
    },
    "/api/article": {
      "get": {
        "operationId": "getArticle",
        "summary": "Get a complete Daily Read Bytes story summary",
        "parameters": [
          { "name": "slug", "in": "query", "required": true, "schema": { "type": "string" } },
          { "name": "locale", "in": "query", "schema": { "type": "string", "default": "en" } }
        ],
        "responses": {
          "200": {
            "description": "Story detail",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ArticleResponse" }
              }
            }
          },
          "400": { "description": "Missing slug or invalid locale" },
          "404": { "description": "Story not found" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Health": {
        "type": "object",
        "required": ["status", "service"],
        "properties": {
          "status": { "type": "string", "const": "ok" },
          "service": { "type": "string", "const": "daily-read-bytes-api" }
        }
      },
      "Feed": {
        "type": "object",
        "required": ["cards"],
        "properties": {
          "cards": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "region": { "type": "string" }
        }
      },
      "ArticleResponse": {
        "type": "object",
        "required": ["article"],
        "properties": {
          "article": { "type": "object", "additionalProperties": true }
        }
      }
    }
  }
}
