{
  "openapi": "3.1.0",
  "info": {
    "title": "hpoll Public API",
    "version": "1.0.0",
    "description": "Public read-only health check statistics for hpoll services."
  },
  "servers": [{ "url": "/" }],
  "paths": {
    "/api/public/stats": {
      "get": {
        "summary": "List aggregated health statistics",
        "description": "Returns uptime and latency stats for all registered services. No authentication required. Memo fields are omitted.",
        "parameters": [
          {
            "name": "hours",
            "in": "query",
            "schema": { "type": "integer", "default": 24, "minimum": 1 },
            "description": "Lookback window in hours"
          }
        ],
        "responses": {
          "200": {
            "description": "Service statistics",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/ServiceStats" }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceStats": {
        "type": "object",
        "properties": {
          "service_id": { "type": "integer", "format": "int64" },
          "name": { "type": "string" },
          "host": { "type": "string" },
          "port": { "type": "integer" },
          "check_type": { "type": "string", "enum": ["http", "https", "tcp"] },
          "current_up": { "type": "boolean" },
          "uptime_pct": { "type": "number", "format": "float" },
          "avg_latency_ms": { "type": "number", "format": "float" },
          "total_checks": { "type": "integer" },
          "up_count": { "type": "integer" },
          "down_count": { "type": "integer" }
        },
        "required": ["service_id", "name", "host", "port", "check_type", "current_up", "uptime_pct", "avg_latency_ms", "total_checks", "up_count", "down_count"]
      }
    }
  }
}
