File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ class GenerateSwaggerDoc extends Command
12
12
* @var string
13
13
*/
14
14
protected $ signature = 'laravel-swagger:generate
15
- {--format=json : The format of the output, current options are json and yaml} ' ;
15
+ {--format=json : The format of the output, current options are json and yaml}
16
+ {--filter= : Filter to a specific route prefix, such as /api or /v2/api} ' ;
16
17
17
18
/**
18
19
* The console command description.
@@ -30,7 +31,7 @@ public function handle()
30
31
{
31
32
$ config = config ('laravel-swagger ' );
32
33
33
- $ docs = (new Generator ($ config ))->generate ();
34
+ $ docs = (new Generator ($ config, $ this -> option ( ' filter ' ) ?: null ))->generate ();
34
35
35
36
$ formattedDocs = (new FormatterManager ($ docs ))
36
37
->setFormat ($ this ->option ('format ' ))
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ class Generator
11
11
{
12
12
protected $ config ;
13
13
14
+ protected $ routeFilter ;
15
+
14
16
protected $ docs ;
15
17
16
18
protected $ uri ;
@@ -21,9 +23,10 @@ class Generator
21
23
22
24
protected $ action ;
23
25
24
- public function __construct ($ config )
26
+ public function __construct ($ config, $ routeFilter = null )
25
27
{
26
28
$ this ->config = $ config ;
29
+ $ this ->routeFilter = $ routeFilter ;
27
30
}
28
31
29
32
public function generate ()
@@ -33,6 +36,11 @@ public function generate()
33
36
foreach ($ this ->getAppRoutes () as $ route ) {
34
37
$ this ->originalUri = $ uri = $ this ->getRouteUri ($ route );
35
38
$ this ->uri = strip_optional_char ($ uri );
39
+
40
+ if ($ this ->routeFilter && !preg_match ('/^ ' . preg_quote ($ this ->routeFilter , '/ ' ) . '/ ' , $ this ->uri )) {
41
+ continue ;
42
+ }
43
+
36
44
$ this ->action = $ route ->getAction ('uses ' );
37
45
$ methods = $ route ->methods ();
38
46
You can’t perform that action at this time.
0 commit comments