4
4
5
5
namespace Vyuldashev \LaravelOpenApi ;
6
6
7
+ use Illuminate \Contracts \Foundation \Application ;
7
8
use Illuminate \Support \Collection ;
8
9
use Illuminate \Support \ServiceProvider ;
9
10
use Vyuldashev \LaravelOpenApi \Builders \Components \CallbacksBuilder ;
19
20
20
21
class OpenApiServiceProvider extends ServiceProvider
21
22
{
22
- public function boot (): void
23
+ public function register (): void
23
24
{
24
- if ($ this ->app ->runningInConsole ()) {
25
- $ this ->publishes ([
26
- __DIR__ .'/../config/openapi.php ' => config_path ('openapi.php ' ),
27
- ], 'openapi-config ' );
28
- }
25
+ $ this ->mergeConfigFrom (
26
+ __DIR__ .'/../config/openapi.php ' ,
27
+ 'openapi '
28
+ );
29
29
30
30
$ this ->app ->bind (CallbacksBuilder::class, function () {
31
31
return new CallbacksBuilder ($ this ->getPathsFromConfig ('callbacks ' ));
@@ -47,29 +47,19 @@ public function boot(): void
47
47
return new SecuritySchemesBuilder ($ this ->getPathsFromConfig ('security_schemes ' ));
48
48
});
49
49
50
- $ this ->app ->singleton (Generator::class, static function ($ app ) {
50
+ $ this ->app ->singleton (Generator::class, static function (Application $ app ) {
51
51
$ config = config ('openapi ' );
52
52
53
53
return new Generator (
54
54
$ config ,
55
- $ app[ InfoBuilder::class] ,
56
- $ app[ ServersBuilder::class] ,
57
- $ app[ TagsBuilder::class] ,
58
- $ app[ PathsBuilder::class] ,
59
- $ app[ ComponentsBuilder::class]
55
+ $ app-> make ( InfoBuilder::class) ,
56
+ $ app-> make ( ServersBuilder::class) ,
57
+ $ app-> make ( TagsBuilder::class) ,
58
+ $ app-> make ( PathsBuilder::class) ,
59
+ $ app-> make ( ComponentsBuilder::class)
60
60
);
61
61
});
62
62
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
-
73
63
$ this ->commands ([
74
64
Console \GenerateCommand::class,
75
65
]);
@@ -87,6 +77,17 @@ public function register(): void
87
77
}
88
78
}
89
79
80
+ public function boot (): void
81
+ {
82
+ if ($ this ->app ->runningInConsole ()) {
83
+ $ this ->publishes ([
84
+ __DIR__ .'/../config/openapi.php ' => config_path ('openapi.php ' ),
85
+ ], 'openapi-config ' );
86
+ }
87
+
88
+ $ this ->loadRoutesFrom (__DIR__ .'/../routes/api.php ' );
89
+ }
90
+
90
91
private function getPathsFromConfig (string $ type ): array
91
92
{
92
93
$ directories = config ('openapi.locations. ' .$ type , []);
0 commit comments