Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Assert/Choice not handled with Callback function #28

Open
s0meRandomDev opened this issue Nov 21, 2018 · 0 comments
Open

Assert/Choice not handled with Callback function #28

s0meRandomDev opened this issue Nov 21, 2018 · 0 comments

Comments

@s0meRandomDev
Copy link

Hi !

I have the following line that works perfectly with the schema generator :

@Assert\Choice(choices={"ongoing", "finalised", "new"}, strict=true)

However, when I do that:

@Assert\Choice(callback="getProgressStages", strict=true)

coupled with this method:

public static function getProgressStages()
    {
        return array('ongoing', 'finalised', 'new');
    }

Doctrine has no problem using it, but as soon as I try to generate a json schema, I get the following stacktrace:

1) Tests\ApiBundle\Controller\BuildingReviewControllerTest::testBuildingReviewsOptions
TypeError: Argument 1 passed to Knp\JsonSchemaBundle\Model\Property::setEnumeration() must be of the type array, null given, called in /opt/vendor/ivanmilosavljevic/knp-json-schema-bundle/src/Knp/JsonSchemaBundle/Property/ExtraValidatorConstraintsHandler.php on line 21

/opt/vendor/ivanmilosavljevic/knp-json-schema-bundle/src/Knp/JsonSchemaBundle/Model/Property.php:141
/opt/vendor/ivanmilosavljevic/knp-json-schema-bundle/src/Knp/JsonSchemaBundle/Property/ExtraValidatorConstraintsHandler.php:21
/opt/vendor/ivanmilosavljevic/knp-json-schema-bundle/src/Knp/JsonSchemaBundle/Schema/SchemaGenerator.php:145
/opt/vendor/ivanmilosavljevic/knp-json-schema-bundle/src/Knp/JsonSchemaBundle/Schema/SchemaGenerator.php:72
/opt/src/ApiBundle/Controller/BuildingReviewsController.php:203
/opt/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151
/opt/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68
/opt/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:202
/opt/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Client.php:68
/opt/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Client.php:131
/opt/vendor/symfony/symfony/src/Symfony/Component/BrowserKit/Client.php:312
/opt/tests/ApiBundle/Controller/BuildingReviewControllerTest.php:302
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant