diff --git a/app/Containers/Documentation/Configs/documentation-container.php b/app/Containers/Documentation/Configs/documentation-container.php index 9615826ed..1379a9f08 100755 --- a/app/Containers/Documentation/Configs/documentation-container.php +++ b/app/Containers/Documentation/Configs/documentation-container.php @@ -22,7 +22,7 @@ | */ - 'swagger-converter' => '$(npm bin)/apidoc-swagger', + 'swagger-converter' => 'node_modules/.bin/apidoc-swagger', /* |-------------------------------------------------------------------------- diff --git a/app/Containers/Documentation/Tasks/GenerateAPIDocsTask.php b/app/Containers/Documentation/Tasks/GenerateAPIDocsTask.php index 7808d975a..99675c292 100644 --- a/app/Containers/Documentation/Tasks/GenerateAPIDocsTask.php +++ b/app/Containers/Documentation/Tasks/GenerateAPIDocsTask.php @@ -31,7 +31,7 @@ public function run($type, $console) $command = [ $this->getExecutable(), - # executable parameters + // executable parameters "-c", $this->getJsonFilePath($type) . ' ' . $this->getEndpointFiles($type), "-i", @@ -46,12 +46,13 @@ public function run($type, $console) $process->run(); if (!$process->isSuccessful()) { + $console->error('Error Output: ' . $process->getOutput()); throw new ProcessFailedException($process); } // echo the output $console->info('[' . $type . '] ' . implode (' ', $command)); - $console->info('Result: ' . $process->getOutput()); + $console->info('Output: ' . $process->getOutput()); // return the past to that generated documentation return $this->getFullApiUrl($type); diff --git a/app/Containers/Documentation/Tasks/GenerateSwaggerTask.php b/app/Containers/Documentation/Tasks/GenerateSwaggerTask.php index 5ce1c7d65..f1d3db3a7 100644 --- a/app/Containers/Documentation/Tasks/GenerateSwaggerTask.php +++ b/app/Containers/Documentation/Tasks/GenerateSwaggerTask.php @@ -27,30 +27,41 @@ class GenerateSwaggerTask extends Task */ public function run($type, $console) { - $path = $this->getDocumentationPath($type); - - $exe = $this->getSwaggerConverter(); - - $app_path = './app'; + // little hack to move the apidoc.json file to the /app directory in order to be seen by apidoc-swagger + // since the command doesn't support passing custom path. + $app_path = 'app'; $apidoc_json = '/apidoc.json'; - copy($this->getJsonFilePath($type).$apidoc_json, $app_path.$apidoc_json); + copy($this->getJsonFilePath($type) . $apidoc_json, $app_path . $apidoc_json); - $command = $exe . ' ' . "-v -f '.*\.php$' -i {$app_path} -o {$path}/swagger"; + $command = [ + $this->getSwaggerConverter(), + // executable parameters + "-v", + "", + "-f", + "'.*\.php$'", + "-i", + $app_path, + "-o", + "{$this->getDocumentationPath($type)}/swagger" + ]; $process = new Process($command); // execute the command $process->run(); - unlink($app_path.$apidoc_json); + // delete the apidoc.json file after executing the command since it's no longer needed. + unlink($app_path . $apidoc_json); if (!$process->isSuccessful()) { + $console->error('Error Output: ' . $process->getOutput()); throw new ProcessFailedException($process); } // echo the output - $console->info('[' . $type . '] ' . $command); - $console->info('Result: ' . $process->getOutput()); + $console->info('[' . $type . '] ' . implode (' ', $command)); + $console->info('Output: ' . $process->getOutput()); // return the past to that generated documentation return $this->getFullApiUrl($type).'/swagger/swagger.json'; diff --git a/app/Containers/Documentation/UI/CLI/Commands/GenerateApiDocsCommand.php b/app/Containers/Documentation/UI/CLI/Commands/GenerateApiDocsCommand.php index c93c91c20..da36cb794 100644 --- a/app/Containers/Documentation/UI/CLI/Commands/GenerateApiDocsCommand.php +++ b/app/Containers/Documentation/UI/CLI/Commands/GenerateApiDocsCommand.php @@ -19,14 +19,14 @@ class GenerateApiDocsCommand extends ConsoleCommand * * @var string */ - protected $signature = "apiato:docs"; + protected $signature = "apiato:apidoc"; /** * The console command description. * * @var string */ - protected $description = "Generate API Documentations (using API-Doc-JS)"; + protected $description = "Generate API Documentations with (API-Doc-JS)"; /** * Create a new command instance. diff --git a/app/Containers/Documentation/UI/CLI/Commands/GenerateSwaggerCommand.php b/app/Containers/Documentation/UI/CLI/Commands/GenerateSwaggerCommand.php index f97e24ae6..12bacd426 100644 --- a/app/Containers/Documentation/UI/CLI/Commands/GenerateSwaggerCommand.php +++ b/app/Containers/Documentation/UI/CLI/Commands/GenerateSwaggerCommand.php @@ -7,7 +7,7 @@ use App\Ship\Transporters\DataTransporter; /** - * Class GenerateApiDocsCommand + * Class GenerateSwaggerCommand * * @author Mahmoud Zalt */ @@ -26,7 +26,7 @@ class GenerateSwaggerCommand extends ConsoleCommand * * @var string */ - protected $description = "Generate Swagger/OpenAPI JSON schema from apiDoc"; + protected $description = "Generate API Documentations with (Swagger from API-Doc-JS)"; /** * Create a new command instance.