9
9
use Illuminate \Contracts \Validation \ValidationRule ;
10
10
use Illuminate \Foundation \Http \FormRequest ;
11
11
use Illuminate \Routing \Router ;
12
- use Illuminate \Support \Facades \Log ;
13
12
use Illuminate \Support \Facades \Storage ;
14
13
use Illuminate \Support \Facades \Validator ;
15
14
use Illuminate \Support \Str ;
@@ -28,8 +27,7 @@ class ExportPostmanCommand extends Command
28
27
/** @var string */
29
28
protected $ signature = 'export:postman
30
29
{--bearer= : The bearer token to use on your endpoints}
31
- {--basic= : The basic auth to use on your endpoints}
32
- {--continue-on-errors : Continues even if an error occurs in any route, middleware or method (boolean)} ' ;
30
+ {--basic= : The basic auth to use on your endpoints} ' ;
33
31
34
32
/** @var string */
35
33
protected $ description = 'Automatically generate a Postman collection for your API routes ' ;
@@ -64,9 +62,6 @@ class ExportPostmanCommand extends Command
64
62
'basic ' ,
65
63
];
66
64
67
- /** @var bool */
68
- private $ stopOnErrors = true ;
69
-
70
65
/** @var \Illuminate\Validation\Validator */
71
66
private $ validator ;
72
67
@@ -82,14 +77,12 @@ public function handle(): void
82
77
{
83
78
$ this ->setFilename ();
84
79
$ this ->setAuthToken ();
85
- $ this ->setOptions ();
86
80
$ this ->initializeStructure ();
87
81
$ this ->initializePhpDocParser ();
88
82
89
83
foreach ($ this ->router ->getRoutes () as $ route ) {
90
84
$ methods = array_filter ($ route ->methods (), fn ($ value ) => $ value !== 'HEAD ' );
91
-
92
- $ middlewares = $ this ->handleCallable (fn () => $ route ->gatherMiddleware ());
85
+ $ middlewares = $ route ->gatherMiddleware ();
93
86
94
87
foreach ($ methods as $ method ) {
95
88
$ includedMiddleware = false ;
@@ -110,7 +103,7 @@ public function handle(): void
110
103
111
104
$ routeAction = $ route ->getAction ();
112
105
113
- $ reflectionMethod = $ this ->handleCallable ( fn () => $ this -> getReflectionMethod ($ routeAction) );
106
+ $ reflectionMethod = $ this ->getReflectionMethod ($ routeAction );
114
107
115
108
if (! $ reflectionMethod ) {
116
109
continue ;
@@ -230,18 +223,6 @@ public function handle(): void
230
223
$ this ->info ('Postman Collection Exported: ' .storage_path ('app/ ' .$ exportName ));
231
224
}
232
225
233
- protected function handleCallable ($ callable )
234
- {
235
- try {
236
- return $ callable ();
237
- } catch (\Throwable $ th ) {
238
- if ($ this ->stopOnErrors ) {
239
- throw $ th ;
240
- }
241
- Log::error ($ th ->getMessage ()."\n[stacktrace] \n" .$ th ->getTraceAsString ()."\n" );
242
- }
243
- }
244
-
245
226
protected function getReflectionMethod (array $ routeAction ): ?object
246
227
{
247
228
// Hydrates the closure if it is an instance of Opis\Closure\SerializableClosure
@@ -508,13 +489,6 @@ protected function setAuthToken()
508
489
}
509
490
}
510
491
511
- protected function setOptions ()
512
- {
513
- if ($ this ->option ('continue-on-errors ' ) === true ) {
514
- $ this ->stopOnErrors = false ;
515
- }
516
- }
517
-
518
492
protected function isStructured ()
519
493
{
520
494
return $ this ->config ['structured ' ];
0 commit comments