{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/digitraffic-fi/json-schema/digitraffic-fi-train-running-message-schema.json",
  "title": "TrainRunningMessage",
  "description": "TrainRunMessages are generated when a train either enters or exists a TrackSection",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/digitraffic-fi-rail-api-openapi.yml#/components/schemas/TrainRunningMessage",
  "required": [
    "departureDate",
    "trainNumber"
  ],
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "format": "int64"
    },
    "version": {
      "type": "integer",
      "format": "int64"
    },
    "trainNumber": {
      "type": "string",
      "description": "Identifies the train inside a single departure date"
    },
    "departureDate": {
      "type": "string",
      "description": "Date of the train's first departure",
      "format": "date"
    },
    "timestamp": {
      "type": "string",
      "description": "Timestamp when the message was generated",
      "format": "date-time"
    },
    "trackSection": {
      "type": "string"
    },
    "nextTrackSection": {
      "type": "string"
    },
    "previousTrackSection": {
      "type": "string"
    },
    "station": {
      "type": "string"
    },
    "nextStation": {
      "type": "string"
    },
    "previousStation": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "description": "OCCUPY = train entered TrackSection, RELEASE = train exited TrackSection",
      "enum": [
        "OCCUPY",
        "RELEASE"
      ]
    }
  }
}