Add exceptions in the upgrading command to warn about the requirement to run it on 2.x (#1501)

This commit is contained in:
Guilhem N 2019-04-11 20:54:16 +02:00 committed by GitHub
parent 92dfcc41a4
commit 2c504cdd98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -12,7 +12,7 @@ for your APIs.
## Migrate from 2.x to 3.0
[To migrate from 2.x to 3.0, just follow our guide.](https://github.com/nelmio/NelmioApiDocBundle/blob/master/UPGRADE-3.0.md)
[To migrate from 2.x to 3.0, follow our guide.](https://github.com/nelmio/NelmioApiDocBundle/blob/master/UPGRADE-3.0.md)
## Installation

View File

@ -44,6 +44,14 @@ class SwaggerDocblockConvertCommand extends ContainerAwareCommand
{
$views = explode(',', $input->getOption('views'));
if (!$this->getContainer()->has('nelmio_api_doc.extractor.api_doc_extractor')) {
if (!$this->getContainer()->has('nelmio_api_doc.controller.swagger_ui')) {
throw new \RuntimeException('NelmioApiDocBundle is not installed. Please run `composer require nelmio/api-doc-bundle`.');
} else {
throw new \RuntimeException('This command only works with NelmioApiDocBundle 2.x installed while version 3.x is currently installed. Please downgrade to 2.x to execute this command and bump your constraint only after its execution.');
}
}
$extractor = $this->getContainer()->get('nelmio_api_doc.extractor.api_doc_extractor');
$apiDocs = [];