{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peakcam-io/json-schema/peakcam-io-status-schema.json",
  "title": "Status",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peakcam-io-openapi.json#/components/schemas/Status",
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "ok",
        "degraded"
      ],
      "description": "`degraded` when any check below is failing; the HTTP status stays 200 so the body can be read."
    },
    "generatedAt": {
      "type": "string"
    },
    "checks": {
      "type": "object",
      "properties": {
        "snowReports": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "ok",
                "degraded"
              ]
            },
            "resorts": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Active resorts in the catalogue."
            },
            "reporting": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Resorts with at least one snow report."
            },
            "newestReportAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Newest `latest_snow_reports.updated_at` across the catalogue."
            },
            "ageHours": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Hours since `newestReportAt`. The sync jobs run every 6 h, so above 12 h is degraded."
            },
            "staleResorts": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Reporting resorts whose latest report is older than 24 h."
            },
            "bySource": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "description": "Reporting resorts per `source` (`snotel`, `open_meteo`, …)."
            }
          },
          "required": [
            "status",
            "resorts",
            "reporting",
            "newestReportAt",
            "ageHours",
            "staleResorts",
            "bySource"
          ],
          "additionalProperties": false
        },
        "cams": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "ok",
                "degraded"
              ]
            },
            "total": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "live": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Last health check passed."
            },
            "down": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "unchecked": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "liveRatio": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "description": "live / (live + down); null when nothing has been checked. Below 0.9 is degraded."
            },
            "newestCheckAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "status",
            "total",
            "live",
            "down",
            "unchecked",
            "liveRatio",
            "newestCheckAt"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "snowReports",
        "cams"
      ],
      "additionalProperties": false
    },
    "thresholds": {
      "type": "object",
      "properties": {
        "reportMaxAgeHours": {
          "type": "number"
        },
        "camLiveMinRatio": {
          "type": "number"
        }
      },
      "required": [
        "reportMaxAgeHours",
        "camLiveMinRatio"
      ],
      "additionalProperties": false
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "One sentence per failing check; empty when `ok`."
    },
    "attribution": {
      "type": "string"
    }
  },
  "required": [
    "status",
    "generatedAt",
    "checks",
    "thresholds",
    "issues",
    "attribution"
  ],
  "additionalProperties": false
}