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

api-platform / core / 14635100171

24 Apr 2025 06:39AM UTC coverage: 8.271% (+0.02%) from 8.252%
14635100171

Pull #6904

github

web-flow
Merge c9cefd82e into a3e5e53ea
Pull Request #6904: feat(graphql): added support for graphql subscriptions to work for actions

0 of 73 new or added lines in 3 files covered. (0.0%)

1999 existing lines in 144 files now uncovered.

13129 of 158728 relevant lines covered (8.27%)

13.6 hits per line

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

100.0
/src/OpenApi/Serializer/LegacyOpenApiNormalizer.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\OpenApi\Serializer;
15

16
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
17

18
final class LegacyOpenApiNormalizer implements NormalizerInterface
19
{
20
    public const SPEC_VERSION = 'spec_version';
21
    private array $defaultContext = [
22
        self::SPEC_VERSION => '3.1.0',
23
    ];
24

25
    public function __construct(private readonly NormalizerInterface $decorated, $defaultContext = [])
26
    {
27
        $this->defaultContext = array_merge($this->defaultContext, $defaultContext);
1,160✔
28
    }
29

30
    public function normalize(mixed $object, ?string $format = null, array $context = []): array
31
    {
32
        $openapi = $this->decorated->normalize($object, $format, $context);
32✔
33

34
        if ('3.0.0' !== ($context['spec_version'] ?? null)) {
32✔
35
            return $openapi;
31✔
36
        }
37

UNCOV
38
        $schemas = &$openapi['components']['schemas'];
1✔
UNCOV
39
        $openapi['openapi'] = '3.0.0';
1✔
UNCOV
40
        foreach ($openapi['components']['schemas'] as $name => $component) {
1✔
UNCOV
41
            foreach ($component['properties'] ?? [] as $property => $value) {
1✔
UNCOV
42
                if (\is_array($value['type'] ?? false)) {
1✔
UNCOV
43
                    foreach ($value['type'] as $type) {
1✔
UNCOV
44
                        $schemas[$name]['properties'][$property]['anyOf'][] = ['type' => $type];
1✔
45
                    }
UNCOV
46
                    unset($schemas[$name]['properties'][$property]['type']);
1✔
47
                }
48
            }
49
        }
50

UNCOV
51
        return $openapi;
1✔
52
    }
53

54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
58
    {
59
        return $this->decorated->supportsNormalization($data, $format, $context);
32✔
60
    }
61

62
    public function getSupportedTypes($format): array
63
    {
64
        return $this->decorated->getSupportedTypes($format);
1,118✔
65
    }
66
}
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