From ac6828d2b93696a6f5fd519487e07380ee4b1f9e Mon Sep 17 00:00:00 2001 From: Balaji Dharma Date: Mon, 12 Feb 2024 09:56:08 -0500 Subject: [PATCH 1/4] prevent doc genration when generate_always is false --- src/Console/GenerateDocsCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Console/GenerateDocsCommand.php b/src/Console/GenerateDocsCommand.php index 2af91c5..772f666 100644 --- a/src/Console/GenerateDocsCommand.php +++ b/src/Console/GenerateDocsCommand.php @@ -3,6 +3,7 @@ namespace L5Swagger\Console; use Illuminate\Console\Command; +use L5Swagger\ConfigFactory; use L5Swagger\Exceptions\L5SwaggerException; use L5Swagger\GeneratorFactory; @@ -68,6 +69,15 @@ private function generateDocumentation(GeneratorFactory $generatorFactory, strin { $this->info('Regenerating docs '.$documentation); + $configFactory = resolve(ConfigFactory::class); + $config = $configFactory->documentationConfig($documentation); + + if (! $config['generate_always']) { + $this->info('Config generate_always false - skipping doc generation'); + + return; + } + $generator = $generatorFactory->make($documentation); $generator->generateDocs(); } From aa83e5f9182ae2e0678bf27a10b004cae53d60bd Mon Sep 17 00:00:00 2001 From: Balaji Dharma Date: Mon, 12 Feb 2024 10:14:53 -0500 Subject: [PATCH 2/4] prevent doc generation when generate_always is false --- src/Console/GenerateDocsCommand.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Console/GenerateDocsCommand.php b/src/Console/GenerateDocsCommand.php index 772f666..88f4b4a 100644 --- a/src/Console/GenerateDocsCommand.php +++ b/src/Console/GenerateDocsCommand.php @@ -36,7 +36,7 @@ public function __construct() * * @throws L5SwaggerException */ - public function handle(GeneratorFactory $generatorFactory) + public function handle(GeneratorFactory $generatorFactory, ConfigFactory $configFactory) { $all = $this->option('all'); @@ -44,7 +44,7 @@ public function handle(GeneratorFactory $generatorFactory) $documentations = array_keys(config('l5-swagger.documentations', [])); foreach ($documentations as $documentation) { - $this->generateDocumentation($generatorFactory, $documentation); + $this->generateDocumentation($generatorFactory, $documentation, $configFactory); } return; @@ -56,7 +56,7 @@ public function handle(GeneratorFactory $generatorFactory) $documentation = config('l5-swagger.default'); } - $this->generateDocumentation($generatorFactory, $documentation); + $this->generateDocumentation($generatorFactory, $documentation, $configFactory); } /** @@ -65,11 +65,10 @@ public function handle(GeneratorFactory $generatorFactory) * * @throws L5SwaggerException */ - private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation) + private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation, ConfigFactory $configFactory) { $this->info('Regenerating docs '.$documentation); - $configFactory = resolve(ConfigFactory::class); $config = $configFactory->documentationConfig($documentation); if (! $config['generate_always']) { From ff02853a6a1c1bc42bb200827f3b564a03ad84be Mon Sep 17 00:00:00 2001 From: Balaji Dharma Date: Mon, 12 Feb 2024 10:37:13 -0500 Subject: [PATCH 3/4] prevent doc generation when generate_always is false --- src/Console/GenerateDocsCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Console/GenerateDocsCommand.php b/src/Console/GenerateDocsCommand.php index 88f4b4a..b29a5ad 100644 --- a/src/Console/GenerateDocsCommand.php +++ b/src/Console/GenerateDocsCommand.php @@ -32,6 +32,7 @@ public function __construct() * Execute the console command. * * @param GeneratorFactory $generatorFactory + * @param ConfigFactory $configFactory * @return void * * @throws L5SwaggerException @@ -62,10 +63,15 @@ public function handle(GeneratorFactory $generatorFactory, ConfigFactory $config /** * @param GeneratorFactory $generatorFactory * @param string $documentation + * @param ConfigFactory $configFactory * * @throws L5SwaggerException */ - private function generateDocumentation(GeneratorFactory $generatorFactory, string $documentation, ConfigFactory $configFactory) + private function generateDocumentation( + GeneratorFactory $generatorFactory, + string $documentation, + ConfigFactory $configFactory + ) { $this->info('Regenerating docs '.$documentation); From fc5003fbf1942c3693d56bcf405e8a56a5aa2645 Mon Sep 17 00:00:00 2001 From: Balaji Dharma Date: Mon, 12 Feb 2024 10:38:49 -0500 Subject: [PATCH 4/4] fixed codeclimate issue --- src/Console/GenerateDocsCommand.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Console/GenerateDocsCommand.php b/src/Console/GenerateDocsCommand.php index b29a5ad..7807826 100644 --- a/src/Console/GenerateDocsCommand.php +++ b/src/Console/GenerateDocsCommand.php @@ -69,10 +69,9 @@ public function handle(GeneratorFactory $generatorFactory, ConfigFactory $config */ private function generateDocumentation( GeneratorFactory $generatorFactory, - string $documentation, - ConfigFactory $configFactory - ) - { + string $documentation, + ConfigFactory $configFactory + ) { $this->info('Regenerating docs '.$documentation); $config = $configFactory->documentationConfig($documentation);