Skip to content

Commit

Permalink
Fix: Pass CLI config options into Generator (#1612)
Browse files Browse the repository at this point in the history
Also adds syntax to congigure config array values
  • Loading branch information
DerManoMann authored Jun 30, 2024
1 parent 009c74f commit ce3b9be
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 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 @@ -422,6 +434,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 +449,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 ce3b9be

Please sign in to comment.