Skip to content

Commit

Permalink
Fix handling of processor option in Generator::scan() (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Oct 2, 2024
1 parent 7642943 commit 589821f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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
16 changes: 15 additions & 1 deletion tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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__');
Expand Down

0 comments on commit 589821f

Please sign in to comment.