Skip to content

Commit 476eac8

Browse files
author
bill dirks
committed
Add versions endpoint.
1 parent 998999a commit 476eac8

4 files changed

Lines changed: 110 additions & 0 deletions

File tree

generate_schema/generate_provider_schema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,17 @@ def get_json_file(path):
157157
# Write to the `provider` directory.
158158
with open("../provider/status_changes.json", "w") as statusfile:
159159
statusfile.write(json.dumps(status_changes, indent=2))
160+
161+
# Create the standalone version JSON schema by including the needed definitions
162+
versions = get_json_file("provider/versions.json")
163+
versions["definitions"] = {
164+
"links": common["definitions"]["links"],
165+
"version": common["definitions"]["version"],
166+
}
167+
168+
# Check that it is a valid schema
169+
jsonschema.Draft6Validator.check_schema(versions)
170+
# Write to the `provider` directory.
171+
with open("../provider/versions.json", "w") as f:
172+
f.write(json.dumps(versions, indent=2))
173+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$id": "https://raw.githubusercontent.com/CityofLosAngeles/mobility-data-specification/master/provider/versions.json",
3+
"$schema": "http://json-schema.org/draft-06/schema#",
4+
"title": "The MDS Provider Schema, versions payload",
5+
"type": "object",
6+
"definitions": {},
7+
"required": [
8+
"data"
9+
],
10+
"properties": {
11+
"version": {
12+
"$ref": "#/definitions/version"
13+
},
14+
"data": {
15+
"$id": "#/properties/data",
16+
"type": "object",
17+
"title": "The page of data",
18+
"required": [
19+
"versions"
20+
],
21+
"properties": {
22+
"versions": {
23+
"$id": "#/properties/data/properties/versions",
24+
"type": "array",
25+
"title": "The versions Schema",
26+
"items": {
27+
"type": "string",
28+
"pattern": "^0\\.[0-9]$"
29+
}
30+
}
31+
},
32+
"additionalProperties": false
33+
},
34+
"links": {
35+
"$ref": "#/definitions/links"
36+
}
37+
},
38+
"additionalProperties": false
39+
}

provider/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This specification contains a data standard for *mobility as a service* provider
77
* [General Information](#general-information)
88
* [Trips](#trips)
99
* [Status Changes](#status-changes)
10+
* [Versions](#versions)
1011
* [Realtime Data](#realtime-data)
1112

1213
## General Information
@@ -302,6 +303,22 @@ When multiple query parameters are specified, they should all apply to the retur
302303
| | | `rebalance_pick_up` | Device removed from street and will be placed at another location to rebalance service |
303304
| | | `maintenance_pick_up` | Device removed from street so it can be worked on |
304305

306+
[Top][toc]
307+
308+
## Versions
309+
310+
The versions endpoint allows user to query for the versions the provider supports.
311+
312+
Endpoint: `/versions`
313+
Method: `GET`
314+
Schema: [`versions` schema][versions-schema]
315+
`data` Payload: `{ "versions": [] }`, an array of version strings usable in versioned requests
316+
317+
Here is an example payload:
318+
319+
"versions": [ "0.2", "0.3" ]
320+
321+
305322
[Top][toc]
306323

307324
## Realtime Data
@@ -320,3 +337,4 @@ All MDS compatible `provider` APIs must expose a public [GBFS](https://github.co
320337
[toc]: #table-of-contents
321338
[trips-schema]: trips.json
322339
[ts]: #timestamps
340+
[versions-schema] versions.json

provider/versions.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$id": "https://raw.githubusercontent.com/CityofLosAngeles/mobility-data-specification/master/provider/versions.json",
3+
"$schema": "http://json-schema.org/draft-06/schema#",
4+
"title": "The MDS Provider Schema, versions payload",
5+
"type": "object",
6+
"definitions": {},
7+
"required": [
8+
"data"
9+
],
10+
"properties": {
11+
"version": {
12+
"$ref": "#/definitions/version"
13+
},
14+
"data": {
15+
"$id": "#/properties/data",
16+
"type": "object",
17+
"title": "The page of data",
18+
"required": [
19+
"versions"
20+
],
21+
"properties": {
22+
"versions": {
23+
"$id": "#/properties/data/properties/versions",
24+
"type": "array",
25+
"title": "The versions Schema",
26+
"items": {
27+
"type": "string",
28+
"pattern": "^0\\.[0-9]$"
29+
}
30+
}
31+
},
32+
"additionalProperties": false
33+
},
34+
"links": {
35+
"$ref": "#/definitions/links"
36+
}
37+
},
38+
"additionalProperties": false
39+
}

0 commit comments

Comments
 (0)