{
  "openapi": "3.1.0",
  "info": {
    "title": "CRACK Wiki API",
    "version": "1.0.0",
    "description": "Read-only data from the unofficial CRACK Wiki (game by Rafoli, Steam app 4312190): full-text search, page list and achievements with unlock rates."
  },
  "servers": [
    {
      "url": "https://crack-wiki.pages.dev"
    }
  ],
  "paths": {
    "/api/search": {
      "get": {
        "operationId": "searchWiki",
        "summary": "Search pages and achievements",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "example": "free range"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ranked results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or too long query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/achievements.json": {
      "get": {
        "operationId": "listAchievements",
        "summary": "All 40 achievements with unlock rates and tips",
        "responses": {
          "200": {
            "description": "Achievement list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/pages.json": {
      "get": {
        "operationId": "listPages",
        "summary": "Every wiki page with URLs to HTML and Markdown",
        "responses": {
          "200": {
            "description": "Page list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/{path}/index.md": {
      "get": {
        "operationId": "getPageMarkdown",
        "summary": "Markdown version of a page (also via Accept: text/markdown on the HTML URL)",
        "parameters": [
          {
            "name": "path",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "endings"
          }
        ],
        "responses": {
          "200": {
            "description": "Markdown",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Unknown page"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SearchResponse": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "page",
                    "achievement"
                  ]
                },
                "title": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "category": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "snippet": {
                  "type": "string"
                },
                "score": {
                  "type": "number"
                }
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
