Merge pull request #6095 from wallabag/fix/deprecation-fos-rest

Remove deprecated options from FOSRest
This commit is contained in:
Kevin Decherf 2022-11-23 14:15:08 +01:00 committed by GitHub
commit 827ba15255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 86 additions and 27 deletions

View file

@ -112,14 +112,8 @@ fos_rest:
pdf: true
epub: true
mobi: true
templating_formats:
html: false
force_redirects:
html: true
failed_validation: HTTP_BAD_REQUEST
default_engine: twig
routing_loader:
default_format: json
routing_loader: false
format_listener:
enabled: true
rules:

View file

@ -1,6 +1,7 @@
wallabag_annotation:
type : rest
resource: "@WallabagAnnotationBundle/Resources/config/routing_annotations.yml"
resource: "@WallabagAnnotationBundle/Controller/"
type: annotation
prefix: /
wallabag_import:
resource: "@WallabagImportBundle/Controller/"
@ -25,11 +26,6 @@ doc-api:
resource: "@NelmioApiDocBundle/Resources/config/routing/swaggerui.xml"
prefix: /api/doc
rest :
type : rest
resource : "routing_rest.yml"
prefix : /api
homepage:
path: "/{page}"
defaults:

View file

@ -1,3 +0,0 @@
Rest_Wallabag:
type : rest
resource: "@WallabagApiBundle/Resources/config/routing_rest.yml"

View file

@ -159,6 +159,9 @@ services:
calls:
- ["addSubscriber", ["@bd_guzzle_site_authenticator.authenticator_subscriber"]]
RulerZ\RulerZ:
alias: rulerz
Wallabag\CoreBundle\Operator\PHP\Matches:
tags:
- { name: rulerz.operator, target: native, operator: matches }

View file

