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

PathAttribute: mapping of primitives #3

Open
vbartusevicius opened this issue Jul 1, 2020 · 0 comments
Open

PathAttribute: mapping of primitives #3

vbartusevicius opened this issue Jul 1, 2020 · 0 comments

Comments

@vbartusevicius
Copy link
Contributor

Primitive types could be properly converted to their strict representations instead of being just strings.
I.e.: GET http://domain.local/some/path?active_and_upcoming=true&past=false&visible=true&offset=0&limit=10 will be mapped to the following structure:
image

Now in Normalizer you would expect to hydrate the object like this:

    public function denormalize(ObjectWrapper $input, DenormalizationContext $context)
    {
        $filter = new SomeFilter();

        $filter->setName($input->getString('name'));
        $filter->setUpcoming($input->getRequiredBool('active_and_upcoming'));
        $filter->setEnded($input->getRequiredBool('past'));

        return $filter;
    }

But you will get an error:

{
"error": "invalid_parameters",
"error_description": "Expected boolean but got string for key \"active_and_upcoming\""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant