Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert/Choice not handled with Callback function #28

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

Comments

@liteultom
Copy link

commented Nov 21, 2018

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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.