From 79943653de763137733016ae0693af14720a4c31 Mon Sep 17 00:00:00 2001 From: DerManoMann Date: Tue, 2 Jul 2024 16:12:08 +1200 Subject: [PATCH] Add 'Processor Configuration' section to processor reference --- docs/reference/processors.md | 28 ++++++++++++++++++++++++++ tools/procgen.php | 38 +++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/docs/reference/processors.md b/docs/reference/processors.md index fd2c8d68..73e3fbfd 100644 --- a/docs/reference/processors.md +++ b/docs/reference/processors.md @@ -7,6 +7,34 @@ For improvements head over to [GitHub](https://github.com/zircote/swagger-php) a *Processors are listed in the default order of execution.* +## Processor Configuration +### Command line +The `-c` option allows to specify a name/value pair with the name consisting +of the processor name (starting lowercase) and option name separated by a dot (`.`). + +```shell +> ./bin/openapi -c operatinId.hash=true // ... +> ./bin/openapi -c pathFilter.tags[]=/pets/ -c pathFilter.tags[]=/store/ // ... +``` + +### Programmatically with PHP +Configuration can be set using the `Generator::setConfig()` method. Keys can either be the same +as on the command line or be broken down into nested arrays. + +```php +(new Generator()) + ->setConfig([ + 'operationId.hash' => true, + 'pathFilter' => [ + 'tags' => [ + '/pets/', + '/store/', + ], + ], + ]); +``` + + ## Default Processors ### [DocBlockDescriptions](https://github.com/zircote/swagger-php/tree/master/src/Processors/DocBlockDescriptions.php) diff --git a/tools/procgen.php b/tools/procgen.php index be414d98..cd3992cf 100644 --- a/tools/procgen.php +++ b/tools/procgen.php @@ -9,8 +9,44 @@ ob_start(); echo $procgen->preamble('Processors'); -echo PHP_EOL . '## Default Processors' . PHP_EOL; +echo PHP_EOL . '## Processor Configuration' . PHP_EOL; + +echo '### Command line' . PHP_EOL; +echo <<< EOT +The `-c` option allows to specify a name/value pair with the name consisting +of the processor name (starting lowercase) and option name separated by a dot (`.`). + +```shell +> ./bin/openapi -c operatinId.hash=true // ... +> ./bin/openapi -c pathFilter.tags[]=/pets/ -c pathFilter.tags[]=/store/ // ... +``` + + +EOT; + +echo '### Programmatically with PHP' . PHP_EOL; +echo <<< EOT +Configuration can be set using the `Generator::setConfig()` method. Keys can either be the same +as on the command line or be broken down into nested arrays. + +```php +(new Generator()) + ->setConfig([ + 'operationId.hash' => true, + 'pathFilter' => [ + 'tags' => [ + '/pets/', + '/store/', + ], + ], + ]); +``` + + +EOT; + +echo PHP_EOL . '## Default Processors' . PHP_EOL; foreach ($procgen->getProcessorsDetails() as $ii => $details) { $off = $ii + 1; echo $procgen->formatClassHeader($details['name'], 'Processors');