File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 2222 */
2323 'sort_by ' => 'default ' ,
2424
25+ //Use only routes where ->uri start with next string Using Str::startWith( . e.g. - /api/mobile
26+ 'only_route_uri_start_with ' => '' ,
27+
2528 'hide_matching ' => [
2629 "#^telescope# " ,
2730 "#^docs# " ,
Original file line number Diff line number Diff line change 22
33namespace Rakutentech \LaravelRequestDocs ;
44
5+ use ErrorException ;
56use Route ;
67use ReflectionMethod ;
78use Illuminate \Http \Request ;
89use Illuminate \Foundation \Http \FormRequest ;
910use Illuminate \Support \Str ;
1011use Exception ;
12+ use Throwable ;
1113
1214class LaravelRequestDocs
1315{
@@ -76,7 +78,13 @@ public function getControllersInfo(): array
7678 {
7779 $ controllersInfo = [];
7880 $ routes = collect (Route::getRoutes ());
81+ $ onlyRouteStartWith = config ('request-docs.only_route_uri_start_with ' ) ?? '' ;
82+
7983 foreach ($ routes as $ route ) {
84+ if ($ onlyRouteStartWith && !Str::startsWith ($ route ->uri , $ onlyRouteStartWith )){
85+ continue ;
86+ }
87+
8088 try {
8189 /// Show Pnly Controller Name
8290 $ controllerFullPath = explode ('@ ' , $ route ->action ['controller ' ])[0 ];
@@ -121,13 +129,13 @@ public function appendRequestRules(array $controllersInfo)
121129 $ requestClass = null ;
122130 try {
123131 $ requestClass = new $ requestClassName ();
124- } catch (\ Throwable $ th ) {
132+ } catch (Throwable $ th ) {
125133 //throw $th;
126134 }
127135 if ($ requestClass instanceof FormRequest) {
128136 try {
129137 $ controllersInfo [$ index ]['rules ' ] = $ this ->flattenRules ($ requestClass ->rules ());
130- } catch (\ ErrorException $ th ) {
138+ } catch (ErrorException $ th ) {
131139 $ controllerInfo [$ index ]['rules ' ] = $ this ->rulesByRegex ($ requestClassName );
132140 }
133141 $ controllersInfo [$ index ]['docBlock ' ] = $ this ->lrdDocComment ($ reflectionMethod ->getDocComment ());
You can’t perform that action at this time.
0 commit comments