diff --git a/README.md b/README.md index 0bd90fde3..08723ed6d 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ - [Modes](#modes) - [Versions](#versions) - [Technical Information](#technical-information) + - [Data Validation](#data-validation) - [Get Involved](#get-involved) - [Membership](#membership) - [Cities Using MDS](#cities-using-mds) @@ -125,6 +126,12 @@ The MDS specification is versioned using Git tags and [semantic versioning](http * [MDS Releases](https://github.com/openmobilityfoundation/governance/wiki/Releases) - current/recommended versions, timeline * [Release Guidelines](https://github.com/openmobilityfoundation/governance/blob/main/technical/ReleaseGuidelines.md) +## Data Validation + +To help with MDS data and feed validation, please see our OpenAPI schema description in the OMF [mds-openapi](https://github.com/openmobilityfoundation/mds-openapi) repository. Browsable interactive documentation is also linked to in that repository. + +Starting with MDS 2.0, OpenAPI documents describe MDS endpoints and allow for [schema](/schema) validation, expanding on the JSON Schemas formerly housed in this repository. + [Top][toc] # Get Involved diff --git a/agency/README.md b/agency/README.md index adce04069..3b74203bb 100644 --- a/agency/README.md +++ b/agency/README.md @@ -69,6 +69,12 @@ See the [GBFS Requirement](/README.md#gbfs-requirement) language for more detail [Top][toc] +### Data Schema + +See the [Endpoints](#endpoints) below for information on their specific schema, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation. + +[Top][toc] + ## Vehicles The `/vehicles` endpoints allow providers to register and update the properties of their fleet vehicles, and query current vehicle properties and status. diff --git a/agency/get_stops.json b/agency/get_stops.json deleted file mode 100644 index a966091c3..000000000 --- a/agency/get_stops.json +++ /dev/null @@ -1,308 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/get_stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, GET stops payload", - "type": "object", - "definitions": { - "stop": { - "$id": "#/definitions/stop", - "type": "object", - "description": "The common schema elements for a Stop in MDS", - "required": [ - "stop_id", - "name", - "last_reported", - "location", - "status", - "capacity", - "num_vehicles_available", - "num_vehicles_disabled" - ], - "properties": { - "stop_id": { - "$id": "#/definitions/stop/properties/stop_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "name": { - "$id": "#/definitions/stop/properties/name", - "$ref": "#/definitions/string", - "description": "Name of the Stop" - }, - "last_reported": { - "$id": "#/definitions/stop/properties/last_reported", - "$ref": "#/definitions/timestamp", - "description": "Date/Time of the last status update for this Stop" - }, - "location": { - "$id": "#/definitions/stop/properties/location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Location of the stop" - }, - "status": { - "$id": "#/definitions/stop/properties/status", - "$ref": "#/definitions/stop_status", - "description": "The status of the Stop" - }, - "capacity": { - "$id": "#/definitions/stop/properties/capacity", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of total places per vehicle_type" - }, - "num_vehicles_available": { - "$id": "#/definitions/stop/properties/num_vehicles_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of available vehicles per vehicle_type" - }, - "num_vehicles_disabled": { - "$id": "#/definitions/stop/properties/num_vehicles_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of non_operational/reserved vehicles per vehicle_type" - }, - "provider_id": { - "$id": "#/definitions/stop/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Provider managing this Stop. Null/undefined if managed by an Agency." - }, - "geography_id": { - "$id": "#/definitions/stop/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "region_id": { - "$id": "#/definitions/stop/properties/region_id", - "$ref": "#/definitions/string", - "description": "ID of the region where the Stop is located. See GBFS Station Information." - }, - "short_name": { - "$id": "#/definitions/stop/properties/short_name", - "$ref": "#/definitions/string", - "description": "Abbreviated Stop name" - }, - "address": { - "$id": "#/definitions/stop/properties/address", - "$ref": "#/definitions/string", - "description": "Postal address (useful for directions)" - }, - "post_code": { - "$id": "#/definitions/stop/properties/post_code", - "$ref": "#/definitions/string", - "description": "Postal code (e.g. 10036)" - }, - "cross_street": { - "$id": "#/definitions/stop/properties/cross_street", - "$ref": "#/definitions/string", - "description": "Cross street of where Stop is located" - }, - "num_places_available": { - "$id": "#/definitions/stop/properties/num_places_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places free to be populated per vehicle_type" - }, - "num_places_disabled": { - "$id": "#/definitions/stop/properties/num_places_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places disabled an unable to accept vehicles per vehicle_type" - }, - "parent_stop": { - "$id": "#/definitions/stop/properties/parent_stop", - "$ref": "#/definitions/uuid", - "description": "Describe a basic hierarchy of Stops (e.g. a Stop inside a greater Stop)" - }, - "devices": { - "$id": "#/definitions/stop/properties/devices", - "$ref": "#/definitions/uuid_array", - "description": "List of device_id for vehicles currently at this Stop." - } - } - }, - "stop_status": { - "$id": "#/definitions/stop_status", - "type": "object", - "description": "Status object for a Stop in MDS", - "required": [ - "is_installed", - "is_renting", - "is_returning" - ], - "properties": { - "is_installed": { - "$id": "#/definitions/stop_status/properties/is_installed", - "type": "boolean" - }, - "is_renting": { - "$id": "#/definitions/stop_status/properties/is_renting", - "type": "boolean" - }, - "is_returning": { - "$id": "#/definitions/stop_status/properties/is_returning", - "type": "boolean" - } - } - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "vehicle_type_counts": { - "$id": "#/definitions/vehicle_type_counts", - "type": "object", - "properties": { - "bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/bicycle", - "type": "integer", - "minimum": 0 - }, - "cargo_bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/cargo_bicycle", - "type": "integer", - "minimum": 0 - }, - "car": { - "$id": "#/definitions/vehicle_type_counts/properties/car", - "type": "integer", - "minimum": 0 - }, - "scooter": { - "$id": "#/definitions/vehicle_type_counts/properties/scooter", - "type": "integer", - "minimum": 0 - }, - "moped": { - "$id": "#/definitions/vehicle_type_counts/properties/moped", - "type": "integer", - "minimum": 0 - }, - "other": { - "$id": "#/definitions/vehicle_type_counts/properties/other", - "type": "integer", - "minimum": 0 - } - }, - "additionalProperties": false - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - } - }, - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/stops", - "type": "array", - "description": "The array of stops", - "items": { - "$ref": "#/definitions/stop" - } - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/agency/get_vehicle.json b/agency/get_vehicle.json deleted file mode 100644 index d03929f6b..000000000 --- a/agency/get_vehicle.json +++ /dev/null @@ -1,332 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/get_vehicle.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, GET vehicle payload", - "type": "object", - "definitions": { - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_events": { - "$id": "#/definitions/vehicle_events", - "type": "array", - "description": "Array of events indicating a change to a vehicle's state", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/vehicle_event" - } - } - }, - "required": [ - "provider_id", - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types", - "year", - "mfgr", - "model", - "state", - "prev_events", - "updated" - ], - "properties": { - "provider_id": { - "$id": "#/definitions/vehicle/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "The UUID for the Provider, unique within MDS" - }, - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - }, - "year": { - "$id": "#/properties/year", - "type": "integer", - "description": "The year the vehicle was manufactured", - "default": 1970, - "examples": [ - 2018 - ] - }, - "mfgr": { - "$id": "#/properties/mfgr", - "$ref": "#/definitions/string", - "description": "The vehicle manufacturer" - }, - "model": { - "$id": "#/properties/model", - "$ref": "#/definitions/string", - "description": "The vehicle model" - }, - "state": { - "$id": "#/properties/state", - "$ref": "#/definitions/vehicle_state", - "description": "Current vehicle state" - }, - "prev_events": { - "$id": "#/properties/prev_events", - "$ref": "#/definitions/vehicle_events", - "description": "Last vehicle event" - }, - "updated": { - "$id": "#/properties/updated", - "$ref": "#/definitions/timestamp" - } - }, - "additionalProperties": false, - "allOf": [ - { - "description": "valid vehicle_state and vehicle_events combinations", - "oneOf": [ - { - "properties": { - "state": { - "const": "available" - }, - "prev_events": { - "contains": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "located", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "state": { - "const": "elsewhere" - }, - "prev_events": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_leave_jurisdiction", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "state": { - "const": "non_operational" - }, - "prev_events": { - "contains": { - "enum": [ - "battery_low", - "comms_restored", - "located", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "state": { - "const": "on_trip" - }, - "prev_events": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_enter_jurisdiction", - "trip_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "state": { - "const": "removed" - }, - "prev_events": { - "contains": { - "enum": [ - "agency_pick_up", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "state": { - "const": "reserved" - }, - "prev_events": { - "contains": { - "enum": [ - "comms_restored", - "located", - "reservation_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "state": { - "const": "unknown" - }, - "prev_events": { - "contains": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - } - } - } - ] - } - ] -} \ No newline at end of file diff --git a/agency/post_stops.json b/agency/post_stops.json deleted file mode 100644 index 570973b92..000000000 --- a/agency/post_stops.json +++ /dev/null @@ -1,308 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, register Stops", - "type": "object", - "definitions": { - "stop": { - "$id": "#/definitions/stop", - "type": "object", - "description": "The common schema elements for a Stop in MDS", - "required": [ - "stop_id", - "name", - "last_reported", - "location", - "status", - "capacity", - "num_vehicles_available", - "num_vehicles_disabled" - ], - "properties": { - "stop_id": { - "$id": "#/definitions/stop/properties/stop_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "name": { - "$id": "#/definitions/stop/properties/name", - "$ref": "#/definitions/string", - "description": "Name of the Stop" - }, - "last_reported": { - "$id": "#/definitions/stop/properties/last_reported", - "$ref": "#/definitions/timestamp", - "description": "Date/Time of the last status update for this Stop" - }, - "location": { - "$id": "#/definitions/stop/properties/location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Location of the stop" - }, - "status": { - "$id": "#/definitions/stop/properties/status", - "$ref": "#/definitions/stop_status", - "description": "The status of the Stop" - }, - "capacity": { - "$id": "#/definitions/stop/properties/capacity", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of total places per vehicle_type" - }, - "num_vehicles_available": { - "$id": "#/definitions/stop/properties/num_vehicles_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of available vehicles per vehicle_type" - }, - "num_vehicles_disabled": { - "$id": "#/definitions/stop/properties/num_vehicles_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of non_operational/reserved vehicles per vehicle_type" - }, - "provider_id": { - "$id": "#/definitions/stop/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Provider managing this Stop. Null/undefined if managed by an Agency." - }, - "geography_id": { - "$id": "#/definitions/stop/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "region_id": { - "$id": "#/definitions/stop/properties/region_id", - "$ref": "#/definitions/string", - "description": "ID of the region where the Stop is located. See GBFS Station Information." - }, - "short_name": { - "$id": "#/definitions/stop/properties/short_name", - "$ref": "#/definitions/string", - "description": "Abbreviated Stop name" - }, - "address": { - "$id": "#/definitions/stop/properties/address", - "$ref": "#/definitions/string", - "description": "Postal address (useful for directions)" - }, - "post_code": { - "$id": "#/definitions/stop/properties/post_code", - "$ref": "#/definitions/string", - "description": "Postal code (e.g. 10036)" - }, - "cross_street": { - "$id": "#/definitions/stop/properties/cross_street", - "$ref": "#/definitions/string", - "description": "Cross street of where Stop is located" - }, - "num_places_available": { - "$id": "#/definitions/stop/properties/num_places_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places free to be populated per vehicle_type" - }, - "num_places_disabled": { - "$id": "#/definitions/stop/properties/num_places_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places disabled an unable to accept vehicles per vehicle_type" - }, - "parent_stop": { - "$id": "#/definitions/stop/properties/parent_stop", - "$ref": "#/definitions/uuid", - "description": "Describe a basic hierarchy of Stops (e.g. a Stop inside a greater Stop)" - }, - "devices": { - "$id": "#/definitions/stop/properties/devices", - "$ref": "#/definitions/uuid_array", - "description": "List of device_id for vehicles currently at this Stop." - } - } - }, - "stop_status": { - "$id": "#/definitions/stop_status", - "type": "object", - "description": "Status object for a Stop in MDS", - "required": [ - "is_installed", - "is_renting", - "is_returning" - ], - "properties": { - "is_installed": { - "$id": "#/definitions/stop_status/properties/is_installed", - "type": "boolean" - }, - "is_renting": { - "$id": "#/definitions/stop_status/properties/is_renting", - "type": "boolean" - }, - "is_returning": { - "$id": "#/definitions/stop_status/properties/is_returning", - "type": "boolean" - } - } - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "vehicle_type_counts": { - "$id": "#/definitions/vehicle_type_counts", - "type": "object", - "properties": { - "bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/bicycle", - "type": "integer", - "minimum": 0 - }, - "cargo_bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/cargo_bicycle", - "type": "integer", - "minimum": 0 - }, - "car": { - "$id": "#/definitions/vehicle_type_counts/properties/car", - "type": "integer", - "minimum": 0 - }, - "scooter": { - "$id": "#/definitions/vehicle_type_counts/properties/scooter", - "type": "integer", - "minimum": 0 - }, - "moped": { - "$id": "#/definitions/vehicle_type_counts/properties/moped", - "type": "integer", - "minimum": 0 - }, - "other": { - "$id": "#/definitions/vehicle_type_counts/properties/other", - "type": "integer", - "minimum": 0 - } - }, - "additionalProperties": false - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - } - }, - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/stops", - "type": "array", - "description": "The array of stops", - "items": { - "$ref": "#/definitions/stop" - } - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/agency/post_vehicle.json b/agency/post_vehicle.json deleted file mode 100644 index 21d14ec21..000000000 --- a/agency/post_vehicle.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_vehicle.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, register vehicle body", - "type": "object", - "definitions": { - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - } - }, - "required": [ - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types" - ], - "properties": { - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - }, - "year": { - "$id": "#/properties/year", - "type": "integer", - "description": "The year the vehicle was manufactured", - "default": 1970, - "examples": [ - 2018 - ] - }, - "mfgr": { - "$id": "#/properties/mfgr", - "$ref": "#/definitions/string", - "description": "The vehicle manufacturer" - }, - "model": { - "$id": "#/properties/model", - "$ref": "#/definitions/string", - "description": "The vehicle model" - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/agency/post_vehicle_event.json b/agency/post_vehicle_event.json deleted file mode 100644 index 284bc2224..000000000 --- a/agency/post_vehicle_event.json +++ /dev/null @@ -1,345 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_vehicle_event.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, POST vehicle status body", - "type": "object", - "definitions": { - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "vehicle_telemetry": { - "$id": "#/definitions/vehicle_telemetry", - "type": "object", - "description": "A telemetry datum for a specific vehicle at a specific time", - "required": [ - "device_id", - "timestamp", - "gps" - ], - "additionalProperties": false, - "properties": { - "device_id": { - "$ref": "#/definitions/uuid" - }, - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "gps": { - "type": "object", - "required": [ - "lat", - "lng" - ], - "additionalProperties": false, - "properties": { - "lat": { - "type": "number", - "description": "Latitude of the location", - "minimum": -90, - "maximum": 90 - }, - "lng": { - "type": "number", - "description": "Longitude of the location", - "minimum": -180, - "maximum": 180 - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "charge": { - "type": "number", - "description": "Fraction of charge of the vehicle (required if applicable)", - "minimum": 0, - "maximum": 1 - } - } - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_events": { - "$id": "#/definitions/vehicle_events", - "type": "array", - "description": "Array of events indicating a change to a vehicle's state", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/vehicle_event" - } - } - }, - "required": [ - "vehicle_state", - "event_types", - "timestamp", - "telemetry" - ], - "properties": { - "vehicle_state": { - "$ref": "#/definitions/vehicle_state" - }, - "event_types": { - "$ref": "#/definitions/vehicle_events" - }, - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "telemetry": { - "$ref": "#/definitions/vehicle_telemetry" - }, - "trip_id": { - "$ref": "#/definitions/uuid" - } - }, - "additionalProperties": false, - "allOf": [ - { - "description": "valid vehicle_state and vehicle_events combinations", - "oneOf": [ - { - "properties": { - "vehicle_state": { - "const": "available" - }, - "event_types": { - "contains": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "located", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "elsewhere" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_leave_jurisdiction", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "non_operational" - }, - "event_types": { - "contains": { - "enum": [ - "battery_low", - "comms_restored", - "located", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "on_trip" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_enter_jurisdiction", - "trip_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "removed" - }, - "event_types": { - "contains": { - "enum": [ - "agency_pick_up", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "reserved" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "reservation_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "unknown" - }, - "event_types": { - "contains": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - } - } - } - ] - }, - { - "description": "Conditionally require a trip_id reference", - "anyOf": [ - { - "not": { - "properties": { - "event_types": { - "contains": { - "enum": [ - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start" - ] - } - } - } - } - }, - { - "required": [ - "trip_id" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/agency/post_vehicle_telemetry.json b/agency/post_vehicle_telemetry.json deleted file mode 100644 index 021c9d8e1..000000000 --- a/agency/post_vehicle_telemetry.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_vehicle_telemetry.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, POST vehicle telemetry body", - "type": "object", - "definitions": { - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "vehicle_telemetry": { - "$id": "#/definitions/vehicle_telemetry", - "type": "object", - "description": "A telemetry datum for a specific vehicle at a specific time", - "required": [ - "device_id", - "timestamp", - "gps" - ], - "additionalProperties": false, - "properties": { - "device_id": { - "$ref": "#/definitions/uuid" - }, - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "gps": { - "type": "object", - "required": [ - "lat", - "lng" - ], - "additionalProperties": false, - "properties": { - "lat": { - "type": "number", - "description": "Latitude of the location", - "minimum": -90, - "maximum": 90 - }, - "lng": { - "type": "number", - "description": "Longitude of the location", - "minimum": -180, - "maximum": 180 - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "charge": { - "type": "number", - "description": "Fraction of charge of the vehicle (required if applicable)", - "minimum": 0, - "maximum": 1 - } - } - } - }, - "required": [ - "data" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/vehicle_telemetry" - } - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/agency/put_stops.json b/agency/put_stops.json deleted file mode 100644 index 5f510cdbd..000000000 --- a/agency/put_stops.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/put_stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, update Stops", - "type": "object", - "definitions": { - "stop_status": { - "$id": "#/definitions/stop_status", - "type": "object", - "description": "Status object for a Stop in MDS", - "required": [ - "is_installed", - "is_renting", - "is_returning" - ], - "properties": { - "is_installed": { - "$id": "#/definitions/stop_status/properties/is_installed", - "type": "boolean" - }, - "is_renting": { - "$id": "#/definitions/stop_status/properties/is_renting", - "type": "boolean" - }, - "is_returning": { - "$id": "#/definitions/stop_status/properties/is_returning", - "type": "boolean" - } - } - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "vehicle_type_counts": { - "$id": "#/definitions/vehicle_type_counts", - "type": "object", - "properties": { - "bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/bicycle", - "type": "integer", - "minimum": 0 - }, - "cargo_bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/cargo_bicycle", - "type": "integer", - "minimum": 0 - }, - "car": { - "$id": "#/definitions/vehicle_type_counts/properties/car", - "type": "integer", - "minimum": 0 - }, - "scooter": { - "$id": "#/definitions/vehicle_type_counts/properties/scooter", - "type": "integer", - "minimum": 0 - }, - "moped": { - "$id": "#/definitions/vehicle_type_counts/properties/moped", - "type": "integer", - "minimum": 0 - }, - "other": { - "$id": "#/definitions/vehicle_type_counts/properties/other", - "type": "integer", - "minimum": 0 - } - }, - "additionalProperties": false - } - }, - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/stops", - "type": "array", - "description": "The array of stops", - "items": { - "type": "object", - "required": [ - "stop_id" - ], - "properties": { - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "status": { - "$ref": "#/definitions/stop_status" - }, - "num_spots_disabled": { - "$ref": "#/definitions/vehicle_type_counts" - } - } - } - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/geography/README.md b/geography/README.md index a654df286..4f4131267 100644 --- a/geography/README.md +++ b/geography/README.md @@ -80,7 +80,7 @@ See the [Responses][responses] and [Error Messages][error-messages] sections. ## Schema -See the [Endpoints](#endpoints) below for links to their specific JSON Schema documents. +See the [Endpoints](#endpoints) below for links to specific data objects, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation. [Top][toc] @@ -167,9 +167,9 @@ The Geography API consists of the following endpoints: ### Geography -**Endpoint**: `/geographies/{geography_id}` -**Method**: `GET` -**Schema:** [`geography` schema](./geography.json) +**Endpoint**: `/geographies/{geography_id}` +**Method**: `GET` +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. #### Path Parameters @@ -206,9 +206,9 @@ Response codes: ### Geographies -**Endpoint**: `/geographies` -**Method**: `GET` -**Schema:** [`geographies` schema](./geographies.json) +**Endpoint**: `/geographies` +**Method**: `GET` +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. Returns: All geography objects diff --git a/geography/geographies.json b/geography/geographies.json deleted file mode 100644 index d1ebbc765..000000000 --- a/geography/geographies.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/geography/geographies.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Geographies Schema", - "type": "object", - "definitions": { - "geography": { - "$id": "#/definitions/geography", - "type": "object", - "title": "The geography object schema", - "additionalProperties": false, - "required": [ - "name", - "geography_id", - "geography_json", - "published_date" - ], - "properties": { - "name": { - "$id": "#/definitions/geography/properties/name", - "$ref": "#/definitions/string", - "description": "Name of geography" - }, - "description": { - "$id": "#/definitions/geography/properties/description", - "$ref": "#/definitions/string", - "description": "Description of geography" - }, - "geography_type": { - "$id": "#/definitions/geography/properties/geography_type", - "type": "string", - "description": "The type of geography" - }, - "geography_id": { - "$id": "#/definitions/geography/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of geography" - }, - "geography_json": { - "$id": "#/definitions/geography/properties/geography_json", - "$ref": "https://geojson.org/schema/FeatureCollection.json", - "description": "The GeoJSON FeatureCollection that defines the geographical coordinates" - }, - "effective_date": { - "$id": "#/definitions/geography/properties/effective_date", - "$ref": "#/definitions/null_timestamp", - "description": "The date at which a Geography is considered 'live'. Must be at or after published_date." - }, - "published_date": { - "$id": "#/definitions/geography/properties/published_date", - "$ref": "#/definitions/timestamp", - "description": "Timestamp at which the geography was published i.e. made immutable" - }, - "retire_date": { - "$id": "#/definitions/geography/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "Time that the geography is slated to retire. Once the retire date is passed, new policies can no longer reference it and old policies referencing it should be updated. Retired geographies should continue to be returned in the geographies list. Must be after effective_date." - }, - "prev_geographies": { - "$id": "#/definitions/geography/properties/prev_geographies", - "$ref": "#/definitions/null_uuid_array", - "description": "Unique IDs of prior geographies replaced by this one", - "uniqueItems": true - } - } - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "null_timestamp": { - "$id": "#/definitions/null_timestamp", - "type": [ - "number", - "null" - ], - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "null_uuid_array": { - "$id": "#/definitions/null_uuid_array", - "type": [ - "array", - "null" - ], - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - } - }, - "required": [ - "geographies", - "updated", - "version" - ], - "properties": { - "geographies": { - "$id": "#/properties/geographies", - "type": "array", - "title": "The array of policy objects in this payload", - "items": { - "$id": "#/properties/geographies/items", - "$ref": "#/definitions/geography" - } - }, - "updated": { - "$id": "#/properties/updated", - "$ref": "#/definitions/timestamp", - "description": "The timestamp when geographies was last updated" - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version", - "description": "The version of MDS that the geographies represents" - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/geography/geography.json b/geography/geography.json deleted file mode 100644 index 661263f80..000000000 --- a/geography/geography.json +++ /dev/null @@ -1,154 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/geography/geography.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Geography Schema", - "type": "object", - "definitions": { - "geography": { - "$id": "#/definitions/geography", - "type": "object", - "title": "The geography object schema", - "additionalProperties": false, - "required": [ - "name", - "geography_id", - "geography_json", - "published_date" - ], - "properties": { - "name": { - "$id": "#/definitions/geography/properties/name", - "$ref": "#/definitions/string", - "description": "Name of geography" - }, - "description": { - "$id": "#/definitions/geography/properties/description", - "$ref": "#/definitions/string", - "description": "Description of geography" - }, - "geography_type": { - "$id": "#/definitions/geography/properties/geography_type", - "type": "string", - "description": "The type of geography" - }, - "geography_id": { - "$id": "#/definitions/geography/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of geography" - }, - "geography_json": { - "$id": "#/definitions/geography/properties/geography_json", - "$ref": "https://geojson.org/schema/FeatureCollection.json", - "description": "The GeoJSON FeatureCollection that defines the geographical coordinates" - }, - "effective_date": { - "$id": "#/definitions/geography/properties/effective_date", - "$ref": "#/definitions/null_timestamp", - "description": "The date at which a Geography is considered 'live'. Must be at or after published_date." - }, - "published_date": { - "$id": "#/definitions/geography/properties/published_date", - "$ref": "#/definitions/timestamp", - "description": "Timestamp at which the geography was published i.e. made immutable" - }, - "retire_date": { - "$id": "#/definitions/geography/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "Time that the geography is slated to retire. Once the retire date is passed, new policies can no longer reference it and old policies referencing it should be updated. Retired geographies should continue to be returned in the geographies list. Must be after effective_date." - }, - "prev_geographies": { - "$id": "#/definitions/geography/properties/prev_geographies", - "$ref": "#/definitions/null_uuid_array", - "description": "Unique IDs of prior geographies replaced by this one", - "uniqueItems": true - } - } - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "null_timestamp": { - "$id": "#/definitions/null_timestamp", - "type": [ - "number", - "null" - ], - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "null_uuid_array": { - "$id": "#/definitions/null_uuid_array", - "type": [ - "array", - "null" - ], - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - } - }, - "required": [ - "geography", - "version" - ], - "properties": { - "geography": { - "$id": "#/properties/geography", - "$ref": "#/definitions/geography", - "description": "The geography in this payload", - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version", - "description": "The version of MDS that the geography represents" - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/jurisdiction/README.md b/jurisdiction/README.md index 085624ea5..cf1c2691f 100644 --- a/jurisdiction/README.md +++ b/jurisdiction/README.md @@ -86,7 +86,9 @@ Jurisdictions can be served by agencies through the following REST API, or via [ ## Schema -A Jurisdiction optionally contains a reference to a Geography object. This reference may change over time, e.g. if two +See the [Endpoints](#endpoints) below for information on their specific schema, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation. + +A Jurisdiction optionally contains a reference to a Geography object. When a Jurisdiction is updated, the old version should remain in the back-end for archival purposes. diff --git a/metrics/README.md b/metrics/README.md index 29510ec5d..af0529c39 100644 --- a/metrics/README.md +++ b/metrics/README.md @@ -14,6 +14,7 @@ The Metrics API endpoints are intended to be implemented by regulatory agencies, - [Data Requirements](#data-requirements) - [Beta Feature](#beta-feature) - [Date and Time Format](#date-and-time-format) +- [Data Schema](#data-schema) - [Data Redaction](#data-redaction) - [Metrics Discovery API](#metrics-discovery-api) - [Metrics Query API](#metrics-query-api) @@ -98,6 +99,12 @@ All interval durations (duration) are [ISO 8601](https://en.wikipedia.org/wiki/I [Top][toc] +## Data Schema + +See the [Endpoints](#endpoints) below for information on their specific schema, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation. + +[Top][toc] + ## Data Redaction Some combinations of dimensions, filters, time, and geography may return a small count of trips, which could increase a privacy risk of re-identification. To correct for that, Metrics does not return data below a certain count of results. This data redaction is called k-anonymity, and the threshold is set at a k-value of 10. For more explanation of this methodology, see our [Data Redaction Guidance document](https://github.com/openmobilityfoundation/mobility-data-specification/wiki/MDS-Data-Redaction). diff --git a/policy/README.md b/policy/README.md index 326e36194..82cab4c59 100644 --- a/policy/README.md +++ b/policy/README.md @@ -25,7 +25,7 @@ This specification describes the digital relationship between _mobility as a ser - [Example `policies.json`](#example-policiesjson) - [Example `geographies.json`](#example-geographiesjson) - [Schema](#schema) - - [JSON Schema](#json-schema) + - [Data Schema](#data-schema) - [Policy](#policy) - [Rules](#rules) - [Rule Types](#rule-types) @@ -142,8 +142,8 @@ See the [Responses section][responses] for information on valid MDS response cod **Endpoint**: `/policies/{policy_id}` **Method**: `GET` +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **Authorization**: public -**Schema:** [`policy` schema][json-schema] **`data` Payload**: `{ "policies": [] }`, an array of objects with the structure [outlined below](#policy). _Path Parameters:_ @@ -176,9 +176,9 @@ Policies will be returned in order of effective date (see schema below), with pa **Endpoint**: `/requirements/` **Method**: `GET` +**[Beta feature](/general-information.md#beta-features)**: *No (as of 2.0.0)*. **Authorization**: public -**[Beta feature](/general-information.md#beta-features)**: *No (as of 2.0.0)*. -**Schema:** TBD +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload**: `{ requirements: [] }`, JSON objects that follow the schema [outlined here](#requirement). See [Policy Requirements Examples](/policy/examples/requirements.md) for how this can be implemented. @@ -257,9 +257,9 @@ Response bodies must be a `UTF-8` encoded JSON object and must minimally include } ``` -### JSON Schema +### Data Schema -The JSON Schema file is available in this repository: [`policy.json`](./policy.json). +See the [Endpoints](#endpoints) below for information on their specific schema, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation. Before publishing a new Policy document, the document should be validated against the schema to ensure it has the correct format and fields. @@ -272,7 +272,8 @@ An individual `Policy` object is defined by the following fields: | Name | Type | Required / Optional | Description | | ---------------- | --------------- | ---------- | ----------------------------------------------------------------------------------- | | `name` | String | Required | Name of policy | -| `mode_id` | [Mode][modes] | Required | Mode this rule should apply, see MDS [mode list][modes] for options. Default `micromobility` for backwards compatibility (this default will likely be removed in a subsequent MDS release) | +| `mode` | [Mode][modes] | Required | Mode this rule should apply, see MDS [mode list][modes] for options. Default `micromobility` for backwards compatibility (this default will likely be removed in a subsequent MDS release) | +| `mode_id` | [Mode][modes] | Required | Mode this rule should apply, see MDS [mode list][modes] for options. Default `micromobility` for backwards compatibility (this default will likely be removed in a subsequent MDS release) | | `policy_id` | UUID | Required | Unique ID of policy | | `provider_ids` | UUID[] | Optional | Providers for whom this policy is applicable; empty arrays and `null`/absent implies all Providers. See MDS [provider list](/providers.csv). | | `description` | String | Required | Description of policy | diff --git a/policy/policy.json b/policy/policy.json deleted file mode 100644 index 8e173d5e3..000000000 --- a/policy/policy.json +++ /dev/null @@ -1,645 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/policy/policy.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Policy Schema", - "type": "object", - "definitions": { - "policy": { - "$id": "#/definitions/policy", - "type": "object", - "title": "The policy object schema", - "additionalProperties": false, - "required": [ - "name", - "policy_id", - "description", - "start_date", - "published_date", - "rules" - ], - "properties": { - "name": { - "$id": "#/definitions/policy/properties/name", - "$ref": "#/definitions/string", - "description": "Name of policy" - }, - "policy_id": { - "$id": "#/definitions/policy/properties/policy_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of policy" - }, - "provider_ids": { - "$id": "#/definitions/policy/properties/provider_ids", - "$ref": "#/definitions/null_uuid_array", - "description": "Providers for whom this policy is applicable; empty arrays and null/absent implies all Providers.", - "uniqueItems": true - }, - "description": { - "$id": "#/definitions/policy/properties/description", - "$ref": "#/definitions/string", - "description": "Description of policy" - }, - "currency": { - "$id": "#/definitions/policy/properties/currency", - "$ref": "#/definitions/currency" - }, - "start_date": { - "$id": "#/definitions/policy/properties/start_date", - "$ref": "#/definitions/timestamp", - "description": "Beginning date/time of policy enforcement" - }, - "end_date": { - "$id": "#/definitions/policy/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "End date/time of policy enforcement" - }, - "published_date": { - "$id": "#/definitions/policy/properties/published_date", - "$ref": "#/definitions/timestamp", - "description": "Timestamp at which the policy was published" - }, - "prev_policies": { - "$id": "#/definitions/policy/properties/prev_policies", - "$ref": "#/definitions/null_uuid_array", - "description": "Unique IDs of prior policies replaced by this one", - "uniqueItems": true - }, - "rules": { - "$id": "#/definitions/rules", - "type": "array", - "description": "Array of applicable Rule objects", - "items": { - "$id": "#/definitions/policy/properties/rules/items", - "$ref": "#/definitions/rule" - }, - "minItems": 1 - } - } - }, - "rule": { - "$id": "#/definitions/rule", - "type": "object", - "description": "An individual rule in a policy", - "additionalProperties": false, - "required": [ - "name", - "rule_id", - "rule_type", - "geographies", - "states" - ], - "properties": { - "name": { - "$id": "#/definitions/rule/properties/name", - "$ref": "#/definitions/string", - "description": "Name of rule" - }, - "rule_id": { - "$id": "#/definitions/rule/properties/rule_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of rule" - }, - "rule_type": { - "$id": "#/definitions/rule/properties/rule_type", - "type": "string", - "description": "The type of rule", - "enum": [ - "count", - "time", - "speed", - "user" - ] - }, - "geographies": { - "$id": "#/definitions/rule/properties/geographies", - "$ref": "#/definitions/uuid_array", - "description": "List of Geography UUIDs (non-overlapping) specifying the covered geography", - "minItems": 1, - "uniqueItems": true - }, - "states": { - "$id": "#/definitions/rule/properties/states", - "type": "object", - "description": "Vehicle state to which this rule applies. Optionally provide a list of specific vehicle events as a subset of a given state for the rule to apply to. An empty list or null/absent defaults to \"all\" for the state.", - "propertyNames": { - "$id": "#/definitions/rule/properties/states/propertyNames", - "$ref": "#/definitions/vehicle_state" - }, - "properties": {}, - "additionalProperties": { - "type": "array", - "uniqueItems": true, - "items": { - "$ref": "#/definitions/vehicle_event" - } - } - }, - "rule_units": { - "$id": "#/definitions/rule/properties/rule_units", - "type": "string", - "description": "Measured units of policy", - "enum": [ - "seconds", - "minutes", - "hours", - "days", - "mph", - "kph", - "devices", - "amount" - ] - }, - "vehicle_types": { - "$id": "#/definitions/rule/properties/vehicle_types", - "$ref": "#/definitions/null_vehicle_types", - "description": "Applicable vehicle types, default \"all\"" - }, - "propulsion_types": { - "$id": "#/definitions/rule/properties/propulsion_types", - "$ref": "#/definitions/null_propulsion_types", - "description": "Applicable vehicle propulsion types, default \"all\"" - }, - "minimum": { - "$id": "#/definitions/rule/properties/minimum", - "type": [ - "null", - "integer" - ], - "description": "Minimum value, if applicable (default 0)" - }, - "maximum": { - "$id": "#/definitions/rule/properties/maximum", - "type": [ - "null", - "integer" - ], - "description": "Maximum value, if applicable (default unlimited)" - }, - "inclusive_minimum": { - "$id": "#/definitions/rule/properties/inclusive_minimum", - "type": [ - "null", - "boolean" - ], - "description": "Whether the rule minimum is considered in-bounds (default true)" - }, - "inclusive_maximum": { - "$id": "#/definitions/rule/properties/inclusive_maximum", - "type": [ - "null", - "boolean" - ], - "description": "Whether the rule maximum is considered in-bounds (default true)" - }, - "rate_amount": { - "$id": "#/definitions/rule/properties/rate_amount", - "type": [ - "null", - "integer" - ], - "description": "The amount of a rate applied when this rule applies, if applicable (default zero). A positive integer rate amount represents a fee, while a negative integer represents a subsidy. Rate amounts are given in the currency defined in the Policy." - }, - "rate_recurrence": { - "$id": "#/definitions/rule/properties/rate_recurrence", - "type": [ - "string", - "null" - ], - "description": "Specify how a rate is applied \u00e2\u20ac\u201c either once, or periodically according to a time unit specified using rule_units", - "enum": [ - "once_on_match", - "once_on_unmatch", - "each_time_unit", - "per_complete_time_unit" - ] - }, - "rate_applies_when": { - "$id": "#/definitions/rule/properties/rate_applies_when", - "type": [ - "string", - "null" - ], - "description": "Specify when a rate is applicable to an event or count: when it's within rule bounds or when it is not", - "enum": [ - "in_bounds", - "out_of_bounds" - ] - }, - "start_time": { - "$id": "#/definitions/rule/properties/start_time", - "$ref": "#/definitions/null_iso_time", - "description": "Beginning time-of-day when the rule is in effect (default 00:00:00)" - }, - "end_time": { - "$id": "#/definitions/rule/properties/end_time", - "$ref": "#/definitions/null_iso_time", - "description": "Ending time-of-day when the rule is in effect (default 23:59:59)" - }, - "days": { - "$id": "#/definitions/rule/properties/days", - "$ref": "#/definitions/null_days", - "description": "Days when the rule is in effect (default all)" - }, - "messages": { - "$id": "#/definitions/rule/properties/messages", - "type": [ - "null", - "object" - ], - "description": "Message to rider user, if desired, in various languages, keyed by BCP 47 language tag", - "propertyNames": { - "pattern": "([A-Za-z]{2,3})([-][A-Za-z]{3}){0,3}([-]([A-Za-z]{4}))?([-]([A-Za-z]{2}|[0-9]{3}))?" - } - }, - "value_url": { - "$id": "#/definitions/rule/properties/value_url", - "type": [ - "null", - "string" - ], - "description": "URL to an API endpoint that can provide dynamic information for the measured value", - "format": "uri" - } - }, - "allOf": [ - { - "description": "Valid rule_type and rule_unit values for this rule", - "oneOf": [ - { - "properties": { - "rule_type": { - "const": "user" - } - } - }, - { - "allOf": [ - { - "required": [ - "rule_units" - ] - }, - { - "oneOf": [ - { - "properties": { - "rule_type": { - "const": "time" - }, - "rule_units": { - "enum": [ - "seconds", - "minutes", - "hours", - "days" - ] - } - } - }, - { - "properties": { - "rule_type": { - "const": "speed" - }, - "rule_units": { - "enum": [ - "mph", - "kph" - ] - } - } - }, - { - "properties": { - "rule_type": { - "const": "count" - }, - "rule_units": { - "enum": [ - "devices" - ] - } - } - }, - { - "required": [ - "rate_amount", - "rate_recurrence" - ], - "properties": { - "rule_units": { - "enum": [ - "amount", - "seconds", - "minutes", - "hours", - "days" - ] - } - } - } - ] - } - ] - } - ] - } - ] - }, - "currency": { - "$id": "#/definitions/currency", - "type": [ - "string", - "null" - ], - "pattern": "^[A-Z]{3}$", - "default": "USD", - "description": "An ISO 4217 Alphabetic Currency Code representing currency of the payee. If null, USD cents is implied.", - "examples": [ - "USD", - "EUR", - "GBP" - ] - }, - "day": { - "$id": "#/definitions/day", - "type": "string", - "description": "A day of the week", - "enum": [ - "sun", - "mon", - "tue", - "wed", - "thu", - "fri", - "sat" - ] - }, - "propulsion_type": { - "$id": "#/definitions/propulsion_type", - "type": "string", - "description": "The type of propulsion", - "enum": [ - "combustion", - "electric", - "electric_assist", - "human" - ] - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "days": { - "$id": "#/definitions/days", - "type": "array", - "description": "Array of days of the week", - "items": { - "$id": "#/definitions/days/items", - "$ref": "#/definitions/day" - }, - "uniqueItems": true - }, - "iso_time": { - "$id": "#/definitions/iso_time", - "type": "string", - "description": "Time-of-day expressed as ISO 8601 hh:mm:ss", - "pattern": "([0-2][0-3]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]" - }, - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "vehicle_types": { - "$id": "#/definitions/vehicle_types", - "type": "array", - "description": "Array of vehicle types", - "items": { - "$id": "#/definitions/vehicle_types/items", - "$ref": "#/definitions/vehicle_type" - }, - "uniqueItems": true - }, - "null_days": { - "$id": "#/definitions/null_days", - "type": [ - "array", - "null" - ], - "description": "Array of days of the week", - "items": { - "$id": "#/definitions/days/items", - "$ref": "#/definitions/day" - }, - "uniqueItems": true - }, - "null_iso_time": { - "$id": "#/definitions/null_iso_time", - "type": [ - "string", - "null" - ], - "description": "Time-of-day expressed as ISO 8601 hh:mm:ss", - "pattern": "([0-2][0-3]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]" - }, - "null_propulsion_types": { - "$id": "#/definitions/null_propulsion_types", - "type": [ - "array", - "null" - ], - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "null_timestamp": { - "$id": "#/definitions/null_timestamp", - "type": [ - "number", - "null" - ], - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "null_uuid_array": { - "$id": "#/definitions/null_uuid_array", - "type": [ - "array", - "null" - ], - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "null_vehicle_types": { - "$id": "#/definitions/null_vehicle_types", - "type": [ - "array", - "null" - ], - "description": "Array of vehicle types", - "items": { - "$id": "#/definitions/vehicle_types/items", - "$ref": "#/definitions/vehicle_type" - }, - "uniqueItems": true - } - }, - "required": [ - "data", - "updated", - "version" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "policies" - ], - "properties": { - "policies": { - "$id": "#/properties/data/properties/policies", - "type": "array", - "title": "The array of policy objects in this payload", - "items": { - "$id": "#/properties/data/properties/policies/items", - "$ref": "#/definitions/policy" - } - } - }, - "additionalProperties": false - }, - "end_date": { - "$id": "#/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "The timestamp after which the Policy is no longer effective" - }, - "updated": { - "$id": "#/properties/updated", - "$ref": "#/definitions/timestamp", - "description": "The timestamp when the Policy was last updated" - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version", - "description": "The version of MDS that the Policy represents" - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/provider/README.md b/provider/README.md index cd06ca705..c28834040 100644 --- a/provider/README.md +++ b/provider/README.md @@ -15,7 +15,7 @@ This specification contains a data standard for *mobility as a service* provider * [Responses and Error Messages](#responses-and-error-messages) * [GBFS](#GBFS) * [Data Latency Requirements][data-latency] - * [JSON Schema](#json-schema) + * [Data Schema](#data-schema) * [Pagination](#pagination) * [Municipality Boundary](#municipality-boundary) * [Other Data Types](#other-data-types) @@ -109,11 +109,9 @@ ttl | Yes | Integer representing the number of millisecond [Top][toc] -### JSON Schema +### Data Schema -MDS defines [JSON Schema][json-schema] files for each endpoint. - -`provider` API responses must validate against their respective schema files. The schema files always take precedence over the language and examples in this and other supporting documentation meant for *human* consumption. +See the [Endpoints](#endpoints) below for information on their specific schema, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation. [Top][toc] @@ -192,8 +190,8 @@ The `/vehicles` endpoint returns the specified vehicle (if a device_id is provid **Endpoint:** `/vehicles/{device_id}` **Method:** `GET` **[Beta feature][beta]:** No (as of 1.2.0) -**Schema:** [`vehicles` schema][vehicles-schema] -**`data` Payload:** `{ "vehicles": [] }`, an array of [Vehicle][vehicle] objects +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. +**`data` Payload:** `{ "vehicles": [] }`, an array of [Vehicle](vehicle) objects _Path Parameters:_ @@ -230,7 +228,7 @@ The `/vehicles/status` endpoint returns the specified vehicle (if a device_id is **Endpoint:** `/vehicles/status/{device_id}` **Method:** `GET` **[Beta feature][beta]:** No (as of 1.2.0) -**Schema:** N/A. +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload:** `{ "vehicles_status": [] }`, an array of [Vehicle Status][vehicle-status] objects _Path Parameters:_ @@ -272,7 +270,7 @@ Unless stated otherwise by the municipality, the trips endpoint must return all **Endpoint:** `/trips` **Method:** `GET` **[Beta feature][beta]:** No -**Schema:** [`trips` schema][trips-schema] +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload:** `{ "trips": [] }`, an array of [Trip][trips] objects ### Trips - Query Parameters @@ -326,7 +324,7 @@ Telemetry for a [trip](#trip) must include at least 2 points: the start point an **Endpoint:** `/telemetry` **Method:** `GET` -**Schema:** [`telemetry` schema][telemetry-schema] +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload:** `{ "telemetry": [] }`, an array of [Vehicle Telemetry][vehicle-telemetry] objects [Top][toc] @@ -352,7 +350,7 @@ Unless stated otherwise by the municipality, this endpoint must return only thos **Endpoint:** `/events/historical` **Method:** `GET` **[Beta feature][beta]:** No -**Schema:** [`events` schema][events-schema] +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload:** `{ "data": [] }`, an array of [Events](/data-types.md#events) object [Top][toc] @@ -403,7 +401,7 @@ See also [Stop-based Geographic Data][stop-based-geo]. **Endpoint:** `/events/recent` **Method:** `GET` **[Beta feature][beta]:** No (as of 1.0.0) -**Schema:** [`events` schema][events-schema] +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload:** `{ "events": [] }`, an array of [Events](/data-types.md#events) object objects #### Recent Events - Query Parameters @@ -441,7 +439,7 @@ In addition to the standard [Provider payload wrapper](#response-format), respon **Endpoint:** `/stops/{stop_id}` **Method:** `GET` **[Beta feature][beta]:** Yes (as of 1.0.0). [Leave feedback](https://github.com/openmobilityfoundation/mobility-data-specification/issues/638) -**Schema:** [`stops` schema][stops-schema] +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Payload:** `{ "stops": [] }`, an array of [Stops][stops] In the case that a `stop_id` path parameter is specified, the `stops` array returned will only have one entry. In the case that no `stop_id` query parameter is specified, all stops will be returned. @@ -461,8 +459,8 @@ The authenticated reports are monthly, historic flat files that may be pre-gener **Endpoint:** `/reports` **Method:** `GET` **[Beta feature][beta]:** No (as of 2.0.0). [Leave feedback](https://github.com/openmobilityfoundation/mobility-data-specification/issues/672) -**Usage note:** This endpoint uses media-type `text/vnd.mds+csv` instead of `application/vnd.mds+json`, see [Versioning][versioning]. -**Schema:** TBD +**Usage note:** This endpoint uses media-type `text/vnd.mds+csv` instead of `application/vnd.mds+json`, see [Versioning][versioning]. +**Schema:** See [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for schema. **`data` Filename:** monthly file named by year and month, e.g. `/reports/YYYY-MM.csv` **`data` Payload:** monthly CSV files of [Report](/data-types.md#Reports) objects @@ -482,7 +480,6 @@ See [Provider examples](examples.md#reports). [error-messages]: /general-information.md#error-messages [events]: /data-types.md#events [events---query-parameters]: #events---query-parameters -[events-schema]: events.json [event-times]: #event-times [gbfs]: https://github.com/NABSA/gbfs [general-information]: /general-information.md @@ -500,14 +497,11 @@ See [Provider examples](examples.md#reports). [responses]: /general-information.md#responses [stops]: /data-types.md#stops [stop-based-geo]: /general-information.md#stop-based-geographic-data -[stops-schema]: stops.json [telemetry]: /data-types.md#telemetry -[telemetry-schema]: telemetry.json [telemetry---query-parameters]: #telemetry-query-parameters [toc]: #table-of-contents [trips]: /data-types.md#trips [trips-general-info]: /general-information.md#stop-based-geographic-data -[trips-schema]: trips.json [ts]: /general-information.md#timestamps [vehicles]: /data-types.md#vehicles [vehicle]: /data-types.md#vehicles @@ -516,6 +510,5 @@ See [Provider examples](examples.md#reports). [vehicle-states]: /modes#vehicle-states [vehicle-events]: /modes#event-types [vehicle-event-data]: /general-information.md#event-data -[vehicles-schema]: vehicles.json [vehicle-telemetry]: /data-types.md#telemetry [versioning]: /general-information.md#versioning diff --git a/provider/events.json b/provider/events.json deleted file mode 100644 index b97fe8833..000000000 --- a/provider/events.json +++ /dev/null @@ -1,610 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/provider/events.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Schema for MDS Provider events payloads", - "type": "object", - "definitions": { - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "Point": { - "$id": "#/definitions/Point", - "title": "GeoJSON Point", - "type": "object", - "required": [ - "type", - "coordinates" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Point" - ] - }, - "coordinates": { - "type": "array", - "minItems": 2, - "items": [ - { - "type": "number", - "minimum": -180.0, - "maximum": 180.0 - }, - { - "type": "number", - "minimum": -90.0, - "maximum": 90.0 - } - ], - "maxItems": 2 - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "propulsion_type": { - "$id": "#/definitions/propulsion_type", - "type": "string", - "description": "The type of propulsion", - "enum": [ - "combustion", - "electric", - "electric_assist", - "human" - ] - }, - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_events": { - "$id": "#/definitions/vehicle_events", - "type": "array", - "description": "Array of events indicating a change to a vehicle's state", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/vehicle_event" - } - }, - "links": { - "$id": "#/definitions/links", - "type": "object", - "required": [ - "next" - ], - "properties": { - "first": { - "$id": "#/definitions/links/first", - "type": [ - "null", - "string" - ], - "title": "The URL to the first page of data", - "examples": [ - "https://data.provider.co/trips/first" - ], - "format": "uri" - }, - "last": { - "$id": "#/definitions/links/last", - "type": [ - "null", - "string" - ], - "title": "The URL to the last page of data", - "examples": [ - "https://data.provider.co/trips/last" - ], - "format": "uri" - }, - "prev": { - "$id": "#/definitions/links/prev", - "type": [ - "null", - "string" - ], - "title": "The URL to the previous page of data", - "examples": [ - "https://data.provider.co/trips/prev" - ], - "format": "uri" - }, - "next": { - "$id": "#/definitions/links/next", - "type": [ - "null", - "string" - ], - "title": "The URL to the next page of data", - "examples": [ - "https://data.provider.co/trips/next" - ], - "format": "uri", - "pattern": "^(.*)$" - } - }, - "additionalProperties": false - } - }, - "required": [ - "data", - "version" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "status_changes" - ], - "properties": { - "status_changes": { - "$id": "#/properties/data/properties/status_changes", - "type": "array", - "title": "The status_changes payload", - "items": { - "$id": "#/properties/data/properties/status_changes/items", - "type": "object", - "title": "The status_change item schema", - "additionalProperties": false, - "required": [ - "provider_name", - "provider_id", - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types", - "vehicle_state", - "event_types", - "event_time", - "event_location" - ], - "properties": { - "provider_name": { - "$id": "#/definitions/vehicle/properties/provider_name", - "$ref": "#/definitions/string", - "description": "The public-facing name of the Provider" - }, - "provider_id": { - "$id": "#/definitions/vehicle/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "The UUID for the Provider, unique within MDS" - }, - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - }, - "event_time": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_time", - "$ref": "#/definitions/timestamp", - "description": "The time the event occurred, expressed as a Unix Timestamp" - }, - "publication_time": { - "$id": "#/properties/data/properties/status_changes/items/properties/publication_time", - "$ref": "#/definitions/timestamp", - "description": "The time the event became available through the status changes endpoint, expressed as a Unix Timestamp" - }, - "event_location": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "The GPS or GNSS coordinates of where the event occurred" - }, - "vehicle_state": { - "$id": "#/properties/data/properties/status_changes/items/properties/vehicle_state", - "$ref": "#/definitions/vehicle_state", - "description": "The state of the vehicle" - }, - "event_types": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_types", - "$ref": "#/definitions/vehicle_events", - "description": "The event(s) that caused a change in the vehicle's state" - }, - "battery_pct": { - "$id": "#/properties/data/properties/status_changes/items/properties/battery_pct", - "type": [ - "number", - "null" - ], - "description": "Percent charge of device battery, expressed between 0 and 1", - "examples": [ - 0.89 - ], - "minimum": 0, - "maximum": 1 - }, - "trip_id": { - "$id": "#/properties/data/properties/status_changes/items/properties/trip_id", - "$ref": "#/definitions/uuid", - "description": "Trip UUID (foreign key to Trips API), required if event_types contains trip_start, trip_end, trip_cancel, trip_enter_jurisdiction, or trip_leave_jurisdiction" - }, - "associated_ticket": { - "$id": "#/properties/data/properties/status_changes/items/properties/associated_ticket", - "$ref": "#/definitions/string", - "description": "Identifier for an associated ticket inside an Agency-maintained 311 or CRM system." - } - }, - "allOf": [ - { - "description": "valid vehicle_state and vehicle_events combinations", - "oneOf": [ - { - "properties": { - "vehicle_state": { - "const": "available" - }, - "event_types": { - "contains": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "located", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "elsewhere" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_leave_jurisdiction", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "non_operational" - }, - "event_types": { - "contains": { - "enum": [ - "battery_low", - "comms_restored", - "located", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "on_trip" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_enter_jurisdiction", - "trip_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "removed" - }, - "event_types": { - "contains": { - "enum": [ - "agency_pick_up", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "reserved" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "reservation_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "unknown" - }, - "event_types": { - "contains": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - } - } - } - ] - }, - { - "description": "Conditionally require a trip_id reference", - "anyOf": [ - { - "not": { - "properties": { - "event_types": { - "contains": { - "enum": [ - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start" - ] - } - } - } - } - }, - { - "required": [ - "trip_id" - ] - } - ] - } - ] - } - } - }, - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version" - }, - "links": { - "$id": "#/properties/links", - "$ref": "#/definitions/links" - } - }, - "additionalProperties": false -} diff --git a/provider/status_changes.json b/provider/status_changes.json deleted file mode 100644 index 68faca22a..000000000 --- a/provider/status_changes.json +++ /dev/null @@ -1,547 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/provider/status_changes.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Schema for MDS Provider status_changes payloads", - "type": "object", - "definitions": { - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "Point": { - "$id": "#/definitions/Point", - "title": "GeoJSON Point", - "type": "object", - "required": [ - "type", - "coordinates" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Point" - ] - }, - "coordinates": { - "type": "array", - "minItems": 2, - "items": [ - { - "type": "number", - "minimum": -180.0, - "maximum": 180.0 - }, - { - "type": "number", - "minimum": -90.0, - "maximum": 90.0 - } - ], - "maxItems": 2 - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "propulsion_type": { - "$id": "#/definitions/propulsion_type", - "type": "string", - "description": "The type of propulsion", - "enum": [ - "combustion", - "electric", - "electric_assist", - "human" - ] - }, - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_events": { - "$id": "#/definitions/vehicle_events", - "type": "array", - "description": "Array of events indicating a change to a vehicle's state", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/vehicle_event" - } - } - }, - "required": [ - "data", - "version" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "status_changes" - ], - "properties": { - "status_changes": { - "$id": "#/properties/data/properties/status_changes", - "type": "array", - "title": "The status_changes payload", - "items": { - "$id": "#/properties/data/properties/status_changes/items", - "type": "object", - "title": "The status_change item schema", - "additionalProperties": false, - "required": [ - "provider_name", - "provider_id", - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types", - "vehicle_state", - "event_types", - "event_time", - "event_location" - ], - "properties": { - "provider_name": { - "$id": "#/definitions/vehicle/properties/provider_name", - "$ref": "#/definitions/string", - "description": "The public-facing name of the Provider" - }, - "provider_id": { - "$id": "#/definitions/vehicle/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "The UUID for the Provider, unique within MDS" - }, - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - }, - "event_time": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_time", - "$ref": "#/definitions/timestamp", - "description": "The time the event occurred, expressed as a Unix Timestamp" - }, - "publication_time": { - "$id": "#/properties/data/properties/status_changes/items/properties/publication_time", - "$ref": "#/definitions/timestamp", - "description": "The time the event became available through the status changes endpoint, expressed as a Unix Timestamp" - }, - "event_location": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "The GPS or GNSS coordinates of where the event occurred" - }, - "vehicle_state": { - "$id": "#/properties/data/properties/status_changes/items/properties/vehicle_state", - "$ref": "#/definitions/vehicle_state", - "description": "The state of the vehicle" - }, - "event_types": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_types", - "$ref": "#/definitions/vehicle_events", - "description": "The event(s) that caused a change in the vehicle's state" - }, - "battery_pct": { - "$id": "#/properties/data/properties/status_changes/items/properties/battery_pct", - "type": [ - "number", - "null" - ], - "description": "Percent charge of device battery, expressed between 0 and 1", - "examples": [ - 0.89 - ], - "minimum": 0, - "maximum": 1 - }, - "trip_id": { - "$id": "#/properties/data/properties/status_changes/items/properties/trip_id", - "$ref": "#/definitions/uuid", - "description": "Trip UUID (foreign key to Trips API), required if event_types contains trip_start, trip_end, trip_cancel, trip_enter_jurisdiction, or trip_leave_jurisdiction" - }, - "associated_ticket": { - "$id": "#/properties/data/properties/status_changes/items/properties/associated_ticket", - "$ref": "#/definitions/string", - "description": "Identifier for an associated ticket inside an Agency-maintained 311 or CRM system." - } - }, - "allOf": [ - { - "description": "valid vehicle_state and vehicle_events combinations", - "oneOf": [ - { - "properties": { - "vehicle_state": { - "const": "available" - }, - "event_types": { - "contains": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "located", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "elsewhere" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_leave_jurisdiction", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "non_operational" - }, - "event_types": { - "contains": { - "enum": [ - "battery_low", - "comms_restored", - "located", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "on_trip" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_enter_jurisdiction", - "trip_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "removed" - }, - "event_types": { - "contains": { - "enum": [ - "agency_pick_up", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "reserved" - }, - "event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "reservation_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "unknown" - }, - "event_types": { - "contains": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - } - } - } - ] - }, - { - "description": "Conditionally require a trip_id reference", - "anyOf": [ - { - "not": { - "properties": { - "event_types": { - "contains": { - "enum": [ - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start" - ] - } - } - } - } - }, - { - "required": [ - "trip_id" - ] - } - ] - } - ] - } - } - }, - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version" - } - }, - "additionalProperties": false -} diff --git a/provider/stops.json b/provider/stops.json deleted file mode 100644 index 5f9139700..000000000 --- a/provider/stops.json +++ /dev/null @@ -1,392 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/provider/stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Schema for MDS Provider stops payloads", - "type": "object", - "definitions": { - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "Point": { - "$id": "#/definitions/Point", - "title": "GeoJSON Point", - "type": "object", - "required": [ - "type", - "coordinates" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Point" - ] - }, - "coordinates": { - "type": "array", - "minItems": 2, - "items": [ - { - "type": "number", - "minimum": -180.0, - "maximum": 180.0 - }, - { - "type": "number", - "minimum": -90.0, - "maximum": 90.0 - } - ], - "maxItems": 2 - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "ttl": { - "$id": "#/definitions/ttl", - "type": "integer", - "description": "Integer milliseconds until next data update (0 if the data is always refreshed)", - "minimum": 0, - "maximum": 300000 - }, - "stop": { - "$id": "#/definitions/stop", - "type": "object", - "description": "The common schema elements for a Stop in MDS", - "required": [ - "stop_id", - "name", - "last_reported", - "location", - "status", - "capacity", - "num_vehicles_available", - "num_vehicles_disabled" - ], - "properties": { - "stop_id": { - "$id": "#/definitions/stop/properties/stop_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "name": { - "$id": "#/definitions/stop/properties/name", - "$ref": "#/definitions/string", - "description": "Name of the Stop" - }, - "last_reported": { - "$id": "#/definitions/stop/properties/last_reported", - "$ref": "#/definitions/timestamp", - "description": "Date/Time of the last status update for this Stop" - }, - "location": { - "$id": "#/definitions/stop/properties/location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Location of the stop" - }, - "status": { - "$id": "#/definitions/stop/properties/status", - "$ref": "#/definitions/stop_status", - "description": "The status of the Stop" - }, - "capacity": { - "$id": "#/definitions/stop/properties/capacity", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of total places per vehicle_type" - }, - "num_vehicles_available": { - "$id": "#/definitions/stop/properties/num_vehicles_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of available vehicles per vehicle_type" - }, - "num_vehicles_disabled": { - "$id": "#/definitions/stop/properties/num_vehicles_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of non_operational/reserved vehicles per vehicle_type" - }, - "provider_id": { - "$id": "#/definitions/stop/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Provider managing this Stop. Null/undefined if managed by an Agency." - }, - "geography_id": { - "$id": "#/definitions/stop/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "region_id": { - "$id": "#/definitions/stop/properties/region_id", - "$ref": "#/definitions/string", - "description": "ID of the region where the Stop is located. See GBFS Station Information." - }, - "short_name": { - "$id": "#/definitions/stop/properties/short_name", - "$ref": "#/definitions/string", - "description": "Abbreviated Stop name" - }, - "address": { - "$id": "#/definitions/stop/properties/address", - "$ref": "#/definitions/string", - "description": "Postal address (useful for directions)" - }, - "post_code": { - "$id": "#/definitions/stop/properties/post_code", - "$ref": "#/definitions/string", - "description": "Postal code (e.g. 10036)" - }, - "cross_street": { - "$id": "#/definitions/stop/properties/cross_street", - "$ref": "#/definitions/string", - "description": "Cross street of where Stop is located" - }, - "num_places_available": { - "$id": "#/definitions/stop/properties/num_places_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places free to be populated per vehicle_type" - }, - "num_places_disabled": { - "$id": "#/definitions/stop/properties/num_places_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places disabled an unable to accept vehicles per vehicle_type" - }, - "parent_stop": { - "$id": "#/definitions/stop/properties/parent_stop", - "$ref": "#/definitions/uuid", - "description": "Describe a basic hierarchy of Stops (e.g. a Stop inside a greater Stop)" - }, - "devices": { - "$id": "#/definitions/stop/properties/devices", - "$ref": "#/definitions/uuid_array", - "description": "List of device_id for vehicles currently at this Stop." - } - } - }, - "stop_status": { - "$id": "#/definitions/stop_status", - "type": "object", - "description": "Status object for a Stop in MDS", - "required": [ - "is_installed", - "is_renting", - "is_returning" - ], - "properties": { - "is_installed": { - "$id": "#/definitions/stop_status/properties/is_installed", - "type": "boolean" - }, - "is_renting": { - "$id": "#/definitions/stop_status/properties/is_renting", - "type": "boolean" - }, - "is_returning": { - "$id": "#/definitions/stop_status/properties/is_returning", - "type": "boolean" - } - } - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "vehicle_type_counts": { - "$id": "#/definitions/vehicle_type_counts", - "type": "object", - "properties": { - "bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/bicycle", - "type": "integer", - "minimum": 0 - }, - "cargo_bicycle": { - "$id": "#/definitions/vehicle_type_counts/properties/cargo_bicycle", - "type": "integer", - "minimum": 0 - }, - "car": { - "$id": "#/definitions/vehicle_type_counts/properties/car", - "type": "integer", - "minimum": 0 - }, - "scooter": { - "$id": "#/definitions/vehicle_type_counts/properties/scooter", - "type": "integer", - "minimum": 0 - }, - "moped": { - "$id": "#/definitions/vehicle_type_counts/properties/moped", - "type": "integer", - "minimum": 0 - }, - "other": { - "$id": "#/definitions/vehicle_type_counts/properties/other", - "type": "integer", - "minimum": 0 - } - }, - "additionalProperties": false - } - }, - "required": [ - "data", - "version", - "last_updated", - "ttl" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/data/properties/stops", - "type": "array", - "title": "The stops payload", - "items": { - "$id": "#/properties/data/properties/stops/items", - "$ref": "#/definitions/stop" - } - } - }, - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version" - }, - "last_updated": { - "$id": "#/properties/last_updated", - "$ref": "#/definitions/timestamp" - }, - "ttl": { - "$id": "#/properties/ttl", - "$ref": "#/definitions/ttl" - } - }, - "additionalProperties": false -} diff --git a/provider/trips.json b/provider/trips.json deleted file mode 100644 index f89c87483..000000000 --- a/provider/trips.json +++ /dev/null @@ -1,413 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/provider/trips.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Schema for MDS Provider trips payloads", - "type": "object", - "definitions": { - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "Point": { - "$id": "#/definitions/Point", - "title": "GeoJSON Point", - "type": "object", - "required": [ - "type", - "coordinates" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Point" - ] - }, - "coordinates": { - "type": "array", - "minItems": 2, - "items": [ - { - "type": "number", - "minimum": -180.0, - "maximum": 180.0 - }, - { - "type": "number", - "minimum": -90.0, - "maximum": 90.0 - } - ], - "maxItems": 2 - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "currency": { - "$id": "#/definitions/currency", - "type": [ - "string", - "null" - ], - "pattern": "^[A-Z]{3}$", - "default": "USD", - "description": "An ISO 4217 Alphabetic Currency Code representing currency of the payee. If null, USD cents is implied.", - "examples": [ - "USD", - "EUR", - "GBP" - ] - }, - "MDS_FeatureCollection_Route": { - "$id": "#/definitions/MDS_FeatureCollection_Route", - "title": "MDS GeoJSON FeatureCollection Route", - "type": "object", - "required": [ - "type", - "features" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "FeatureCollection" - ] - }, - "features": { - "type": "array", - "items": { - "$ref": "#/definitions/MDS_Feature_Point" - }, - "minItems": 2 - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "propulsion_type": { - "$id": "#/definitions/propulsion_type", - "type": "string", - "description": "The type of propulsion", - "enum": [ - "combustion", - "electric", - "electric_assist", - "human" - ] - }, - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - } - }, - "required": [ - "data", - "version" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "trips" - ], - "properties": { - "trips": { - "$id": "#/properties/data/properties/trips", - "type": "array", - "title": "The trips payload", - "items": { - "$id": "#/properties/data/properties/trips/items", - "type": "object", - "title": "The trip item schema", - "additionalProperties": false, - "required": [ - "provider_name", - "provider_id", - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types", - "trip_id", - "trip_duration", - "trip_distance", - "route", - "accuracy", - "start_time", - "end_time" - ], - "properties": { - "provider_name": { - "$id": "#/definitions/vehicle/properties/provider_name", - "$ref": "#/definitions/string", - "description": "The public-facing name of the Provider" - }, - "provider_id": { - "$id": "#/definitions/vehicle/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "The UUID for the Provider, unique within MDS" - }, - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - }, - "trip_id": { - "$id": "#/properties/data/properties/trips/items/properties/trip_id", - "description": "A unique ID for each trip", - "$ref": "#/definitions/uuid" - }, - "trip_duration": { - "$id": "#/properties/data/properties/trips/items/properties/trip_duration", - "type": "integer", - "description": "The length of time, in seconds, that the trip lasted", - "default": 0, - "examples": [ - 600 - ] - }, - "trip_distance": { - "$id": "#/properties/data/properties/trips/items/properties/trip_distance", - "type": "integer", - "description": "The distance, in meters, that the trip covered", - "default": 0, - "examples": [ - 1000 - ] - }, - "route": { - "$id": "#/properties/data/properties/trips/items/properties/route", - "title": "The Route Schema", - "$ref": "#/definitions/MDS_FeatureCollection_Route" - }, - "accuracy": { - "$id": "#/properties/data/properties/trips/items/properties/accuracy", - "type": "integer", - "title": "The approximate level of accuracy, in meters, of Points within route", - "default": 0, - "examples": [ - 15 - ] - }, - "start_time": { - "$id": "#/properties/data/properties/trips/items/properties/start_time", - "description": "The time the trip began, expressed as a Unix Timestamp", - "$ref": "#/definitions/timestamp" - }, - "end_time": { - "$id": "#/properties/data/properties/trips/items/properties/end_time", - "description": "The time the trip ended, expressed as a Unix Timestamp", - "$ref": "#/definitions/timestamp" - }, - "publication_time": { - "$id": "#/properties/data/properties/trips/items/properties/publication_time", - "description": "The time the trip became available through the trips endpoint, expressed as a Unix Timestamp", - "$ref": "#/definitions/timestamp" - }, - "parking_verification_url": { - "$id": "#/properties/data/properties/trips/items/properties/parking_verification_url", - "type": [ - "string", - "null" - ], - "format": "uri", - "description": "A URL to a photo (or other evidence) of proper vehicle parking", - "examples": [ - "https://data.provider.co/parking_verify/1234.jpg" - ] - }, - "standard_cost": { - "$id": "#/properties/data/properties/trips/items/properties/standard_cost", - "type": [ - "integer", - "null" - ], - "description": "The cost, in the currency defined in `currency`, that it would cost to perform that trip in the standard operation of the System. If no currency is given, USD cents is implied.", - "examples": [ - 500 - ] - }, - "actual_cost": { - "$id": "#/properties/data/properties/trips/items/properties/actual_cost", - "type": [ - "integer", - "null" - ], - "description": "The actual cost, in the currency defined in `currency`, paid by the customer of the *mobility as a service* provider. If no currency is given, USD cents is implied.", - "examples": [ - 520 - ] - }, - "currency": { - "$id": "#/properties/data/properties/trips/items/properties/currency", - "$ref": "#/definitions/currency" - } - } - } - } - }, - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version" - } - }, - "additionalProperties": false -} diff --git a/provider/vehicles.json b/provider/vehicles.json deleted file mode 100644 index 6bda6bc38..000000000 --- a/provider/vehicles.json +++ /dev/null @@ -1,605 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/provider/vehicles.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Schema for MDS Provider vehicles payloads", - "type": "object", - "definitions": { - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - }, - "MDS_Feature_Point": { - "$id": "#/definitions/MDS_Feature_Point", - "title": "MDS GeoJSON Feature Point", - "type": "object", - "required": [ - "type", - "properties", - "geometry" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Feature" - ] - }, - "id": { - "oneOf": [ - { - "type": "number" - }, - { - "type": "string" - } - ] - }, - "properties": { - "type": "object", - "required": [ - "timestamp" - ], - "properties": { - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "geometry": { - "$ref": "#/definitions/Point" - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "Point": { - "$id": "#/definitions/Point", - "title": "GeoJSON Point", - "type": "object", - "required": [ - "type", - "coordinates" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "Point" - ] - }, - "coordinates": { - "type": "array", - "minItems": 2, - "items": [ - { - "type": "number", - "minimum": -180.0, - "maximum": 180.0 - }, - { - "type": "number", - "minimum": -90.0, - "maximum": 90.0 - } - ], - "maxItems": 2 - }, - "bbox": { - "type": "array", - "minItems": 4, - "items": { - "type": "number" - } - } - } - }, - "links": { - "$id": "#/definitions/links", - "type": "object", - "required": [ - "next" - ], - "properties": { - "first": { - "$id": "#/definitions/links/first", - "type": [ - "null", - "string" - ], - "title": "The URL to the first page of data", - "examples": [ - "https://data.provider.co/trips/first" - ], - "format": "uri" - }, - "last": { - "$id": "#/definitions/links/last", - "type": [ - "null", - "string" - ], - "title": "The URL to the last page of data", - "examples": [ - "https://data.provider.co/trips/last" - ], - "format": "uri" - }, - "prev": { - "$id": "#/definitions/links/prev", - "type": [ - "null", - "string" - ], - "title": "The URL to the previous page of data", - "examples": [ - "https://data.provider.co/trips/prev" - ], - "format": "uri" - }, - "next": { - "$id": "#/definitions/links/next", - "type": [ - "null", - "string" - ], - "title": "The URL to the next page of data", - "examples": [ - "https://data.provider.co/trips/next" - ], - "format": "uri", - "pattern": "^(.*)$" - } - }, - "additionalProperties": false - }, - "ttl": { - "$id": "#/definitions/ttl", - "type": "integer", - "description": "Integer milliseconds until next data update (0 if the data is always refreshed)", - "minimum": 0, - "maximum": 300000 - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_events": { - "$id": "#/definitions/vehicle_events", - "type": "array", - "description": "Array of events indicating a change to a vehicle's state", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/vehicle_event" - } - }, - "propulsion_type": { - "$id": "#/definitions/propulsion_type", - "type": "string", - "description": "The type of propulsion", - "enum": [ - "combustion", - "electric", - "electric_assist", - "human" - ] - }, - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - } - }, - "required": [ - "data", - "version", - "last_updated", - "ttl" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "vehicles" - ], - "properties": { - "vehicles": { - "$id": "#/properties/data/properties/vehicles", - "type": "array", - "title": "The vehicles payload", - "items": { - "$id": "#/properties/data/properties/vehicles/items", - "type": "object", - "title": "The vehicle item schema", - "required": [ - "provider_name", - "provider_id", - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types", - "last_event_time", - "last_vehicle_state", - "last_event_types", - "last_event_location" - ], - "properties": { - "provider_name": { - "$id": "#/definitions/vehicle/properties/provider_name", - "$ref": "#/definitions/string", - "description": "The public-facing name of the Provider" - }, - "provider_id": { - "$id": "#/definitions/vehicle/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "The UUID for the Provider, unique within MDS" - }, - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - }, - "last_event_time": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_event_time", - "$ref": "#/definitions/timestamp", - "description": "The time the most recent status change event occurred, expressed as a Unix Timestamp" - }, - "last_vehicle_state": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_vehicle_state", - "$ref": "#/definitions/vehicle_state", - "description": "The last known state of the vehicle" - }, - "last_event_types": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_event_types", - "$ref": "#/definitions/vehicle_events", - "description": "The most recent event(s) that caused a change in the vehicle's state" - }, - "last_event_location": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_event_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Location of the vehicle's last status change event" - }, - "current_location": { - "$id": "#/properties/data/properties/vehicles/items/properties/current_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Current location of vehicle if different from last event, and the vehicle is not currently on a trip" - }, - "battery_pct": { - "$id": "#/properties/data/properties/vehicles/items/properties/battery_pct", - "type": [ - "number", - "null" - ], - "description": "Percent charge of device battery, expressed between 0 and 1", - "examples": [ - 0.89 - ], - "minimum": 0, - "maximum": 1 - } - }, - "allOf": [ - { - "description": "Valid last_vehicle_state values for this endpoint", - "properties": { - "last_vehicle_state": { - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - } - } - }, - { - "description": "valid vehicle_state and vehicle_events combinations", - "oneOf": [ - { - "properties": { - "last_vehicle_state": { - "const": "available" - }, - "last_event_types": { - "contains": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "located", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "last_vehicle_state": { - "const": "elsewhere" - }, - "last_event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_leave_jurisdiction", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "last_vehicle_state": { - "const": "non_operational" - }, - "last_event_types": { - "contains": { - "enum": [ - "battery_low", - "comms_restored", - "located", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "last_vehicle_state": { - "const": "on_trip" - }, - "last_event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_enter_jurisdiction", - "trip_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "last_vehicle_state": { - "const": "removed" - }, - "last_event_types": { - "contains": { - "enum": [ - "agency_pick_up", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "last_vehicle_state": { - "const": "reserved" - }, - "last_event_types": { - "contains": { - "enum": [ - "comms_restored", - "located", - "reservation_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "last_vehicle_state": { - "const": "unknown" - }, - "last_event_types": { - "contains": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - } - } - } - ] - } - ] - } - } - }, - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version" - }, - "links": { - "$id": "#/properties/links", - "$ref": "#/definitions/links" - }, - "last_updated": { - "$id": "#/properties/last_updated", - "$ref": "#/definitions/timestamp" - }, - "ttl": { - "$id": "#/properties/ttl", - "$ref": "#/definitions/ttl" - } - }, - "additionalProperties": false -} diff --git a/schema/README.md b/schema/README.md index 04200056a..e26cb8e4b 100644 --- a/schema/README.md +++ b/schema/README.md @@ -1,34 +1,5 @@ # MDS Schema Definitions -This directory contains the templates and code that _generate_ the official JSON schemas for the Mobility Data Specification. However, the official schema documents live inside the `provider`, `agency` or appropriate folder. +Starting with MDS 2.0, [OpenAPI](https://www.openapis.org/) documents describe MDS endpoints and allow for schema validation, expanding on the prior JSON Schemas work. -## Regenerating the Schemas - -At a command prompt within this `schema` directory run: - -```bash -python generate_schemas.py [--agency] [--geography] [--policy] [--provider] -``` - -The optional flags `--agency`, `--geography`, `--policy`, and `--provider` can be used to specify which -set of schemas to generate. The default is to generate all schemas. - -## Updating Schemas - -1. Edit the appropriate file(s) inside the the [`templates/`][templates] directory. - -1. Run the command to regenerate the schema(s). - -## Adding New Schemas - -1. Create a new template in the appropriate folder inside [`templates/`][templates]. See the existing templates for ideas. Remember to reference shared definitions from [`templates/common.json`][common-template]. - -1. Edit the appropriate `.py` file to add a function that creates the new schema as a `dict`. See the existing functions for ideas. The [`common` module][common-module] defines some shared functionality. - -1. Add your schema name and generator function to the collection in the `schema_generators()` function at the top of each `.py` file. - -1. Run the command to regenerate the schema(s). - -[common-module]: common.py -[common-template]: templates/common.json -[templates]: templates/ +See the external OMF GitHub repository called [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) for more details and schema definitions, and browse the interactive API documentation on our [MDS Stoplight workspace](https://openmobilityfnd.stoplight.io/docs/mds-openapi/˜). diff --git a/schema/__init__.py b/schema/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/schema/agency.py b/schema/agency.py deleted file mode 100644 index 9c7e41c03..000000000 --- a/schema/agency.py +++ /dev/null @@ -1,193 +0,0 @@ -""" -Schema generators for Agency endpoints. -""" - -import json - -import common - - -def vehicle_telemetry(): - telemetry = common.load_definitions("telemetry") - vehicle_telemetry = common.load_definitions("vehicle_telemetry") - - # merge the standard telemetry props into vehicle_telemetry.gps - vehicle_telemetry["properties"]["gps"]["properties"].update(telemetry["properties"]) - - return vehicle_telemetry - - -def get_stops_schema(): - """ - Create the schema for the Agency GET /stops endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/agency/get_stops.json") - stops = common.stop_definitions() - schema["definitions"].update(stops) - - # verify and return - return common.check_schema(schema) - - -def post_stops_schema(): - """ - Create the schema for the Agency POST /stops endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/agency/post_stops.json") - stops = common.stop_definitions() - schema["definitions"].update(stops) - - # verify and return - return common.check_schema(schema) - - -def put_stops_schema(): - """ - Create the schema for the Agency POST /stops endpoint. - """ - # load schema template and insert definitions - - # the PUT body allows a small subset of fields - schema = common.load_json("./templates/agency/put_stops.json") - - stops = common.stop_definitions() - needed_defs = ["stop_status", "uuid", "vehicle_type_counts"] - for key in [k for k in stops.keys() if k not in needed_defs]: - del stops[key] - - schema["definitions"].update(stops) - - # verify and return - return common.check_schema(schema) - - -def get_vehicle_schema(): - """ - Create the schema for the Agency GET /vehicles endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/agency/get_vehicle.json") - definitions = common.load_definitions( - "propulsion_types", - "string", - "timestamp", - "vehicle_type", - "uuid" - ) - schema["definitions"].update(definitions) - - # merge the state machine definitions and transition combinations rule - state_machine_defs, transitions = common.vehicle_state_machine("state", "prev_events") - schema["definitions"].update(state_machine_defs) - schema["allOf"].append(transitions) - - # merge common vehicle information, with Agency tweaks - vehicle = common.vehicle_definition(provider_name=False) - schema["required"] = vehicle["required"] + schema["required"] - schema["properties"] = { **vehicle["properties"], **schema["properties"] } - - # verify and return - return common.check_schema(schema) - - -def post_vehicle_schema(): - """ - Create the schema for the Agency POST /vehicles endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/agency/post_vehicle.json") - definitions = common.load_definitions( - "propulsion_types", - "string", - "vehicle_type", - "uuid" - ) - schema["definitions"].update(definitions) - - # merge common vehicle information, with Agency tweaks - vehicle = common.vehicle_definition(provider_name=False, provider_id=False) - - schema["required"] = vehicle["required"] + schema["required"] - schema["properties"] = { **vehicle["properties"], **schema["properties"] } - - # verify and return - return common.check_schema(schema) - - -def post_vehicle_event_schema(): - """ - Create the schema for the Agency POST /vehicles/:id/event endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/agency/post_vehicle_event.json") - definitions = common.load_definitions( - "timestamp", - "uuid" - ) - definitions["vehicle_telemetry"] = vehicle_telemetry() - schema["definitions"].update(definitions) - - # merge the state machine definitions and transition combinations rule - state_machine_defs, transitions = common.vehicle_state_machine("vehicle_state", "event_types") - schema["definitions"].update(state_machine_defs) - schema["allOf"].append(transitions) - - # add the conditionally-required trip_id rule - trip_id_ref = common.load_definitions("trip_id_reference") - schema["allOf"].append(trip_id_ref) - - # verify and return - return common.check_schema(schema) - - -def post_vehicle_telemetry_schema(): - """ - Create the schema for the Agency POST /vehicles/telemetry endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/agency/post_vehicle_telemetry.json") - definitions = common.load_definitions( - "timestamp", - "uuid" - ) - definitions["vehicle_telemetry"] = vehicle_telemetry() - schema["definitions"].update(definitions) - - # verify and return - return common.check_schema(schema) - - -def schema_generators(): - """ - The dict of schema generators for Agency. - - The key is the name of the schema file/template file. - The value is the generator function, taking a dict of common definitions as an argument. - The generator function should return the complete, validated schema document as a dict. - """ - return { - "get_vehicle": get_vehicle_schema, - "post_vehicle": post_vehicle_schema, - "post_vehicle_event": post_vehicle_event_schema, - "post_vehicle_telemetry": post_vehicle_telemetry_schema, - "post_stops": post_stops_schema, - "put_stops": put_stops_schema, - "get_stops": get_stops_schema - } - - -def write_schema_files(): - """ - Create each of the Agency endpoint schema files in the appropriate directory. - """ - print("\nStarting to generate Agency JSON Schemas...\n") - - for name, generator in schema_generators().items(): - schema = generator() - with open(f"../agency/{name}.json", "w") as schemafile: - schemafile.write(json.dumps(schema, indent=2)) - print(f"Wrote {name}.json") - - print("\nFinished generating Agency JSON Schemas") diff --git a/schema/common.py b/schema/common.py deleted file mode 100644 index cd0184fcc..000000000 --- a/schema/common.py +++ /dev/null @@ -1,282 +0,0 @@ -""" -Shared functionality for schema generation. -""" - -import copy -import json -import jsonschema -import requests - - -COMMON_DEFINITIONS = {} - - -MDS_FEATURE_POINT = "MDS_Feature_Point" - - -def load_json(path): - """ - Load a JSON file from disk. - """ - with open(path) as f: - data = json.load(f) - return data - - -def definition_id(id): - """ - Generate a JSON Schema definition reference for the given id. - """ - return f"#/definitions/{id}" - - -def vehicle_definition(provider_name=True, provider_id=True): - """ - Extract a deep-copy of the common vehicle model definition to allow for customization. - """ - vehicle = copy.deepcopy(load_definitions("vehicle")) - - if not provider_name: - vehicle["required"].remove("provider_name") - del vehicle["properties"]["provider_name"] - - if not provider_id: - vehicle["required"].remove("provider_id") - del vehicle["properties"]["provider_id"] - - return vehicle - - -def vehicle_state_machine(vehicle_state=None, vehicle_events=None): - """ - Return a tuple (definitions, transitions) with the common vehicle state schema. - * defitions is the common definitions for vehicle state fields - * transitions is the rule for valid state/event combinations - - Optionally pass field names for the vehicle_state and vehicle_events schemas - to override those in transitions. - """ - state_machine_defs = load_definitions("vehicle_state", "vehicle_event", "vehicle_events") - transitions = copy.deepcopy(load_definitions("vehicle_state_transitions")) - - if vehicle_state: - for option in transitions["oneOf"]: - state = option["properties"]["vehicle_state"] - del option["properties"]["vehicle_state"] - option["properties"][vehicle_state] = state - - if vehicle_events: - for option in transitions["oneOf"]: - events = option["properties"]["vehicle_events"] - del option["properties"]["vehicle_events"] - option["properties"][vehicle_events] = events - - return (state_machine_defs, transitions) - - -def vehicle_type_counts_definition(definitions): - """ - Generate a definition for a dict of vehicle_type: int. - """ - vehicle_type_counts = {} - def_name = "vehicle_type_counts" - def_id = definition_id(def_name) - vehicle_types = definitions["vehicle_type"] - - for vehicle_type in vehicle_types["enum"]: - vehicle_type_counts[vehicle_type] = { - "$id": f"{def_id}/properties/{vehicle_type}", - "type": "integer", - "minimum": 0 - } - - return { - def_name: { - "$id": def_id, - "type": "object", - "properties": vehicle_type_counts, - "additionalProperties": False - } - } - - -def point_definition(): - """ - Get the canonical schema definition for a GeoJSON point. - """ - name = "Point" - point = requests.get("http://geojson.org/schema/Point.json").json() - - # Modify some metadata - point.pop("$schema") - point["$id"] = definition_id("Point") - - # enforce lat/lon bounds - point["properties"]["coordinates"]["maxItems"] = 2 - point["properties"]["coordinates"]["items"] = [ - { - "type": "number", - "minimum": -180.0, - "maximum": 180.0 - }, - { - "type": "number", - "minimum": -90.0, - "maximum": 90.0 - } - ] - - return { - name: point - } - - -def mds_feature_point_definition(definitions): - """ - Create a customized definition of the GeoJSON Feature schema for MDS Points. - """ - # Get the canonical Feature schema - feature = requests.get("http://geojson.org/schema/Feature.json").json() - - # Modify metadata - feature.pop("$schema") - feature["$id"] = definition_id(MDS_FEATURE_POINT) - feature["title"] = "MDS GeoJSON Feature Point" - - # Only allow GeoJSON Point feature geometry - feature["properties"]["geometry"] = { "$ref": definition_id("Point") } - - # Modfy properties definition/requirements - f_properties = feature["properties"]["properties"] - del f_properties["oneOf"] - f_properties["type"] = "object" - - # Point features must include the timestamp - f_properties["required"] = ["timestamp"] - - f_properties["properties"] = { - "timestamp": { - "$ref": definition_id("timestamp") - }, - # Locations corresponding to Stops must include a stop_id reference - "stop_id": { - "$ref": definition_id("uuid") - } - } - - # merge telemetry props - telemetry = definitions["telemetry"] - f_properties["properties"].update(telemetry["properties"]) - - return {MDS_FEATURE_POINT: feature} - - -def stop_definitions(): - """ - Return a dict of definitions needed for stops. - """ - definitions = load_definitions( - "stop", - "stop_status", - "string", - "timestamp", - "uuid", - "uuid_array", - "vehicle_type_counts", - MDS_FEATURE_POINT - ) - - return definitions - - -def property_definition(property_id, ref=""): - """ - Return a tuple (property, definition) of schema elements for the given id. - """ - # property ref definition - definition = { property_id: load_definitions(property_id) } - # the property - ref = ref or definition_id(property_id) - prop = { property_id: { "$id": f"#/properties/{property_id}", "$ref": ref } } - - return prop, definition - - -def load_definitions(*args, allow_null=False): - """ - Load the common.json definitions file, with some generated additions. - - If args are provided, filter to a dictionary of definitions using the args as keys. - - With only a single arg, return the definition with that key directly. - - If allow_null is True, override definition types to allow null. - """ - # store the definitions once globally after reading from the source file - global COMMON_DEFINITIONS - - if COMMON_DEFINITIONS == {}: - common = load_json("./templates/common.json") - common_definitions = common["definitions"] - - # MDS specific geography definition - mds_feature = mds_feature_point_definition(common_definitions) - common_definitions.update(mds_feature) - - # vehicle_type -> count definition - veh_type_counts = vehicle_type_counts_definition(common_definitions) - common_definitions.update(veh_type_counts) - - COMMON_DEFINITIONS = common_definitions - - # filter all definitions to those requested as args - if args and len(args) > 0: - _d = { key: COMMON_DEFINITIONS.get(key) for key in args } - else: - _d = COMMON_DEFINITIONS - - # create a deepcopy for possible modifications - definitions = copy.deepcopy(_d) - - # modify definitions to allow null - if allow_null: - # get all definitions with a type property - typekey = "type" - typedefs = { k: v for k, v in definitions.items() if typekey in v } - for key, defn in typedefs.items(): - nullkey = f"null_{key}" - - # for reference definitions, override the reference to the null version - if "$ref" in defn: - refid = defn["$ref"].split("/") - refid[-1] = f"null_{refid[-1]}" - - defn["$ref"] = "/".join(refid) - # for type definitions, create a new definition allowing null - else: - defnid = defn["$id"].split("/") - defnid[-1] = f"null_{defnid[-1]}" - - nulldefn = copy.deepcopy(defn) - nulldefn["$id"] = "/".join(defnid) - - if isinstance(nulldefn[typekey], str): - nulldefn[typekey] = [nulldefn[typekey]] - if "null" not in nulldefn[typekey]: - nulldefn[typekey].append("null") - # add the null definition to the definitions dict - definitions[nullkey] = nulldefn - - # if there was only one arg, return the definition directly - return definitions.get(args[0]) if len(args) == 1 else definitions - - -def check_schema(schema): - """ - Check the validity of the given schema document under Draft 7 of the JSON Schema spec. - - Returns the (valid) schema instance. - """ - jsonschema.Draft7Validator.check_schema(schema) - - return schema diff --git a/schema/generate_schemas.py b/schema/generate_schemas.py deleted file mode 100644 index 014545883..000000000 --- a/schema/generate_schemas.py +++ /dev/null @@ -1,36 +0,0 @@ -""" -Generate the JSON Schema documents for MDS endpoints. - -USAGE: - python generate_schemas.py [--agency] [--geography] [--policy] [--provider] -""" - -import sys - -import agency -import geography -import policy -import provider - - -if __name__ == "__main__": - if len(sys.argv) == 1: - agency.write_schema_files() - geography.write_schema_files() - policy.write_schema_files() - provider.write_schema_files() - else: - if "--agency" in sys.argv: - agency.write_schema_files() - sys.argv.remove("--agency") - if "--geography" in sys.argv: - geography.write_schema_files() - sys.argv.remove("--geography") - if "--policy" in sys.argv: - policy.write_schema_files() - sys.argv.remove("--policy") - if "--provider" in sys.argv: - provider.write_schema_files() - sys.argv.remove("--provider") - if len(sys.argv) > 1: - print(__doc__) diff --git a/schema/geography.py b/schema/geography.py deleted file mode 100644 index 125402fd1..000000000 --- a/schema/geography.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -Schema generators for Geography endpoints. -""" - -import json - -import common - - -def geography_schema(): - """ - Create the schema for the Geography endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/geography/geography.json") - definitions = common.load_definitions( - "string", - "timestamp", - "uuid", - "version" - ) - definitions.update(common.load_definitions( - "timestamp", - "uuid_array", - allow_null=True - )) - schema["definitions"].update(definitions) - - # verify and return - return common.check_schema(schema) - - -def geographies_schema(): - """ - Create the schema for the Geographies endpoint. - """ - # load schema template and insert definitions from geography - geography = geography_schema() - schema = common.load_json("./templates/geography/geographies.json") - schema["definitions"].update(geography["definitions"]) - - return common.check_schema(schema) - - -def schema_generators(): - """ - The dict of schema generators for Geography. - - The key is the name of the schema file/template file. - The value is the generator function, taking a dict of common definitions as an argument. - The generator function should return the complete, validated schema document as a dict. - """ - return { - "geography": geography_schema, - "geographies": geographies_schema - } - - -def write_schema_files(): - """ - Create each of the Geography endpoint schema files in the appropriate directory. - """ - print("\nStarting to generate Geography JSON Schemas...\n") - - for name, generator in schema_generators().items(): - schema = generator() - with open(f"../geography/{name}.json", "w") as schemafile: - schemafile.write(json.dumps(schema, indent=2)) - print(f"Wrote {name}.json") - - print("\nFinished generating Geography JSON Schemas") diff --git a/schema/policy.py b/schema/policy.py deleted file mode 100644 index 5d2ae8b41..000000000 --- a/schema/policy.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -Schema generators for Policy endpoints. -""" - -import json - -import common - - -def policy_schema(): - """ - Create the schema for the Policy endpoint. - """ - # load schema template and insert definitions - schema = common.load_json("./templates/policy/policy.json") - definitions = common.load_definitions( - "currency", - "day", - "propulsion_type", - "string", - "timestamp", - "uuid", - "uuid_array", - "vehicle_event", - "vehicle_state", - "vehicle_type", - "version" - ) - definitions.update(common.load_definitions( - "days", - "iso_time", - "propulsion_types", - "timestamp", - "uuid_array", - "vehicle_types", - allow_null=True - )) - schema["definitions"].update(definitions) - - # verify and return - return common.check_schema(schema) - - -def schema_generators(): - """ - The dict of schema generators for Policy. - - The key is the name of the schema file/template file. - The value is the generator function, taking a dict of common definitions as an argument. - The generator function should return the complete, validated schema document as a dict. - """ - return { - "policy": policy_schema - } - - -def write_schema_files(): - """ - Create each of the Policy endpoint schema files in the appropriate directory. - """ - print("\nStarting to generate Policy JSON Schemas...\n") - - for name, generator in schema_generators().items(): - schema = generator() - with open(f"../policy/{name}.json", "w") as schemafile: - schemafile.write(json.dumps(schema, indent=2)) - print(f"Wrote {name}.json") - - print("\nFinished generating Policy JSON Schemas") diff --git a/schema/provider.py b/schema/provider.py deleted file mode 100644 index cb8efad98..000000000 --- a/schema/provider.py +++ /dev/null @@ -1,226 +0,0 @@ -""" -Schema generators for Provider endpoints. -""" - -import json -import requests - -import common - - -def feature_collection_schema(id=None, title=None, features=None): - """ - Get the canonical schema for a GeoJSON Feature Collection, - and make any given modifications. - - :id: overrides the `$id` metadata - :title: overrides the `title` metadata - :features: overrides the allowed `features` for the FeatureCollection - """ - # Get the canonical FeatureCollection schema - feature_collection = requests.get("http://geojson.org/schema/FeatureCollection.json").json() - - # Modify some metadata - feature_collection.pop("$schema") - if id is not None: - feature_collection["$id"] = id - if title is not None: - feature_collection["title"] = title - - if features is not None: - fc_features = feature_collection["properties"]["features"] - feature_collection["properties"]["features"] = { **fc_features, **features } - - return feature_collection - - -def endpoint_schema(endpoint, extra_definitions={}): - """ - Generate the Provider payload schema for the given endpoint. - """ - # load common schema template and update metadata - schema = common.load_json("./templates/provider/endpoint.json") - schema["$id"] = schema["$id"].replace("endpoint.json", f"{endpoint}.json") - schema["title"] = schema["title"].replace("endpoint", endpoint) - - # merge custom definitions with relevant common definitions - definitions = common.load_definitions( - "string", - "timestamp", - "uuid", - "version", - common.MDS_FEATURE_POINT - ) - definitions.update(common.point_definition()) - definitions.update(extra_definitions) - - endpoint_schema = common.load_json(f"./templates/provider/{endpoint}.json") - - # for all but stops, merge standard vehicle info with items schema - if endpoint not in ["stops"]: - items = endpoint_schema[endpoint]["items"] - vehicle = common.vehicle_definition() - items["required"] = vehicle["required"] + items["required"] - items["properties"] = { **vehicle["properties"], **items["properties"] } - definitions.update(common.load_definitions("propulsion_type", "propulsion_types", "vehicle_type")) - - # merge endpoint schema into the endpoint template - data_schema = schema["properties"]["data"] - data_schema["required"] = [endpoint] - data_schema["properties"] = endpoint_schema - - # insert definitions - schema["definitions"].update(definitions) - - return schema - - -def trips_schema(): - """ - Create the schema for the /trips endpoint. - """ - # generate the route definition - mds_feature_collection_route = feature_collection_schema( - id = common.definition_id("MDS_FeatureCollection_Route"), - title = "MDS GeoJSON FeatureCollection Route", - # 1. Only allow MDS Feature Points - # 2. There must be *at least* two Features in the FeatureCollection. - features = { "items": { "$ref": common.definition_id("MDS_Feature_Point") }, "minItems": 2 } - ) - trips_definitions = { - "currency": common.load_definitions("currency"), - "MDS_FeatureCollection_Route": mds_feature_collection_route - } - - # create the trips schema - schema = endpoint_schema("trips", trips_definitions) - - # verify and return - return common.check_schema(schema) - - -def status_changes_schema(): - """ - Create the schema for the /status_changes endpoint. - """ - schema = endpoint_schema("status_changes") - items = schema["properties"]["data"]["properties"]["status_changes"]["items"] - - # merge the state machine definitions and transition combinations rule - state_machine_defs, transitions = common.vehicle_state_machine("vehicle_state", "event_types") - schema["definitions"].update(state_machine_defs) - items["allOf"].append(transitions) - - trip_id_ref = common.load_definitions("trip_id_reference") - items["allOf"].append(trip_id_ref) - - # verify and return - return common.check_schema(schema) - - -def events_schema(): - """ - Create the schema for the /events endpoint. - """ - links_prop, links_def = common.property_definition("links") - - # events is the same as status_changes, but allows paging - schema = status_changes_schema() - schema["$id"] = schema["$id"].replace("status_changes", "events") - schema["title"] = schema["title"].replace("status_changes", "events") - schema["definitions"].update(links_def) - schema["properties"].update(links_prop) - - # verify and return - return common.check_schema(schema) - - -def stops_schema(): - """ - Create the schema for the /stops endpoint. - """ - definitions, properties = {}, {} - - prop, _ = common.property_definition("last_updated", ref=common.definition_id("timestamp")) - properties.update(prop) - - prop, defn = common.property_definition("ttl") - definitions.update(defn) - properties.update(prop) - - stop_defs = common.stop_definitions() - definitions.update(stop_defs) - - schema = endpoint_schema("stops", definitions) - - # update list of required and properties object - schema["required"].extend(["last_updated", "ttl"]) - schema["properties"].update(properties) - - # verify and return - return common.check_schema(schema) - - -def vehicles_schema(): - """ - Create the schema for the /vehicles endpoint. - """ - definitions, properties = {}, {} - - prop, defn = common.property_definition("links") - definitions.update(defn) - properties.update(prop) - - prop, _ = common.property_definition("last_updated", ref=common.definition_id("timestamp")) - properties.update(prop) - - prop, defn = common.property_definition("ttl") - definitions.update(defn) - properties.update(prop) - - state_defs, transitions = common.vehicle_state_machine("last_vehicle_state", "last_event_types") - definitions.update(state_defs) - - schema = endpoint_schema("vehicles", definitions) - - # update list of required and properties object - schema["required"].extend(["last_updated", "ttl"]) - schema["properties"].update(properties) - - # add state machine transition rules - schema["properties"]["data"]["properties"]["vehicles"]["items"]["allOf"].append(transitions) - - # verify and return - return common.check_schema(schema) - - -def schema_generators(): - """ - The dict of schema generators for Provider. - - The key is the name of the schema file/template file. - The value is the generator function, taking a dict of common definitions as an argument. - The generator function should return the complete, validated schema document as a dict. - """ - return { - "trips": trips_schema, - "status_changes": status_changes_schema, - "events": events_schema, - "vehicles": vehicles_schema, - "stops": stops_schema - } - - -def write_schema_files(): - """ - Create each of the Provider endpoint schema files in the appropriate directory. - """ - print("\nStarting to generate Provider JSON Schemas...\n") - - for name, generator in schema_generators().items(): - schema = generator() - with open(f"../provider/{name}.json", "w") as schemafile: - schemafile.write(json.dumps(schema, indent=2)) - print(f"Wrote {name}.json") - - print("\nFinished generating Provider JSON Schemas") diff --git a/schema/requirements.txt b/schema/requirements.txt deleted file mode 100644 index fb758e7a0..000000000 --- a/schema/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -jsonschema==3.0.1 -requests diff --git a/schema/templates/agency/get_stops.json b/schema/templates/agency/get_stops.json deleted file mode 100644 index 128930ae0..000000000 --- a/schema/templates/agency/get_stops.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/get_stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, GET stops payload", - "type": "object", - "definitions": {}, - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/stops", - "type": "array", - "description": "The array of stops", - "items": { - "$ref": "#/definitions/stop" - } - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/schema/templates/agency/get_vehicle.json b/schema/templates/agency/get_vehicle.json deleted file mode 100644 index 048fff661..000000000 --- a/schema/templates/agency/get_vehicle.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/get_vehicle.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, GET vehicle payload", - "type": "object", - "definitions": {}, - "required": [ - "year", - "mfgr", - "model", - "state", - "prev_events", - "updated" - ], - "properties": { - "year": { - "$id": "#/properties/year", - "type": "integer", - "description": "The year the vehicle was manufactured", - "default": 1970, - "examples": [ - 2018 - ] - }, - "mfgr": { - "$id": "#/properties/mfgr", - "$ref": "#/definitions/string", - "description": "The vehicle manufacturer" - }, - "model": { - "$id": "#/properties/model", - "$ref": "#/definitions/string", - "description": "The vehicle model" - }, - "state": { - "$id": "#/properties/state", - "$ref": "#/definitions/vehicle_state", - "description": "Current vehicle state" - }, - "prev_events": { - "$id": "#/properties/prev_events", - "$ref": "#/definitions/vehicle_events", - "description": "Last vehicle event" - }, - "updated": { - "$id": "#/properties/updated", - "$ref": "#/definitions/timestamp" - } - }, - "additionalProperties": false, - "allOf": [] -} diff --git a/schema/templates/agency/post_stops.json b/schema/templates/agency/post_stops.json deleted file mode 100644 index ba53da2dd..000000000 --- a/schema/templates/agency/post_stops.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, register Stops", - "type": "object", - "definitions": {}, - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/stops", - "type": "array", - "description": "The array of stops", - "items": { - "$ref": "#/definitions/stop" - } - } - }, - "additionalProperties": false - } - \ No newline at end of file diff --git a/schema/templates/agency/post_vehicle.json b/schema/templates/agency/post_vehicle.json deleted file mode 100644 index ec58eba8e..000000000 --- a/schema/templates/agency/post_vehicle.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_vehicle.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, register vehicle body", - "type": "object", - "definitions": {}, - "required": [], - "properties": { - "year": { - "$id": "#/properties/year", - "type": "integer", - "description": "The year the vehicle was manufactured", - "default": 1970, - "examples": [ - 2018 - ] - }, - "mfgr": { - "$id": "#/properties/mfgr", - "$ref": "#/definitions/string", - "description": "The vehicle manufacturer" - }, - "model": { - "$id": "#/properties/model", - "$ref": "#/definitions/string", - "description": "The vehicle model" - } - }, - "additionalProperties": false -} diff --git a/schema/templates/agency/post_vehicle_event.json b/schema/templates/agency/post_vehicle_event.json deleted file mode 100644 index d7b4dfdc0..000000000 --- a/schema/templates/agency/post_vehicle_event.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_vehicle_event.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, POST vehicle status body", - "type": "object", - "definitions": {}, - "required": [ - "vehicle_state", - "event_types", - "timestamp", - "telemetry" - ], - "properties": { - "vehicle_state": { - "$ref": "#/definitions/vehicle_state" - }, - "event_types": { - "$ref": "#/definitions/vehicle_events" - }, - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "telemetry": { - "$ref": "#/definitions/vehicle_telemetry" - }, - "trip_id": { - "$ref": "#/definitions/uuid" - } - }, - "additionalProperties": false, - "allOf": [] -} diff --git a/schema/templates/agency/post_vehicle_telemetry.json b/schema/templates/agency/post_vehicle_telemetry.json deleted file mode 100644 index f7ad99f9c..000000000 --- a/schema/templates/agency/post_vehicle_telemetry.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/post_vehicle_telemetry.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, POST vehicle telemetry body", - "type": "object", - "definitions": {}, - "required": [ - "data" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/vehicle_telemetry" - } - } - }, - "additionalProperties": false -} diff --git a/schema/templates/agency/put_stops.json b/schema/templates/agency/put_stops.json deleted file mode 100644 index cf904d10f..000000000 --- a/schema/templates/agency/put_stops.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/agency/put_stops.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Agency Schema, update Stops", - "type": "object", - "definitions": {}, - "required": [ - "stops" - ], - "properties": { - "stops": { - "$id": "#/properties/stops", - "type": "array", - "description": "The array of stops", - "items": { - "type": "object", - "required": [ - "stop_id" - ], - "properties": { - "stop_id": { - "$ref": "#/definitions/uuid" - }, - "status": { - "$ref": "#/definitions/stop_status" - }, - "num_spots_disabled": { - "$ref": "#/definitions/vehicle_type_counts" - } - } - } - } - }, - "additionalProperties": false - } - \ No newline at end of file diff --git a/schema/templates/common.json b/schema/templates/common.json deleted file mode 100644 index 08919fd15..000000000 --- a/schema/templates/common.json +++ /dev/null @@ -1,722 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/schema/templates/common.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Common schema definitions for MDS", - "definitions": { - "area_type": { - "$id": "#/definitions/area_type", - "type": "string", - "description": "The type of a service area", - "enum": [ - "unrestricted", - "restricted", - "preferred_pick_up", - "preferred_drop_off" - ] - }, - "currency": { - "$id": "#/definitions/currency", - "type": [ - "string", - "null" - ], - "pattern": "^[A-Z]{3}$", - "default": "USD", - "description": "An ISO 4217 Alphabetic Currency Code representing currency of the payee. If null, USD cents is implied.", - "examples": [ - "USD", - "EUR", - "GBP" - ] - }, - "day": { - "$id": "#/definitions/day", - "type": "string", - "description": "A day of the week", - "enum": [ - "sun", - "mon", - "tue", - "wed", - "thu", - "fri", - "sat" - ] - }, - "days": { - "$id": "#/definitions/days", - "type": "array", - "description": "Array of days of the week", - "items": { - "$id": "#/definitions/days/items", - "$ref": "#/definitions/day" - }, - "uniqueItems": true - }, - "iso_time": { - "$id": "#/definitions/iso_time", - "type": "string", - "description": "Time-of-day expressed as ISO 8601 hh:mm:ss", - "pattern": "([0-2][0-3]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]" - }, - "links": { - "$id": "#/definitions/links", - "type": "object", - "required": [ - "next" - ], - "properties": { - "first": { - "$id": "#/definitions/links/first", - "type": [ - "null", - "string" - ], - "title": "The URL to the first page of data", - "examples": [ - "https://data.provider.co/trips/first" - ], - "format": "uri" - }, - "last": { - "$id": "#/definitions/links/last", - "type": [ - "null", - "string" - ], - "title": "The URL to the last page of data", - "examples": [ - "https://data.provider.co/trips/last" - ], - "format": "uri" - }, - "prev": { - "$id": "#/definitions/links/prev", - "type": [ - "null", - "string" - ], - "title": "The URL to the previous page of data", - "examples": [ - "https://data.provider.co/trips/prev" - ], - "format": "uri" - }, - "next": { - "$id": "#/definitions/links/next", - "type": [ - "null", - "string" - ], - "title": "The URL to the next page of data", - "examples": [ - "https://data.provider.co/trips/next" - ], - "format": "uri", - "pattern": "^(.*)$" - } - }, - "additionalProperties": false - }, - "propulsion_type": { - "$id": "#/definitions/propulsion_type", - "type": "string", - "description": "The type of propulsion", - "enum": [ - "combustion", - "electric", - "electric_assist", - "human" - ] - }, - "propulsion_types": { - "$id": "#/definitions/propulsion_types", - "type": "array", - "description": "Array of propulsion types, allowing multiple values", - "items": { - "$id": "#/definitions/propulsion_types/items", - "$ref": "#/definitions/propulsion_type" - }, - "uniqueItems": true - }, - "rental_methods": { - "$id": "#/definitions/rental_methods", - "type": "array", - "description": "Payment methods accepted at this Stop. From GBFS Station Information.", - "items": { - "enum": [ - "KEY", - "CREDITCARD", - "PAYPASS", - "APPLEPAY", - "ANDROIDPAY", - "TRANSITCARD", - "ACCOUNTNUMBER", - "PHONE" - ] - }, - "uniqueItems": true - }, - "stop": { - "$id": "#/definitions/stop", - "type": "object", - "description": "The common schema elements for a Stop in MDS", - "required": [ - "stop_id", - "name", - "last_reported", - "location", - "status", - "capacity", - "num_vehicles_available", - "num_vehicles_disabled" - ], - "properties": { - "stop_id": { - "$id": "#/definitions/stop/properties/stop_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "name": { - "$id": "#/definitions/stop/properties/name", - "$ref": "#/definitions/string", - "description": "Name of the Stop" - }, - "last_reported": { - "$id": "#/definitions/stop/properties/last_reported", - "$ref": "#/definitions/timestamp", - "description": "Date/Time of the last status update for this Stop" - }, - "location": { - "$id": "#/definitions/stop/properties/location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Location of the stop" - }, - "status": { - "$id": "#/definitions/stop/properties/status", - "$ref": "#/definitions/stop_status", - "description": "The status of the Stop" - }, - "capacity": { - "$id": "#/definitions/stop/properties/capacity", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of total places per vehicle_type" - }, - "num_vehicles_available": { - "$id": "#/definitions/stop/properties/num_vehicles_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of available vehicles per vehicle_type" - }, - "num_vehicles_disabled": { - "$id": "#/definitions/stop/properties/num_vehicles_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of non_operational/reserved vehicles per vehicle_type" - }, - "provider_id": { - "$id": "#/definitions/stop/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Provider managing this Stop. Null/undefined if managed by an Agency." - }, - "geography_id": { - "$id": "#/definitions/stop/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "UUID for the Stop" - }, - "region_id": { - "$id": "#/definitions/stop/properties/region_id", - "$ref": "#/definitions/string", - "description": "ID of the region where the Stop is located. See GBFS Station Information." - }, - "short_name": { - "$id": "#/definitions/stop/properties/short_name", - "$ref": "#/definitions/string", - "description": "Abbreviated Stop name" - }, - "address": { - "$id": "#/definitions/stop/properties/address", - "$ref": "#/definitions/string", - "description": "Postal address (useful for directions)" - }, - "post_code": { - "$id": "#/definitions/stop/properties/post_code", - "$ref": "#/definitions/string", - "description": "Postal code (e.g. 10036)" - }, - "cross_street": { - "$id": "#/definitions/stop/properties/cross_street", - "$ref": "#/definitions/string", - "description": "Cross street of where Stop is located" - }, - "num_places_available": { - "$id": "#/definitions/stop/properties/num_places_available", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places free to be populated per vehicle_type" - }, - "num_places_disabled": { - "$id": "#/definitions/stop/properties/num_places_disabled", - "$ref": "#/definitions/vehicle_type_counts", - "description": "Number of places disabled an unable to accept vehicles per vehicle_type" - }, - "parent_stop": { - "$id": "#/definitions/stop/properties/parent_stop", - "$ref": "#/definitions/uuid", - "description": "Describe a basic hierarchy of Stops (e.g. a Stop inside a greater Stop)" - }, - "devices": { - "$id": "#/definitions/stop/properties/devices", - "$ref": "#/definitions/uuid_array", - "description": "List of device_id for vehicles currently at this Stop." - } - } - }, - "stop_status": { - "$id": "#/definitions/stop_status", - "type": "object", - "description": "Status object for a Stop in MDS", - "required": [ - "is_installed", - "is_renting", - "is_returning" - ], - "properties": { - "is_installed": { - "$id": "#/definitions/stop_status/properties/is_installed", - "type": "boolean" - }, - "is_renting": { - "$id": "#/definitions/stop_status/properties/is_renting", - "type": "boolean" - }, - "is_returning": { - "$id": "#/definitions/stop_status/properties/is_returning", - "type": "boolean" - } - } - }, - "string": { - "$id": "#/definitions/string", - "type": "string", - "description": "A length-limited string type", - "maxLength": 255, - "default": "", - "examples": [ - "ABC123" - ], - "pattern": "^(.*)$" - }, - "telemetry": { - "$id": "#/definitions/telemetry", - "type": "object", - "description": "A telemetry datum", - "additionalProperties": false, - "properties": { - "altitude": { - "type": "number", - "description": "Altitude above mean sea level in meters" - }, - "heading": { - "type": "number", - "description": "Degrees - clockwise starting at 0 degrees at true North" - }, - "speed": { - "type": "number", - "description": "Estimated speed in meters / sec as reported by the GPS chipset" - }, - "accuracy": { - "type": "number", - "description": "Horizontal accuracy, in meters" - }, - "hdop": { - "type": "number", - "description": "Horizontal GPS or GNSS accuracy value" - }, - "satellites": { - "type": "integer", - "description": "Number of GPS or GNSS satellites" - } - } - }, - "timestamp": { - "$id": "#/definitions/timestamp", - "type": "number", - "description": "Integer milliseconds since Unix epoch", - "multipleOf": 1.0, - "minimum": 1514764800000 - }, - "trip_id_reference": { - "description": "Conditionally require a trip_id reference", - "anyOf": [ - { - "not": { - "properties": { - "event_types": { - "contains": { - "enum": [ - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start" - ] - } - } - } - } - }, - { - "required": [ - "trip_id" - ] - } - ] - }, - "ttl": { - "$id": "#/definitions/ttl", - "type": "integer", - "description": "Integer milliseconds until next data update (0 if the data is always refreshed)", - "minimum": 0, - "maximum": 300000 - }, - "uuid": { - "$id": "#/definitions/uuid", - "type": "string", - "description": "A UUID used to uniquely identifty an object", - "default": "", - "examples": [ - "3c9604d6-b5ee-11e8-96f8-529269fb1459" - ], - "pattern": "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$" - }, - "uuid_array": { - "$id": "#/definitions/uuid_array", - "type": "array", - "description": "Array of UUID", - "items": { - "$id": "#/definitions/uuid_array/items", - "$ref": "#/definitions/uuid" - } - }, - "vehicle": { - "$id": "#/definitions/vehicle", - "type": "object", - "description": "The common schema elements for a Vehicle in MDS", - "required": [ - "provider_name", - "provider_id", - "device_id", - "vehicle_id", - "vehicle_type", - "propulsion_types" - ], - "properties": { - "provider_name": { - "$id": "#/definitions/vehicle/properties/provider_name", - "$ref": "#/definitions/string", - "description": "The public-facing name of the Provider" - }, - "provider_id": { - "$id": "#/definitions/vehicle/properties/provider_id", - "$ref": "#/definitions/uuid", - "description": "The UUID for the Provider, unique within MDS" - }, - "device_id": { - "$id": "#/definitions/vehicle/properties/device_id", - "$ref": "#/definitions/uuid", - "description": "A unique device ID in UUID format" - }, - "vehicle_id": { - "$id": "#/definitions/vehicle/properties/vehicle_id", - "$ref": "#/definitions/string", - "description": "The Vehicle Identification Number visible on the vehicle itself" - }, - "vehicle_type": { - "$id": "#/definitions/vehicle/properties/vehicle_type", - "$ref": "#/definitions/vehicle_type", - "description": "The type of vehicle" - }, - "propulsion_types": { - "$id": "#/definitions/vehicle/properties/propulsion_types", - "$ref": "#/definitions/propulsion_types", - "description": "The type of propulsion; allows multiple values", - "minItems": 1 - } - }, - "additionalProperties": false - }, - "vehicle_event": { - "$id": "#/definitions/vehicle_event", - "type": "string", - "description": "An event that changes a vehicle's state", - "enum": [ - "agency_drop_off", - "agency_pick_up", - "battery_charged", - "battery_low", - "comms_lost", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance", - "maintenance_pick_up", - "missing", - "off_hours", - "on_hours", - "provider_drop_off", - "rebalance_pick_up", - "reservation_cancel", - "reservation_start", - "system_resume", - "system_suspend", - "trip_cancel", - "trip_end", - "trip_enter_jurisdiction", - "trip_leave_jurisdiction", - "trip_start", - "unspecified" - ] - }, - "vehicle_events": { - "$id": "#/definitions/vehicle_events", - "type": "array", - "description": "Array of events indicating a change to a vehicle's state", - "uniqueItems": true, - "minItems": 1, - "items": { - "$ref": "#/definitions/vehicle_event" - } - }, - "vehicle_state": { - "$id": "#/definitions/vehicle_state", - "type": "string", - "description": "The state of a vehicle", - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - }, - "vehicle_state_transitions": { - "description": "valid vehicle_state and vehicle_events combinations", - "oneOf": [ - { - "properties": { - "vehicle_state": { - "const": "available" - }, - "vehicle_events": { - "contains": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "located", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "elsewhere" - }, - "vehicle_events": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_leave_jurisdiction", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "non_operational" - }, - "vehicle_events": { - "contains": { - "enum": [ - "battery_low", - "comms_restored", - "located", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "on_trip" - }, - "vehicle_events": { - "contains": { - "enum": [ - "comms_restored", - "located", - "trip_enter_jurisdiction", - "trip_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "removed" - }, - "vehicle_events": { - "contains": { - "enum": [ - "agency_pick_up", - "comms_restored", - "compliance_pick_up", - "decommissioned", - "located", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "reserved" - }, - "vehicle_events": { - "contains": { - "enum": [ - "comms_restored", - "located", - "reservation_start", - "unspecified" - ] - } - } - } - }, - { - "properties": { - "vehicle_state": { - "const": "unknown" - }, - "vehicle_events": { - "contains": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - } - } - } - ] - }, - "vehicle_telemetry": { - "$id": "#/definitions/vehicle_telemetry", - "type": "object", - "description": "A telemetry datum for a specific vehicle at a specific time", - "required": [ - "device_id", - "timestamp", - "gps" - ], - "additionalProperties": false, - "properties": { - "device_id": { - "$ref": "#/definitions/uuid" - }, - "timestamp": { - "$ref": "#/definitions/timestamp" - }, - "gps": { - "type": "object", - "required": [ - "lat", - "lng" - ], - "additionalProperties": false, - "properties": { - "lat": { - "type": "number", - "description": "Latitude of the location", - "minimum": -90, - "maximum": 90 - }, - "lng": { - "type": "number", - "description": "Longitude of the location", - "minimum": -180, - "maximum": 180 - } - } - }, - "charge": { - "type": "number", - "description": "Fraction of charge of the vehicle (required if applicable)", - "minimum": 0, - "maximum": 1 - } - } - }, - "vehicle_type": { - "$id": "#/definitions/vehicle_type", - "type": "string", - "description": "The type of vehicle", - "enum": [ - "bicycle", - "cargo_bicycle", - "car", - "scooter", - "moped", - "other" - ] - }, - "vehicle_types": { - "$id": "#/definitions/vehicle_types", - "type": "array", - "description": "Array of vehicle types", - "items": { - "$id": "#/definitions/vehicle_types/items", - "$ref": "#/definitions/vehicle_type" - }, - "uniqueItems": true - }, - "version": { - "$id": "#/definitions/version", - "type": "string", - "description": "The version of MDS this data represents", - "examples": [ - "1.2.0" - ], - "pattern": "^1\\.2\\.[0-9]+$" - } - } -} diff --git a/schema/templates/geography/geographies.json b/schema/templates/geography/geographies.json deleted file mode 100644 index 133801816..000000000 --- a/schema/templates/geography/geographies.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/geography/geographies.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Geographies Schema", - "type": "object", - "definitions": { - }, - "required": [ - "geographies", - "updated", - "version" - ], - "properties": { - "geographies": { - "$id": "#/properties/geographies", - "type": "array", - "title": "The array of policy objects in this payload", - "items": { - "$id": "#/properties/geographies/items", - "$ref": "#/definitions/geography" - } - }, - "updated": { - "$id": "#/properties/updated", - "$ref": "#/definitions/timestamp", - "description": "The timestamp when geographies was last updated" - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version", - "description": "The version of MDS that the geographies represents" - } - }, - "additionalProperties": false -} diff --git a/schema/templates/geography/geography.json b/schema/templates/geography/geography.json deleted file mode 100644 index e5987bcc0..000000000 --- a/schema/templates/geography/geography.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/geography/geography.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Geography Schema", - "type": "object", - "definitions": { - "geography": { - "$id": "#/definitions/geography", - "type": "object", - "title": "The geography object schema", - "additionalProperties": false, - "required": [ - "name", - "geography_id", - "geography_json", - "published_date" - ], - "properties": { - "name": { - "$id": "#/definitions/geography/properties/name", - "$ref": "#/definitions/string", - "description": "Name of geography" - }, - "description": { - "$id": "#/definitions/geography/properties/description", - "$ref": "#/definitions/string", - "description": "Description of geography" - }, - "geography_type": { - "$id": "#/definitions/geography/properties/geography_type", - "type": "string", - "description": "The type of geography" - }, - "geography_id": { - "$id": "#/definitions/geography/properties/geography_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of geography" - }, - "geography_json": { - "$id": "#/definitions/geography/properties/geography_json", - "$ref": "https://geojson.org/schema/FeatureCollection.json", - "description": "The GeoJSON FeatureCollection that defines the geographical coordinates" - }, - "effective_date":{ - "$id": "#/definitions/geography/properties/effective_date", - "$ref": "#/definitions/null_timestamp", - "description": "The date at which a Geography is considered 'live'. Must be at or after published_date." - }, - "published_date": { - "$id": "#/definitions/geography/properties/published_date", - "$ref": "#/definitions/timestamp", - "description": "Timestamp at which the geography was published i.e. made immutable" - }, - "retire_date": { - "$id": "#/definitions/geography/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "Time that the geography is slated to retire. Once the retire date is passed, new policies can no longer reference it and old policies referencing it should be updated. Retired geographies should continue to be returned in the geographies list. Must be after effective_date." - }, - "prev_geographies": { - "$id": "#/definitions/geography/properties/prev_geographies", - "$ref": "#/definitions/null_uuid_array", - "description": "Unique IDs of prior geographies replaced by this one", - "uniqueItems": true - } - } - } - }, - "required": [ - "geography", - "version" - ], - "properties": { - "geography": { - "$id": "#/properties/geography", - "$ref": "#/definitions/geography", - "description": "The geography in this payload", - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version", - "description": "The version of MDS that the geography represents" - } - }, - "additionalProperties": false -} diff --git a/schema/templates/policy/policy.json b/schema/templates/policy/policy.json deleted file mode 100644 index 3f2109550..000000000 --- a/schema/templates/policy/policy.json +++ /dev/null @@ -1,393 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/policy/policy.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "The MDS Policy Schema", - "type": "object", - "definitions": { - "policy": { - "$id": "#/definitions/policy", - "type": "object", - "title": "The policy object schema", - "additionalProperties": false, - "required": [ - "name", - "policy_id", - "description", - "start_date", - "published_date", - "rules" - ], - "properties": { - "name": { - "$id": "#/definitions/policy/properties/name", - "$ref": "#/definitions/string", - "description": "Name of policy" - }, - "policy_id": { - "$id": "#/definitions/policy/properties/policy_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of policy" - }, - "provider_ids": { - "$id": "#/definitions/policy/properties/provider_ids", - "$ref": "#/definitions/null_uuid_array", - "description": "Providers for whom this policy is applicable; empty arrays and null/absent implies all Providers.", - "uniqueItems": true - }, - "description": { - "$id": "#/definitions/policy/properties/description", - "$ref": "#/definitions/string", - "description": "Description of policy" - }, - "currency": { - "$id": "#/definitions/policy/properties/currency", - "$ref": "#/definitions/currency" - }, - "start_date": { - "$id": "#/definitions/policy/properties/start_date", - "$ref": "#/definitions/timestamp", - "description": "Beginning date/time of policy enforcement" - }, - "end_date": { - "$id": "#/definitions/policy/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "End date/time of policy enforcement" - }, - "published_date": { - "$id": "#/definitions/policy/properties/published_date", - "$ref": "#/definitions/timestamp", - "description": "Timestamp at which the policy was published" - }, - "prev_policies": { - "$id": "#/definitions/policy/properties/prev_policies", - "$ref": "#/definitions/null_uuid_array", - "description": "Unique IDs of prior policies replaced by this one", - "uniqueItems": true - }, - "rules": { - "$id": "#/definitions/rules", - "type": "array", - "description": "Array of applicable Rule objects", - "items": { - "$id": "#/definitions/policy/properties/rules/items", - "$ref": "#/definitions/rule" - }, - "minItems": 1 - } - } - }, - "rule": { - "$id": "#/definitions/rule", - "type": "object", - "description": "An individual rule in a policy", - "additionalProperties": false, - "required": [ - "name", - "rule_id", - "rule_type", - "geographies", - "states" - ], - "properties": { - "name": { - "$id": "#/definitions/rule/properties/name", - "$ref": "#/definitions/string", - "description": "Name of rule" - }, - "rule_id": { - "$id": "#/definitions/rule/properties/rule_id", - "$ref": "#/definitions/uuid", - "description": "Unique ID of rule" - }, - "rule_type": { - "$id": "#/definitions/rule/properties/rule_type", - "type": "string", - "description": "The type of rule", - "enum": [ - "count", - "time", - "speed", - "user" - ] - }, - "geographies": { - "$id": "#/definitions/rule/properties/geographies", - "$ref": "#/definitions/uuid_array", - "description": "List of Geography UUIDs (non-overlapping) specifying the covered geography", - "minItems": 1, - "uniqueItems": true - }, - "states": { - "$id": "#/definitions/rule/properties/states", - "type": "object", - "description": "Vehicle state to which this rule applies. Optionally provide a list of specific vehicle events as a subset of a given state for the rule to apply to. An empty list or null/absent defaults to \"all\" for the state.", - "propertyNames": { - "$id": "#/definitions/rule/properties/states/propertyNames", - "$ref": "#/definitions/vehicle_state" - }, - "properties": {}, - "additionalProperties": { - "type": "array", - "uniqueItems": true, - "items": { - "$ref": "#/definitions/vehicle_event" - } - } - }, - "rule_units": { - "$id": "#/definitions/rule/properties/rule_units", - "type": "string", - "description": "Measured units of policy", - "enum": [ - "seconds", - "minutes", - "hours", - "days", - "mph", - "kph", - "devices", - "amount" - ] - }, - "vehicle_types": { - "$id": "#/definitions/rule/properties/vehicle_types", - "$ref": "#/definitions/null_vehicle_types", - "description": "Applicable vehicle types, default \"all\"" - }, - "propulsion_types": { - "$id": "#/definitions/rule/properties/propulsion_types", - "$ref": "#/definitions/null_propulsion_types", - "description": "Applicable vehicle propulsion types, default \"all\"" - }, - "minimum": { - "$id": "#/definitions/rule/properties/minimum", - "type": [ - "null", - "integer" - ], - "description": "Minimum value, if applicable (default 0)" - }, - "maximum": { - "$id": "#/definitions/rule/properties/maximum", - "type": [ - "null", - "integer" - ], - "description": "Maximum value, if applicable (default unlimited)" - }, - "inclusive_minimum": { - "$id": "#/definitions/rule/properties/inclusive_minimum", - "type": [ - "null", - "boolean" - ], - "description": "Whether the rule minimum is considered in-bounds (default true)" - }, - "inclusive_maximum": { - "$id": "#/definitions/rule/properties/inclusive_maximum", - "type": [ - "null", - "boolean" - ], - "description": "Whether the rule maximum is considered in-bounds (default true)" - }, - "rate_amount": { - "$id": "#/definitions/rule/properties/rate_amount", - "type": [ - "null", - "integer" - ], - "description": "The amount of a rate applied when this rule applies, if applicable (default zero). A positive integer rate amount represents a fee, while a negative integer represents a subsidy. Rate amounts are given in the currency defined in the Policy." - }, - "rate_recurrence": { - "$id": "#/definitions/rule/properties/rate_recurrence", - "type": [ - "string", - "null" - ], - "description": "Specify how a rate is applied – either once, or periodically according to a time unit specified using rule_units", - "enum": [ - "once_on_match", - "once_on_unmatch", - "each_time_unit", - "per_complete_time_unit" - ] - }, - "rate_applies_when": { - "$id": "#/definitions/rule/properties/rate_applies_when", - "type": [ - "string", - "null" - ], - "description": "Specify when a rate is applicable to an event or count: when it's within rule bounds or when it is not", - "enum": [ - "in_bounds", - "out_of_bounds" - ] - }, - "start_time": { - "$id": "#/definitions/rule/properties/start_time", - "$ref": "#/definitions/null_iso_time", - "description": "Beginning time-of-day when the rule is in effect (default 00:00:00)" - }, - "end_time": { - "$id": "#/definitions/rule/properties/end_time", - "$ref": "#/definitions/null_iso_time", - "description": "Ending time-of-day when the rule is in effect (default 23:59:59)" - }, - "days": { - "$id": "#/definitions/rule/properties/days", - "$ref": "#/definitions/null_days", - "description": "Days when the rule is in effect (default all)" - }, - "messages": { - "$id": "#/definitions/rule/properties/messages", - "type": [ - "null", - "object" - ], - "description": "Message to rider user, if desired, in various languages, keyed by BCP 47 language tag", - "propertyNames": { - "pattern": "([A-Za-z]{2,3})([-][A-Za-z]{3}){0,3}([-]([A-Za-z]{4}))?([-]([A-Za-z]{2}|[0-9]{3}))?" - } - }, - "value_url": { - "$id": "#/definitions/rule/properties/value_url", - "type": [ - "null", - "string" - ], - "description": "URL to an API endpoint that can provide dynamic information for the measured value", - "format": "uri" - } - }, - "allOf": [ - { - "description": "Valid rule_type and rule_unit values for this rule", - "oneOf": [ - { - "properties": { - "rule_type": { - "const": "user" - } - } - }, - { - "allOf": [ - { - "required": [ - "rule_units" - ] - }, - { - "oneOf": [ - { - "properties": { - "rule_type": { - "const": "time" - }, - "rule_units": { - "enum": [ - "seconds", - "minutes", - "hours", - "days" - ] - } - } - }, - { - "properties": { - "rule_type": { - "const": "speed" - }, - "rule_units": { - "enum": [ - "mph", - "kph" - ] - } - } - }, - { - "properties": { - "rule_type": { - "const": "count" - }, - "rule_units": { - "enum": [ - "devices" - ] - } - } - }, - { - "required": [ - "rate_amount", - "rate_recurrence" - ], - "properties": { - "rule_units": { - "enum": [ - "amount", - "seconds", - "minutes", - "hours", - "days" - ] - } - } - } - ] - } - ] - } - ] - } - ] - } - }, - "required": [ - "data", - "updated", - "version" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [ - "policies" - ], - "properties": { - "policies": { - "$id": "#/properties/data/properties/policies", - "type": "array", - "title": "The array of policy objects in this payload", - "items": { - "$id": "#/properties/data/properties/policies/items", - "$ref": "#/definitions/policy" - } - } - }, - "additionalProperties": false - }, - "end_date": { - "$id": "#/properties/end_date", - "$ref": "#/definitions/null_timestamp", - "description": "The timestamp after which the Policy is no longer effective" - }, - "updated": { - "$id": "#/properties/updated", - "$ref": "#/definitions/timestamp", - "description": "The timestamp when the Policy was last updated" - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version", - "description": "The version of MDS that the Policy represents" - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/schema/templates/provider/endpoint.json b/schema/templates/provider/endpoint.json deleted file mode 100644 index 1a2dc8f36..000000000 --- a/schema/templates/provider/endpoint.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$id": "https://raw.githubusercontent.com/openmobilityfoundation/mobility-data-specification/main/provider/endpoint.json", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "Schema for MDS Provider endpoint payloads", - "type": "object", - "definitions": {}, - "required": [ - "data", - "version" - ], - "properties": { - "data": { - "$id": "#/properties/data", - "type": "object", - "description": "The data records in this payload", - "required": [], - "properties": {}, - "additionalProperties": false - }, - "version": { - "$id": "#/properties/version", - "$ref": "#/definitions/version" - } - }, - "additionalProperties": false -} \ No newline at end of file diff --git a/schema/templates/provider/status_changes.json b/schema/templates/provider/status_changes.json deleted file mode 100644 index c289a7cb6..000000000 --- a/schema/templates/provider/status_changes.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "status_changes": { - "$id": "#/properties/data/properties/status_changes", - "type": "array", - "title": "The status_changes payload", - "items": { - "$id": "#/properties/data/properties/status_changes/items", - "type": "object", - "title": "The status_change item schema", - "additionalProperties": false, - "required": [ - "vehicle_state", - "event_types", - "event_time", - "event_location" - ], - "properties": { - "event_time": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_time", - "$ref": "#/definitions/timestamp", - "description": "The time the event occurred, expressed as a Unix Timestamp" - }, - "publication_time": { - "$id": "#/properties/data/properties/status_changes/items/properties/publication_time", - "$ref": "#/definitions/timestamp", - "description": "The time the event became available through the status changes endpoint, expressed as a Unix Timestamp" - }, - "event_location": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "The GPS or GNSS coordinates of where the event occurred" - }, - "vehicle_state": { - "$id": "#/properties/data/properties/status_changes/items/properties/vehicle_state", - "$ref": "#/definitions/vehicle_state", - "description": "The state of the vehicle" - }, - "event_types": { - "$id": "#/properties/data/properties/status_changes/items/properties/event_types", - "$ref": "#/definitions/vehicle_events", - "description": "The event(s) that caused a change in the vehicle's state" - }, - "battery_pct": { - "$id": "#/properties/data/properties/status_changes/items/properties/battery_pct", - "type": [ - "number", - "null" - ], - "description": "Percent charge of device battery, expressed between 0 and 1", - "examples": [ - 0.89 - ], - "minimum": 0, - "maximum": 1 - }, - "trip_id": { - "$id": "#/properties/data/properties/status_changes/items/properties/trip_id", - "$ref": "#/definitions/uuid", - "description": "Trip UUID (foreign key to Trips API), required if event_types contains trip_start, trip_end, trip_cancel, trip_enter_jurisdiction, or trip_leave_jurisdiction" - }, - "associated_ticket": { - "$id": "#/properties/data/properties/status_changes/items/properties/associated_ticket", - "$ref": "#/definitions/string", - "description": "Identifier for an associated ticket inside an Agency-maintained 311 or CRM system." - } - }, - "allOf": [] - } - } -} \ No newline at end of file diff --git a/schema/templates/provider/stops.json b/schema/templates/provider/stops.json deleted file mode 100644 index d2fcbb5fd..000000000 --- a/schema/templates/provider/stops.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "stops": { - "$id": "#/properties/data/properties/stops", - "type": "array", - "title": "The stops payload", - "items": { - "$id": "#/properties/data/properties/stops/items", - "$ref": "#/definitions/stop" - } - } -} \ No newline at end of file diff --git a/schema/templates/provider/trips.json b/schema/templates/provider/trips.json deleted file mode 100644 index d271332a1..000000000 --- a/schema/templates/provider/trips.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "trips": { - "$id": "#/properties/data/properties/trips", - "type": "array", - "title": "The trips payload", - "items": { - "$id": "#/properties/data/properties/trips/items", - "type": "object", - "title": "The trip item schema", - "additionalProperties": false, - "required": [ - "trip_id", - "trip_duration", - "trip_distance", - "route", - "accuracy", - "start_time", - "end_time" - ], - "properties": { - "trip_id": { - "$id": "#/properties/data/properties/trips/items/properties/trip_id", - "description": "A unique ID for each trip", - "$ref": "#/definitions/uuid" - }, - "trip_duration": { - "$id": "#/properties/data/properties/trips/items/properties/trip_duration", - "type": "integer", - "description": "The length of time, in seconds, that the trip lasted", - "default": 0, - "examples": [ - 600 - ] - }, - "trip_distance": { - "$id": "#/properties/data/properties/trips/items/properties/trip_distance", - "type": "integer", - "description": "The distance, in meters, that the trip covered", - "default": 0, - "examples": [ - 1000 - ] - }, - "route": { - "$id": "#/properties/data/properties/trips/items/properties/route", - "title": "The Route Schema", - "$ref": "#/definitions/MDS_FeatureCollection_Route" - }, - "accuracy": { - "$id": "#/properties/data/properties/trips/items/properties/accuracy", - "type": "integer", - "title": "The approximate level of accuracy, in meters, of Points within route", - "default": 0, - "examples": [ - 15 - ] - }, - "start_time": { - "$id": "#/properties/data/properties/trips/items/properties/start_time", - "description": "The time the trip began, expressed as a Unix Timestamp", - "$ref": "#/definitions/timestamp" - }, - "end_time": { - "$id": "#/properties/data/properties/trips/items/properties/end_time", - "description": "The time the trip ended, expressed as a Unix Timestamp", - "$ref": "#/definitions/timestamp" - }, - "publication_time": { - "$id": "#/properties/data/properties/trips/items/properties/publication_time", - "description": "The time the trip became available through the trips endpoint, expressed as a Unix Timestamp", - "$ref": "#/definitions/timestamp" - }, - "parking_verification_url": { - "$id": "#/properties/data/properties/trips/items/properties/parking_verification_url", - "type": [ - "string", - "null" - ], - "format": "uri", - "description": "A URL to a photo (or other evidence) of proper vehicle parking", - "examples": [ - "https://data.provider.co/parking_verify/1234.jpg" - ] - }, - "standard_cost": { - "$id": "#/properties/data/properties/trips/items/properties/standard_cost", - "type": [ - "integer", - "null" - ], - "description": "The cost, in the currency defined in `currency`, that it would cost to perform that trip in the standard operation of the System. If no currency is given, USD cents is implied.", - "examples": [ - 500 - ] - }, - "actual_cost": { - "$id": "#/properties/data/properties/trips/items/properties/actual_cost", - "type": [ - "integer", - "null" - ], - "description": "The actual cost, in the currency defined in `currency`, paid by the customer of the *mobility as a service* provider. If no currency is given, USD cents is implied.", - "examples": [ - 520 - ] - }, - "currency": { - "$id": "#/properties/data/properties/trips/items/properties/currency", - "$ref": "#/definitions/currency" - } - } - } - } -} \ No newline at end of file diff --git a/schema/templates/provider/vehicles.json b/schema/templates/provider/vehicles.json deleted file mode 100644 index e9117524a..000000000 --- a/schema/templates/provider/vehicles.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "vehicles": { - "$id": "#/properties/data/properties/vehicles", - "type": "array", - "title": "The vehicles payload", - "items": { - "$id": "#/properties/data/properties/vehicles/items", - "type": "object", - "title": "The vehicle item schema", - "required": [ - "last_event_time", - "last_vehicle_state", - "last_event_types", - "last_event_location" - ], - "properties": { - "last_event_time": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_event_time", - "$ref": "#/definitions/timestamp", - "description": "The time the most recent status change event occurred, expressed as a Unix Timestamp" - }, - "last_vehicle_state": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_vehicle_state", - "$ref": "#/definitions/vehicle_state", - "description": "The last known state of the vehicle" - }, - "last_event_types": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_event_types", - "$ref": "#/definitions/vehicle_events", - "description": "The most recent event(s) that caused a change in the vehicle's state" - }, - "last_event_location": { - "$id": "#/properties/data/properties/vehicles/items/properties/last_event_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Location of the vehicle's last status change event" - }, - "current_location": { - "$id": "#/properties/data/properties/vehicles/items/properties/current_location", - "$ref": "#/definitions/MDS_Feature_Point", - "description": "Current location of vehicle if different from last event, and the vehicle is not currently on a trip" - }, - "battery_pct": { - "$id": "#/properties/data/properties/vehicles/items/properties/battery_pct", - "type": [ - "number", - "null" - ], - "description": "Percent charge of device battery, expressed between 0 and 1", - "examples": [ - 0.89 - ], - "minimum": 0, - "maximum": 1 - } - }, - "allOf": [ - { - "description": "Valid last_vehicle_state values for this endpoint", - "properties": { - "last_vehicle_state": { - "enum": [ - "available", - "elsewhere", - "non_operational", - "on_trip", - "removed", - "reserved", - "unknown" - ] - } - } - } - ] - } - } -}