{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://loop.firmiana.si/api/v1/schemas/status.schema.json",
  "title": "Current API state and uptime per provider, from official status pages (api/v1/status.json)",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "version", "generated_at", "license", "live", "providers"],
  "properties": {
    "schema": { "type": "string", "format": "uri" }, "version": { "const": 1 }, "generated_at": { "type": "string", "format": "date-time" }, "license": { "const": "CC-BY-4.0" },
    "live": { "type": "string", "format": "uri", "description": "Fresher state, read every 1 to 5 minutes by the web server" },
    "providers": { "type": "array", "items": { "$ref": "#/$defs/provider" } }
  },
  "$defs": {
    "uptime": {
      "type": "object",
      "additionalProperties": false,
      "required": ["days", "availability", "incidents", "incident_minutes"],
      "properties": {
        "days": { "type": "integer" },
        "availability": { "type": ["number", "null"], "minimum": 0, "maximum": 1 },
        "incidents": { "type": ["integer", "null"] },
        "incident_minutes": { "type": ["number", "null"] }
      }
    },
    "provider": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "region", "status_page", "state", "last_checked", "open_incidents", "uptime", "url"],
      "properties": {
        "id": { "type": "string" },
        "name": { "type": "string" },
        "region": { "type": "string" },
        "status_page": { "type": ["string", "null"], "format": "uri" },
        "state": { "enum": ["ok", "degraded", "outage", "unknown", "no_status_page"], "description": "From open API incidents: minor = degraded; major or critical = outage" },
        "last_checked": { "type": ["string", "null"], "format": "date-time" },
        "open_incidents": { "type": "array", "items": { "$ref": "https://loop.firmiana.si/status/v1/incidents.schema.json#/$defs/incident" } },
        "uptime": { "type": "array", "items": { "$ref": "#/$defs/uptime" }, "description": "Last 7, 30 and 90 days; API incidents only" },
        "url": { "type": "string", "format": "uri" }
      }
    }
  }
}
