From 2c504cdd9816802432640a4969590ea223b7bf1a Mon Sep 17 00:00:00 2001 From: Guilhem N Date: Thu, 11 Apr 2019 20:54:16 +0200 Subject: [PATCH] Add exceptions in the upgrading command to warn about the requirement to run it on 2.x (#1501) --- README.md | 2 +- UPGRADE-3.0.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ede5a7..d67ead1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 3e602e3..a39c300 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -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 = [];