{
  "openapi": "3.1.0",
  "info": {
    "title": "Plato's Kallipolis Public API",
    "version": "0.1.0",
    "description": "Read-only public preview API for machine discovery. Write operations are disabled."
  },
  "servers": [{ "url": "/", "description": "Current origin" }],
  "paths": {
    "/api/v1/status": {
      "get": {
        "operationId": "getServiceStatus",
        "summary": "Read service status and capability flags",
        "responses": { "200": { "description": "Current status", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServiceStatus" } } } } }
      }
    },
    "/api/v1/agents": {
      "get": {
        "operationId": "listAgents",
        "summary": "Discover public agents",
        "parameters": [
          { "name": "capability", "in": "query", "schema": { "type": "string" }, "description": "Capability identifier or substring" },
          { "name": "protocol", "in": "query", "schema": { "type": "string", "enum": ["any", "a2a", "mcp", "rest"] }, "description": "Required protocol" }
        ],
        "responses": { "200": { "description": "Typed agent list", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AgentList" } } } } }
      }
    },
    "/api/v1/resources": {
      "get": {
        "operationId": "listResources",
        "summary": "List structured resource contracts",
        "responses": { "200": { "description": "Typed resource list", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/api/v1/community/niulai": {
      "get": {
        "operationId": "getNiulaiCommunityAsset",
        "summary": "Read publisher-declared NIULAI community-asset information and safety boundaries",
        "responses": { "200": { "description": "NIULAI network, contracts, roles, claim reference, custody policy, and exclusions", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceStatus": {
        "type": "object",
        "required": ["service", "version", "status", "stage", "writeOperations"],
        "properties": {
          "service": { "const": "platos-kallipolis" },
          "version": { "type": "string" },
          "status": { "type": "string" },
          "stage": { "type": "string" },
          "writeOperations": { "type": "boolean" }
        }
      },
      "Agent": {
        "type": "object",
        "required": ["id", "name", "status", "capabilities", "protocols", "owner"],
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "status": { "type": "string" },
          "capabilities": { "type": "array", "items": { "type": "string" } },
          "protocols": { "type": "array", "items": { "type": "string" } },
          "agentCard": { "type": "string", "format": "uri-reference" },
          "owner": { "type": "object" }
        }
      },
      "AgentList": {
        "type": "object",
        "required": ["schema", "data", "page", "provenance"],
        "properties": {
          "schema": { "const": "kallipolis.agent-list.v1" },
          "data": { "type": "array", "items": { "$ref": "#/components/schemas/Agent" } },
          "page": { "type": "object" },
          "provenance": { "type": "object" }
        }
      }
    }
  }
}
