{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mindthegates-uk/json-schema/mindthegates-uk-crossing-schema.json",
  "title": "Crossing",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mindthegates-uk-openapi.json#/components/schemas/Crossing",
  "type": "object",
  "required": [
    "api",
    "slug",
    "name",
    "generated_at",
    "status",
    "timeline"
  ],
  "properties": {
    "api": {
      "type": "integer",
      "const": 1
    },
    "slug": {
      "type": "string",
      "description": "Word slug, as in the page URL"
    },
    "name": {
      "type": "string"
    },
    "type": {
      "type": [
        "string",
        "null"
      ],
      "description": "Crossing type in plain words"
    },
    "region": {
      "type": [
        "string",
        "null"
      ],
      "description": "Network Rail route or NI"
    },
    "source": {
      "type": "string",
      "enum": [
        "nr",
        "nir"
      ],
      "description": "nr: Great Britain, live feeds can confirm. nir: Northern Ireland, timetable forecast only"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "status": {
      "type": "object",
      "required": [
        "state",
        "confirmed",
        "until",
        "marginal"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "open",
            "closed",
            "unknown"
          ]
        },
        "confirmed": {
          "type": "boolean",
          "description": "True only when signalling data proves the barriers down"
        },
        "confirmed_source": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "signalling",
            "monitor",
            null
          ]
        },
        "until": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Median estimate of when the state changes; show with ~"
        },
        "marginal": {
          "type": "boolean",
          "description": "Open, but the next closure may be starting"
        },
        "held_note": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "timeline": {
      "type": "array",
      "description": "Forecast state windows for the next half hour, in order",
      "items": {
        "type": "object",
        "required": [
          "state",
          "start",
          "end"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "open",
              "closed"
            ]
          },
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "conditional": {
            "type": "boolean",
            "description": "Depends on a train that may not run"
          },
          "parked": {
            "type": "boolean",
            "description": "A train stands on the approach"
          },
          "marginal": {
            "type": "boolean"
          }
        }
      }
    },
    "direction_labels": {
      "type": "object",
      "properties": {
        "up": {
          "type": "string"
        },
        "down": {
          "type": "string"
        }
      }
    },
    "direction_captions": {
      "type": "object",
      "properties": {
        "up": {
          "type": "string"
        },
        "down": {
          "type": "string"
        }
      }
    },
    "trains": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "headcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "direction": {
            "type": [
              "string",
              "null"
            ]
          },
          "origin": {
            "type": [
              "string",
              "null"
            ]
          },
          "destination": {
            "type": [
              "string",
              "null"
            ]
          },
          "cancelled": {
            "type": "boolean"
          },
          "live": {
            "type": "boolean",
            "description": "Seen in live running data"
          },
          "delay_sec": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "disclaimer": {
          "type": "string"
        },
        "disclaimer_full": {
          "type": "string"
        },
        "disclaimer_emphasis": {
          "type": "string"
        },
        "known_coverage_gap": {
          "type": [
            "object",
            "null"
          ]
        }
      }
    }
  }
}