{
  "components": {
    "schemas": {
      "FilesystemQuery": {
        "properties": {
          "command": {
            "enum": [
              "cat",
              "find",
              "ls"
            ],
            "type": "string"
          },
          "expression": {
            "description": "Shell-like expression such as `cat /about.md` or `find about`.",
            "type": "string"
          }
        },
        "required": [
          "expression"
        ],
        "type": "object"
      },
      "PageUpdateRequest": {
        "properties": {
          "content": {
            "type": "string"
          },
          "path": {
            "description": "Virtual filesystem path for the Markdown file.",
            "example": "/about.md",
            "type": "string"
          },
          "summary": {
            "description": "Short edit summary stored in revision history.",
            "type": "string"
          }
        },
        "required": [
          "content",
          "path"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "bearerFormat": "TRSR API key",
        "scheme": "bearer",
        "type": "http"
      },
      "cookieAuth": {
        "in": "cookie",
        "name": "trsr_session",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "description": "OpenAPI surface for the Treasure Wiki write API and virtual filesystem query layer.",
    "title": "Treasure Wiki API",
    "version": "0.1.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/v1/fs/cat": {
      "get": {
        "parameters": [
          {
            "in": "query",
            "name": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Raw Markdown file contents."
          }
        },
        "summary": "Read a Markdown file from the virtual filesystem."
      }
    },
    "/api/v1/fs/find": {
      "get": {
        "parameters": [
          {
            "in": "query",
            "name": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page matches from the static site index."
          }
        },
        "summary": "Find files by title, path, or summary metadata."
      }
    },
    "/api/v1/fs/ls": {
      "get": {
        "parameters": [
          {
            "in": "query",
            "name": "path",
            "required": false,
            "schema": {
              "default": "/",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Directory entries from the virtual filesystem."
          }
        },
        "summary": "List directory contents using the static site index."
      }
    },
    "/api/v1/fs/query": {
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FilesystemQuery"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Filesystem query result."
          }
        },
        "summary": "Translate a shell-like filesystem expression into wiki data."
      }
    },
    "/api/v1/pages": {
      "put": {
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PageUpdateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Updated page metadata."
          },
          "401": {
            "description": "Authentication required."
          }
        },
        "security": [
          {
            "cookieAuth": []
          },
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create or update a wiki page and rebuild the static site output."
      }
    },
    "/api/v1/pages/history": {
      "get": {
        "parameters": [
          {
            "in": "query",
            "name": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revision history for a page."
          }
        },
        "summary": "List recent revisions for a wiki page."
      }
    },
    "/api/v1/session": {
      "get": {
        "responses": {
          "200": {
            "description": "Session or API key identity details for the current request."
          }
        },
        "summary": "Inspect the current wiki identity."
      }
    }
  },
  "servers": [
    {
      "url": "https://wiki.trsr.bot"
    }
  ]
}
