{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peakcam-io/json-schema/peakcam-io-resort-conditions-schema.json",
  "title": "ResortConditions",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peakcam-io-openapi.json#/components/schemas/ResortConditions",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "string",
      "const": "1.0.0",
      "description": "Contract version; the schema file name carries the major."
    },
    "schemaUrl": {
      "type": "string",
      "description": "The JSON Schema this document validates against."
    },
    "slug": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "canonicalUrl": {
      "type": "string",
      "description": "The resort's PeakCam page. Cite this."
    },
    "apiUrl": {
      "type": "string",
      "description": "The full resort document."
    },
    "sentence": {
      "type": "string",
      "description": "A dated, source-labelled status sentence that can be quoted verbatim."
    },
    "meta": {
      "type": "object",
      "properties": {
        "generatedAt": {
          "type": "string"
        },
        "resolvedAt": {
          "type": "string",
          "description": "ISO instant the status was evaluated at (ages are measured from it)."
        },
        "timeZone": {
          "type": "string",
          "description": "IANA zone the resort's calendar day runs on."
        },
        "localDate": {
          "type": "string",
          "description": "YYYY-MM-DD at the resort when the status was resolved."
        },
        "newestObservationAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The newest `observedAt` across the populated fields."
        },
        "freshness": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "enum": [
              "status",
              "seasonOpening",
              "seasonClosing",
              "baseDepthIn",
              "operatorBaseDepthIn",
              "newSnow24hIn",
              "newSnow48hIn",
              "sweIn",
              "liftsOpen",
              "liftsTotal",
              "runsOpen",
              "runsTotal",
              "surface",
              "snowQuality",
              "tempF",
              "windMph",
              "forecastNext48hCm",
              "percentOfNormal"
            ]
          },
          "additionalProperties": {
            "$ref": "#/$defs/FreshnessTier"
          },
          "required": [
            "status",
            "seasonOpening",
            "seasonClosing",
            "baseDepthIn",
            "operatorBaseDepthIn",
            "newSnow24hIn",
            "newSnow48hIn",
            "sweIn",
            "liftsOpen",
            "liftsTotal",
            "runsOpen",
            "runsTotal",
            "surface",
            "snowQuality",
            "tempF",
            "windMph",
            "forecastNext48hCm",
            "percentOfNormal"
          ],
          "description": "Freshness tier per field."
        },
        "sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ConditionSource"
          },
          "description": "Distinct sources used, best first."
        }
      },
      "required": [
        "generatedAt",
        "resolvedAt",
        "timeZone",
        "localDate",
        "newestObservationAt",
        "freshness",
        "sources"
      ],
      "additionalProperties": false
    },
    "data": {
      "$ref": "#/$defs/ConditionsContract"
    },
    "measuredNow": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MeasuredNow"
      },
      "description": "The station layer's latest reading per station (P3), the same rows as `/resorts/{slug}.measuredNow`."
    },
    "attribution": {
      "type": "string"
    },
    "license": {
      "type": "string"
    }
  },
  "required": [
    "schemaVersion",
    "schemaUrl",
    "slug",
    "name",
    "canonicalUrl",
    "apiUrl",
    "sentence",
    "meta",
    "data",
    "measuredNow",
    "attribution",
    "license"
  ],
  "additionalProperties": false,
  "$defs": {
    "ConditionFreshness": {
      "type": "object",
      "properties": {
        "tier": {
          "$ref": "#/$defs/FreshnessTier"
        },
        "ageHours": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Hours between the observation and `generatedAt`, one decimal; null for static facts and empty fields."
        }
      },
      "required": [
        "tier",
        "ageHours"
      ],
      "additionalProperties": false
    },
    "ConditionNumberField": {
      "type": "object",
      "properties": {
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Null when PeakCam has nothing for this field."
        },
        "source": {
          "$ref": "#/$defs/ConditionSource"
        },
        "observedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO-8601 instant the value was observed or published; null for static facts and empty fields."
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "0–1: SNOTEL 0.9, other stations 0.8, operator 0.7, profile 0.6, derived 0.6, model 0.5; halved when stale, 0 when unknown."
        },
        "freshness": {
          "$ref": "#/$defs/ConditionFreshness"
        }
      },
      "required": [
        "value",
        "source",
        "observedAt",
        "confidence",
        "freshness"
      ],
      "additionalProperties": false
    },
    "ConditionSnowQualityField": {
      "type": "object",
      "properties": {
        "value": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "powder",
                "packed",
                "spring",
                "ice"
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "Null when PeakCam has nothing for this field."
        },
        "source": {
          "$ref": "#/$defs/ConditionSource"
        },
        "observedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO-8601 instant the value was observed or published; null for static facts and empty fields."
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "0–1: SNOTEL 0.9, other stations 0.8, operator 0.7, profile 0.6, derived 0.6, model 0.5; halved when stale, 0 when unknown."
        },
        "freshness": {
          "$ref": "#/$defs/ConditionFreshness"
        }
      },
      "required": [
        "value",
        "source",
        "observedAt",
        "confidence",
        "freshness"
      ],
      "additionalProperties": false
    },
    "ConditionSource": {
      "type": "string",
      "enum": [
        "snotel",
        "station:snotel",
        "station:ghcn",
        "station:nws",
        "station:bc_asws",
        "station:eccc",
        "operator",
        "model",
        "profile",
        "derived",
        "none"
      ]
    },
    "ConditionStatusField": {
      "type": "object",
      "properties": {
        "value": {
          "anyOf": [
            {
              "$ref": "#/$defs/ResortStatus"
            },
            {
              "type": "null"
            }
          ],
          "description": "Null when PeakCam has nothing for this field."
        },
        "source": {
          "$ref": "#/$defs/ConditionSource"
        },
        "observedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO-8601 instant the value was observed or published; null for static facts and empty fields."
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "0–1: SNOTEL 0.9, other stations 0.8, operator 0.7, profile 0.6, derived 0.6, model 0.5; halved when stale, 0 when unknown."
        },
        "freshness": {
          "$ref": "#/$defs/ConditionFreshness"
        }
      },
      "required": [
        "value",
        "source",
        "observedAt",
        "confidence",
        "freshness"
      ],
      "additionalProperties": false
    },
    "ConditionTextField": {
      "type": "object",
      "properties": {
        "value": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Null when PeakCam has nothing for this field."
        },
        "source": {
          "$ref": "#/$defs/ConditionSource"
        },
        "observedAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO-8601 instant the value was observed or published; null for static facts and empty fields."
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "0–1: SNOTEL 0.9, other stations 0.8, operator 0.7, profile 0.6, derived 0.6, model 0.5; halved when stale, 0 when unknown."
        },
        "freshness": {
          "$ref": "#/$defs/ConditionFreshness"
        }
      },
      "required": [
        "value",
        "source",
        "observedAt",
        "confidence",
        "freshness"
      ],
      "additionalProperties": false
    },
    "ConditionsContract": {
      "type": "object",
      "properties": {
        "status": {
          "$ref": "#/$defs/ConditionStatusField"
        },
        "recommendableToday": {
          "type": "boolean",
          "description": "True only when the status is OPEN on a usable source, a current base depth is on file and the rating is not poor."
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Why the status and the verdict came out as they did, in order; quote them."
        },
        "depthDisagreement": {
          "anyOf": [
            {
              "$ref": "#/$defs/DepthDisagreement"
            },
            {
              "type": "null"
            }
          ]
        },
        "seasonOpening": {
          "description": "YYYY-MM-DD. Source `operator` for a resort-confirmed date, `profile` for a third-party projection.",
          "$ref": "#/$defs/ConditionTextField"
        },
        "seasonClosing": {
          "description": "YYYY-MM-DD, mainly Southern-hemisphere rows.",
          "$ref": "#/$defs/ConditionTextField"
        },
        "baseDepthIn": {
          "description": "Measured (or model) base depth from the snow report, inches. Prefer this over `operatorBaseDepthIn`.",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "operatorBaseDepthIn": {
          "description": "The operator's own base figure, when a feed carries one.",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "newSnow24hIn": {
          "$ref": "#/$defs/ConditionNumberField"
        },
        "newSnow48hIn": {
          "$ref": "#/$defs/ConditionNumberField"
        },
        "sweIn": {
          "description": "Snow water equivalent, inches.",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "liftsOpen": {
          "description": "Lifts open per the operator feed.",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "liftsTotal": {
          "description": "From the operator feed when it lists lifts, else the profile total.",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "runsOpen": {
          "$ref": "#/$defs/ConditionNumberField"
        },
        "runsTotal": {
          "$ref": "#/$defs/ConditionNumberField"
        },
        "surface": {
          "description": "Operator-reported surface, when a feed carries one.",
          "$ref": "#/$defs/ConditionTextField"
        },
        "snowQuality": {
          "$ref": "#/$defs/ConditionSnowQualityField"
        },
        "tempF": {
          "description": "The highest station with a temperature (summit first).",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "windMph": {
          "$ref": "#/$defs/ConditionNumberField"
        },
        "forecastNext48hCm": {
          "description": "Blended forecast snowfall over the next 48 h, cm (P4 blend, summit point).",
          "$ref": "#/$defs/ConditionNumberField"
        },
        "percentOfNormal": {
          "description": "SWE against the station's 1991–2020 median, inside the publishable band.",
          "$ref": "#/$defs/ConditionNumberField"
        }
      },
      "required": [
        "status",
        "recommendableToday",
        "reasons",
        "depthDisagreement",
        "seasonOpening",
        "seasonClosing",
        "baseDepthIn",
        "operatorBaseDepthIn",
        "newSnow24hIn",
        "newSnow48hIn",
        "sweIn",
        "liftsOpen",
        "liftsTotal",
        "runsOpen",
        "runsTotal",
        "surface",
        "snowQuality",
        "tempF",
        "windMph",
        "forecastNext48hCm",
        "percentOfNormal"
      ],
      "additionalProperties": false
    },
    "DepthDisagreement": {
      "type": "object",
      "properties": {
        "measuredIn": {
          "type": "number"
        },
        "operatorIn": {
          "type": "number"
        },
        "differencePct": {
          "type": "number",
          "description": "|measured − operator| as a percent of the larger value; present only above 30 %."
        },
        "preferred": {
          "type": "string",
          "const": "measured"
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "measuredIn",
        "operatorIn",
        "differencePct",
        "preferred",
        "note"
      ],
      "additionalProperties": false
    },
    "FreshnessTier": {
      "type": "string",
      "enum": [
        "live",
        "recent",
        "estimated",
        "stale",
        "unknown"
      ]
    },
    "MeasuredNow": {
      "type": "object",
      "properties": {
        "stationId": {
          "type": "string",
          "description": "PeakCam station id; joins `stations[]`."
        },
        "role": {
          "type": "string",
          "enum": [
            "summit",
            "mid",
            "base",
            "approach"
          ],
          "description": "summit / mid / base by the station's elevation against the resort's vertical."
        },
        "source": {
          "$ref": "#/$defs/StationSource"
        },
        "sourceId": {
          "type": "string",
          "description": "The provider's own station id, e.g. `AMB`, `1308:UT:SNTL`, `USC00420072`."
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "elevationFt": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Station elevation. Every value below describes this elevation."
        },
        "distanceKm": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "Great-circle distance from the resort's coordinates."
        },
        "observedAt": {
          "type": "string",
          "description": "ISO-8601 instant of the observation; a daily value is stamped at the end of its UTC day."
        },
        "ageMinutes": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Minutes between `observedAt` and `generatedAt`. Daily sources read 1,440 or more; hourly sources under 120 when live."
        },
        "snowDepthIn": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "sweIn": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "newSnowIn": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "description": "New snow over the provider's own period (24 h for daily sources), inches. Null for hourly sources, which do not measure it."
        },
        "tempF": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "windMph": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "attribution": {
          "type": "string",
          "description": "The credit line the provider's terms ask for."
        }
      },
      "required": [
        "stationId",
        "role",
        "source",
        "sourceId",
        "name",
        "elevationFt",
        "distanceKm",
        "observedAt",
        "ageMinutes",
        "snowDepthIn",
        "sweIn",
        "newSnowIn",
        "tempF",
        "windMph",
        "attribution"
      ],
      "additionalProperties": false
    },
    "ResortStatus": {
      "type": "string",
      "enum": [
        "OPEN",
        "CLOSED_TODAY",
        "PRE_SEASON",
        "OFF_SEASON",
        "UNKNOWN"
      ]
    },
    "StationSource": {
      "type": "string",
      "enum": [
        "snotel",
        "ghcn",
        "nws",
        "bc_asws",
        "eccc"
      ]
    }
  }
}