diff mbox

[2/2] REST: Allow users to omit version entirely

Message ID 20170426235804.31181-2-stephen@that.guru
State Accepted
Headers show

Commit Message

Stephen Finucane April 26, 2017, 11:58 p.m. UTC
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 | 17 +++++++++++++++++
 patchwork/urls.py |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)

Comments

Andy Doan May 1, 2017, 2:29 p.m. UTC | #1
On 04/26/2017 06:58 PM, Stephen Finucane wrote:
> This is super handy for debugging/development of Patchwork and Patchwork
> clients alike.
>
> Signed-off-by: Stephen Finucane <stephen@that.guru>

Nice change as well

Reviewed-by: Andy Doan <andy.doan@linaro.org>
diff mbox

Patch

diff --git a/docs/api/rest.rst b/docs/api/rest.rst
index 75e31f6..1750913 100644
--- a/docs/api/rest.rst
+++ b/docs/api/rest.rst
@@ -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
 ------
 
diff --git a/patchwork/urls.py b/patchwork/urls.py
index 8c8c172..f700f38 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -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)),
     ]