{
  "openapi": "3.1.0",
  "info": {
    "title": "XCX.LA 投稿 API",
    "version": "1.0.0",
    "description": "无需注册的审核制产品投稿。状态查询使用投稿时返回的 Bearer token。"
  },
  "servers": [
    {
      "url": "https://xcx.la"
    }
  ],
  "components": {
    "securitySchemes": {
      "receipt": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Submission": {
        "type": "object",
        "required": [
          "name",
          "url",
          "summary",
          "description"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "summary": {
            "type": "string",
            "minLength": 4,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "minLength": 20,
            "maxLength": 10000
          },
          "category": {
            "type": "string",
            "enum": [
              "games",
              "interactive",
              "quizzes",
              "productivity",
              "coding",
              "automation",
              "agents",
              "utilities",
              "information",
              "showcase",
              "data",
              "models",
              "research",
              "learning",
              "writing",
              "design",
              "creation",
              "audio",
              "video",
              "podcasts",
              "events",
              "social",
              "collaboration",
              "other"
            ],
            "default": "other"
          },
          "kind": {
            "type": "string",
            "enum": [
              "product",
              "correction"
            ],
            "default": "product"
          },
          "features": {
            "type": "array",
            "maxItems": 6,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40
            }
          },
          "source": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "contact": {
            "type": "string",
            "maxLength": 200
          }
        }
      },
      "Receipt": {
        "type": "object",
        "required": [
          "id",
          "token",
          "status",
          "status_url"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "token": {
            "type": "string"
          },
          "status": {
            "const": "pending_review"
          },
          "status_url": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Status": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "pending_review",
              "published",
              "rejected"
            ]
          },
          "page_url": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/submissions": {
      "post": {
        "operationId": "submitProduct",
        "summary": "提交产品（进入待审核）",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Submission"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "已接收，保存 token 用于查询",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "409": {
            "description": "网址已收录或待审核"
          },
          "413": {
            "description": "请求超过 24 KB"
          },
          "422": {
            "description": "参数错误，响应包含 error 和 field"
          },
          "429": {
            "description": "频率限制"
          }
        }
      }
    },
    "/api/v1/submissions/{id}": {
      "get": {
        "operationId": "getSubmissionStatus",
        "summary": "查看自己的投稿状态",
        "security": [
          {
            "receipt": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "审核状态",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "404": {
            "description": "不存在或凭据不符"
          },
          "429": {
            "description": "查询过于频繁"
          }
        }
      }
    },
    "/catalog.json": {
      "get": {
        "operationId": "readCatalog",
        "summary": "读取所有已发布产品",
        "responses": {
          "200": {
            "description": "公开产品目录"
          }
        }
      }
    },
    "/categories.json": {
      "get": {
        "operationId": "readCategories",
        "summary": "读取大类、投稿细分类与真实收录数",
        "responses": {
          "200": {
            "description": "groups 为浏览大类，categories 为投稿 category 可用值"
          }
        }
      }
    }
  }
}