1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Aweapi\Openapi\Objects; |
6
|
|
|
|
7
|
|
|
use Aweapi\Openapi\Extensions; |
8
|
|
|
use Aweapi\Openapi\ValueObject; |
9
|
|
|
|
10
|
|
|
abstract class SecurityScheme extends ValueObject implements SecuritySchemeAggregate |
11
|
|
|
{ |
12
|
|
|
use Properties\OptionalDescription; |
13
|
|
|
use Properties\OptionalExtensions; |
14
|
|
|
|
15
|
|
|
public const TYPE_API_KEY = 'apiKey'; |
16
|
|
|
|
17
|
|
|
public const TYPE_HTTP = 'http'; |
18
|
|
|
|
19
|
|
|
public const TYPE_OAUTH2 = 'oauth2'; |
20
|
|
|
|
21
|
|
|
public const TYPE_OPEN_ID_CONNECT = 'openIdConnect'; |
22
|
|
|
|
23
|
|
|
private $type; |
24
|
|
|
|
25
|
10 |
|
public function __construct( |
26
|
|
|
string $type, |
27
|
|
|
string $description = null, |
28
|
|
|
Extensions $extensions = null |
29
|
|
|
) { |
30
|
10 |
|
$this->type = $type; |
31
|
10 |
|
$this->description = $description; |
32
|
10 |
|
$this->extensions = $extensions; |
33
|
|
|
} |
34
|
|
|
|
35
|
9 |
|
public function getType(): string |
36
|
|
|
{ |
37
|
9 |
|
return $this->type; |
38
|
|
|
} |
39
|
|
|
|
40
|
9 |
|
final public function jsonSerialize(): ?array |
41
|
|
|
{ |
42
|
9 |
|
return $this->extendedProperties(parent::jsonSerialize()); |
43
|
|
|
} |
44
|
|
|
|
45
|
9 |
|
protected function normalizeOptionalProperties(): array |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
9 |
|
'description' => $this->getNormalizedDescription(), |
49
|
9 |
|
] + $this->normalizeOptionalSchemeProperties(); |
50
|
|
|
} |
51
|
|
|
|
52
|
7 |
|
protected function normalizeOptionalSchemeProperties(): array |
53
|
|
|
{ |
54
|
7 |
|
return []; |
55
|
|
|
} |
56
|
|
|
|
57
|
9 |
|
protected function normalizeRequiredProperties(): array |
58
|
|
|
{ |
59
|
|
|
return [ |
60
|
9 |
|
'type' => $this->getType(), |
61
|
9 |
|
] + $this->normalizeRequiredSchemeProperties(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
abstract protected function normalizeRequiredSchemeProperties(): array; |
65
|
|
|
} |
66
|
|
|
|