Skip to content

Commit 7f8f5cc

Browse files
authored
Add versioning for Agency and Policy API (#444)
* add versioning for Agency API A minimal set of changes to add versioning to the Agency API and stay consistent with the Provider API. * add backward-compatibility support * Fix table of content link * Create general-information.md This commit just copies the Versioning section from the provider spec to a "General information" file. * Agency : reference general information versioning * Provider: reference general information versioning * Policy: reference general information versioning * Correct fallback provider version
1 parent d34a93f commit 7f8f5cc

4 files changed

Lines changed: 79 additions & 39 deletions

File tree

agency/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This specification contains a collection of RESTful APIs used to specify the dig
77

88
## Table of Contents
99

10+
* [General Information](#general-information)
1011
* [Authorization](#authorization)
1112
* [Timestamps](#timestamps)
1213
* [Vehicles](#vehicles)
@@ -18,6 +19,16 @@ This specification contains a collection of RESTful APIs used to specify the dig
1819
* [Enum definitions](#enum-definitions)
1920
* [Responses](#responses)
2021

22+
## General information
23+
24+
The following information applies to all `agency` API endpoints. Details on providing authorization to endpoints is specified in the [Authorization](#authorization) section.
25+
26+
### Versioning
27+
28+
`agency` APIs must handle requests for specific versions of the specification from clients.
29+
30+
Versioning must be implemented as specified in the [`General information versioning section`][general-information/versioning].
31+
2132
## Authorization
2233

2334
When making requests, the Agency API expects `provider_id` to be part of the claims in a [JWT](https://jwt.io/) `access_token` in the `Authorization` header, in the form `Authorization: Bearer <access_token>`. The token issuance, expiration and revocation policies are at the discretion of the Agency.
@@ -300,3 +311,8 @@ A vehicle may have one or more values from the `propulsion`, depending on the nu
300311
| `error` | String | Error message string |
301312
| `error_description` | String | Human readable error description (can be localized) |
302313
| `error_details` | String[] | Array of error details |
314+
315+
[Top][toc]
316+
317+
[toc]: #table-of-contents
318+
[general-information/versioning]: /general-information.md#versioning

general-information.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Mobility Data Specification: **General information**
2+
3+
This document contains specifications that are shared between the various MDS APIs such as `agency`, `provider` and `policy`.
4+
5+
## Table of Contents
6+
7+
* [Versioning](#versioning)
8+
9+
## Versioning
10+
11+
MDS APIs must handle requests for specific versions of the specification from clients.
12+
13+
Versioning must be implemented through the use of a custom media-type, `application/vnd.mds.provider+json`, combined with a required `version` parameter.
14+
15+
The version parameter specifies the dot-separated combination of major and minor versions from a published version of the specification. For example, the media-type for version `0.2.1` would be specified as `application/vnd.mds.provider+json;version=0.2`
16+
17+
> Note: Normally breaking changes are covered by different major versions in semver notation. However, as this specification is still pre-1.0.0, changes in minor versions may include breaking changes, and therefore are included in the version string.
18+
19+
Clients must specify the version they are targeting through the `Accept` header. For example:
20+
21+
```http
22+
Accept: application/vnd.mds.provider+json;version=0.3
23+
```
24+
25+
> Since versioning was not available from the start, the following APIs provide a fallback version if the `Accept` header is not set as specified above:
26+
> - The `provider` API must respond as if version `0.2` was requested.
27+
> - The `agency` API must respond as if version `0.3` was requested.
28+
> - The `policy` API must respond as if version `0.4` was requested.
29+
30+
If an unsupported or invalid version is requested, the API must respond with a status of `406 Not Acceptable`. If this occurs, a client can explicitly negotiate available versions.
31+
32+
A client negotiates available versions 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:
33+
34+
```http
35+
OPTIONS /trips/ HTTP/1.1
36+
Host: provider.example.com
37+
Accept: application/vnd.mds.provider+json;version=0.2,application/vnd.mds.provider+json;version=0.3;q=0.9
38+
```
39+
40+
The response will include the most preferred supported version in the `Content-Type` header. For example, if only `0.3` is supported:
41+
42+
```http
43+
Content-Type: application/vnd.mds.provider+json;version=0.3
44+
```
45+
46+
The client can use the returned value verbatim as a version request in the `Accept` header.
47+
48+
[Top](#table-of-contents)

policy/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@ This specification describes the digital relationship between _mobility as a ser
44

55
## Table of Contents
66

7+
- [General Information](#general-information)
78
- [Background](#background)
89
- [Distribution](#distribution)
910
- [REST Endpoints](#rest-endpoints)
1011
- [Flat Files](#flat-files)
1112
- [Schema](#schema)
1213

14+
## General information
15+
16+
The following information applies to all `policy` API endpoints.
17+
18+
### Versioning
19+
20+
`policy` APIs must handle requests for specific versions of the specification from clients.
21+
22+
Versioning must be implemented as specified in the [`General information versioning section`][general-information/versioning].
23+
1324
## Background
1425

1526
The goal of this specification is to enable Agencies to create, revise, and publish machine-readable policies, as sets of rules for individual and collective device behavior exhibited by both _mobility as a service_ Providers and riders / users. Examples of policies include:
@@ -281,3 +292,5 @@ If a vehicle is matched with a rule, then it _will not_ be considered in the sub
281292
The internal mechanics of ordering are up to the Policy editing and hosting software.
282293

283294
[Top](#table-of-contents)
295+
296+
[general-information/versioning]: /general-information.md#versioning

provider/README.md

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,7 @@ Currently, the provider API is implemented for shared dockless scooters, bikes,
2121

2222
`provider` APIs must handle requests for specific versions of the specification from clients.
2323

24-
Versioning must be implemented through the use of a custom media-type, `application/vnd.mds.provider+json`, combined with a required `version` parameter.
25-
26-
The version parameter specifies the dot-separated combination of major and minor versions from a published version of the specification. For example, the media-type for version `0.2.1` would be specified as `application/vnd.mds.provider+json;version=0.2`
27-
28-
> Note: Normally breaking changes are covered by different major versions in semver notation. However, as this specification is still pre-1.0.0, changes in minor versions may include breaking changes, and therefore are included in the version string.
29-
30-
Clients must specify the version they are targeting through the `Accept` header. For example:
31-
32-
```http
33-
Accept: application/vnd.mds.provider+json;version=0.3
34-
```
35-
36-
> Since versioning was not added until the 0.3.0 release, if the `Accept` header is not set as specified above, the `provider` API must respond as if version `0.2` was requested.
37-
38-
Responses to client requests must indicate the version the response adheres to through the `Content-Type` header. For example:
39-
40-
```http
41-
Content-Type: application/vnd.mds.provider+json;version=0.3
42-
```
43-
44-
> Since versioning was not added until the 0.3.0 release, if the `Content-Type` header is not set as specified above, version `0.2` must be assumed.
45-
46-
If an unsupported or invalid version is requested, the API must respond with a status of `406 Not Acceptable`. If this occurs, a client can explicitly negotiate available versions.
47-
48-
A client negotiates available versions 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:
49-
50-
```http
51-
OPTIONS /trips/ HTTP/1.1
52-
Host: provider.example.com
53-
Accept: application/vnd.mds.provider+json;version=0.2,application/vnd.mds.provider+json;version=0.3;q=0.9
54-
```
55-
56-
The response will include the most preferred supported version in the `Content-Type` header. For example, if only `0.3` is supported:
57-
58-
```http
59-
Content-Type: application/vnd.mds.provider+json;version=0.3
60-
```
61-
62-
The client can use the returned value verbatim as a version request in the `Accept` header.
24+
Versioning must be implemented as specified in the [`General information versioning section`][general-information/versioning].
6325

6426
### Response Format
6527

@@ -432,6 +394,7 @@ Should either side of the requested time range be greater than 2 weeks before th
432394

433395
[Top][toc]
434396

397+
[general-information/versioning]: /general-information.md#versioning
435398
[geo]: #geographic-data
436399
[sc-schema]: status_changes.json
437400
[status]: #status-changes

0 commit comments

Comments
 (0)