Completed
Pull Request — master (#591)
by Amrouche
12:54 queued 07:22
created

SwaggerCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
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
namespace ApiPlatform\Core\Bridge\Symfony\Bundle\Command;
13
14
use ApiPlatform\Core\Swagger\ApiDocumentationBuilder;
15
use Symfony\Component\Console\Command\Command;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Console command to dump Swagger API documentations.
21
 *
22
 * @author Amrouche Hamza <[email protected]>
23
 */
24
class SwaggerCommand extends Command
25
{
26
    /**
27
     * @var ApiDocumentationBuilder
28
     */
29
    protected $apiDocumentationBuilder;
30
31
    public function __construct(ApiDocumentationBuilder $apiDocumentationBuilder)
32
    {
33
        $this->apiDocumentationBuilder = $apiDocumentationBuilder;
34
35
        parent::__construct();
36
    }
37
38
    protected function configure()
39
    {
40
        $this
41
            ->setName('api:swagger:export')
42
            ->setDescription('Export a beautiful json of swagger api');
43
    }
44
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        $data = $this->apiDocumentationBuilder->getApiDocumentation();
48
        $content = json_encode($data, JSON_PRETTY_PRINT);
49
        $output->writeln($content);
50
    }
51
}
52