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\Annotation\OpenApi; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Import classes |
16
|
|
|
*/ |
17
|
|
|
use Sunrise\Http\Router\OpenApi\ComponentObjectInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Import functions |
21
|
|
|
*/ |
22
|
|
|
use function spl_object_hash; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @Annotation |
26
|
|
|
* |
27
|
|
|
* @Target({"ALL"}) |
28
|
|
|
* |
29
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#parameter-object |
30
|
|
|
*/ |
31
|
|
|
final class Parameter extends AbstractAnnotation implements ParameterInterface, ComponentObjectInterface |
32
|
|
|
{ |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritDoc} |
36
|
|
|
*/ |
37
|
|
|
protected const IGNORE_FIELDS = ['refName']; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $refName; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @Required |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
* |
49
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parametername |
50
|
|
|
*/ |
51
|
|
|
public $name; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Required |
55
|
|
|
* |
56
|
|
|
* @Enum({"cookie", "header", "query"}) |
57
|
|
|
* |
58
|
|
|
* @var string |
59
|
|
|
* |
60
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterin |
61
|
|
|
*/ |
62
|
|
|
public $in; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var string |
66
|
|
|
* |
67
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterdescription |
68
|
|
|
*/ |
69
|
|
|
public $description; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @var bool |
73
|
|
|
* |
74
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterrequired |
75
|
|
|
*/ |
76
|
|
|
public $required; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var bool |
80
|
|
|
* |
81
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterdeprecated |
82
|
|
|
*/ |
83
|
|
|
public $deprecated; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var bool |
87
|
|
|
* |
88
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterallowemptyvalue |
89
|
|
|
*/ |
90
|
|
|
public $allowEmptyValue; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @Enum({"matrix", "label", "form", "simple", "spaceDelimited", "pipeDelimited", "deepObject"}) |
94
|
|
|
* |
95
|
|
|
* @var string |
96
|
|
|
* |
97
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterstyle |
98
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#style-values |
99
|
|
|
*/ |
100
|
|
|
public $style; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var bool |
104
|
|
|
* |
105
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterexplode |
106
|
|
|
*/ |
107
|
|
|
public $explode; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @var bool |
111
|
|
|
* |
112
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterallowreserved |
113
|
|
|
*/ |
114
|
|
|
public $allowReserved; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @var \Sunrise\Http\Router\Annotation\OpenApi\SchemaInterface |
118
|
|
|
* |
119
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterschema |
120
|
|
|
*/ |
121
|
|
|
public $schema; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @var mixed |
125
|
|
|
* |
126
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterexample |
127
|
|
|
*/ |
128
|
|
|
public $example; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @var array<\Sunrise\Http\Router\Annotation\OpenApi\ExampleInterface> |
132
|
|
|
* |
133
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parameterexamples |
134
|
|
|
*/ |
135
|
|
|
public $examples; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @var array<\Sunrise\Http\Router\Annotation\OpenApi\MediaTypeInterface> |
139
|
|
|
* |
140
|
|
|
* @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-parametercontent |
141
|
|
|
*/ |
142
|
|
|
public $content; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* {@inheritDoc} |
146
|
|
|
*/ |
147
|
|
|
public function getComponentName() : string |
148
|
|
|
{ |
149
|
|
|
return 'parameters'; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* {@inheritDoc} |
154
|
|
|
*/ |
155
|
|
|
public function getReferenceName() : string |
156
|
|
|
{ |
157
|
|
|
return $this->refName ?? spl_object_hash($this); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|