-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPathItem.php
301 lines (270 loc) · 9.36 KB
/
PathItem.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php
namespace Zerotoprod\DataModelOpenapi30;
use Zerotoprod\DataModel\Describe;
use Zerotoprod\DataModelOpenapi30\Helpers\DataModel;
/**
* Describes the operations available on a single path. A Path Item _MAY_
* be empty, due to ACL constraints. The path itself is still exposed
* to the documentation viewer, but they will not know which
* operations and parameters are available.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#path-item-object
*/
class PathItem
{
use DataModel;
/**
* Allows for a referenced definition of this path item. The value
* _MUST_ be in the form of a URL, and the referenced structure _MUST_
* be in the form of a Path Item Object. In case a Path Item
* Object field appears both in the defined object and the
* referenced object, the behavior is undefined. See the
* rules for resolving Relative References.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see https://spec.openapis.org/oas/v3.0.4.html#path-item-object
* @see https://spec.openapis.org/oas/v3.0.4.html#relative-references-in-urls
* @see $ref
*/
public const ref = '$ref';
/**
* Allows for a referenced definition of this path item. The value
* _MUST_ be in the form of a URL, and the referenced structure _MUST_
* be in the form of a Path Item Object. In case a Path Item
* Object field appears both in the defined object and the
* referenced object, the behavior is undefined. See the
* rules for resolving Relative References.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see https://spec.openapis.org/oas/v3.0.4.html#path-item-object
* @see https://spec.openapis.org/oas/v3.0.4.html#relative-references-in-urls
*/
#[Describe(['from' => self::ref])]
public ?string $ref = null;
/**
* An optional string summary, intended to apply to all operations
* in this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $summary
*/
public const summary = 'summary';
/**
* An optional string summary, intended to apply to all operations
* in this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?string $summary;
/**
* An optional string description, intended to apply to all operations
* in this path. [CommonMark] syntax _MAY_ be used for rich text
* representation.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see https://spec.commonmark.org/
* @see $description
*/
public const description = 'description';
/**
* An optional string description, intended to apply to all operations
* in this path. [CommonMark] syntax _MAY_ be used for rich text
* representation.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see https://spec.commonmark.org/
*/
#[Describe(['nullable'])]
public ?string $description;
/**
* A definition of a GET operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $get
*/
public const get = 'get';
/**
* A definition of a GET operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $get;
/**
* A definition of a PUT operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $put
*/
public const put = 'put';
/**
* A definition of a PUT operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $put;
/**
* A definition of a POST operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $post
*/
public const post = 'post';
/**
* A definition of a POST operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $post;
/**
* A definition of a DELETE operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $delete
*/
public const delete = 'delete';
/**
* A definition of a DELETE operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $delete;
/**
* A definition of a OPTIONS operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $options
*/
public const options = 'options';
/**
* A definition of a OPTIONS operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $options;
/**
* A definition of a HEAD operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $head
*/
public const head = 'head';
/**
* A definition of a HEAD operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $head;
/**
* A definition of a PATCH operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $patch
*/
public const patch = 'patch';
/**
* A definition of a PATCH operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $patch;
/**
* A definition of a TRACE operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $trace
*/
public const trace = 'trace';
/**
* A definition of a TRACE operation on this path.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe(['nullable'])]
public ?Operation $trace;
/**
* An alternative `servers` array to service this operation. If a `servers`
* array is specified at the Path Item Object or OpenAPI Object level,
* it will be overridden by this value.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $servers
*/
public const servers = 'servers';
/**
* An alternative `servers` array to service this operation. If a `servers`
* array is specified at the Path Item Object or OpenAPI Object level,
* it will be overridden by this value.
*
* @var Server[]
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe([
'cast' => [self::class, 'mapOf'],
'type' => Server::class,
'default' => [],
])]
public array $servers;
/**
* A list of parameters that are applicable for this operation. If a parameter
* is already defined in the Path Item, the new definition will override it
* but can never remove it. The list _MUST NOT_ include duplicated
* parameters. A unique parameter is defined by a combination of a
* name and location. The list can use the Reference Object to link
* to parameters that are defined in the OpenAPI Object’s
* `components.parameters`.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $parameters
*/
public const parameters = 'parameters';
/**
* A list of parameters that are applicable for this operation. If a parameter
* is already defined in the Path Item, the new definition will override it
* but can never remove it. The list _MUST NOT_ include duplicated
* parameters. A unique parameter is defined by a combination of a
* name and location. The list can use the Reference Object to link
* to parameters that are defined in the OpenAPI Object’s
* `components.parameters`.
*
* @var array<string, Parameter|Reference> $parameters
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
*/
#[Describe([
'cast' => [self::class, 'parameters'],
'default' => []
])]
public array $parameters;
/**
* A list of parameters that are applicable for this operation. If a parameter
* is already defined in the Path Item, the new definition will override it
* but can never remove it. The list _MUST NOT_ include duplicated
* parameters. A unique parameter is defined by a combination of a
* name and location. The list can use the Reference Object to link
* to parameters that are defined in the OpenAPI Object’s
* `components.parameters`.
*
* @link https://spec.openapis.org/oas/v3.0.4.html#fixed-fields-6
* @see $parameters
*/
public static function parameters($value, array $context): array
{
return isset($context[self::parameters])
? array_map(
static fn($value) => isset($value[Reference::ref])
? Reference::from($value)
: Parameter::from($value),
$value
)
: [];
}
}