mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-24 16:40:30 +00:00
Merge pull request #6102 from caspermeijn/apidoc
ApiDoc: Add response description to WallabagRestController
This commit is contained in:
commit
dc02c679d2
2 changed files with 61 additions and 12 deletions
|
@ -7,6 +7,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
use FOS\RestBundle\Controller\AbstractFOSRestController;
|
use FOS\RestBundle\Controller\AbstractFOSRestController;
|
||||||
use JMS\Serializer\SerializationContext;
|
use JMS\Serializer\SerializationContext;
|
||||||
use JMS\Serializer\SerializerInterface;
|
use JMS\Serializer\SerializerInterface;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
use Nelmio\ApiDocBundle\Annotation\Operation;
|
use Nelmio\ApiDocBundle\Annotation\Operation;
|
||||||
use OpenApi\Annotations as OA;
|
use OpenApi\Annotations as OA;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
@ -15,6 +16,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
use Wallabag\ApiBundle\Entity\ApplicationInfo;
|
||||||
use Wallabag\UserBundle\Entity\User;
|
use Wallabag\UserBundle\Entity\User;
|
||||||
|
|
||||||
class WallabagRestController extends AbstractFOSRestController
|
class WallabagRestController extends AbstractFOSRestController
|
||||||
|
@ -38,11 +40,16 @@ class WallabagRestController extends AbstractFOSRestController
|
||||||
* Retrieve version number.
|
* Retrieve version number.
|
||||||
*
|
*
|
||||||
* @Operation(
|
* @Operation(
|
||||||
* tags={"Informations"},
|
* tags={"Information"},
|
||||||
* summary="Retrieve version number.",
|
* summary="Retrieve version number.",
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="200",
|
* response="200",
|
||||||
* description="Returned when successful"
|
* description="Returned when successful",
|
||||||
|
* @OA\JsonContent(
|
||||||
|
* description="Version number of the application.",
|
||||||
|
* type="string",
|
||||||
|
* example="2.5.2",
|
||||||
|
* )
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
|
@ -61,14 +68,13 @@ class WallabagRestController extends AbstractFOSRestController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve information about the wallabag instance.
|
|
||||||
*
|
|
||||||
* @Operation(
|
* @Operation(
|
||||||
* tags={"Informations"},
|
* tags={"Information"},
|
||||||
* summary="Retrieve information about the wallabag instance.",
|
* summary="Retrieve information about the running wallabag application.",
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response="200",
|
* response="200",
|
||||||
* description="Returned when successful"
|
* description="Returned when successful",
|
||||||
|
* @Model(type=ApplicationInfo::class),
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
|
@ -78,11 +84,10 @@ class WallabagRestController extends AbstractFOSRestController
|
||||||
*/
|
*/
|
||||||
public function getInfoAction(Config $craueConfig)
|
public function getInfoAction(Config $craueConfig)
|
||||||
{
|
{
|
||||||
$info = [
|
$info = new ApplicationInfo(
|
||||||
'appname' => 'wallabag',
|
$this->getParameter('wallabag_core.version'),
|
||||||
'version' => $this->getParameter('wallabag_core.version'),
|
$this->getParameter('fosuser_registration') && $craueConfig->get('api_user_registration'),
|
||||||
'allowed_registration' => $this->getParameter('fosuser_registration') && $craueConfig->get('api_user_registration'),
|
);
|
||||||
];
|
|
||||||
|
|
||||||
return (new JsonResponse())->setJson($this->serializer->serialize($info, 'json'));
|
return (new JsonResponse())->setJson($this->serializer->serialize($info, 'json'));
|
||||||
}
|
}
|
||||||
|
|
44
src/Wallabag/ApiBundle/Entity/ApplicationInfo.php
Normal file
44
src/Wallabag/ApiBundle/Entity/ApplicationInfo.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Wallabag\ApiBundle\Entity;
|
||||||
|
|
||||||
|
use OpenApi\Annotations as OA;
|
||||||
|
|
||||||
|
class ApplicationInfo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
* @OA\Property(
|
||||||
|
* description="Name of the application.",
|
||||||
|
* type="string",
|
||||||
|
* example="wallabag",
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public $appname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
* @OA\Property(
|
||||||
|
* description="Version number of the application.",
|
||||||
|
* type="string",
|
||||||
|
* example="2.5.2",
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
* @OA\Property(
|
||||||
|
* description="Indicates whether registration is allowed. See PUT /api/user.",
|
||||||
|
* type="boolean"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public $allowed_registration;
|
||||||
|
|
||||||
|
public function __construct($version, $allowed_registration)
|
||||||
|
{
|
||||||
|
$this->appname = 'wallabag';
|
||||||
|
$this->version = $version;
|
||||||
|
$this->allowed_registration = $allowed_registration;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue