Skip to content

PathAttribute: mapping of primitives #3

@vbartusevicius

Description

@vbartusevicius

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\""
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions