Skip to content

Commit e249e86

Browse files
committed
Support YAML output from SwaggerCommand with --yaml
1 parent c8b45fa commit e249e86

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ script:
5454
- if [[ $APP_ENV != 'postgres' ]]; then vendor/bin/behat --format=progress; fi
5555
- if [[ $APP_ENV = 'postgres' ]]; then vendor/bin/behat --tags='~@sqlite' --format=progress; fi
5656
- tests/Fixtures/app/console api:swagger:export > swagger.json && swagger-cli validate swagger.json && rm swagger.json
57+
- tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml
5758
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff --no-ansi; fi
5859
- if [[ $lint = 1 ]]; then phpstan analyse -c phpstan.neon -l5 --ansi src tests; fi

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6666
{
6767
$documentation = new Documentation($this->resourceNameCollectionFactory->create(), $this->apiTitle, $this->apiDescription, $this->apiVersion, $this->apiFormats);
6868
$data = $this->documentationNormalizer->normalize($documentation);
69-
if ($input->getOption('yaml')) {
70-
$content = Yaml::dump($data);
71-
} else {
72-
$content = json_encode($data, JSON_PRETTY_PRINT);
73-
}
69+
$content = $input->getOption('yaml') ? Yaml::dump($data) : json_encode($data, JSON_PRETTY_PRINT);
7470
$output->writeln($content);
7571
}
7672
}

0 commit comments

Comments
 (0)