Ygg69
Ygg69

Reputation: 261

Symfony fosrestbundle optional parameter in route

I have an api rest and i try to give an optional paramter in my route like this :

/**
 * @Rest\View
 * @Rest\Get("/dossier/{idDossier}", requirements={"idDossier" = "\d+"}, defaults={"idDossier" = null})
 * @ApiDoc(
 *  description="...",
 *  parameters={
 *      {"name"="idDossier", "dataType"="integer", "required"=false, "description"="Folder Id"}
 *  }
 * )
 */

public function getDossierAction($idDossier = null, Request $request){

But i have an error :

[Semantical Error] The annotation "@Rest\View" in method ...\Controller\DossierAPIController::getDossierAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?

Upvotes: 0

Views: 3151

Answers (1)

tinos
tinos

Reputation: 572

Your are not importing that annotation class. Put something like this after the namespace declaration:

use FOS\RestBundle\Controller\Annotations as Rest;

so you can use it like what you have:

@Rest\View()

Upvotes: 1

Related Questions