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

api-platform / core / 10740459985

06 Sep 2024 02:47PM UTC coverage: 6.92% (-0.2%) from 7.159%
10740459985

push

github

web-flow
fix(laravel): docs _format and open swagger ui (#6595)

0 of 90 new or added lines in 11 files covered. (0.0%)

1910 existing lines in 69 files now uncovered.

11347 of 163980 relevant lines covered (6.92%)

14.18 hits per line

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

0.0
/src/Laravel/Controller/EntrypointController.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\Laravel\Controller;
15

16
use ApiPlatform\Documentation\Entrypoint;
17
use ApiPlatform\Metadata\Get;
18
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
19
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
20
use ApiPlatform\OpenApi\Serializer\LegacyOpenApiNormalizer;
21
use ApiPlatform\State\ProcessorInterface;
22
use ApiPlatform\State\ProviderInterface;
23
use Symfony\Component\HttpFoundation\Request;
24
use Symfony\Component\HttpFoundation\Response;
25

26
/**
27
 * Generates the API entrypoint.
28
 *
29
 * @author Kévin Dunglas <dunglas@gmail.com>
30
 */
31
final class EntrypointController
32
{
33
    private static ResourceNameCollection $resourceNameCollection;
34

35
    /**
36
     * @param array<string, string[]>             $documentationFormats
37
     * @param ProviderInterface<object>           $provider
38
     * @param ProcessorInterface<mixed, Response> $processor
39
     */
40
    public function __construct(
41
        private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
42
        private readonly ProviderInterface $provider,
43
        private readonly ProcessorInterface $processor,
44
        private readonly array $documentationFormats = [],
45
    ) {
NEW
46
    }
×
47

48
    public function __invoke(Request $request): Response
49
    {
NEW
50
        self::$resourceNameCollection = $this->resourceNameCollectionFactory->create();
×
NEW
51
        $context = [
×
NEW
52
            'request' => $request,
×
NEW
53
            'spec_version' => (string) $request->query->get(LegacyOpenApiNormalizer::SPEC_VERSION),
×
NEW
54
        ];
×
NEW
55
        $request->attributes->set('_api_platform_disable_listeners', true);
×
NEW
56
        $operation = new Get(
×
NEW
57
            outputFormats: $this->documentationFormats,
×
NEW
58
            read: true,
×
NEW
59
            serialize: true,
×
NEW
60
            class: Entrypoint::class,
×
NEW
61
            provider: [self::class, 'provide']
×
NEW
62
        );
×
NEW
63
        $request->attributes->set('_api_operation', $operation);
×
NEW
64
        $body = $this->provider->provide($operation, [], $context);
×
NEW
65
        $operation = $request->attributes->get('_api_operation');
×
66

NEW
67
        return $this->processor->process($body, $operation, [], $context);
×
68
    }
69

70
    public static function provide(): Entrypoint
71
    {
NEW
72
        return new Entrypoint(self::$resourceNameCollection);
×
73
    }
74
}
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