Skip to content

Commit e4eed3e

Browse files
committed
Add ability for user to set security = ''
1 parent 738f4ca commit e4eed3e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Attributes/Operation.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
namespace Vyuldashev\LaravelOpenApi\Attributes;
43

54
use Attribute;
@@ -31,10 +30,16 @@ public function __construct(string $id = null, array $tags = [], string $securit
3130
$this->tags = $tags;
3231
$this->method = $method;
3332

33+
if ($security === '') {
34+
//user wants to turn off security on this operation
35+
$this->security = $security;
36+
return;
37+
}
38+
3439
if ($security) {
35-
$this->security = class_exists($security) ? $security : app()->getNamespace().'OpenApi\\SecuritySchemes\\'.$security;
40+
$this->security = class_exists($security) ? $security : app()->getNamespace() . 'OpenApi\\SecuritySchemes\\' . $security;
3641

37-
if (! is_a($this->security, SecuritySchemeFactory::class, true)) {
42+
if (!is_a($this->security, SecuritySchemeFactory::class, true)) {
3843
throw new InvalidArgumentException(
3944
sprintf('Security class is either not declared or is not an instance of %s', SecuritySchemeFactory::class)
4045
);

0 commit comments

Comments
 (0)