wallabag/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php
Casper Meijn 470a8575c0 Update to nelmio/api-doc 3.0
Convert ApiDoc to Swagger
2022-11-16 16:10:33 +01:00

48 lines
1.3 KiB
PHP

<?php
namespace Wallabag\ApiBundle\Controller;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\Response;
class TaggingRuleRestController extends WallabagRestController
{
/**
* Export all tagging rules as a json file.
*
* @Operation(
* tags={"TaggingRule"},
* summary="Export all tagging rules as a json file.",
* @SWG\Response(
* response="200",
* description="Returned when successful"
* )
* )
*
* @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',
]
);
}
}