{
  "openapi": "3.1.0",
  "info": {
    "title": "Agent Report read API",
    "version": "1.0.0",
    "description": "Published reports only. No authentication. Read-only discovery and full-text search."
  },
  "servers": [
    {
      "url": "https://agentreport.io"
    }
  ],
  "paths": {
    "/api/search": {
      "get": {
        "operationId": "searchReports",
        "summary": "Search published reports",
        "parameters": [
          {
            "name": "q",
            "schema": {
              "type": "string",
              "maxLength": 200,
              "default": ""
            },
            "in": "query",
            "required": false
          },
          {
            "name": "topic",
            "schema": {
              "type": "string",
              "enum": [
                "",
                "personal-assistants",
                "interoperability",
                "permissions-and-safety",
                "evaluation"
              ]
            },
            "in": "query",
            "required": false
          },
          {
            "name": "format",
            "schema": {
              "type": "string",
              "enum": [
                "",
                "news",
                "roundup",
                "essay",
                "guide",
                "profile",
                "explainer",
                "briefing",
                "methodology"
              ]
            },
            "in": "query",
            "required": false
          },
          {
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            },
            "in": "query",
            "required": false
          },
          {
            "name": "offset",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            },
            "in": "query",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Search results with total, offset, limit, results, next and previous links.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid search parameters"
          },
          "503": {
            "description": "Search catalogue temporarily unavailable"
          }
        }
      }
    },
    "/articles.json": {
      "get": {
        "operationId": "listReports",
        "responses": {
          "200": {
            "description": "Versioned catalogue with full article text, metadata and canonical URLs"
          }
        }
      }
    },
    "/articles/{slug}.json": {
      "get": {
        "operationId": "readReport",
        "parameters": [
          {
            "in": "path",
            "name": "slug",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full public article representation"
          },
          "404": {
            "description": "Unknown or unpublished article"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SearchResponse": {
        "type": "object",
        "required": [
          "version",
          "query",
          "filters",
          "total",
          "offset",
          "limit",
          "results",
          "next",
          "previous"
        ],
        "properties": {
          "version": {
            "const": 1
          },
          "query": {
            "type": "string"
          },
          "filters": {
            "type": "object",
            "properties": {
              "topic": {
                "type": "string"
              },
              "format": {
                "type": "string"
              }
            }
          },
          "total": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "slug",
                "title",
                "url",
                "markdownUrl",
                "jsonUrl",
                "excerpt"
              ],
              "properties": {
                "slug": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "markdownUrl": {
                  "type": "string",
                  "format": "uri"
                },
                "jsonUrl": {
                  "type": "string",
                  "format": "uri"
                },
                "excerpt": {
                  "type": "string"
                }
              }
            }
          },
          "next": {
            "type": [
              "string",
              "null"
            ]
          },
          "previous": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}
