diff --git a/Config/module.xml b/Config/module.xml index e824f56..f0d1e1e 100644 --- a/Config/module.xml +++ b/Config/module.xml @@ -19,7 +19,7 @@ en_US fr_FR - 2.2.23 + 2.2.24 Vincent Lopes-Vicente diff --git a/Controller/OpenApiController.php b/Controller/OpenApiController.php index 451817f..5b84331 100644 --- a/Controller/OpenApiController.php +++ b/Controller/OpenApiController.php @@ -23,15 +23,27 @@ public function getDocumentation(Request $request) { header('Access-Control-Allow-Origin: *'); - $annotations = Generator::scan(Util::finder([ + $directories = [ THELIA_MODULE_DIR.'/*/Model/Api', THELIA_MODULE_DIR.'/*/Model/OpenApi', THELIA_MODULE_DIR.'/*/EventListener', THELIA_MODULE_DIR.'/*/ApiExtend', THELIA_MODULE_DIR.'/*/Controller', - ])); + ]; + + $validDirectories = []; + + foreach ($directories as $directory) { + $matches = glob($directory); + + if (!empty($matches)) { + $validDirectories[] = $directory; + } + } + + $annotations = Generator::scan(Util::finder($validDirectories)); - $annotations = json_decode($annotations->toJson(), true); + $annotations = json_decode($annotations?->toJson(), true); $modelAnnotations = $annotations['components']['schemas']; foreach ($modelAnnotations as $modelName => $modelAnnotation) {