Skip to content

Commit 0cc210a

Browse files
antograssiotdunglas
authored andcommitted
Fix Yaml Swagger export (#2256)
* Fix Yaml Swagger export * Increase inlining depth to improve readability
1 parent a7bbbd0 commit 0cc210a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Bridge/Symfony/Bundle/Command/SwaggerCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
{
6868
$documentation = new Documentation($this->resourceNameCollectionFactory->create(), $this->apiTitle, $this->apiDescription, $this->apiVersion, $this->apiFormats);
6969
$data = $this->documentationNormalizer->normalize($documentation);
70-
$content = $input->getOption('yaml') ? Yaml::dump($data, Yaml::DUMP_OBJECT_AS_MAP) : json_encode($data, JSON_PRETTY_PRINT);
71-
70+
$content = $input->getOption('yaml') ? Yaml::dump($data, 6, 4, Yaml::DUMP_OBJECT_AS_MAP) : json_encode($data, JSON_PRETTY_PRINT);
7271
if (!empty($input->getOption('output'))) {
7372
file_put_contents($input->getOption('output'), $content);
7473
$output->writeln(

tests/Bridge/Symfony/Bundle/Command/SwaggerCommandTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,18 @@ public function testExecuteWithYaml()
5151
{
5252
$this->tester->run(['command' => 'api:swagger:export', '--yaml' => true]);
5353

54-
$this->assertYaml($this->tester->getDisplay());
54+
$result = $this->tester->getDisplay();
55+
$this->assertYaml($result);
56+
57+
$expected = <<<YAML
58+
/dummy_cars:
59+
get:
60+
tags:
61+
- DummyCar
62+
operationId: getDummyCarCollection
63+
YAML;
64+
65+
$this->assertContains($expected, $result);
5566
}
5667

5768
public function testWriteToFile()

0 commit comments

Comments
 (0)