Skip to content

Commit

Permalink
Allow "processor" to be passed as scan options
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Johnston committed Aug 27, 2024
1 parent 7ae3dc5 commit 6656657
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
12 changes: 12 additions & 0 deletions tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ 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 testScanConfig(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
{
Expand Down

0 comments on commit 6656657

Please sign in to comment.