Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Feb 7, 2025
1 parent 5c0261e commit e810260
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
22 changes: 12 additions & 10 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,21 @@ protected function createOpenApiGenerator(): OpenApiGenerator
protected function setProcessors(OpenApiGenerator $generator): void
{
$processorClasses = Arr::get($this->scanOptions, self::SCAN_OPTION_PROCESSORS, []);
$processors = [];

foreach ($generator->getProcessorPipeline() as $processor) {
$processors[] = $processor;
if ($processor instanceof \OpenApi\Processors\BuildPaths) {
foreach ($processorClasses as $customProcessor) {
$processors[] = new $customProcessor();
$newPipeLine = [];

$generator->getProcessorPipeline()->walk(
function (callable $pipe) use ($processorClasses, &$newPipeLine) {
$newPipeLine[] = $pipe;
if ($pipe instanceof \OpenApi\Processors\BuildPaths) {
foreach ($processorClasses as $customProcessor) {
$newPipeLine[] = new $customProcessor();
}
}
}
}
);

if (! empty($processors)) {
$generator->setProcessorPipeline(new Pipeline($processors));
if (! empty($newPipeLine)) {
$generator->setProcessorPipeline(new Pipeline($newPipeLine));
}
}

Expand Down
21 changes: 11 additions & 10 deletions tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,22 @@ public function testCanGenerateWithLegacyExcludedDirectories(): void
}

/**
* @throws L5SwaggerException
* @throws L5SwaggerException 190/226
*/
public function testCanGenerateWithScanOptions(): void
{
$cfg = config('l5-swagger.documentations.default');

$cfg['scanOptions']['exclude'] = [__DIR__.'/storage/annotations/OpenApi/Clients'];
$cfg['scanOptions']['pattern'] = 'L5SwaggerAnnotationsExample*.*';
$cfg['scanOptions']['analyser'] = new ReflectionAnalyser([
new AttributeAnnotationFactory(),
new DocBlockAnnotationFactory(),
]);
$cfg['scanOptions']['open_api_spec_version'] = '3.1.0';
$cfg['scanOptions']['processors'] = [new CleanUnmerged];
$cfg['scanOptions']['default_processors_configuration'] = ['operationId' => ['hash' => false]];
$cfg['scanOptions'] = [
'exclude' => [__DIR__.'/storage/annotations/OpenApi/Clients'],
'analyser' => new ReflectionAnalyser([
new AttributeAnnotationFactory(),
new DocBlockAnnotationFactory(),
]),
'open_api_spec_version' => '3.1.0',
'processors' => [new CleanUnmerged],
'default_processors_configuration' => ['operationId' => ['hash' => false]],
];

config(['l5-swagger' => [
'default' => 'default',
Expand Down

0 comments on commit e810260

Please sign in to comment.