Skip to content

Commit d27c431

Browse files
hide matching
1 parent 54187e8 commit d27c431

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

config/request-docs.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,10 @@
77
//Example
88
// \App\Http\Middleware\NotFoundWhenProduction::class,
99
],
10-
'docs_path' => base_path('docs/request-docs/')
10+
'docs_path' => base_path('docs/request-docs/'),
11+
'hide_matching' => [
12+
"#^telescope#",
13+
"#^docs#",
14+
"#^request-docs#",
15+
]
1116
];

src/LaravelRequestDocs.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
use ReflectionMethod;
77
use Illuminate\Http\Request;
88
use Illuminate\Foundation\Http\FormRequest;
9+
use Illuminate\Support\Str;
910
class LaravelRequestDocs
1011
{
1112

1213
public function getDocs()
1314
{
1415
$docs = [];
16+
$excludePatterns = config('request-docs.hide_matching') ?? [];
1517
$controllersInfo = $this->getControllersInfo();
1618
$controllersInfo = $this->appendRequestRules($controllersInfo);
1719
foreach ($controllersInfo as $controllerInfo) {
18-
if (!empty($controllerInfo['rules'])) {
20+
$exclude = false;
21+
foreach ($excludePatterns as $regex) {
22+
$uri = $controllerInfo['uri'];
23+
if (preg_match($regex, $uri)) {
24+
$exclude = true;
25+
}
26+
}
27+
if (!$exclude) {
1928
$docs[] = $controllerInfo;
2029
}
2130
}

0 commit comments

Comments
 (0)