Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<comment>Scan begining.</comment>');
     $result = $this->getContainer()->get('dokapi.swagger.scanner')->scan();
     $output->writeln('<comment>Scan done.</comment>');
     $apis = $result->getAll('api');
     $output->writeln(sprintf('<info>%s api(s) detected(s)</info>', count($apis)));
     if ($input->getOption('verbose')) {
         foreach ($result->getAll('api') as $api) {
             $output->writeln(sprintf('-----------------------------------------------------------------'));
             $output->writeln(sprintf('--- Api version: <info>%s</info>, path: <info>%s</info>', $api->getVersion(), $api->getPath()));
             $output->writeln(sprintf('-----------------------------------------------------------------'));
             foreach ($api->getResources() as $resource) {
                 $output->writeln(sprintf('------ Resource: <comment>%s</comment>', $resource->getId()));
                 foreach ($resource->getOperations() as $operation) {
                     $output->writeln(sprintf('--------- <comment>%s</comment>, path: <comment>%s</comment>, parameters: <comment>%s</comment>, responses: <comment>%s</comment>', $operation->getId(), $operation->getPath(), count($operation->getParameters()), count($operation->getResponses())));
                 }
             }
         }
     }
     if ($outputDir = $input->getOption('output-dir')) {
         $output->writeln(sprintf('Output results in directory <info>%s</info>', $outputDir));
         $renderer = new FilesystemRenderer($outputDir);
         $renderer->render($result);
         $output->writeln('<info>Done.</info>');
     }
 }
 /**
  * @param string $cacheDir cacheDir
  */
 public function warmUp($cacheDir)
 {
     $renderer = new FilesystemRenderer($this->directory);
     $renderer->render($this->scanner->scan());
 }