Merge pull request #1761 from wallabag/v2-API-version

V2 api version
This commit is contained in:
Nicolas Lœuillet 2016-03-08 10:09:57 +01:00
commit d442cf4a92
3 changed files with 27 additions and 0 deletions

View 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 }

View 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.

View 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);
}
}