]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #1761 from wallabag/v2-API-version
authorNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 8 Mar 2016 09:09:57 +0000 (10:09 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 8 Mar 2016 09:09:57 +0000 (10:09 +0100)
V2 api version

app/config/security.yml
src/Wallabag/ApiBundle/Controller/WallabagRestController.php
src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php

index 7f05123ab38cf51867dbb475f182ca8f65423316..0748c06ce03d316c67e5237541718569d95caa9a 100644 (file)
@@ -53,6 +53,7 @@ security:
 
     access_control:
         - { path: ^/api/doc, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+        - { path: ^/api/version, roles: IS_AUTHENTICATED_ANONYMOUSLY }
         - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
         - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
         - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
index 35a90edde12bee3bc8b923edda9fa7311a4ff963..29cab1f4df0f6b4f465a949bda377cfb3f1e5811 100644 (file)
@@ -340,6 +340,21 @@ class WallabagRestController extends FOSRestController
 
         return $this->renderJsonResponse($json);
     }
+    /**
+     * Retrieve version number.
+     *
+     * @ApiDoc()
+     *
+     * @return Response
+     */
+    public function getVersionAction()
+    {
+        $version = $this->container->getParameter('wallabag_core.version');
+
+        $json = $this->get('serializer')->serialize($version, 'json');
+
+        return $this->renderJsonResponse($json);
+    }
 
     /**
      * Validate that the first id is equal to the second one.
index 630b75bfe62adb2bbd21d387635e8613a027a587..a705f9dea4f00fdac5c84194f900cdc219151521 100644 (file)
@@ -336,4 +336,15 @@ class WallabagRestControllerTest extends WallabagApiTestCase
 
         $this->assertCount(0, $entries);
     }
+
+    public function testGetVersion()
+    {
+        $this->client->request('GET', '/api/version');
+
+        $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
+
+        $content = json_decode($this->client->getResponse()->getContent(), true);
+
+        $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content);
+    }
 }