FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 702 forks source link

[BUG] InvalidParameterException: property_path is empty with @QueryParam #2153

Open krabouilleur opened 4 years ago

krabouilleur commented 4 years ago

Hi,

my queryParam :

@Get("/foo", name="foo")
@QueryParam( name="limit", requirements="^[1-9]+$|(^[1-9][0-9]+$)", strict=true, nullable=false )
  1. I go to my route /foo (without de query param ?limit)
  2. With the Exception controller I get the InvalidParameterException came from FOS\RestBundle\Exception\InvalidParameterException;

the response in json : "message": [

[
    {
        "property_path": "",
        "message": "This value should not be null."
    }
]

EXPECTED:

[
    {
        "property_path": "limit",
        "message": "This value should not be null."
    }
]

The property path is empty it seems a bug because the $exception->getMessage() give the parameter name : "Parameter "limit" of value "NULL" violated a constraint "This value should not be null."" (but not the $exception->getViolations()

xabbuh commented 4 years ago

Which version of the bundle do you use?

krabouilleur commented 4 years ago

my dependencies :

"require": {
        "php": "^7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "doctrine/annotations": "^1.8",
        "friendsofsymfony/rest-bundle": "dev-master",
        "jms/serializer-bundle": "^3.5",
        "mark-gerarts/automapper-plus-bundle": "^1.2",
        "nelmio/cors-bundle": "^2.0",
        "sensio/framework-extra-bundle": "^5.5",
        "symfony/apache-pack": "^1.0",
        "symfony/console": "5.0.*",
        "symfony/dotenv": "5.0.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.0.*",
        "symfony/framework-bundle": "5.0.*",
        "symfony/monolog-bundle": "^3.5",
        "symfony/orm-pack": "^1.0",
        "symfony/validator": "5.0.*",
        "symfony/yaml": "5.0.*"
    },