-
-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug with analyser & analysis config parameters #414
Comments
You can fork the project and open a PR with these changes. I would really appreciate it because I'm having the exact same problem. |
My workaround was to create a new command which changes the config file on runtime. In my case, I couldn't set up a different analyser. So I kept the // ...
'scanOptions' => [
/**
* analyser: defaults to \OpenApi\StaticAnalyser .
*
* @see \OpenApi\scan
*/
'analyser' => \OpenApi\Analysers\TokenAnalyser::class,
// ...
],
// ... Then I created a new command (fitting my needs) in class GenerateDocs extends Command
{
protected $signature = 'make:docs';
protected $description = 'Generate API docs.';
public function handle() {
$analyser_class = config('l5-swagger.defaults.scanOptions.analyser');
config(['l5-swagger.defaults.scanOptions.analyser' => new $analyser_class]);
$this->call('l5-swagger:generate');
}
} Finally, you can run |
I just figured out another fancier way to solve it. class AppServiceProvider extends ServiceProvider
{
// ...
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// ...
$analyser_class = config('l5-swagger.defaults.scanOptions.analyser');
config(['l5-swagger.defaults.scanOptions.analyser' => new $analyser_class]);
}
// ...
} |
Description:
Hello,
I try to implement a custom analysis but it's impossible due to the way Laravel caches the configuration.
I solved the problem but I do not have the rights to create a new branch to do a pull request.
The problem is also present with the analyzer option.
I describe below how to reproduce the problem and fix it.
Thank you
Steps To Reproduce:
If I try to indicate the custom class to use :
When I use the command
php artisan l5-swagger:generate
, I have a PHP TypeError :Argument 2 passed to OpenApi\Generator::generate() must be an instance of OpenApi\Analysis or null, string given,
And if I try to indicate a new instance of the custom class :
When I use the command
php artisan config:cache
, I have a PHP LogicException :Your configuration files are not serializable.
Correction of the problem:
In class
\L5Swagger\Generator
, in functionprotected function getScanOptions
line 223, I add these lines :The text was updated successfully, but these errors were encountered: