Skip to content

Commit 56f5fa1

Browse files
author
bill dirks
committed
Update version negotiation to use OPTIONS method
1 parent 476eac8 commit 56f5fa1

4 files changed

Lines changed: 16 additions & 110 deletions

File tree

generate_schema/generate_provider_schema.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,3 @@ 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-

generate_schema/provider/versions.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

provider/README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ 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)
1110
* [Realtime Data](#realtime-data)
1211

1312
## General Information
@@ -42,6 +41,22 @@ Content-Type: application/vnd.mds.provider+json;version=0.3
4241
4342
If an unsupported or invalid version is requested, the API must respond with a status of `406 Not Acceptable`. In which case, the response should include a body specifying a list of supported versions.
4443

44+
A client can explicitly negotiate headers using the `OPTIONS` method to an MDS endpoint. For example, to check if `trips` supports either version `0.2` or `0.3` with a preference for `0.2`, the client would issue the following request:
45+
46+
```http
47+
OPTIONS /trips/ HTTP/1.1
48+
Host: provider.example.com
49+
Accept: application/vnd.mds.provider+json;version=0.2,application/vnd.mds.provider+json;version=0.3;q=0.9
50+
```
51+
52+
The response will include the most preferred supported version in the `Content-Type` header. For example, if only `0.3` is supported:
53+
54+
```http
55+
Content-Type: application/vnd.mds.provider+json;version=0.3
56+
```
57+
58+
The client can use the returned value verbatim as a version request in the `Accept` header.
59+
4560
### Response Format
4661

4762
The response to a client request must include a valid HTTP status code defined in the [IANA HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml). It also must set the `Content-Type` header, as specified in the [Versioning](#Versioning) section.
@@ -303,22 +318,6 @@ When multiple query parameters are specified, they should all apply to the retur
303318
| | | `rebalance_pick_up` | Device removed from street and will be placed at another location to rebalance service |
304319
| | | `maintenance_pick_up` | Device removed from street so it can be worked on |
305320

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-
322321
[Top][toc]
323322

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

provider/versions.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)