Skip to content

Commit a847397

Browse files
authored
API: return the api_version on the response (#10276)
* API: accept `X-RTD-Hosting-Integrations-API-Version` This new header will force the API endpoint to return a specific JSON version schema without taking into consideration the any other header. The idea behind this is to allow theme authors guarrantees about the JSON scheme they are expecting; without stopping us to move forward with potential changes required to the API response when adding new features/addons/etc. Related readthedocs/addons#64 * Remove old test * Use text for `api_version`, since it could be something like `0.1.2`
1 parent 3c27c71 commit a847397

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

readthedocs/proxito/tests/responses/v0.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"api_version": "0",
23
"comment": "THIS RESPONSE IS IN ALPHA FOR TEST PURPOSES ONLY AND IT'S GOING TO CHANGE COMPLETELY -- DO NOT USE IT!",
34
"projects": {
45
"current": {
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"api_version": "1",
23
"comment": "Undefined yet. Use v0 for now"
34
}

readthedocs/proxito/views/hosting.py

+2
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def _v0(self, project, version, build, filename, user):
244244
project_features = project.features.all().values_list("feature_id", flat=True)
245245

246246
data = {
247+
"api_version": "0",
247248
"comment": (
248249
"THIS RESPONSE IS IN ALPHA FOR TEST PURPOSES ONLY"
249250
" AND IT'S GOING TO CHANGE COMPLETELY -- DO NOT USE IT!"
@@ -432,6 +433,7 @@ def _v0(self, project, version, build, filename, user):
432433

433434
def _v1(self, project, version, build, filename, user):
434435
return {
436+
"api_version": "1",
435437
"comment": "Undefined yet. Use v0 for now",
436438
}
437439

0 commit comments

Comments
 (0)