{
  "openapi": "3.1.0",
  "info": {
    "title": "Forma — WeChat Typesetting API",
    "version": "0.1.0",
    "description": "AI-friendly Markdown to WeChat-themed HTML rendering API",
    "contact": {
      "url": "https://forma.quickext.com"
    }
  },
  "servers": [
    {
      "url": "https://forma.quickext.com/api/v1",
      "description": "Production"
    }
  ],
  "paths": {
    "/render": {
      "post": {
        "operationId": "render",
        "summary": "Render markdown to WeChat HTML",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["content"],
                "properties": {
                  "content": {
                    "type": "string",
                    "description": "Markdown content to render"
                  },
                  "format": {
                    "type": "string",
                    "enum": ["markdown"],
                    "default": "markdown"
                  },
                  "theme": {
                    "type": "string",
                    "enum": ["swiss", "evolution-cat", "default", "暖纸"],
                    "default": "swiss"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful render",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "const": true },
                    "data": {
                      "type": "object",
                      "properties": {
                        "html": { "type": "string" },
                        "css": { "type": "string" },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "wordCount": { "type": "integer" },
                            "readingTimeMinutes": { "type": "integer" }
                          }
                        }
                      }
                    },
                    "theme": {
                      "type": "object",
                      "properties": {
                        "id": { "type": "string" },
                        "name": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "const": false },
                    "error": {
                      "type": "object",
                      "properties": {
                        "type": { "type": "string" },
                        "code": { "type": "string" },
                        "message": { "type": "string" },
                        "doc_url": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Content too large"
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "health",
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string" },
                    "version": { "type": "string" },
                    "timestamp": { "type": "string", "format": "date-time" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/themes": {
      "get": {
        "operationId": "themes",
        "summary": "List available themes",
        "responses": {
          "200": {
            "description": "Theme list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "themes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": { "type": "string" },
                          "name": { "type": "string" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
