processors() public static method

Get direct access to the processors array.
public static processors ( ) : array
return array reference
示例#1
0
 /**
  * Scan the filesystem for swagger annotations and build swagger-documentation.
  *
  * @param string|array|Finder $directory The directory(s) or filename(s)
  * @param array $options 
  *   exclude: string|array $exclude The directory(s) or filename(s) to exclude (as absolute or relative paths)
  *   analyser: defaults to StaticAnalyser
  *   analysis: defaults to a new Analysis
  *   processors: defaults to the registered processors in Analysis
  * @return Swagger
  */
 function scan($directory, $options = array())
 {
     $analyser = @$options['analyser'] ?: new StaticAnalyser();
     $analysis = @$options['analysis'] ?: new Analysis();
     $processors = @$options['processors'] ?: Analysis::processors();
     $exclude = @$options['exclude'] ?: null;
     // Crawl directory and parse all files
     $finder = Util::finder($directory, $exclude);
     foreach ($finder as $file) {
         $analysis->addAnalysis($analyser->fromFile($file->getPathname()));
     }
     // Post processing
     $analysis->process($processors);
     // Validation (Generate notices & warnings)
     $analysis->validate();
     return $analysis->swagger;
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function getServiceConfig()
 {
     return array('aliases' => array('service.swagger' => 'Swagger\\Annotations\\Swagger'), 'factories' => array('SwaggerModule\\Options\\ModuleOptions' => function ($serviceManager) {
         $config = $serviceManager->get('Config');
         $config = isset($config['swagger']) ? $config['swagger'] : null;
         if ($config === null) {
             throw new RuntimeException('Configuration for SwaggerModule was not found');
         }
         return new SwaggerModuleOptions($config);
     }, 'Swagger\\Annotations\\Swagger' => function ($serviceManager) {
         /** @var $options \SwaggerModule\Options\ModuleOptions */
         $options = $serviceManager->get('SwaggerModule\\Options\\ModuleOptions');
         $analyser = new SwaggerStaticAnalyser();
         $analysis = new SwaggerAnalysis();
         $processors = SwaggerAnalysis::processors();
         // Crawl directory and parse all files
         $paths = $options->getPaths();
         foreach ($paths as $directory) {
             $finder = SwaggerUtil::finder($directory);
             foreach ($finder as $file) {
                 $analysis->addAnalysis($analyser->fromFile($file->getPathname()));
             }
         }
         // Post processing
         $analysis->process($processors);
         // Validation (Generate notices & warnings)
         $analysis->validate();
         // Pass options to analyzer
         $resourceOptions = $options->getResourceOptions();
         if (!empty($resourceOptions['defaultBasePath'])) {
             $analysis->swagger->basePath = $resourceOptions['defaultBasePath'];
         }
         if (!empty($resourceOptions['defaultHost'])) {
             $analysis->swagger->host = $resourceOptions['defaultHost'];
         }
         if (!empty($resourceOptions['schemes'])) {
             $analysis->swagger->schemes = $resourceOptions['schemes'];
         }
         return $analysis->swagger;
     }));
 }
 public function provideDataForGetScanOptions()
 {
     return ['exclude' => ['exclude', __DIR__], 'analyser' => ['analyser', $this->prophesize('Swagger\\StaticAnalyser')->reveal()], 'analysis' => ['analysis', $this->prophesize('Swagger\\Analysis')->reveal()], 'processors' => ['processors', Analysis::processors()]];
 }
示例#4
0
/**
 * Same as the Swagger\scan however allows for LaravelModels
 *
 * @param string|array|Finder $directory The directory(s) or filename(s)
 * @param array $options
 *   exclude: string|array $exclude The directory(s) or filename(s) to exclude (as absolute or relative paths)
 *   analyser: defaults to StaticAnalyser
 *   analysis: defaults to a new Analysis
 *   processors: defaults to the registered processors in Analysis
 *   models: the laravel models to convert into definitions
 * @return Swagger
 */
function scan($directory, $options = array())
{
    $models = @$options['models'] ?: [];
    $options['processors'] = @$options['processors'] ?: array_merge([new LaravelSwagger($models)], Analysis::processors());
    return \Swagger\scan($directory, $options);
}