Reputation: 307
Maybe im just missing it, I would like to hide some rest methods from controllers that do not implement them like options , delete, head
Is there an annotation for this? I could not find it in the documentation using https://github.com/nelmio/NelmioApiDocBundle v3
currently when i view /api/doc any controllers I add list all rest methods even if I only have a GET method implemented.
<?php
namespace ApiBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Swagger\Annotations as SWG;
class UserController extends Controller
{
/**
* @Security("is_granted('IS_AUTHENTICATED_FULLY')")
* @Route("/api/users", name="get_users", methods={"GET"})
*
* @SWG\Response(
* response=200,
* description="Returns all users"
* )
* @SWG\Tag(name="users")
*
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function getUsersAction()
{
$repo = $this->getDoctrine()
->getRepository('AccountBundle:User');
$users = $repo->createQueryBuilder('q')
->getQuery()
->getArrayResult();
return new JsonResponse($users);
}
}
Upvotes: 3
Views: 6646
Reputation: 563
Specify @Value and @method type in the @RequestMapping
@RequestMapping(value="/instances/all",method=RequestMethod.GET)
@JsonFormat
public String showInstances(){
return "instances";
}
Upvotes: 2
Reputation: 307
Just figured it out if you do not specify the methods in the controller in the @Route() annotation then it will show all of them but if you add methods={} to the Route annotation then it will only list the defined methods
* @Route("/api/users", name="get_users", methods={"GET"})
Upvotes: 2