FOSRestBundle icon indicating copy to clipboard operation
FOSRestBundle copied to clipboard

ParamFetcher parameter conflicts with a path parameter 'page' for route 'route_name'

Open marcj opened this issue 11 years ago • 4 comments

I get that exception

ParamFetcher parameter conflicts with a path parameter 'page' for route 'route_name'
500 Internal Server Error - InvalidArgumentException

vendor/friendsofsymfony/rest-bundle/FOS/RestBundle/EventListener/ParamFetcherListener.php at line 67

with my route:

    /**
     * @Rest\QueryParam(name="page", requirements="\d+", description="Page of the overview.")
     *
     * @Rest\Get("/{page}")
     *
     * @param string $page
     */
    public function getItemsAction($page)
    {

I've

fos_rest:
    param_fetcher_listener: force

Does this not work for a route pattern with a placeholder {page}?

marcj avatar Dec 10 '13 00:12 marcj

Ok, got it. Have to define the requirements in the @Rest\Get annotation. Unfortunately, that annotation does not support descriptions or something like that.

marcj avatar Dec 10 '13 00:12 marcj

Unfortunately, that issue still persists for me, but now with a non-path parameter withAcl.

My route:

/**
     * @ApiDoc(
     *    description="Returns a single object item"
     * )
     *
     * @Rest\QueryParam(name="fields", requirements=".+", description="Fields to select")
     * @Rest\QueryParam(name="withAcl", requirements=".+", default=false, description="With ACL information")
     *
     * @Rest\View()
     * @Rest\Get("/{pk}", requirements={"pk" = ".+"})
     *
     * @param string $pk
     * @param string $fields
     * @param boolean $withAcl
     *
     * @return array
     */
    public function getItemAction($pk, $fields = null, $withAcl = false)
    {

Same Exception as abov:

ParamFetcher parameter conflicts with a path parameter 'withAcl' for route 'route_name'

Anyone a idea how to fix that?

marcj avatar Dec 10 '13 11:12 marcj

Temporarily fixed with

 ... , $withAcl = null)

But shouldn't it be possible to set default values, or should those php default values are replaced with those in @QueryParam&Co?

marcj avatar Dec 10 '13 11:12 marcj

yeah .. i guess it would be good to make this work. i guess if the defaults match there is no reason to complain about the conflict

lsmith77 avatar Jan 21 '14 07:01 lsmith77