]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
REST: Allow users to omit version entirely
authorStephen Finucane <stephen@that.guru>
Wed, 26 Apr 2017 23:58:04 +0000 (00:58 +0100)
committerStephen Finucane <stephen@that.guru>
Fri, 28 Apr 2017 22:52:04 +0000 (23:52 +0100)
This is super handy for debugging/development of Patchwork and Patchwork
clients alike.

Signed-off-by: Stephen Finucane <stephen@that.guru>
docs/api/rest.rst
patchwork/urls.py

index 75e31f6fb120bad4eb4740e71676cf25599aade2..17509134eabcd37b9f336b814f73b49fab6e7d25 100644 (file)
@@ -86,6 +86,23 @@ overview of existing API clients, refer to :doc:`../usage/clients`.
     own instance of Patchwork locally <../development/installation>` and
     experiment with that instead.
 
+Versioning
+----------
+
+By default, all requests will receive the latest version of the API: currently
+``1.0``:
+
+.. code-block:: http
+
+    GET /api HTTP/1.1
+
+You should explicitly request this version through the URL to prevent API
+changes breaking your application:
+
+.. code-block:: http
+
+    GET /api/1.0 HTTP/1.1
+
 Schema
 ------
 
index 8c8c172fe7a24b56eea5d597ec8cad57cfb4d289..f700f38633122e4a553aec03da635fba8d15d0c1 100644 (file)
@@ -232,7 +232,7 @@ if settings.ENABLE_REST_API:
     ]
 
     urlpatterns += [
-        url(r'^api/(?P<version>(1.0))/', include(api_patterns)),
+        url(r'^api/(?:(?P<version>(1.0))/)?', include(api_patterns)),
     ]