Skip to content

Commit

Permalink
Fix: Pass CLI config options into Generator
Browse files Browse the repository at this point in the history
Also adds syntax to congigure config array values
  • Loading branch information
DerManoMann committed Jun 30, 2024
1 parent 009c74f commit 55ad911
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,24 @@ protected function normaliseConfig(array $config): array
$value = 'true' == $value;
}

if ($isList = ('[]' == substr($key, -2))) {
$key = substr($key, 0, -2);
}
$token = explode('.', $key);
if (2 == count($token)) {
// 'operationId.hash' => false
$normalised[$token[0]][$token[1]] = $value;
// namespaced / processor
if ($isList) {
$normalised[$token[0]][$token[1]][] = $value;
} else {
$normalised[$token[0]][$token[1]] = $value;
}
} else {
$normalised[$key] = $value;
if ($isList) {
$normalised[$key][] = $value;
} else {
$normalised[$key] = $value;
}
}
}

Expand Down Expand Up @@ -264,6 +276,7 @@ public function getProcessorPipeline(): Pipeline
new Processors\MergeXmlContent(),
new Processors\OperationId(),
new Processors\CleanUnmerged(),
new Processors\PathFilter(),

Check failure on line 279 in src/Generator.php

View workflow job for this annotation

GitHub Actions / static-analysis

Instantiated class OpenApi\Processors\PathFilter not found.
]);
}

Expand Down Expand Up @@ -422,6 +435,7 @@ public static function scan(iterable $sources, array $options = []): ?OA\OpenApi
'analysis' => null,
'processor' => null,
'processors' => null,
'config' => [],
'logger' => null,
'validate' => true,
'version' => null,
Expand All @@ -436,6 +450,7 @@ public static function scan(iterable $sources, array $options = []): ?OA\OpenApi
->setNamespaces($config['namespaces'])
->setAnalyser($config['analyser'])
->setProcessorPipeline($processorPipeline)
->setConfig($config['config'])
->generate($sources, $config['analysis'], $config['validate']);
}

Expand Down

0 comments on commit 55ad911

Please sign in to comment.