コード例 #1
0
 /**
  * @return void
  */
 public function fire()
 {
     $output = dirname(__DIR__) . '/docs/api-docs/specs/swagger.json';
     $paths = $this->getScanFolders();
     $exclude = array_map(function ($p) {
         return $p . DIRECTORY_SEPARATOR . 'vendor';
     }, $paths);
     $this->prepareSwagger();
     $swagger = Swagger\scan($paths, ['exclude' => $exclude]);
     $methods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch'];
     $counter = 0;
     // Output report
     foreach ($swagger->paths as $path) {
         foreach ($path as $method => $operation) {
             if ($operation !== null && in_array($method, $methods)) {
                 error_log(str_pad($method, 7, ' ', STR_PAD_LEFT) . ' ' . $path->path);
                 $counter++;
             }
         }
     }
     error_log('----------------------' . str_repeat('-', strlen($counter)));
     error_log($counter . ' operations documented');
     error_log('----------------------' . str_repeat('-', strlen($counter)));
     $swagger->saveAs($output);
     error_log('Written to ' . realpath($output));
 }
コード例 #2
0
ファイル: api.php プロジェクト: bluzphp/skeleton
<?php

/**
 * Generate Swagger configuration
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Controller\Controller;
use Swagger;
/**
 * @accept HTML
 * @accept JSON
 *
 * @return void
 */
return function () {
    /**
     * @var Controller $this
     */
    $this->useJson();
    $paths = array(PATH_APPLICATION . '/configs', PATH_APPLICATION . '/models', PATH_APPLICATION . '/modules');
    $exclude = array();
    // @todo: remove this `die` call
    print Swagger\scan($paths, $exclude);
    die;
};
コード例 #3
0
ファイル: api.php プロジェクト: dezvell/skeleton
<?php

/**
 * Generate Swagger configuration
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Swagger;
return function () {
    /**
     * @var Bootstrap $this
     */
    $this->useJson();
    $paths = array(PATH_APPLICATION . '/configs', PATH_APPLICATION . '/models', PATH_APPLICATION . '/modules');
    $exclude = array();
    return Swagger\scan($paths, $exclude);
};