diff --git a/docs/reference/processors.md b/docs/reference/processors.md index 7375b25b..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) @@ -62,7 +90,7 @@ Augments shared and operations parameters from docblock comments. #### Config settings
augmentParameters.augmentOperationParameters : bool
-
default : : true
+
default : true

If set to true try to find operation parameter descriptions in the operation docblock.

@@ -82,7 +110,7 @@ Generate the OperationId based on the context of the OpenApi annotation. #### Config settings
operationId.hash : bool
-
default : : true
+
default : true

If set to true generate ids (md5) instead of clear text operation ids.

@@ -102,12 +130,12 @@ All filter (regular) expressions must be enclosed within delimiter characters as #### Config settings
pathFilter.tags : array
-
default : : []
+
default : []

A list of regular expressions to match tags to include.

pathFilter.paths : array
-
default : : []
+
default : []

A list of regular expressions to match paths to include.

@@ -118,7 +146,7 @@ Tracks the use of all Components and removed unused schemas. #### Config settings
cleanUnusedComponents.enabled : bool
-
default : : false
+
default : false

Enables/disables the CleanUnusedComponents processor.

diff --git a/tools/procgen.php b/tools/procgen.php index f6018dda..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'); @@ -26,7 +62,7 @@ echo '
' . PHP_EOL; echo '
' . $configPrefix . $name . '' . $var . '
' . PHP_EOL; - echo '
default : ' . $default . '
' . PHP_EOL; + echo '
default' . $default . '
' . PHP_EOL; echo '
'; echo '

' . nl2br($odetails['phpdoc'] ? $odetails['phpdoc']['content'] : ProcGenerator::NO_DETAILS_AVAILABLE) . '

'; echo '
' . PHP_EOL;