Skip to content

Commit

Permalink
Allow to pass processors configuration to swagger-php
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Aug 28, 2024
1 parent 44bab24 commit 84639e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions config/l5-swagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,24 @@
],

'scanOptions' => [
/**
* Configuration for default processors. Allows to pass processors configuration to swagger-php
*
* @link https://zircote.github.io/swagger-php/reference/processors.html
*/
'default_processors_configuration' => [
/** Example */
/**
'operationId.hash' => true,
'pathFilter' => [
'tags' => [
'/pets/',
'/store/',
],
],
*/
],

/**
* analyser: defaults to \OpenApi\StaticAnalyser .
*
Expand Down
9 changes: 9 additions & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ protected function createOpenApiGenerator(): OpenApiGenerator
{
$generator = new OpenApiGenerator();

// Only from zircote/swagger-php 4
if (
!empty($this->scanOptions['default_processors_configuration'])
&& is_array($this->scanOptions['default_processors_configuration'])
&& method_exists($generator, 'setConfig')
) {
$generator->setConfig($this->scanOptions['default_processors_configuration']);
}

// OpenApi spec version - only from zircote/swagger-php 4
if (method_exists($generator, 'setVersion')) {
$generator->setVersion(
Expand Down
1 change: 1 addition & 0 deletions src/L5SwaggerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function register()
$this->app->bind(Generator::class, function ($app) {
$documentation = config('l5-swagger.default');

/** @var GeneratorFactory $factory */
$factory = $app->make(GeneratorFactory::class);

return $factory->make($documentation);
Expand Down

0 comments on commit 84639e8

Please sign in to comment.