-
Notifications
You must be signed in to change notification settings - Fork 98
TRG API Versioning #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
TRG API Versioning #526
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bd21c5
added TRG for Versioning
tobzahn dd0b135
Update trg-0.md
tobzahn 684d6bd
Merge pull request #1 from tobzahn/branch-versioning-1
tobzahn 8d82049
Add files via upload
tobzahn 549b328
Included Feedback
tobzahn ebe4178
Restructured for clarity
tobzahn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: TRG 6.02 - API Versioning | ||
sidebar_position: 1 | ||
--- | ||
|
||
:::caution | ||
Proposed release date: "mandatory after": 01st of May 2024 | ||
::: | ||
|
||
| Status | Created | Post-History | | ||
|------------|--------------|----------------------------------------| | ||
| Draft | 30-Nov-2023 | Initial contribution | | ||
|
||
## Why | ||
|
||
For publicly available APIs a versioning mechanism is required, so that all APIs are versioned the same way. | ||
|
||
Note that for APIs accessible only via EDC, the API-version is included in the EDC asset and not the URL. This is described in CX-0018. | ||
|
||
## What | ||
|
||
This TRG applies to all APIs created within Tractus-X, but does not apply where existing standards (e.g. Data Space Protocol) are implemented where contracticting behavoir is required in order to adhere to that standard. | ||
|
||
For APIs that are called through an EDC asset, the version information hast to be included as a property in the EDC asset. This needs to be done in accordance with Catena-X standard CX-0018. More information and guidance is available there. | ||
|
||
## Description | ||
|
||
For public REST-APIs (= called through an EDC aspect), the Version number **must** be included in the URL. | ||
|
||
Example: `https://example.com/api/v2/customers` | ||
|
||
A standard **should** offer the following aliases as well (meaning they all answer identically to HTTP requests): | ||
|
||
`https://example.com/api/v2.1/customers` | ||
|
||
`https://example.com/api/latest/customers` | ||
|
||
For the version in the URL, semantic versioning **must** be used. | ||
|
||
Old endpoints (that have been offered bevor) and are not supported anymore **should** respond with an appropriate HTTP 30x status code and the new location (URL). | ||
|
||
For example, when v3 of an API is released, an request to `https://example.com/api/v2/customers` would return HTTP 301 (moved permanently) and point to `https://example.com/api/v3/customers` | ||
|
||
Queries and fragments **may** be used, so the following example is valid: | ||
|
||
https://example.com:443/messaging/v1/messages?textContains=AMG#resultlist | ||
\___/ \______________/\___________________/\_______________/ \________/ | ||
| | | | | | ||
scheme authority path query fragment | ||
|
||
Note that the structure of the URL needs to be chosen mindfully. For example: | ||
|
||
* `https://example.com/api/customers/v2` → this is bad idea since you might want to rename 'customers' to something else in the future | ||
* `https://example.com/api/customers/` → does not make it clear which version is used. It might be the latest, but some developers might not notice and assume the API is stable for ever | ||
* `https://example.com/api/v2.4.8/customers/` → not recommended since a patch (according to semantic versioning) is always backward compatible the need for this can be questioned. Adding the patch level to the URL forces clients to frequently to adapt to a new URL. | ||
|
||
Further rules and recommendations on URL design: | ||
|
||
* It is **recommended** to use nouns over verbs. For example, use `/customers` instead of `/getCustomers/` | ||
* It is **recommended** to use plural nouns. For example, use `/customers/` instead of `/customer/` | ||
* It is **recommended** to use the concrete object, not a abstraction. For example, use `/customers/` instead of `/persons/` | ||
* The technical identifier **should** be part of the path, not the query. For example, use `/customers/12345/` instead of `/customers?key=12345` | ||
* Only English words **must** be used. For example, use `/customers/` instead of `/kunden/` | ||
* Camel case **should not** be used in the URI, but it MAY be used in the query or fragment part. For example, use `/vehicleorders/`, `/vehicle-orders/` or `/vehicle_orders/` instead of `/VehicleOrders/` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CX-0018 should be linked to the standard document
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SebastianBezold I can do that - to what URL should I link to? Is there a best practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I thought there is a public doc already behind the standard ID, since i saw that in some of the KITs.
Example taken from Adoption view of RuL
CX - 0059 Triangle Behavioral Twin Endurance Predictor:
I think some of the Links I saw are pointing to the overall page containing all the standards, but that was an exception, because AFAIK, the standard is implemented together with the KIT and not yet officially released in public