From 4fd9a49f0189ca5f9ef485c7170390a50ad28e66 Mon Sep 17 00:00:00 2001 From: Pieter Vlasblom <40738917+stcktrce@users.noreply.github.com> Date: Tue, 31 Jul 2018 07:47:57 +0200 Subject: [PATCH] Properly support OpenAPI (#54) * Update generator.php to properly support OpenAPI * Resolve styleci issue and switch to using version_compare instead * Update the test annotations from OAS to OA --- src/Generator.php | 7 +++- .../annotations/OpenApi/Anotations.php | 42 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index d699f7c..5ad738d 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -20,7 +20,12 @@ public static function generateDocs() File::makeDirectory($docDir); $excludeDirs = config('swagger-lume.paths.excludes'); - $swagger = \Swagger\scan($appDir, ['exclude' => $excludeDirs]); + + if (version_compare(config('swagger-lume.swagger_version'), '3.0', '>=')) { + $swagger = \OpenApi\scan($appDir, ['exclude' => $excludeDirs]); + } else { + $swagger = \Swagger\scan($appDir, ['exclude' => $excludeDirs]); + } if (config('swagger-lume.paths.base') !== null) { $swagger->basePath = config('swagger-lume.paths.base'); diff --git a/tests/storage/annotations/OpenApi/Anotations.php b/tests/storage/annotations/OpenApi/Anotations.php index e43b39e..b938aab 100644 --- a/tests/storage/annotations/OpenApi/Anotations.php +++ b/tests/storage/annotations/OpenApi/Anotations.php @@ -1,14 +1,14 @@