Skip to content

Commit

Permalink
feat(plugins): implement a method to register API specs
Browse files Browse the repository at this point in the history
make API Documentation easier to be extended by providing the generic configuration merging mechanics as a provider method.
  • Loading branch information
warlof committed Mar 23, 2020
1 parent b59ec23 commit 40182f0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/Providers/AbstractSeatPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,25 @@ final public function registerPermissions(string $permissions_path, string $scop

$this->mergeConfigFrom($permissions_path, $key);
}

/**
* Register new path to annotations dictionary used by Swagger API Documentation.
*
* @param string $path
*/
final public function registerApiAnnotationsPath(string $path)
{
// ensure current annotation setting is an array of path or transform into it
$current_annotations = config('l5-swagger.paths.annotations', []);

if (! is_array($current_annotations))
$current_annotations = [$current_annotations];

// merge paths together and update config
config([
'l5-swagger.paths.annotations' => array_unique(array_merge($current_annotations, [
$path,
])),
]);
}
}

0 comments on commit 40182f0

Please sign in to comment.