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

api-platform / core / 20832557808

08 Jan 2026 09:35PM UTC coverage: 18.991% (-9.9%) from 28.875%
20832557808

Pull #7658

github

web-flow
Merge c8402145f into 39c55837e
Pull Request #7658: fix(openapi): properly document list parameters

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

14885 existing lines in 487 files now uncovered.

10912 of 57460 relevant lines covered (18.99%)

21.79 hits per line

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

2.63
/src/JsonLd/JsonStreamer/WritePropertyMetadataLoader.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\JsonLd\JsonStreamer;
15

16
use ApiPlatform\Hydra\Collection;
17
use ApiPlatform\Hydra\IriTemplate;
18
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
19
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
20
use ApiPlatform\Metadata\ResourceClassResolverInterface;
21
use ApiPlatform\Metadata\Util\TypeHelper;
22
use Symfony\Component\JsonStreamer\Mapping\PropertyMetadata;
23
use Symfony\Component\JsonStreamer\Mapping\PropertyMetadataLoaderInterface;
24
use Symfony\Component\TypeInfo\Type;
25

26
final class WritePropertyMetadataLoader implements PropertyMetadataLoaderInterface
27
{
28
    public function __construct(
29
        private readonly PropertyMetadataLoaderInterface $loader,
30
        private readonly ResourceClassResolverInterface $resourceClassResolver,
31
        private readonly PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory,
32
        private readonly PropertyMetadataFactoryInterface $propertyMetadataFactory,
33
    ) {
UNCOV
34
    }
559✔
35

36
    public function load(string $className, array $options = [], array $context = []): array
37
    {
UNCOV
38
        $properties = $this->loader->load($className, $options, $context);
×
39

UNCOV
40
        if (IriTemplate::class === $className) {
×
UNCOV
41
            return $properties;
×
42
        }
43

UNCOV
44
        if (Collection::class !== $className && !$this->resourceClassResolver->isResourceClass($className)) {
×
UNCOV
45
            return $properties;
×
46
        }
47

UNCOV
48
        $originalClassName = TypeHelper::getClassName($context['original_type']);
×
UNCOV
49
        $hasIri = true;
×
UNCOV
50
        $virtualProperty = 'id';
×
51

UNCOV
52
        foreach ($this->propertyNameCollectionFactory->create($originalClassName) as $property) {
×
UNCOV
53
            $propertyMetadata = $this->propertyMetadataFactory->create($originalClassName, $property);
×
UNCOV
54
            if ($propertyMetadata->isIdentifier()) {
×
UNCOV
55
                $virtualProperty = $property;
×
56
            }
57

UNCOV
58
            if ($className === $originalClassName) {
×
UNCOV
59
                continue;
×
60
            }
61

UNCOV
62
            if ($propertyMetadata->getNativeType()->isIdentifiedBy($className)) {
×
UNCOV
63
                $hasIri = $propertyMetadata->getGenId();
×
UNCOV
64
                $virtualProperty = iterator_to_array($this->propertyNameCollectionFactory->create($className))[0];
×
65
            }
66
        }
67

UNCOV
68
        if ($hasIri) {
×
UNCOV
69
            $properties['@id'] = new PropertyMetadata(
×
UNCOV
70
                $virtualProperty, // virtual property
×
UNCOV
71
                Type::mixed(), // virtual property
×
UNCOV
72
                ['api_platform.jsonld.json_streamer.write.value_transformer.iri'],
×
UNCOV
73
            );
×
74
        }
75

UNCOV
76
        $properties['@type'] = new PropertyMetadata(
×
UNCOV
77
            $virtualProperty, // virtual property
×
UNCOV
78
            Type::mixed(), // virtual property
×
UNCOV
79
            ['api_platform.jsonld.json_streamer.write.value_transformer.type'],
×
UNCOV
80
        );
×
81

UNCOV
82
        if ($className !== $originalClassName) {
×
UNCOV
83
            return $properties;
×
84
        }
85

UNCOV
86
        if (Collection::class === $originalClassName || ($this->resourceClassResolver->isResourceClass($originalClassName) && !isset($context['generated_classes'][Collection::class]))) {
×
UNCOV
87
            $properties['@context'] = new PropertyMetadata(
×
UNCOV
88
                $virtualProperty, // virual property
×
UNCOV
89
                Type::string(), // virtual property
×
UNCOV
90
                ['api_platform.jsonld.json_streamer.write.value_transformer.context'],
×
UNCOV
91
            );
×
92
        }
93

UNCOV
94
        return $properties;
×
95
    }
96
}
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