wallabag/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
Casper Meijn 4f9c7a92a1 Update annotations to OpenApi 3
Most of the API annotations are directly converted. The changes in meaning are:
- Parameters "in body" is not supported anymore. These are changed to "in query" or to a request body (depending on the code).
2022-12-23 14:54:55 +01:00

51 lines
1.5 KiB
PHP

<?php
namespace Wallabag\ApiBundle\Controller;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use Nelmio\ApiDocBundle\Annotation\Operation;
use OpenApi\Annotations as OA;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class TaggingRuleRestController extends WallabagRestController
{
/**
* Export all tagging rules as a json file.
*
* @Operation(
* tags={"TaggingRule"},
* summary="Export all tagging rules as a json file.",
* @OA\Response(
* response="200",
* description="Returned when successful"
* )
* )
*
* @Route("/api/taggingrule/export.{_format}", methods={"GET"}, name="api_get_taggingrule_export", defaults={"_format": "json"})
*
* @return Response
*/
public function getTaggingruleExportAction()
{
$this->validateAuthentication();
$data = SerializerBuilder::create()->build()->serialize(
$this->getUser()->getConfig()->getTaggingRules(),
'json',
SerializationContext::create()->setGroups(['export_tagging_rule'])
);
return Response::create(
$data,
200,
[
'Content-type' => 'application/json',
'Content-Disposition' => 'attachment; filename="tagging_rules_' . $this->getUser()->getUsername() . '.json"',
'Content-Transfer-Encoding' => 'UTF-8',
]
);
}
}