Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Attributes/head.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

namespace RouteDocs\Attributes;

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class head extends httpMethod {}
6 changes: 6 additions & 0 deletions src/Attributes/options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

namespace RouteDocs\Attributes;

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class options extends httpMethod {}
18 changes: 18 additions & 0 deletions src/Support/RouteDocInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use ReflectionClass;
use ReflectionMethod;
Expand Down Expand Up @@ -74,6 +75,23 @@
action: $method->getName()
);

$rules = [
'path' => 'required|string|regex:/^\//',
'method' => 'required|string|in:GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS',
'name' => 'nullable|string|regex:/^[a-zA-Z0-9_.-]+$/',
];
$validator = Validator::make(
[
'path' => $instance->path,
'method' => $instance::method(),
'name' => $instance->name,
],
$rules
);
if ($validator->fails()) {
$error = true;

Check warning on line 92 in src/Support/RouteDocInspector.php

View check run for this annotation

Codecov / codecov/patch

src/Support/RouteDocInspector.php#L92

Added line #L92 was not covered by tests
}

$entry = new RouteDocEntry(
class : $shortClass,
action: $method->getName(),
Expand Down