Reputation: 55
I have an EventApiController
class that looks like the following
Class EventApiController
{
public function getAction($event_id)
{
// ...
}
public function putAction($event_id)
{
// ...
}
}
Using the Friends of Symfony bundle's route generate i am expecting the route to look like
CalendarBundle_get_events [GET] /api/v1/events/{event_id}.{_format}
CalendarBundle_put_events [PUT] /api/v1/events/{event_id}.{_format}
However it seems like the Route generator automatically adds a post fix /api to all of the routes so the route looks like. And the documentation does not show this as the expected behaviour as well.
CalendarBundle_get_events_api [GET] /api/v1/events/{event_id}/api.{_format}
CalendarBundle_put_events_api [PUT] /api/v1/events/{event_id}/api.{_format}
Does anyone know how to get rid of the /api post fix from the generated link? I am using FOS/ResutBundle version 1.3.1
My config.yml for fos_rest
fos_rest:
routing_loader:
default_format: json
include_format: true
view:
view_response_listener: true
And the routing.yml looks like this in my Bundle
event_api:
type: rest
resource: "@CalendarBundle/Controller/EventsApiController.php"
prefix: /api/v1
name_prefix: CalendarBundle_
Upvotes: 1
Views: 1083
Reputation: 52493
It's the Api
in EventApiController
that gets detected as route resource by FOSRestBundle.
You can override the resource name like this in order to prevent the _api
route name and /api
urls:
use FOS\RestBundle\Routing\ClassResourceInterface;
/**
* @RouteResource("Event")
*/
Class EventApiController implements ClassResourceInterface
{
Upvotes: 1