{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://schema.ruter.no/journey.json",
  "type": "object",
  "title": "Journey MQTT Message",
  "description": "List of stops for current journey in block",
  "required": [
    "eventTimestamp",
    "route"
  ],
  "additionalProperties": false,
  "properties": {
    "eventTimestamp": {
      "$id": "#/properties/eventTimestamp",
      "type": "string",
      "description": "Event Timestamp must be ISO 8601 UTC",
      "format": "date-time"
    },
    "journeyId": {
      "$id": "#/properties/journeyId",
      "type": "string",
      "description": "Ruter's external journey id"
    },
    "journeyRef": {
      "$id": "#/properties/journeyRef",
      "type": "string",
      "description": "Ruter's internal journey reference"
    },
    "routeChangeTimestamp": {
      "$id": "#/properties/routeChangeTimestamp",
      "type": "string",
      "description": "Event Timestamp must be ISO 8601 UTC",
      "format": "date-time"
    },
    "route": {
      "$id": "#/properties/route",
      "type": "object",
      "description": "Route information",
      "required": [
        "id",
        "name",
        "line",
        "stopPlaces"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "$id": "#/properties/route/properties/id",
          "type": "string",
          "description": "Route id"
        },
        "name": {
          "$id": "#/properties/route/properties/name",
          "type": "string",
          "description": "Public name of route"
        },
        "line": {
          "$id": "#/properties/route/properties/line",
          "type": "object",
          "description": "Line information",
          "required": [
            "id",
            "name",
            "publicCode"
          ],
          "additionalProperties": false,
          "properties": {
            "id": {
              "$id": "#/properties/route/properties/line/properties/id",
              "type": "string",
              "description": "Line id"
            },
            "name": {
              "$id": "#/properties/route/properties/line/properties/name",
              "type": "string",
              "description": "Public name of line"
            },
            "publicCode": {
              "$id": "#/properties/route/properties/line/properties/publicCode",
              "type": "string",
              "description": "Public code of line"
            }
          }
        },
        "stopPlaces": {
          "$id": "#/properties/route/properties/stopPlaces",
          "type": "array",
          "description": "Ordered list of stop places on journey",
          "items": {
            "$id": "#/properties/route/properties/stopPlaces/items",
            "type": "object",
            "description": "Stop place info",
            "required": [
              "id",
              "name",
              "connections",
              "location"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "$id": "#/properties/route/properties/stopPlaces/items/properties/id",
                "type": "string",
                "description": "Stop place id"
              },
              "name": {
                "$id": "#/properties/route/properties/stopPlaces/items/properties/name",
                "type": "string",
                "description": "Public name of stop"
              },
              "connections": {
                "$id": "#/properties/route/properties/stopPlaces/items/properties/connections",
                "type": "array",
                "description": "List of connections",
                "items": {
                  "$id": "#/properties/route/properties/stopPlaces/items/properties/connections/connection",
                  "type": "object",
                  "description": "Connection",
                  "required": [
                    "id",
                    "name",
                    "publicCode",
                    "type",
                    "colour"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "$id": "#/properties/route/properties/stopPlaces/items/properties/connections/connection/properties/id",
                      "type": "string",
                      "description": "Line id"
                    },
                    "name": {
                      "$id": "#/properties/route/properties/stopPlaces/items/properties/connections/connection/properties/name",
                      "type": "string",
                      "description": "Public name"
                    },
                    "publicCode": {
                      "$id": "#/properties/route/properties/stopPlaces/items/properties/connections/connection/properties/publicCode",
                      "type": "string",
                      "description": "Public code"
                    },
                    "type": {
                      "$id": "#/properties/route/properties/stopPlaces/items/properties/connections/connection/properties/transportType",
                      "type": "string",
                      "title": "TransportType",
                      "description": "Transport type",
                      "enum": [
                        "BUS",
                        "TRAM",
                        "METRO",
                        "TRAIN",
                        "BOAT",
                        "OTHER"
                      ]
                    },
                    "colour": {
                      "$id": "#/properties/route/properties/stopPlaces/items/properties/connections/connection/properties/colour",
                      "type": "string",
                      "description": "Hex value of display colour",
                      "examples": [
                        "e60000"
                      ],
                      "pattern": "^[0-9a-fA-F]{6}$"
                    }
                  }
                }
              },
              "location": {
                "$id": "#/properties/route/properties/stopPlaces/items/properties/location",
                "type": "object",
                "description": "Coordinates of stop place",
                "required": [
                  "latitude",
                  "longitude"
                ],
                "additionalProperties": false,
                "properties": {
                  "latitude": {
                    "$id": "#/properties/route/properties/stopPlaces/items/properties/location/properties/latitude",
                    "type": "number",
                    "description": "Latitude",
                    "minimum": -90.0000,
                    "maximum": 90.0000
                  },
                  "longitude": {
                    "$id": "#/properties/route/properties/stopPlaces/items/properties/location/properties/longitude",
                    "type": "number",
                    "description": "Longitude",
                    "minimum": -180.0000,
                    "maximum": 180.0000
                  }
                }
              },
              "description": {
                "$id": "#/properties/route/properties/stopPlaces/items/properties/description",
                "type": "string",
                "description": "Description for travelers"
              },
              "publicCode": {
                "$id": "#/properties/route/properties/stopPlaces/items/properties/publicCode",
                "type": "string",
                "description": "Public code for a stop"
              }
            }
          }
        }
      }
    }
  }
}
