Skip to content

Commit

Permalink
OAS 3.0 uses servers specification instead of basePath (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Gerasimov authored and DarkaOnLine committed Jun 11, 2018
1 parent 89438e7 commit 397bff2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use File;
use Config;
use Swagger\Annotations\Server;

class Generator
{
Expand All @@ -24,7 +25,16 @@ public static function generateDocs()
$swagger = \Swagger\scan($appDir, ['exclude' => $excludeDirs]);

if (config('l5-swagger.paths.base') !== null) {
$swagger->basePath = config('l5-swagger.paths.base');
$isVersion3 = version_compare(config('l5-swagger.swagger_version'), '3.0', '>=');
if ($isVersion3) {
$swagger->servers = [
new Server(['url' => config('l5-swagger.paths.base')]),
];
}

if (! $isVersion3) {
$swagger->basePath = config('l5-swagger.paths.base');
}
}

$filename = $docDir.'/'.config('l5-swagger.paths.docs_json', 'api-docs.json');
Expand Down

0 comments on commit 397bff2

Please sign in to comment.