• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 17496868802

05 Sep 2025 03:02PM UTC coverage: 22.604% (+0.05%) from 22.559%
17496868802

push

github

soyuka
fix(symfony): remove deprecation about jsonopenapi

12072 of 53406 relevant lines covered (22.6%)

26.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Symfony/EventListener/JsonStreamerDeserializeListener.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Symfony\EventListener;
15

16
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
17
use ApiPlatform\State\ProviderInterface;
18
use ApiPlatform\State\Util\OperationRequestInitiatorTrait;
19
use ApiPlatform\State\Util\RequestAttributesExtractor;
20
use Symfony\Component\HttpKernel\Event\RequestEvent;
21

22
/**
23
 * Deserializes the data sent in the requested format using JSON Streamer.
24
 *
25
 * @author Kévin Dunglas <dunglas@gmail.com>
26
 */
27
final class JsonStreamerDeserializeListener
28
{
29
    use OperationRequestInitiatorTrait;
30

31
    /**
32
     * @param ProviderInterface<object> $jsonStreamerProvider
33
     */
34
    public function __construct(
35
        private ProviderInterface $jsonStreamerProvider,
36
        private readonly string $format,
37
        ?ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory = null,
38
    ) {
39
        $this->resourceMetadataCollectionFactory = $resourceMetadataFactory;
325✔
40
    }
41

42
    /**
43
     * Deserializes the data sent in the requested format.
44
     */
45
    public function onKernelRequest(RequestEvent $event): void
46
    {
47
        $request = $event->getRequest();
325✔
48
        $operation = $this->initializeOperation($request);
325✔
49

50
        if (
51
            !($attributes = RequestAttributesExtractor::extractAttributes($request))
325✔
52
            || !$attributes['receive']
325✔
53
            || !$operation
325✔
54
            || !$operation->getJsonStream()
325✔
55
            || $this->format !== $request->attributes->get('input_format')
325✔
56
        ) {
57
            return;
325✔
58
        }
59

60
        $data = $this->jsonStreamerProvider->provide($operation, $request->attributes->get('_api_uri_variables') ?? [], [
2✔
61
            'request' => $request,
2✔
62
            'uri_variables' => $request->attributes->get('_api_uri_variables') ?? [],
2✔
63
            'resource_class' => $operation->getClass(),
2✔
64
        ]);
2✔
65

66
        $request->attributes->set('data', $data);
2✔
67
    }
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc