1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* It's free open-source software released under the MIT License. |
5
|
|
|
* |
6
|
|
|
* @author Anatoly Fenric <[email protected]> |
7
|
|
|
* @copyright Copyright (c) 2018, Anatoly Fenric |
8
|
|
|
* @license https://github.com/sunrise-php/http-router/blob/master/LICENSE |
9
|
|
|
* @link https://github.com/sunrise-php/http-router |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sunrise\Http\Router\OpenApi; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* OAS Security Scheme Object |
16
|
|
|
* |
17
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#security-scheme-object |
18
|
|
|
*/ |
19
|
|
|
class SecurityScheme extends AbstractObject implements ComponentObjectInterface |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
private $refName; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
* |
30
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemetype |
31
|
|
|
*/ |
32
|
|
|
protected $type; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
* |
37
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemedescription |
38
|
|
|
*/ |
39
|
|
|
protected $description; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
* |
44
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemename |
45
|
|
|
*/ |
46
|
|
|
protected $name; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
* |
51
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemein |
52
|
|
|
*/ |
53
|
|
|
protected $in; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
* |
58
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemescheme |
59
|
|
|
*/ |
60
|
|
|
protected $scheme; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
* |
65
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemebearerformat |
66
|
|
|
*/ |
67
|
|
|
protected $bearerFormat; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var OAuthFlows |
71
|
|
|
* |
72
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemeflows |
73
|
|
|
*/ |
74
|
|
|
protected $flows; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @var string |
78
|
|
|
* |
79
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-securityschemeopenidconnecturl |
80
|
|
|
*/ |
81
|
|
|
protected $openIdConnectUrl; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $refName |
85
|
|
|
* @param string $type |
86
|
|
|
*/ |
87
|
|
|
public function __construct(string $refName, string $type) |
88
|
|
|
{ |
89
|
|
|
$this->refName = $refName; |
90
|
|
|
$this->type = $type; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritDoc} |
95
|
|
|
*/ |
96
|
|
|
public function getComponentName() : string |
97
|
|
|
{ |
98
|
|
|
return 'securitySchemes'; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* {@inheritDoc} |
103
|
|
|
*/ |
104
|
|
|
public function getReferenceName() : string |
105
|
|
|
{ |
106
|
|
|
return $this->refName; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param string $description |
111
|
|
|
* |
112
|
|
|
* @return void |
113
|
|
|
*/ |
114
|
|
|
public function setDescription(string $description) : void |
115
|
|
|
{ |
116
|
|
|
$this->description = $description; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param string $name |
121
|
|
|
* |
122
|
|
|
* @return void |
123
|
|
|
*/ |
124
|
|
|
public function setName(string $name) : void |
125
|
|
|
{ |
126
|
|
|
$this->name = $name; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param string $in |
131
|
|
|
* |
132
|
|
|
* @return void |
133
|
|
|
*/ |
134
|
|
|
public function setIn(string $in) : void |
135
|
|
|
{ |
136
|
|
|
$this->in = $in; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param string $scheme |
141
|
|
|
* |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public function setScheme(string $scheme) : void |
145
|
|
|
{ |
146
|
|
|
$this->scheme = $scheme; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param string $bearerFormat |
151
|
|
|
* |
152
|
|
|
* @return void |
153
|
|
|
*/ |
154
|
|
|
public function setBearerFormat(string $bearerFormat) : void |
155
|
|
|
{ |
156
|
|
|
$this->bearerFormat = $bearerFormat; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param OAuthFlows $flows |
161
|
|
|
* |
162
|
|
|
* @return void |
163
|
|
|
*/ |
164
|
|
|
public function setFlows(OAuthFlows $flows) : void |
165
|
|
|
{ |
166
|
|
|
$this->flows = $flows; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @param string $openIdConnectUrl |
171
|
|
|
* |
172
|
|
|
* @return void |
173
|
|
|
*/ |
174
|
|
|
public function setOpenIdConnectUrl(string $openIdConnectUrl) : void |
175
|
|
|
{ |
176
|
|
|
$this->openIdConnectUrl = $openIdConnectUrl; |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|