Skip to content

Commit

Permalink
API: return the api_version on the response (#10276)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
humitos authored Sep 21, 2023
1 parent 3c27c71 commit a847397
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions readthedocs/proxito/tests/responses/v0.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"api_version": "0",
"comment": "THIS RESPONSE IS IN ALPHA FOR TEST PURPOSES ONLY AND IT'S GOING TO CHANGE COMPLETELY -- DO NOT USE IT!",
"projects": {
"current": {
Expand Down
1 change: 1 addition & 0 deletions readthedocs/proxito/tests/responses/v1.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"api_version": "1",
"comment": "Undefined yet. Use v0 for now"
}
2 changes: 2 additions & 0 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def _v0(self, project, version, build, filename, user):
project_features = project.features.all().values_list("feature_id", flat=True)

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

def _v1(self, project, version, build, filename, user):
return {
"api_version": "1",
"comment": "Undefined yet. Use v0 for now",
}

Expand Down

0 comments on commit a847397

Please sign in to comment.