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

api-platform / core / 6407040603

04 Oct 2023 01:56PM UTC coverage: 36.822% (-0.2%) from 36.978%
6407040603

push

github

web-flow
fix: entrypoint for OpenAPI (#5863)

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

10067 of 27340 relevant lines covered (36.82%)

6.69 hits per line

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

88.89
/src/Action/EntrypointAction.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\Action;
15

16
use ApiPlatform\Api\Entrypoint;
17
use ApiPlatform\Metadata\Get;
18
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
19
use ApiPlatform\State\ProcessorInterface;
20
use ApiPlatform\State\ProviderInterface;
21
use Symfony\Component\HttpFoundation\Request;
22
use Symfony\Component\HttpFoundation\Response;
23

24
/**
25
 * Generates the API entrypoint.
26
 *
27
 * @author Kévin Dunglas <dunglas@gmail.com>
28
 */
29
final class EntrypointAction
30
{
31
    public function __construct(
32
        private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
33
        private readonly ?ProviderInterface $provider = null,
34
        private readonly ?ProcessorInterface $processor = null,
35
        private readonly array $documentationFormats = []
36
    ) {
37
    }
27✔
38

39
    /**
40
     * @return Entrypoint|Response
41
     */
42
    public function __invoke(Request $request = null)
43
    {
44
        if ($this->provider && $this->processor) {
27✔
45
            $context = ['request' => $request];
24✔
46
            $operation = new Get(outputFormats: $this->documentationFormats, read: true, serialize: true, class: Entrypoint::class, provider: fn () => new Entrypoint($this->resourceNameCollectionFactory->create()));
24✔
47
            $body = $this->provider->provide($operation, [], $context);
24✔
48
            // see https://github.com/api-platform/core/issues/5845#issuecomment-1732400657
49
            if ($request && ($apiOperation = $request->attributes->get('_api_operation'))) {
24✔
50
                $operation = $apiOperation;
×
51
            }
52

53
            return $this->processor->process($body, $operation, [], $context);
24✔
54
        }
55

56
        return new Entrypoint($this->resourceNameCollectionFactory->create());
3✔
57
    }
58
}
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