@ -8,6 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\AnnotationBundle\Form\EditAnnotationType;
use Wallabag\AnnotationBundle\Form\NewAnnotationType;
@ -20,6 +21,8 @@ class WallabagAnnotationController extends AbstractFOSRestController
*
* @see Wallabag\ApiBundle\Controller\WallabagRestController
*
* @Route("/annotations/{entry}.{_format}", methods={"GET"}, name="annotations_get_annotations", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getAnnotationsAction(Entry $entry)
@ -39,9 +42,11 @@ class WallabagAnnotationController extends AbstractFOSRestController
/**
* Creates a new annotation.
*
* @return JsonResponse
*
* @see Wallabag\ApiBundle\Controller\WallabagRestController
*
* @Route("/annotations/{entry}.{_format}", methods={"POST"}, name="annotations_post_annotation", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function postAnnotationAction(Request $request, Entry $entry)
{
@ -74,6 +79,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
*
* @see Wallabag\ApiBundle\Controller\WallabagRestController
*
* @Route("/annotations/{annotation}.{_format}", methods={"PUT"}, name="annotations_put_annotation", defaults={"_format": "json"})
* @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation")
*
* @return JsonResponse
@ -106,6 +112,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
*
* @see Wallabag\ApiBundle\Controller\WallabagRestController
*
* @Route("/annotations/{annotation}.{_format}", methods={"DELETE"}, name="annotations_delete_annotation", defaults={"_format": "json"})
* @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation")
*
* @return JsonResponse

View file

@ -1,4 +0,0 @@
annotations:
type: rest
resource: 'Wallabag\AnnotationBundle\Controller\WallabagAnnotationController'
name_prefix: annotations_

View file

@ -7,6 +7,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\AnnotationBundle\Entity\Annotation;
use Wallabag\CoreBundle\Entity\Entry;
@ -32,6 +33,8 @@ class AnnotationRestController extends WallabagRestController
* )
* )
*
* @Route("/api/annotations/{entry}.{_format}", methods={"GET"}, name="api_get_annotations", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getAnnotationsAction(Entry $entry)
@ -88,6 +91,8 @@ class AnnotationRestController extends WallabagRestController
* )
* )
*
* @Route("/api/annotations/{entry}.{_format}", methods={"POST"}, name="api_post_annotation", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function postAnnotationAction(Request $request, Entry $entry)
@ -120,6 +125,7 @@ class AnnotationRestController extends WallabagRestController
* )
* )
*
* @Route("/api/annotations/{annotation}.{_format}", methods={"PUT"}, name="api_put_annotation", defaults={"_format": "json"})
* @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation")
*
* @return JsonResponse
@ -154,6 +160,7 @@ class AnnotationRestController extends WallabagRestController
* )
* )
*
* @Route("/api/annotations/{annotation}.{_format}", methods={"DELETE"}, name="api_delete_annotation", defaults={"_format": "json"})
* @ParamConverter("annotation", class="Wallabag\AnnotationBundle\Entity\Annotation")
*
* @return JsonResponse

View file

@ -7,6 +7,7 @@ use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class ConfigRestController extends WallabagRestController
{
@ -22,6 +23,8 @@ class ConfigRestController extends WallabagRestController
* )
* )
*
* @Route("/api/config.{_format}", methods={"GET"}, name="api_get_config", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getConfigAction()

View file

@ -2,7 +2,7 @@
namespace Wallabag\ApiBundle\Controller;
use Hateoas\Configuration\Route;
use Hateoas\Configuration\Route as HateoasRoute;
use Hateoas\Representation\Factory\PagerfantaFactory;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Pagerfanta\Pagerfanta;
@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Event\EntryDeletedEvent;
@ -80,6 +81,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/exists.{_format}", methods={"GET"}, name="api_get_entries_exists", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getEntriesExistsAction(Request $request)
@ -272,6 +275,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries.{_format}", methods={"GET"}, name="api_get_entries", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getEntriesAction(Request $request)
@ -314,7 +319,7 @@ class EntryRestController extends WallabagRestController
$pagerfantaFactory = new PagerfantaFactory('page', 'perPage');
$paginatedCollection = $pagerfantaFactory->createRepresentation(
$pager,
new Route(
new HateoasRoute(
'api_get_entries',
[
'archive' => $isArchived,
@ -355,6 +360,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}.{_format}", methods={"GET"}, name="api_get_entry", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getEntryAction(Entry $entry)
@ -393,6 +400,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}/export.{_format}", methods={"GET"}, name="api_get_entry_export", defaults={"_format": "json"})
*
* @return Response
*/
public function getEntryExportAction(Entry $entry, Request $request)
@ -426,6 +435,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/list.{_format}", methods={"DELETE"}, name="api_delete_entries_list", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteEntriesListAction(Request $request)
@ -483,6 +494,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/lists.{_format}", methods={"POST"}, name="api_post_entries_list", defaults={"_format": "json"})
*
* @throws HttpException When limit is reached
*
* @return JsonResponse
@ -666,6 +679,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries.{_format}", methods={"POST"}, name="api_post_entries", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function postEntriesAction(Request $request)
@ -869,6 +884,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}.{_format}", methods={"PATCH"}, name="api_patch_entries", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function patchEntriesAction(Entry $entry, Request $request)
@ -985,6 +1002,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}/reload.{_format}", methods={"PATCH"}, name="api_patch_entries_reload", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function patchEntriesReloadAction(Entry $entry)
@ -1041,6 +1060,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}.{_format}", methods={"DELETE"}, name="api_delete_entries", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteEntriesAction(Entry $entry, Request $request)
@ -1091,6 +1112,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}/tags.{_format}", methods={"GET"}, name="api_get_entries_tags", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getEntriesTagsAction(Entry $entry)
@ -1131,6 +1154,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}/tags.{_format}", methods={"POST"}, name="api_post_entries_tags", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function postEntriesTagsAction(Request $request, Entry $entry)
@ -1178,6 +1203,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/{entry}/tags/{tag}.{_format}", methods={"DELETE"}, name="api_delete_entries_tags", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteEntriesTagsAction(Entry $entry, Tag $tag)
@ -1212,6 +1239,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/tags/list.{_format}", methods={"DELETE"}, name="api_delete_entries_tags_list", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteEntriesTagsListAction(Request $request)
@ -1280,6 +1309,8 @@ class EntryRestController extends WallabagRestController
* )
* )
*
* @Route("/api/entries/tags/lists.{_format}", methods={"POST"}, name="api_post_entries_tags_list", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function postEntriesTagsListAction(Request $request)

View file

@ -2,7 +2,7 @@
namespace Wallabag\ApiBundle\Controller;
use Hateoas\Configuration\Route;
use Hateoas\Configuration\Route as HateoasRoute;
use Hateoas\Representation\Factory\PagerfantaFactory;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter;
@ -10,6 +10,7 @@ use Pagerfanta\Pagerfanta;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Repository\EntryRepository;
class SearchRestController extends WallabagRestController
@ -53,6 +54,8 @@ class SearchRestController extends WallabagRestController
* )
* )
*
* @Route("/api/search.{_format}", methods={"GET"}, name="api_get_search", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getSearchAction(Request $request)
@ -79,7 +82,7 @@ class SearchRestController extends WallabagRestController
$pagerfantaFactory = new PagerfantaFactory('page', 'perPage');
$paginatedCollection = $pagerfantaFactory->createRepresentation(
$pager,
new Route(
new HateoasRoute(
'api_get_search',
[
'term' => $term,

View file

@ -7,6 +7,7 @@ use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
@ -24,6 +25,8 @@ class TagRestController extends WallabagRestController
* )
* )
*
* @Route("/api/tags.{_format}", methods={"GET"}, name="api_get_tags", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getTagsAction()
@ -59,6 +62,8 @@ class TagRestController extends WallabagRestController
* )
* )
*
* @Route("/api/tag/label.{_format}", methods={"DELETE"}, name="api_delete_tag_label", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteTagLabelAction(Request $request)
@ -107,6 +112,8 @@ class TagRestController extends WallabagRestController
* )
* )
*
* @Route("/api/tags/label.{_format}", methods={"DELETE"}, name="api_delete_tags_label", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteTagsLabelAction(Request $request)
@ -152,6 +159,8 @@ class TagRestController extends WallabagRestController
* )
* )
*
* @Route("/api/tags/{tag}.{_format}", methods={"DELETE"}, name="api_delete_tag", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function deleteTagAction(Tag $tag)

View file

@ -7,6 +7,7 @@ use JMS\Serializer\SerializerBuilder;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class TaggingRuleRestController extends WallabagRestController
{
@ -22,6 +23,8 @@ class TaggingRuleRestController extends WallabagRestController
* )
* )
*
* @Route("/api/taggingrule/export.{_format}", methods={"GET"}, name="api_get_taggingrule_export", defaults={"_format": "json"})
*
* @return Response
*/
public function getTaggingruleExportAction()

