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

api-platform / core / 20822307873

08 Jan 2026 03:35PM UTC coverage: 21.258% (-7.6%) from 28.879%
20822307873

Pull #7658

github

web-flow
Merge 7e9d13d39 into 550b7621d
Pull Request #7658: fix(openapi): properly document list parameters

0 of 2 new or added lines in 1 file covered. (0.0%)

14467 existing lines in 472 files now uncovered.

12215 of 57461 relevant lines covered (21.26%)

49.28 hits per line

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

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

16
use ApiPlatform\Documentation\Entrypoint;
17
use ApiPlatform\Metadata\CollectionOperationInterface;
18
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
19
use ApiPlatform\Metadata\Exception\OperationNotFoundException;
20
use ApiPlatform\Metadata\IriConverterInterface;
21
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
22
use ApiPlatform\Metadata\UrlGeneratorInterface;
23
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
24

25
/**
26
 * Normalizes the API entrypoint.
27
 *
28
 * @author Kévin Dunglas <dunglas@gmail.com>
29
 */
30
final class EntrypointNormalizer implements NormalizerInterface
31
{
32
    public const FORMAT = 'jsonld';
33

34
    public function __construct(private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory, private readonly IriConverterInterface $iriConverter, private readonly UrlGeneratorInterface $urlGenerator)
35
    {
UNCOV
36
    }
1,529✔
37

38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function normalize(mixed $object, ?string $format = null, array $context = []): array
42
    {
UNCOV
43
        $entrypoint = [
2✔
UNCOV
44
            '@context' => $this->urlGenerator->generate('api_jsonld_context', ['shortName' => 'Entrypoint']),
2✔
UNCOV
45
            '@id' => $this->urlGenerator->generate('api_entrypoint'),
2✔
UNCOV
46
            '@type' => 'Entrypoint',
2✔
UNCOV
47
        ];
2✔
48

UNCOV
49
        foreach ($object->getResourceNameCollection() as $resourceClass) {
2✔
UNCOV
50
            $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
2✔
51

UNCOV
52
            foreach ($resourceMetadata as $resource) {
2✔
UNCOV
53
                if ($resource->getExtraProperties()['is_alternate_resource_metadata'] ?? false) {
2✔
UNCOV
54
                    continue;
2✔
55
                }
56

UNCOV
57
                foreach ($resource->getOperations() as $operation) {
2✔
UNCOV
58
                    $key = lcfirst($resource->getShortName());
2✔
UNCOV
59
                    if (true === $operation->getHideHydraOperation() || !$operation instanceof CollectionOperationInterface || isset($entrypoint[$key])) {
2✔
UNCOV
60
                        continue;
2✔
61
                    }
62

63
                    try {
UNCOV
64
                        $entrypoint[$key] = $this->iriConverter->getIriFromResource($resourceClass, UrlGeneratorInterface::ABS_PATH, $operation);
2✔
65
                    } catch (InvalidArgumentException|OperationNotFoundException) {
2✔
66
                        // Ignore resources without GET operations
67
                    }
68
                }
69
            }
70
        }
71

UNCOV
72
        ksort($entrypoint);
2✔
73

UNCOV
74
        return $entrypoint;
2✔
75
    }
76

77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
81
    {
UNCOV
82
        return self::FORMAT === $format && $data instanceof Entrypoint;
2✔
83
    }
84

85
    /**
86
     * @param string|null $format
87
     */
88
    public function getSupportedTypes($format): array
89
    {
UNCOV
90
        return self::FORMAT === $format ? [Entrypoint::class => true] : [];
1,428✔
91
    }
92
}
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

© 2026 Coveralls, Inc