Beispiel #1
0
    /**
     * Main retrieve point for a list of swagger-able services
     * This builds the full swagger cache if it does not exist
     *
     * @return string The JSON contents of the swagger api listing.
     * @throws InternalServerErrorException
     */
    public function getSwagger()
    {
        if (null === ($content = \Cache::get(static::SWAGGER_CACHE_FILE))) {
            \Log::info('Building Swagger cache');
            //  Build services from database
            //  Pull any custom swagger docs
            $result = Service::all(['name', 'description']);
            //  Gather the services
            $services = [];
            //	Spin through services and pull the configs
            foreach ($result as $service) {
                // build main services list
                $services[] = ['path' => '/' . $service->name, 'description' => $service->description];
                unset($service);
            }
            // cache main api listing file
            $description = <<<HTML
HTML;
            $resourceListing = ['swaggerVersion' => static::SWAGGER_VERSION, 'apiVersion' => \Config::get('df.api_version', static::API_VERSION), 'authorizations' => ['apiKey' => ['type' => 'apiKey', 'passAs' => 'header']], 'info' => ['title' => 'DreamFactory Live API Documentation', 'description' => $description, 'contact' => '*****@*****.**', 'license' => 'Apache 2.0', 'licenseUrl' => 'http://www.apache.org/licenses/LICENSE-2.0.html'], 'events' => []];
            $content = array_merge($resourceListing, ['apis' => $services]);
            $content = json_encode($content, JSON_UNESCAPED_SLASHES);
            \Cache::forever(static::SWAGGER_CACHE_FILE, $content);
            \Log::info('Swagger cache build process complete');
        }
        return $content;
    }
 public function index()
 {
     $uri = static::getURI($_SERVER);
     $dist = env('DF_INSTALL', '');
     if (empty($dist) && false !== stripos(env('DB_DATABASE', ''), 'bitnami')) {
         $dist = 'Bitnami';
     }
     $appCount = App::all()->count();
     $adminCount = User::whereIsSysAdmin(1)->count();
     $userCount = User::whereIsSysAdmin(0)->count();
     $serviceCount = Service::all()->count();
     $roleCount = Role::all()->count();
     $status = ["uri" => $uri, "managed" => env('DF_MANAGED', false), "dist" => $dist, "demo" => Environment::isDemoApplication(), "version" => \Config::get('df.version'), "host_os" => PHP_OS, "resources" => ["app" => $appCount, "admin" => $adminCount, "user" => $userCount, "service" => $serviceCount, "role" => $roleCount]];
     return ResponseFactory::sendResponse(ResponseFactory::create($status));
 }