{
  "openapi": "3.1.0",
  "info": { "title": "Arcade Swish Creator API", "version": "1.0.0", "description": "Submit and manage games for the Arcade Swish feed." },
  "servers": [{ "url": "https://arcadeswish.com/api/v1" }],
  "paths": {
    "/kit": {
      "get": {
        "operationId": "getKit",
        "summary": "Read the rules and starter code for building a game",
        "security": [],
        "responses": { "200": { "description": "Game kit as text", "content": { "text/plain": { "schema": { "type": "string" } } } } }
      }
    },
    "/games": {
      "get": {
        "operationId": "listMyGames",
        "summary": "List your games and their status",
        "responses": { "200": { "description": "Your games", "content": { "application/json": { "schema": { "type": "object", "properties": { "games": { "type": "array", "items": { "$ref": "#/components/schemas/GameStatus" } } } } } } } }
      },
      "post": {
        "operationId": "submitGame",
        "summary": "Submit a new game for checks and review",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GameInput" } } } },
        "responses": {
          "201": { "description": "Passed the checks and waiting for review", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GameStatus" } } } },
          "422": { "description": "Failed the automatic checks. Fix each item in checks and submit again.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Daily limit reached", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/games/{id}": {
      "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
      "get": {
        "operationId": "getGame",
        "summary": "Get a game's status",
        "responses": { "200": { "description": "Game status", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GameStatus" } } } } }
      },
      "put": {
        "operationId": "updateGame",
        "summary": "Replace a game. It returns to review.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GameInput" } } } },
        "responses": {
          "200": { "description": "Updated and waiting for review", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GameStatus" } } } },
          "422": { "description": "Failed the automatic checks", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      },
      "delete": {
        "operationId": "removeGame",
        "summary": "Remove a game from Arcade Swish",
        "responses": { "200": { "description": "Removed", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } } }
      }
    }
  },
  "security": [{ "bearerAuth": [] }],
  "components": {
    "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } },
    "schemas": {
      "GameInput": {
        "type": "object",
        "required": ["title", "description", "hint", "control", "html"],
        "properties": {
          "title": { "type": "string", "minLength": 2, "maxLength": 40 },
          "description": { "type": "string", "minLength": 5, "maxLength": 160, "description": "One line that says how to play" },
          "hint": { "type": "string", "minLength": 2, "maxLength": 24, "description": "Short instruction such as Tap to jump" },
          "tags": { "type": "string", "maxLength": 60, "description": "For example #timing #space" },
          "control": { "type": "string", "enum": ["tap", "hold", "drag", "sides"] },
          "mood": { "type": "string", "enum": ["space", "chill", "drive", "funk", "tense", "sunny", "warp", "void"], "description": "Background music style" },
          "html": { "type": "string", "description": "One complete, self-contained HTML game that follows the game kit. 500 KB maximum." }
        }
      },
      "GameStatus": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "status": { "type": "string", "enum": ["review", "testing", "live", "removed"] },
          "review_note": { "type": ["string", "null"] },
          "preview_url": { "type": "string" },
          "share_url": { "type": "string" },
          "next": { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "string" }, "checks": { "type": "array", "items": { "type": "string" } } }
      }
    }
  }
}
