Completed
Pull Request — master (#591)
by Amrouche
06:27
created

SwaggerCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
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\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Input\InputOption;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
22
/**
23
 * Console command to dump Swagger API documentations.
24
 *
25
 * @author Amrouche Hamza <[email protected]>
26
 */
27
class SwaggerCommand extends Command
28
{
29
    /**
30
     * @var ApiDocumentationBuilder
31
     */
32
    protected $apiDocumentationBuilder;
33
34
    public function __construct(ApiDocumentationBuilder $apiDocumentationBuilder)
35
    {
36
        $this->apiDocumentationBuilder = $apiDocumentationBuilder;
37
38
        parent::__construct();
39
    }
40
41
    protected function configure()
42
    {
43
44
        $this
45
            ->setName('api:swagger:export')
46
            ->setDescription('Export a beautiful json of swagger api');
47
    }
48
49
    protected function execute(InputInterface $input, OutputInterface $output)
50
    {
51
        $data = $this->apiDocumentationBuilder->getApiDocumentation();
52
        $content = json_encode($data, JSON_PRETTY_PRINT);
53
        $output->writeln($content);
54
    }
55
}