Witajcie

Staram się przepisać istniejące API aplikacji na FOS Rest i... tyle o ile, z większością akcji nie mam problemu, to tutaj dzieje się coś dziwnego

Akcja w kontrolerze:
  1. /**
  2. * @param Request $request
  3. * @param ParamFetcherInterface $paramFetcherInterface
  4. *
  5. * @ApiDoc(
  6. * section="User",
  7. * resource=true,
  8. * description="Search user",
  9. * requirements={
  10. * {
  11. * "name"="phrase",
  12. * "dataType"="string",
  13. * "requirement"="\[a-zA-Z0-9\s\@]+",
  14. * "description"="Part of 'username', 'email', 'name' or 'surname'"
  15. * }
  16. * }
  17. * )
  18. *
  19. * @Rest\QueryParam("phrase", nullable=false, allowBlank=false, description="User search string.", array=false, requirements="[a-zA-Z0-9\@\s]+", strict=true)
  20. *
  21. * @return Response
  22. */
  23. public function getFindUserAction(Request $request, ParamFetcherInterface $paramFetcherInterface)
  24. {
  25. $view = $this->view(['phrase' => $paramFetcherInterface->all(), 'query' => $request->query->all()]);
  26.  
  27. return $this->handleView($view);
  28. }


app/config/routing.yml
Kod
api:
    resource: "@ApiBundle/Resources/config/routing.yml"
    type:     rest
    prefix:   /api
    options:
        i18n: false



@ApiBundle/Resources/config/routing.yml
Kod
api_user_search:
    path: /user/search
    defaults:
        _controller: ApiBundle:User/UserEndpoint:getFindUser
    methods: [GET]


I teraz, wysyłajac request GET na adres /api/user/search?phrase=xyz mój profiler twierdzi, że w/w request nie ma parametrów GET, a co za tym idzie dostaję błędem:
Kod
{"code":400,"message":"Query parameter \"phrase\" is empty"}


Na domknięcie, config fos_rest:
Kod
fos_rest:
    format_listener: false
    routing_loader:
        default_format: json
        include_format: false
    view:
        view_response_listener: force
        force_redirects:
          html: true
        formats:
            jsonp: true
            json: true
            xml: false
            rss: false
        templating_formats:
            html: true
        mime_types:
            json: ['application/json', 'application/x-json']
            rss: 'application/rss+xml'
            jpg: 'image/jpeg'
            png: 'image/png'
        jsonp_handler: ~
    body_listener: true
    param_fetcher_listener: force
    allowed_methods_listener: true
    access_denied_listener:
        json: true
    routing_loader:
        default_format: ~
    exception:
        codes:
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404
            'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT
        messages:
            'Symfony\Component\Routing\Exception\ResourceNotFoundException': true
    serializer:
        groups:
            - REST