{
  "openapi": "3.1.0",
  "info": {
    "title": "serious AI 内参 API",
    "version": "1.1.0",
    "description": "公开只读 API，用于读取 serious AI 内参公开目录数据和每日 EPUB 下载入口。"
  },
  "servers": [
    {
      "url": "https://seriousai.candobear.com/api/v1"
    }
  ],
  "paths": {
    "/meta.json": {
      "get": {
        "operationId": "getMeta",
        "summary": "读取 API 元信息",
        "responses": {
          "200": {
            "description": "API metadata"
          }
        }
      }
    },
    "/issues.json": {
      "get": {
        "operationId": "listIssues",
        "summary": "列出所有内参期数摘要",
        "responses": {
          "200": {
            "description": "Issue summaries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/IssueSummary"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/issues/latest.json": {
      "get": {
        "operationId": "getLatestIssue",
        "summary": "读取最新一期内参",
        "responses": {
          "200": {
            "description": "Latest issue",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssueDetail"
                }
              }
            }
          }
        }
      }
    },
    "/issues/{id}.json": {
      "get": {
        "operationId": "getIssue",
        "summary": "按期数 ID 读取一期内参",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Issue detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssueDetail"
                }
              }
            }
          },
          "404": {
            "description": "Issue not found"
          }
        }
      }
    },
    "/items.json": {
      "get": {
        "operationId": "listItems",
        "summary": "列出所有公开条目",
        "responses": {
          "200": {
            "description": "Flattened items"
          }
        }
      }
    },
    "/items/{id}.json": {
      "get": {
        "operationId": "getItem",
        "summary": "按条目 ID 读取文章条目",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Item detail"
          },
          "404": {
            "description": "Item not found"
          }
        }
      }
    },
    "/tags.json": {
      "get": {
        "operationId": "listTags",
        "summary": "列出标签及计数",
        "responses": {
          "200": {
            "description": "Tags"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "summary": "读取 OpenAPI schema",
        "responses": {
          "200": {
            "description": "OpenAPI schema"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IssueEpub": {
        "type": "object",
        "required": [
          "path",
          "fileName",
          "url"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "公开站相对下载路径"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "公开站绝对下载 URL"
          },
          "fileName": {
            "type": "string"
          },
          "sizeBytes": {
            "type": "integer",
            "minimum": 0
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "articleCount": {
            "type": "integer",
            "minimum": 0
          },
          "noteWordCount": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "IssueSummary": {
        "type": "object",
        "required": [
          "id",
          "date",
          "issueNo",
          "title",
          "insight",
          "path",
          "itemCount"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "issueNo": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "insight": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "itemCount": {
            "type": "integer",
            "minimum": 0
          },
          "epub": {
            "$ref": "#/components/schemas/IssueEpub"
          }
        }
      },
      "IssueDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/IssueSummary"
          },
          {
            "type": "object",
            "properties": {
              "sections": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          }
        ]
      }
    }
  }
}