diff --git a/src/Generator.php b/src/Generator.php index ab804aaf..55d3e1de 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -444,7 +444,7 @@ public static function scan(iterable $sources, array $options = []): ?OA\OpenApi ]; $processorPipeline = $config['processor'] ?? - $config['processors'] ? new Pipeline($config['processors']) : null; + ($config['processors'] ? new Pipeline($config['processors']) : null); return (new Generator($config['logger'])) ->setVersion($config['version']) diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php index 09d1b97f..9c70a3b0 100644 --- a/tests/GeneratorTest.php +++ b/tests/GeneratorTest.php @@ -26,7 +26,7 @@ public static function sourcesProvider(): iterable /** * @dataProvider sourcesProvider */ - public function testScan(string $sourceDir, iterable $sources): void + public function testGenerate(string $sourceDir, iterable $sources): void { $openapi = (new Generator()) ->setAnalyser($this->getAnalyzer()) @@ -35,6 +35,20 @@ public function testScan(string $sourceDir, iterable $sources): void $this->assertSpecEquals(file_get_contents(sprintf('%s/%s.yaml', $sourceDir, basename($sourceDir))), $openapi); } + /** + * @dataProvider sourcesProvider + */ + public function testScan(string $sourceDir, iterable $sources): void + { + $analyzer = $this->getAnalyzer(); + $processor = (new Generator()) + ->getProcessorPipeline(); + + $openapi = Generator::scan($sources, ['processor' => $processor, 'analyser' => $analyzer]); + + $this->assertSpecEquals(file_get_contents(sprintf('%s/%s.yaml', $sourceDir, basename($sourceDir))), $openapi); + } + public function testScanInvalidSource(): void { $this->assertOpenApiLogEntryContains('Skipping invalid source: /tmp/__swagger_php_does_not_exist__');