View file

@ -13,6 +13,7 @@ use Swagger\Annotations as SWG;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Translation\TranslatorInterface;
use Wallabag\ApiBundle\Entity\Client;
use Wallabag\UserBundle\Entity\User;
@ -32,6 +33,8 @@ class UserRestController extends WallabagRestController
* )
* )
*
* @Route("/api/user.{_format}", methods={"GET"}, name="api_get_user", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getUserAction()
@ -83,6 +86,8 @@ class UserRestController extends WallabagRestController
*
* @todo Make this method (or the whole API) accessible only through https
*
* @Route("/api/user.{_format}", methods={"PUT"}, name="api_put_user", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function putUserAction(Request $request)

View file

@ -8,6 +8,7 @@ use JMS\Serializer\SerializerInterface;
use Nelmio\ApiDocBundle\Annotation\Operation;
use Swagger\Annotations as SWG;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@ -28,6 +29,8 @@ class WallabagRestController extends AbstractFOSRestController
*
* @deprecated Should use info endpoint instead
*
* @Route("/api/version.{_format}", methods={"GET"}, name="api_get_version", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getVersionAction()
@ -50,6 +53,8 @@ class WallabagRestController extends AbstractFOSRestController
* )
* )
*
* @Route("/api/info.{_format}", methods={"GET"}, name="api_get_info", defaults={"_format": "json"})
*
* @return JsonResponse
*/
public function getInfoAction()