From 5fbf59a9272788b942c5b4a9a65b5c55979ebc3b Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Mon, 29 Jun 2020 14:54:01 -0700 Subject: [PATCH] use contains for vehicle_events rule Ensure that the vehicle_events array contains at least one of the valid transition events for the given vehicle_state --- agency/get_vehicle.json | 117 ++++----------------------------- agency/post_vehicle_event.json | 117 ++++----------------------------- provider/events.json | 117 ++++----------------------------- provider/status_changes.json | 117 ++++----------------------------- provider/vehicles.json | 117 ++++----------------------------- schema/templates/common.json | 117 ++++----------------------------- 6 files changed, 84 insertions(+), 618 deletions(-) diff --git a/agency/get_vehicle.json b/agency/get_vehicle.json index dcd25895a..b87025431 100644 --- a/agency/get_vehicle.json +++ b/agency/get_vehicle.json @@ -198,29 +198,10 @@ { "properties": { "state": { - "enum": [ - "available" - ] + "const": "available" }, "prev_events": { - "items": { - "not": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_drop_off", "battery_charged", @@ -241,20 +222,10 @@ { "properties": { "state": { - "enum": [ - "elsewhere" - ] + "const": "elsewhere" }, "prev_events": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_leave_jurisdiction" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_leave_jurisdiction" @@ -266,24 +237,10 @@ { "properties": { "state": { - "enum": [ - "non_operational" - ] + "const": "non_operational" }, "prev_events": { - "items": { - "not": { - "enum": [ - "battery_low", - "comms_restored", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "battery_low", "comms_restored", @@ -299,21 +256,10 @@ { "properties": { "state": { - "enum": [ - "on_trip" - ] + "const": "on_trip" }, "prev_events": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_enter_jurisdiction", - "trip_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_enter_jurisdiction", @@ -326,24 +272,10 @@ { "properties": { "state": { - "enum": [ - "removed" - ] + "const": "removed" }, "prev_events": { - "items": { - "not": { - "enum": [ - "agency_pick_up", - "compliance_pick_up", - "decommissioned", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_pick_up", "compliance_pick_up", @@ -359,20 +291,10 @@ { "properties": { "state": { - "enum": [ - "reserved" - ] + "const": "reserved" }, "prev_events": { - "items": { - "not": { - "enum": [ - "comms_restored", - "reservation_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "reservation_start" @@ -384,21 +306,10 @@ { "properties": { "state": { - "enum": [ - "unknown" - ] + "const": "unknown" }, "prev_events": { - "items": { - "not": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_lost", "missing", diff --git a/agency/post_vehicle_event.json b/agency/post_vehicle_event.json index 92065afb4..9d9afce68 100644 --- a/agency/post_vehicle_event.json +++ b/agency/post_vehicle_event.json @@ -170,29 +170,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "available" - ] + "const": "available" }, "event_types": { - "items": { - "not": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_drop_off", "battery_charged", @@ -213,20 +194,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "elsewhere" - ] + "const": "elsewhere" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_leave_jurisdiction" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_leave_jurisdiction" @@ -238,24 +209,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "non_operational" - ] + "const": "non_operational" }, "event_types": { - "items": { - "not": { - "enum": [ - "battery_low", - "comms_restored", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "battery_low", "comms_restored", @@ -271,21 +228,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "on_trip" - ] + "const": "on_trip" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_enter_jurisdiction", - "trip_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_enter_jurisdiction", @@ -298,24 +244,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "removed" - ] + "const": "removed" }, "event_types": { - "items": { - "not": { - "enum": [ - "agency_pick_up", - "compliance_pick_up", - "decommissioned", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_pick_up", "compliance_pick_up", @@ -331,20 +263,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "reserved" - ] + "const": "reserved" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "reservation_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "reservation_start" @@ -356,21 +278,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "unknown" - ] + "const": "unknown" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_lost", "missing", diff --git a/provider/events.json b/provider/events.json index ae21cbd06..93eb61aba 100644 --- a/provider/events.json +++ b/provider/events.json @@ -386,29 +386,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "available" - ] + "const": "available" }, "event_types": { - "items": { - "not": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_drop_off", "battery_charged", @@ -429,20 +410,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "elsewhere" - ] + "const": "elsewhere" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_leave_jurisdiction" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_leave_jurisdiction" @@ -454,24 +425,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "non_operational" - ] + "const": "non_operational" }, "event_types": { - "items": { - "not": { - "enum": [ - "battery_low", - "comms_restored", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "battery_low", "comms_restored", @@ -487,21 +444,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "on_trip" - ] + "const": "on_trip" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_enter_jurisdiction", - "trip_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_enter_jurisdiction", @@ -514,24 +460,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "removed" - ] + "const": "removed" }, "event_types": { - "items": { - "not": { - "enum": [ - "agency_pick_up", - "compliance_pick_up", - "decommissioned", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_pick_up", "compliance_pick_up", @@ -547,20 +479,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "reserved" - ] + "const": "reserved" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "reservation_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "reservation_start" @@ -572,21 +494,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "unknown" - ] + "const": "unknown" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_lost", "missing", diff --git a/provider/status_changes.json b/provider/status_changes.json index c510fe829..ae374db69 100644 --- a/provider/status_changes.json +++ b/provider/status_changes.json @@ -327,29 +327,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "available" - ] + "const": "available" }, "event_types": { - "items": { - "not": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_drop_off", "battery_charged", @@ -370,20 +351,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "elsewhere" - ] + "const": "elsewhere" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_leave_jurisdiction" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_leave_jurisdiction" @@ -395,24 +366,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "non_operational" - ] + "const": "non_operational" }, "event_types": { - "items": { - "not": { - "enum": [ - "battery_low", - "comms_restored", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "battery_low", "comms_restored", @@ -428,21 +385,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "on_trip" - ] + "const": "on_trip" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_enter_jurisdiction", - "trip_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_enter_jurisdiction", @@ -455,24 +401,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "removed" - ] + "const": "removed" }, "event_types": { - "items": { - "not": { - "enum": [ - "agency_pick_up", - "compliance_pick_up", - "decommissioned", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_pick_up", "compliance_pick_up", @@ -488,20 +420,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "reserved" - ] + "const": "reserved" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "reservation_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "reservation_start" @@ -513,21 +435,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "unknown" - ] + "const": "unknown" }, "event_types": { - "items": { - "not": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_lost", "missing", diff --git a/provider/vehicles.json b/provider/vehicles.json index 7cf05a17f..e579368f6 100644 --- a/provider/vehicles.json +++ b/provider/vehicles.json @@ -396,29 +396,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "available" - ] + "const": "available" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_drop_off", "battery_charged", @@ -439,20 +420,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "elsewhere" - ] + "const": "elsewhere" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_leave_jurisdiction" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_leave_jurisdiction" @@ -464,24 +435,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "non_operational" - ] + "const": "non_operational" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "battery_low", - "comms_restored", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "battery_low", "comms_restored", @@ -497,21 +454,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "on_trip" - ] + "const": "on_trip" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_enter_jurisdiction", - "trip_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_enter_jurisdiction", @@ -524,24 +470,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "removed" - ] + "const": "removed" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "agency_pick_up", - "compliance_pick_up", - "decommissioned", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_pick_up", "compliance_pick_up", @@ -557,20 +489,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "reserved" - ] + "const": "reserved" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "comms_restored", - "reservation_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "reservation_start" @@ -582,21 +504,10 @@ { "properties": { "last_vehicle_state": { - "enum": [ - "unknown" - ] + "const": "unknown" }, "last_event_types": { - "items": { - "not": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_lost", "missing", diff --git a/schema/templates/common.json b/schema/templates/common.json index 242f61830..63fcb31c3 100644 --- a/schema/templates/common.json +++ b/schema/templates/common.json @@ -330,29 +330,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "available" - ] + "const": "available" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "agency_drop_off", - "battery_charged", - "comms_restored", - "maintenance", - "on_hours", - "provider_drop_off", - "reservation_cancel", - "system_resume", - "trip_cancel", - "trip_end", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_drop_off", "battery_charged", @@ -373,20 +354,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "elsewhere" - ] + "const": "elsewhere" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_leave_jurisdiction" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_leave_jurisdiction" @@ -398,24 +369,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "non_operational" - ] + "const": "non_operational" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "battery_low", - "comms_restored", - "maintenance", - "off_hours", - "system_suspend", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "battery_low", "comms_restored", @@ -431,21 +388,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "on_trip" - ] + "const": "on_trip" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "comms_restored", - "trip_enter_jurisdiction", - "trip_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "trip_enter_jurisdiction", @@ -458,24 +404,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "removed" - ] + "const": "removed" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "agency_pick_up", - "compliance_pick_up", - "decommissioned", - "maintenance_pick_up", - "rebalance_pick_up", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "agency_pick_up", "compliance_pick_up", @@ -491,20 +423,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "reserved" - ] + "const": "reserved" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "comms_restored", - "reservation_start" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_restored", "reservation_start" @@ -516,21 +438,10 @@ { "properties": { "vehicle_state": { - "enum": [ - "unknown" - ] + "const": "unknown" }, "vehicle_events": { - "items": { - "not": { - "enum": [ - "comms_lost", - "missing", - "unspecified" - ] - } - }, - "additionalItems": { + "contains": { "enum": [ "comms_lost", "missing",