File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ class GenerateSwaggerDoc extends Command
1313 */
1414 protected $ signature = 'laravel-swagger:generate
1515 {--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+ {--f|filter= : Filter to a specific route prefix, such as /api or /v2/api}
17+ {--o|output= : Output file to write the contents to, defaults to stdout} ' ;
1718
1819 /**
1920 * The console command description.
@@ -30,13 +31,19 @@ class GenerateSwaggerDoc extends Command
3031 public function handle ()
3132 {
3233 $ config = config ('laravel-swagger ' );
34+ $ filter = $ this ->option ('filter ' ) ?: null ;
35+ $ file = $ this ->option ('output ' ) ?: null ;
3336
34- $ docs = (new Generator ($ config , $ this -> option ( ' filter ' ) ?: null ))->generate ();
37+ $ docs = (new Generator ($ config , $ filter ))->generate ();
3538
3639 $ formattedDocs = (new FormatterManager ($ docs ))
3740 ->setFormat ($ this ->option ('format ' ))
3841 ->format ();
3942
40- $ this ->line ($ formattedDocs );
43+ if ($ file ) {
44+ file_put_contents ($ file , $ formattedDocs );
45+ } else {
46+ $ this ->line ($ formattedDocs );
47+ }
4148 }
42- }
49+ }
You can’t perform that action at this time.
0 commit comments