core icon indicating copy to clipboard operation
core copied to clipboard

additional_allowed_attributes

Open ili101 opened this issue 1 year ago • 0 comments

Q A
Branch? main
Tickets Closes https://github.com/api-platform/core/issues/6225
License MIT
Doc PR api-platform/docs#...

Tested it on my project and it works and solves my use case and the id case from https://api-platform.com/docs/core/serialization/#denormalization. But then tried to add to test tests/JsonLd/Serializer/ItemNormalizerTest.php something like:

        $context = [
            'allow_extra_attributes' => false,
            'additional_allowed_attributes' => ['@type', 'extra'],
        ];
        $data = [
            // '@context' => '/contexts/Dummy',
            // '@id' => '/dummies/1988',
            '@type' => 'Dummy',
            'name' => 'hello',
            'extra' => 'hello',
        ];
        $normalizer->denormalize($data, Dummy::class, context: $context);

But the test fails not sure why. I probably set the test wrong?

ili101 avatar Mar 31 '24 17:03 ili101