src/Lib/SwaggerTools.php
public static function getSwaggerDocument($id, $host)
    {
        // load document from filesystem
        $filePath = CACHE . self::$filePrefix . $id . '.json';
        if (!Configure::read('Swagger.docs.crawl')) {
            if (!file_exists($filePath)) {
                throw new NotFoundException("Swagger json document was not found on filesystem: $filePath");
            }
            $fh = new File($filePath);

            return $fh->read();
        }

        // otherwise crawl-generate a fresh document
        $swaggerOptions = [];
        if (Configure::read("Swagger.library.$id.exclude")) {
            $swaggerOptions = [
                'exclude' => Configure::read("Swagger.library.$id.exclude")
            ];
        }
        if (Configure::read('Swagger.analyser')) {
            $swaggerOptions['analyser'] = Configure::read('Swagger.analyser');
        }
        $swagger = \Swagger\scan(Configure::read("Swagger.library.$id.include"), $swaggerOptions);

        // set object properties required by UI to generate the BASE URL
        $swagger->host = $host;
        if (empty($swagger->basePath)) {
            $swagger->basePath = '/' . Configure::read('App.base');
        }
        $swagger->schemes = Configure::read('Swagger.ui.schemes');

        // write document to filesystem
        self::writeSwaggerDocumentToFile($filePath, $swagger);

        return $swagger;
    }
public static function getSwaggerDocument($id, $host)
    {
        // load document from filesystem
        $filePath = CACHE . self::$filePrefix . $id . '.json';
        if (!Configure::read('Swagger.docs.crawl')) {
            if (!file_exists($filePath)) {
                throw new NotFoundException("Swagger json document was not found on filesystem: $filePath");
            }
            $fh = new File($filePath);

            return $fh->read();
        }

        // otherwise crawl-generate a fresh document
        $swaggerOptions = [];
        if (Configure::read("Swagger.library.$id.exclude")) {
            $swaggerOptions = [
                'exclude' => Configure::read("Swagger.library.$id.exclude")
            ];
        }
        if (Configure::read('Swagger.analyser')) {
            $swaggerOptions['analyser'] = Configure::read('Swagger.analyser');
        }
        $swagger = \Swagger\scan(Configure::read("Swagger.library.$id.include"), $swaggerOptions);

        // set object properties required by UI to generate the BASE URL
        $swagger->host = $host;
        if (empty($swagger->basePath)) {
            $swagger->basePath = '/' . Configure::read('App.base');
        }
        $swagger->schemes = Configure::read('Swagger.ui.schemes');

        // write document to filesystem
        self::writeSwaggerDocumentToFile($filePath, $swagger);

        return $swagger;
    }
public static function getSwaggerDocument ( $ id , $ host ) { // load document from filesystem $ filePath = CACHE . self :: $ filePrefix . $ id . '.json' ; if ( ! Configure :: read ( 'Swagger.docs.crawl' ) ) { if ( ! file_exists ( $ filePath ) ) { throw new NotFoundException ( "Swagger json document was not found on filesystem: $filePath" ) ; } $ fh = new File ( $ filePath ) ; return $ fh -> read ( ) ; } // otherwise crawl-generate a fresh document $ swaggerOptions = [ ] ; if ( Configure :: read ( "Swagger.library.$id.exclude" ) ) { $ swaggerOptions = [ 'exclude' => Configure :: read ( "Swagger.library.$id.exclude" ) ] ; } if ( Configure :: read ( 'Swagger.analyser' ) ) { $ swaggerOptions [ 'analyser' ] = Configure :: read ( 'Swagger.analyser' ) ; } $ swagger = \ Swagger \ scan ( Configure :: read ( "Swagger.library.$id.include" ) , $ swaggerOptions ) ; // set object properties required by UI to generate the BASE URL $ swagger -> host = $ host ; if ( empty ( $ swagger -> basePath ) ) { $ swagger -> basePath = '/' . Configure :: read ( 'App.base' ) ; } $ swagger -> schemes = Configure :: read ( 'Swagger.ui.schemes' ) ; // write document to filesystem self :: writeSwaggerDocumentToFile ( $ filePath , $ swagger ) ; return $ swagger ; }
Returns a single swagger document from filesystem or crawl-generates
a fresh one.

@param string $id Name of the document
@param string $host Hostname of system serving swagger documents (without protocol)
@throws \InvalidArgumentException
@return string
Returns a single swagger document from filesystem or crawl - generates a fresh one .