Skip to content

Commit d3efa24

Browse files
committed
fix: add well-known version schema and endpoint priority fields
Signed-off-by: Pavel Shukhman <[email protected]>
1 parent 12b4808 commit d3efa24

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

discovery/readme.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,25 @@ The json must conform to the [TEA Well-Known Schema](tea-well-known.schema.json)
189189
Example:
190190
```json
191191
{
192+
"schemaVersion": 1,
192193
"endpoints": [
193194
{
194195
"url": "https://api.teaexample.com",
195196
"versions":
196197
[
197198
"0.1.0-beta.1",
198199
"0.2.0-beta.2",
199-
"1.0"
200-
]
200+
"1.0.0"
201+
],
202+
"priority": 1
201203
},
202204
{
203205
"url": "https://api2.teaexample.com/mytea",
204206
"versions":
205207
[
206-
"1.0"
207-
]
208+
"1.0.0"
209+
],
210+
"priority": 0.5
208211
}
209212
]
210213
}
@@ -214,7 +217,15 @@ Example:
214217
## Connecting to the API
215218

216219
Clients must pick any one of the endpoints listed in the `.well-known/tea` json
217-
response. They must then construct the full URL to the API by appending the
220+
response. The client MUST pick an endpoint with the at least one version that is
221+
supported by the client is using. The client MUST prioritize endpoints with the
222+
highest matching version supported both by the client and the endpoint based on
223+
SemVer 2.0.0 specification comparison [rules](https://semver.org/#spec-item-11).
224+
If there are several endpoints like these and if the priority field is present,
225+
the client SHOULD pick the endpoint with the highest priority value (a float
226+
between 0 and 1).
227+
228+
The client must then construct the full URL to the API by appending the
218229
"/v" plus one of the versions listed in the `versions` array of the selected endpoint,
219230
plus "/discovery?tei=", plus the TEI that is url-encoded according to [RFC3986]
220231
and [RFC3986]).
@@ -223,7 +234,7 @@ Examples:
223234
1. For TEI `urn:tei:uuid:products.example.com:d4d9f54a-abcf-11ee-ac79-1a52914d44b`
224235
`https://api.teaexample.com/v0.2.0-beta.2/discovery?tei=urn%3Atei%3Auuid%3Aproducts.example.com%3Ad4d9f54a-abcf-11ee-ac79-1a52914d44b`
225236
2. For TEI `urn:tei:purl:products.example.com:pkg:deb/debian/[email protected]?arch=i386&distro=jessie`
226-
`https://api2.teaexample.com/mytea/v1.0/discovery?tei=urn%3Atei%3Apurl%3Aproducts.example.com%3Apkg%3Adeb%2Fdebian%2Fcurl%407.50.3-1%3Farch%3Di386%26distro%3Djessie`
237+
`https://api2.teaexample.com/mytea/v1.0.0/discovery?tei=urn%3Atei%3Apurl%3Aproducts.example.com%3Apkg%3Adeb%2Fdebian%2Fcurl%407.50.3-1%3Farch%3Di386%26distro%3Djessie`
227238

228239
The discovery endpoint is a part of the TEA OpenAPI specification.
229240

discovery/tea-well-known.schema.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
"description": "JSON Schema for the TEA .well-known/tea discovery payload that lists available TEA API endpoints and supported versions.",
66
"type": "object",
77
"additionalProperties": false,
8-
"required": ["endpoints"],
8+
"required": ["schemaVersion", "endpoints"],
99
"properties": {
10+
"schemaVersion": {
11+
"type": "integer",
12+
"const": 1,
13+
"description": "Schema version for the TEA .well-known discovery document. Currently always 1."
14+
},
1015
"endpoints": {
1116
"type": "array",
1217
"description": "List of available TEA service endpoints and their supported versions.",
@@ -35,25 +40,34 @@
3540
"examples": [
3641
"0.1.0-beta.1",
3742
"0.2.0-beta.2",
38-
"1.0.0",
39-
"1.0"
43+
"1.0.0"
4044
],
4145
"description": "TEA OpenAPI Spec Version identifier, conforms to SemVer 2.0 (https://semver.org/)."
4246
}
47+
},
48+
"priority": {
49+
"type": "number",
50+
"minimum": 0,
51+
"maximum": 1,
52+
"default": 1,
53+
"description": "Optional priority for this endpoint. Higher values indicate higher priority. Range: 0 to 1."
4354
}
4455
}
4556
}
4657
},
4758
"examples": [
4859
{
60+
"schemaVersion": 1,
4961
"endpoints": [
5062
{
5163
"url": "https://api.teaexample.com",
52-
"versions": ["0.1.0-beta.1", "0.2.0-beta.2", "1.0"]
64+
"versions": ["0.1.0-beta.1", "0.2.0-beta.2", "1.0"],
65+
"priority": 1
5366
},
5467
{
5568
"url": "https://api2.teaexample.com/mytea",
56-
"versions": ["1.0"]
69+
"versions": ["1.0.0"],
70+
"priority": 0.5
5771
}
5872
]
5973
}

spec/openapi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ paths:
414414
minItems: 1
415415
items:
416416
type: string
417-
example: ["0.2.0-beta.2", "1.0"]
417+
example: ["0.2.0-beta.2", "1.0.0"]
418418
required:
419419
- productReleaseUuid
420420
- rootUrl

0 commit comments

Comments
 (0)