Skip to content

Commit 09912d3

Browse files
committed
Now requiring annotation file if outside of project
1 parent b3e89a6 commit 09912d3

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Specs/SpecGenerator.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function generateSpec(array $pluginNames, string $format = 'json', string
9494
}
9595

9696
$pluginAnnotationsSource = $this->specPathResolver->getAnnotationFilePath($pluginName);
97+
$this->loadAnnotationSourceIfNeeded($pluginAnnotationsSource);
9798
try {
9899
$openapi = (new Generator(StaticContainer::get(NullLogger::class)))->generate([
99100
$pluginAnnotationsSource,
@@ -108,6 +109,9 @@ public function generateSpec(array $pluginNames, string $format = 'json', string
108109
}
109110

110111
$generator = new Generator(StaticContainer::get(LoggerInterface::class));
112+
foreach ($pluginDirs as $pluginDir) {
113+
$this->loadAnnotationSourceIfNeeded($pluginDir);
114+
}
111115
$openapi = $generator->setVersion(OpenApi::VERSION_3_1_0)->generate(array_merge([
112116
$currentPluginDir . '/Annotations/GlobalApiComponents.php',
113117
], $pluginDirs));
@@ -137,4 +141,13 @@ public function generateSpec(array $pluginNames, string $format = 'json', string
137141

138142
return $specContents;
139143
}
144+
145+
private function loadAnnotationSourceIfNeeded(string $annotationSource): void
146+
{
147+
if (!is_file($annotationSource) || pathinfo($annotationSource, PATHINFO_EXTENSION) !== 'php') {
148+
return;
149+
}
150+
151+
require_once $annotationSource;
152+
}
140153
}

0 commit comments

Comments
 (0)