{
  "openapi": "3.1.0",
  "info": {
    "title": "Wall or Difference votes",
    "version": "1.0.0",
    "description": "Thumbs up or thumbs down on whether wallordifference.com made sense. People vote from the page; AI agents can vote here. One vote per reader, please."
  },
  "servers": [{ "url": "https://wallordifference.com" }],
  "paths": {
    "/api/votes": {
      "get": {
        "operationId": "getVotes",
        "summary": "Current vote counts",
        "responses": { "200": { "description": "Counts", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CountsResponse" } } } } }
      },
      "post": {
        "operationId": "castVote",
        "summary": "Cast a thumbs up or thumbs down",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["vote"],
                "properties": {
                  "vote": { "type": "string", "enum": ["up", "down"] },
                  "source": { "type": "string", "enum": ["agent", "human"], "default": "agent", "description": "Agents should send \"agent\"." }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Vote recorded", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VoteResponse" } } } },
          "400": { "description": "vote must be \"up\" or \"down\"" }
        }
      }
    },
    "/api/vote/{vote}": {
      "get": {
        "operationId": "castAgentVoteByUrl",
        "summary": "Cast an agent vote with a plain GET, for tools that cannot POST",
        "parameters": [{ "name": "vote", "in": "path", "required": true, "schema": { "type": "string", "enum": ["up", "down"] } }],
        "responses": { "200": { "description": "Vote recorded", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/VoteResponse" } } } } }
      }
    }
  },
  "components": {
    "schemas": {
      "Pair": { "type": "object", "properties": { "up": { "type": "integer" }, "down": { "type": "integer" } } },
      "Counts": {
        "type": "object",
        "properties": {
          "up": { "type": "integer" },
          "down": { "type": "integer" },
          "human": { "$ref": "#/components/schemas/Pair" },
          "agent": { "$ref": "#/components/schemas/Pair" }
        }
      },
      "CountsResponse": { "type": "object", "properties": { "counts": { "$ref": "#/components/schemas/Counts" } } },
      "VoteResponse": {
        "type": "object",
        "properties": {
          "recorded": { "type": "string", "enum": ["up", "down"] },
          "source": { "type": "string", "enum": ["agent", "human"] },
          "counts": { "$ref": "#/components/schemas/Counts" }
        }
      }
    }
  }
}
