Reputation: 9269
I'm using NelmioApiDocBundle and FOSRestBundle to create an API.
In my routing.yml I have set prefix
to /api
.
The routes in my ApiController
class are configured as follows:
/**
* @Get("/login/{username}/{password}")
* @ApiDoc(
* description="User Loggin",
* resource=true,
* parameters={
* {"name"="username", "dataType"="string", "required"=true, "description"="Username"},
* {"name"="password", "dataType"="string", "required"=true, "description"="Password"},
* }
* )
*/
public function loginAction($username, $password)
{
// ...
}
My problem is that the generated documentation shows these two routes:
/api/login/{username}/{password}
/login/{username}/{password}
I only want the route prefixed with /api
to show up.
How can I achieve that ?
Upvotes: 1
Views: 965
Reputation: 9269
I found a solution, i override the template resources.html.twig
of NelmioBundle and check manually if the uri contains /api or not
Upvotes: 0
Reputation: 52493
It's likely that NelmioApiDocBundle
isn't aware of the prefix
setting in your routing.yml.
As the bundle usually expects annotations you should add the @Prefix
annotation at class-level instead.
use FOS\RestBundle\Controller\Annotations\Prefix;
/**
* @Prefix("/api")
*/
class ApiController
Don't forget to clear your cache after implementing the changes.
Upvotes: 0