Merge pull request #1264 from adeelnawaz/master

Updated SwaggerDocblockConvertCommand command in UPGRADE-3.0.md
This commit is contained in:
Guilhem N 2018-03-24 09:34:31 +01:00 committed by GitHub
commit 82b8d14bb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ namespace AppBundle\Command;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
/**
@ -35,13 +36,20 @@ class SwaggerDocblockConvertCommand extends ContainerAwareCommand
$this
->setDescription('')
->setName('api:doc:convert')
->addOption('views', null, InputOption::VALUE_OPTIONAL, 'Comma separated list of views to convert the documentation for', 'default')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$views = explode(',', $input->getOption('views'));
$extractor = $this->getContainer()->get('nelmio_api_doc.extractor.api_doc_extractor');
$apiDocs = $extractor->extractAnnotations($extractor->getRoutes());
$apiDocs = [];
foreach ($views as $view) {
$apiDocs = array_merge($apiDocs, $extractor->extractAnnotations($extractor->getRoutes(), $view));
}
foreach ($apiDocs as $annotation) {
/** @var ApiDoc $apiDoc */
@ -180,8 +188,11 @@ class SwaggerDocblockConvertCommand extends ContainerAwareCommand
];
}
private function escapeQuotes(string $str): string
private function escapeQuotes(string $str = null): string
{
if ($str === null) {
return '';
}
$lines = [];
foreach (explode("\n", $str) as $line) {
$lines[] = trim($line, ' *');