From 589821f0f1e2c083443749b52a31f077c524dbe6 Mon Sep 17 00:00:00 2001 From: Martin Rademacher Date: Wed, 2 Oct 2024 14:43:50 +1300 Subject: [PATCH] Fix handling of `processor` option in `Generator::scan()` (#1660) --- src/Generator.php | 2 +- tests/GeneratorTest.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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__');