forked from zircote/swagger-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSecurityScheme.php
138 lines (118 loc) · 2.98 KB
/
SecurityScheme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php declare(strict_types=1);
/**
* @license Apache 2.0
*/
namespace OpenApi\Annotations;
use OpenApi\Generator;
/**
* @see [OAI Security Scheme Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#securitySchemeObject).
*
* @Annotation
*/
class SecurityScheme extends AbstractAnnotation
{
/**
* The relative or absolute path to a security scheme.
*
* @see [Using refs](https://swagger.io/docs/specification/using-ref/)
*
* @var string|class-string|object
*/
public $ref = Generator::UNDEFINED;
/**
* The key into OpenApi->security array.
*
* @var string
*/
public $securityScheme = Generator::UNDEFINED;
/**
* The type of the security scheme.
*
* @var string
*/
public $type = Generator::UNDEFINED;
/**
* A short description for security scheme.
*
* @var string
*/
public $description = Generator::UNDEFINED;
/**
* The name of the header or query parameter to be used.
*
* @var string
*/
public $name = Generator::UNDEFINED;
/**
* Required The location of the API key.
*
* @var string
*/
public $in = Generator::UNDEFINED;
/**
* The flow used by the OAuth2 security scheme.
*
* @var Flow[]
*/
public $flows = Generator::UNDEFINED;
/**
* A hint to the client to identify how the bearer token is formatted.
*
* Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes.
*
* @var string
*/
public $bearerFormat = Generator::UNDEFINED;
/**
* The name of the HTTP Authorization scheme.
*
* @see [RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1)
*
* @var string
*/
public $scheme = Generator::UNDEFINED;
/**
* OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of a URL.
*
* @var string
*/
public $openIdConnectUrl = Generator::UNDEFINED;
/**
* @inheritdoc
*/
public static $_required = ['securityScheme', 'type'];
/**
* @inheritdoc
*/
public static $_types = [
'type' => ['http', 'apiKey', 'oauth2', 'openIdConnect'],
'description' => 'string',
'name' => 'string',
'bearerFormat' => 'string',
'in' => ['query', 'header', 'cookie'],
];
/**
* @inheritdoc
*/
public static $_nested = [
Flow::class => ['flows', 'flow'],
Attachable::class => ['attachables'],
];
/**
* @inheritdoc
*/
public static $_parents = [
Components::class,
];
/**
* @inheritdoc
*/
public function merge(array $annotations, bool $ignore = false): array
{
$unmerged = parent::merge($annotations, $ignore);
if ($this->type === 'oauth2') {
$this->name = Generator::UNDEFINED;
}
return $unmerged;
}
}