Skip to content

Commit b177066

Browse files
authored
Use type and properties objects for arrays, tweak required field syntax (#37)
Many arrays defined in GBFS schemas define item properties directly in the containing object. In this commit, we provide a schema for these array items to be validated against. Because in most cases array items are objects, this amounted to adding "type": "object" and moving the properties that were defined under a "properties" key. Additionally, in some cases, array properties would be marked required by setting "required": "true" below the "items" property. We also now use the more common syntax of requiring fields by setting "required" to a list of strings.
1 parent 0e3651f commit b177066

10 files changed

+680
-628
lines changed

free_bike_status.json

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -31,73 +31,76 @@
3131
"bikes": {
3232
"type": "array",
3333
"items": {
34-
"bike_id": {
35-
"description": "Rotating (as of v2.0) identifier of a vehicle.",
36-
"type": "string"
37-
},
38-
"lat": {
39-
"description": "The latitude of the vehicle.",
40-
"type": "number",
41-
"minimum": -90,
42-
"maximum": 90
43-
},
44-
"lon": {
45-
"description": "The longitude of the vehicle.",
46-
"type": "number",
47-
"minimum": -180,
48-
"maximum": 180
49-
},
50-
"is_reserved": {
51-
"description": "Is the vehicle currently reserved?",
52-
"type": "boolean"
53-
},
54-
"is_disabled": {
55-
"description": "Is the vehicle currently disabled (broken)?",
56-
"type": "boolean"
57-
},
58-
"rental_uris": {
59-
"description": "Contains rental uris for Android, iOS, and web in the android, ios, and web fields (added in v1.1).",
60-
"type": "object",
61-
"properties": {
62-
"android": {
63-
"description": "URI that can be passed to an Android app with an intent (added in v1.1).",
64-
"type": "string",
65-
"format": "uri"
66-
},
67-
"ios": {
68-
"description": "URI that can be used on iOS to launch the rental app for this vehicle (added in v1.1).",
69-
"type": "string",
70-
"format": "uri"
71-
},
72-
"web": {
73-
"description": "URL that can be used by a web browser to show more information about renting this vehicle (added in v1.1).",
74-
"type": "string",
75-
"format": "uri"
34+
"type":"object",
35+
"properties": {
36+
"bike_id": {
37+
"description": "Rotating (as of v2.0) identifier of a vehicle.",
38+
"type": "string"
39+
},
40+
"lat": {
41+
"description": "The latitude of the vehicle.",
42+
"type": "number",
43+
"minimum": -90,
44+
"maximum": 90
45+
},
46+
"lon": {
47+
"description": "The longitude of the vehicle.",
48+
"type": "number",
49+
"minimum": -180,
50+
"maximum": 180
51+
},
52+
"is_reserved": {
53+
"description": "Is the vehicle currently reserved?",
54+
"type": "boolean"
55+
},
56+
"is_disabled": {
57+
"description": "Is the vehicle currently disabled (broken)?",
58+
"type": "boolean"
59+
},
60+
"rental_uris": {
61+
"description": "Contains rental uris for Android, iOS, and web in the android, ios, and web fields (added in v1.1).",
62+
"type": "object",
63+
"properties": {
64+
"android": {
65+
"description": "URI that can be passed to an Android app with an intent (added in v1.1).",
66+
"type": "string",
67+
"format": "uri"
68+
},
69+
"ios": {
70+
"description": "URI that can be used on iOS to launch the rental app for this vehicle (added in v1.1).",
71+
"type": "string",
72+
"format": "uri"
73+
},
74+
"web": {
75+
"description": "URL that can be used by a web browser to show more information about renting this vehicle (added in v1.1).",
76+
"type": "string",
77+
"format": "uri"
78+
}
7679
}
80+
},
81+
"vehicle_type_id": {
82+
"description": "The vehicle_type_id of this vehicle (added in v2.1-RC).",
83+
"type": "string"
84+
},
85+
"last_reported": {
86+
"description": "The last time this vehicle reported its status to the operator's backend in POSIX time (added in v2.1-RC).",
87+
"type": "number",
88+
"minimum": 1450155600
89+
},
90+
"current_range_meters": {
91+
"description": "The furthest distance in meters that the vehicle can travel without recharging or refueling with the vehicle's current charge or fuel (added in v2.1-RC).",
92+
"type": "number",
93+
"minimum": 0
94+
},
95+
"station_id": {
96+
"description": "Identifier referencing the station_id if the vehicle is currently at a station (added in v2.1-RC2).",
97+
"type": "string"
98+
},
99+
"pricing_plan_id": {
100+
"description": "The plan_id of the pricing plan this vehicle is eligible for (added in v2.1-RC2).",
101+
"type": "string"
77102
}
78103
},
79-
"vehicle_type_id": {
80-
"description": "The vehicle_type_id of this vehicle (added in v2.1-RC).",
81-
"type": "string"
82-
},
83-
"last_reported": {
84-
"description": "The last time this vehicle reported its status to the operator's backend in POSIX time (added in v2.1-RC).",
85-
"type": "number",
86-
"minimum": 1450155600
87-
},
88-
"current_range_meters": {
89-
"description": "The furthest distance in meters that the vehicle can travel without recharging or refueling with the vehicle's current charge or fuel (added in v2.1-RC).",
90-
"type": "number",
91-
"minimum": 0
92-
},
93-
"station_id": {
94-
"description": "Identifier referencing the station_id if the vehicle is currently at a station (added in v2.1-RC2).",
95-
"type": "string"
96-
},
97-
"pricing_plan_id": {
98-
"description": "The plan_id of the pricing plan this vehicle is eligible for (added in v2.1-RC2).",
99-
"type": "string"
100-
},
101104
"required": [
102105
"bike_id",
103106
"is_reserved",
@@ -108,13 +111,13 @@
108111
"bikes"
109112
]
110113
}
111-
},
112-
"required": [
113-
"last_updated",
114-
"ttl",
115-
"version",
116-
"data"
117-
]
114+
}
118115
}
119-
}
116+
},
117+
"required": [
118+
"last_updated",
119+
"ttl",
120+
"version",
121+
"data"
122+
]
120123
}

gbfs_versions.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@
6363
"url"
6464
]
6565
}
66-
},
67-
"required": true
66+
}
6867
},
68+
"required": [
69+
"versions"
70+
],
6971
"additionalProperties": false
7072
}
7173
},
@@ -75,4 +77,4 @@
7577
"version",
7678
"data"
7779
]
78-
}
80+
}

0 commit comments

Comments
 (0)