| 1 | # Consistent Versioning of external APIs |
| 2 | |
| 3 | ## Decision |
| 4 | |
| 5 | Going forward, all our external APIs will be versioned consistently across all endpoints and controllers. This means, |
| 6 | that the |
| 7 | Management API (to name a prominent example) will encode the same version number consistently across all its existing service endpoint URLs, within a major version. |
| 8 | |
| 9 | ## Rationale |
| 10 | |
| 11 | Currently, every module that contributes an API can have its own versioning model. For example, at the time of writing |
| 12 | some APIs are available under `/v2/...`, some are available under `/v3/...` and some without a version specifier. |
| 13 | |
| 14 | This can be confusing to developers who want to consume the API, because they not only need different base paths for |
| 15 | every API, they also need to re-check every endpoint when a new version of EDC is released, because every API can change |
| 16 | individually. |
| 17 | |
| 18 | Therefore, we will use consistent versioning across _all_ client-facing APIs. At the time of writing, this includes just |
| 19 | the Management API. |
| 20 | |
| 21 | ## Approach |
| 22 | |
| 23 | ### Versioning scheme |
| 24 | |
| 25 | Following the general semantics of SemVer, we will distinguish between a breaking change (major version bump) and |
| 26 | non-breaking and patch changes (minor/patch version bump). The major version will be represented in the URL: |
| 27 | |
| 28 | ``` |
| 29 | https://some.host.com/api/management/v4/... |
| 30 | ``` |
| 31 | |
| 32 | This means, client code only needs to be updated on major version changes of an API. |
| 33 | |
| 34 | > Only major versions are represented in the URL |
| 35 | |
| 36 | > Minor or patch updates will **not** be represented in the URL, and we will **not** host multiple minor/patch versions |
| 37 | > of an API at any given time. |
| 38 | |
| 39 | Consequently, when multiple major versions of an API are available, every versioned URL (e.g. `/v3/assets`) effectively |
| 40 | contains the _latest_ version, so for instance `/v3/assets` would effectively point to version `3.1.4` of the Management |
| 41 | API. |
| 42 | |
| 43 | > The same exact version is used for the entire Management API, we do **not** version independent modules or controllers |
| 44 | |
| 45 | > The version of an API is independent of the version of EDC. |
| 46 | |
| 47 | ### Delegation mechanism for controllers |
| 48 | |
| 49 | Not every endpoint changes from version to version. We will have to make the _same_ controller available |
| 50 | under _multiple_ URL paths as we do not want to duplicate controllers. There are several potential ways we could make |
| 51 | this work: |
| 52 | |
| 53 | - Declare the `@Path` as [wildcard](https://docs.oracle.com/javaee/7/api/javax/ws/rs/Path.html) |
| 54 | - implement a custom interceptor, that parses the path and delegates to the correct controller |
| 55 | |
| 56 | These are as yet untested and need further investigation with regard to the following aspects: |
| 57 | |
| 58 | - do controllers appear as individual endpoints in the OpenAPI documentation? |
| 59 | - is there a significant impact w.r.t. resource consumption and response time? |
| 60 | |
| 61 | ### Storing and publishing version information |
| 62 | |
| 63 | A new endpoint will be available that provides exact information about the version of the API. The path and the response |
| 64 | schema is TBD. |
| 65 | |
| 66 | The version of an API must be stored in a file that is available at runtime. Every change to an API must increase that |
| 67 | version property. The `gradle.properties` file would be the obvious choice, however we would have to craft a way to |
| 68 | access that information at runtime. |
| 69 | |
| 70 | ### Publishing APIs to SwaggerHub |
| 71 | |
| 72 | Ultimately, we will move away from publishing our APIs under the EDC version, and will publish them only under their |
| 73 | own version. Every update (major, minor, patch,...) will be published to SwaggerHub. |
| 74 | For this, we will have to update our Swagger-publish workflow quite significantly and read the |
| 75 | API [version information](#storing-and-publishing-version-information). |
| 76 | |
| 77 | ### Maintenance/deprecation model |
| 78 | |
| 79 | As a standard M/O EDC will expose at most two versions of an API at any given time. The older one must be marked |
| 80 | as `deprecated` both in code and in Swagger. |
| 81 | |
| 82 | All maintenance (bugfixes, patches, improvements) will **only** be made to the most recent API. Deprecated APIs will |
| 83 | **not** receive any maintenance. |