Skip to content

Commit 82538d1

Browse files
committed
Move bindings to the register method
1 parent 40e0b0a commit 82538d1

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/OpenApiServiceProvider.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Vyuldashev\LaravelOpenApi;
66

7+
use Illuminate\Contracts\Foundation\Application;
78
use Illuminate\Support\Collection;
89
use Illuminate\Support\ServiceProvider;
910
use Vyuldashev\LaravelOpenApi\Builders\Components\CallbacksBuilder;
@@ -27,6 +28,16 @@ public function boot(): void
2728
], 'openapi-config');
2829
}
2930

31+
$this->loadRoutesFrom(__DIR__.'/../routes/api.php');
32+
}
33+
34+
public function register(): void
35+
{
36+
$this->mergeConfigFrom(
37+
__DIR__.'/../config/openapi.php',
38+
'openapi'
39+
);
40+
3041
$this->app->bind(CallbacksBuilder::class, function () {
3142
return new CallbacksBuilder($this->getPathsFromConfig('callbacks'));
3243
});
@@ -47,29 +58,19 @@ public function boot(): void
4758
return new SecuritySchemesBuilder($this->getPathsFromConfig('security_schemes'));
4859
});
4960

50-
$this->app->singleton(Generator::class, static function ($app) {
61+
$this->app->singleton(Generator::class, static function (Application $app) {
5162
$config = config('openapi');
5263

5364
return new Generator(
5465
$config,
55-
$app[InfoBuilder::class],
56-
$app[ServersBuilder::class],
57-
$app[TagsBuilder::class],
58-
$app[PathsBuilder::class],
59-
$app[ComponentsBuilder::class]
66+
$app->make(InfoBuilder::class),
67+
$app->make(ServersBuilder::class),
68+
$app->make(TagsBuilder::class),
69+
$app->make(PathsBuilder::class),
70+
$app->make(ComponentsBuilder::class)
6071
);
6172
});
6273

63-
$this->loadRoutesFrom(__DIR__.'/../routes/api.php');
64-
}
65-
66-
public function register(): void
67-
{
68-
$this->mergeConfigFrom(
69-
__DIR__.'/../config/openapi.php',
70-
'openapi'
71-
);
72-
7374
$this->commands([
7475
Console\GenerateCommand::class,
7576
]);

0 commit comments

Comments
 (0)