|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @file ATTENTION!!! The code below was carefully crafted by a mean machine. |
|
4
|
|
|
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Swaggest\JsonSchema\SwaggerSchema; |
|
8
|
|
|
|
|
9
|
|
|
use Swaggest\JsonSchema\Constraint\Properties; |
|
10
|
|
|
use Swaggest\JsonSchema\Schema as JsonBasicSchema; |
|
11
|
|
|
use Swaggest\JsonSchema\Structure\ClassStructure; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class HeaderParameterSubSchema extends ClassStructure { |
|
15
|
|
|
/** @var bool Determines whether or not this parameter is required or optional. */ |
|
16
|
|
|
public $required; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string Determines the location of the parameter. */ |
|
19
|
|
|
public $in; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. */ |
|
22
|
|
|
public $description; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string The name of the parameter. */ |
|
25
|
|
|
public $name; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
public $type; |
|
29
|
|
|
|
|
30
|
|
|
/** @var string */ |
|
31
|
|
|
public $format; |
|
32
|
|
|
|
|
33
|
|
|
/** @var PrimitivesItems */ |
|
34
|
|
|
public $items; |
|
35
|
|
|
|
|
36
|
|
|
/** @var string */ |
|
37
|
|
|
public $collectionFormat; |
|
38
|
|
|
|
|
39
|
|
|
public $default; |
|
40
|
|
|
|
|
41
|
|
|
/** @var float */ |
|
42
|
|
|
public $maximum; |
|
43
|
|
|
|
|
44
|
|
|
/** @var bool */ |
|
45
|
|
|
public $exclusiveMaximum; |
|
46
|
|
|
|
|
47
|
|
|
/** @var float */ |
|
48
|
|
|
public $minimum; |
|
49
|
|
|
|
|
50
|
|
|
/** @var bool */ |
|
51
|
|
|
public $exclusiveMinimum; |
|
52
|
|
|
|
|
53
|
|
|
/** @var int */ |
|
54
|
|
|
public $maxLength; |
|
55
|
|
|
|
|
56
|
|
|
/** @var int */ |
|
57
|
|
|
public $minLength; |
|
58
|
|
|
|
|
59
|
|
|
/** @var string */ |
|
60
|
|
|
public $pattern; |
|
61
|
|
|
|
|
62
|
|
|
/** @var int */ |
|
63
|
|
|
public $maxItems; |
|
64
|
|
|
|
|
65
|
|
|
/** @var int */ |
|
66
|
|
|
public $minItems; |
|
67
|
|
|
|
|
68
|
|
|
/** @var bool */ |
|
69
|
|
|
public $uniqueItems; |
|
70
|
|
|
|
|
71
|
|
|
/** @var array */ |
|
72
|
|
|
public $enum; |
|
73
|
|
|
|
|
74
|
|
|
/** @var float */ |
|
75
|
|
|
public $multipleOf; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @param Properties|static $properties |
|
79
|
|
|
* @param JsonBasicSchema $ownerSchema |
|
80
|
|
|
*/ |
|
81
|
|
|
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema) |
|
82
|
|
|
{ |
|
83
|
|
|
$properties->required = JsonBasicSchema::boolean(); |
|
84
|
|
|
$properties->required->description = 'Determines whether or not this parameter is required or optional.'; |
|
85
|
|
|
$properties->required->default = false; |
|
86
|
|
|
$properties->in = JsonBasicSchema::string(); |
|
87
|
|
|
$properties->in->description = 'Determines the location of the parameter.'; |
|
88
|
|
|
$properties->in->enum = array ( |
|
89
|
|
|
0 => 'header', |
|
90
|
|
|
); |
|
91
|
|
|
$properties->description = JsonBasicSchema::string(); |
|
92
|
|
|
$properties->description->description = 'A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed.'; |
|
93
|
|
|
$properties->name = JsonBasicSchema::string(); |
|
94
|
|
|
$properties->name->description = 'The name of the parameter.'; |
|
95
|
|
|
$properties->type = JsonBasicSchema::string(); |
|
96
|
|
|
$properties->type->enum = array ( |
|
97
|
|
|
0 => 'string', |
|
98
|
|
|
1 => 'number', |
|
99
|
|
|
2 => 'boolean', |
|
100
|
|
|
3 => 'integer', |
|
101
|
|
|
4 => 'array', |
|
102
|
|
|
); |
|
103
|
|
|
$properties->format = JsonBasicSchema::string(); |
|
104
|
|
|
$properties->items = PrimitivesItems::schema(); |
|
105
|
|
|
$properties->collectionFormat = JsonBasicSchema::string(); |
|
106
|
|
|
$properties->collectionFormat->default = 'csv'; |
|
107
|
|
|
$properties->collectionFormat->enum = array ( |
|
108
|
|
|
0 => 'csv', |
|
109
|
|
|
1 => 'ssv', |
|
110
|
|
|
2 => 'tsv', |
|
111
|
|
|
3 => 'pipes', |
|
112
|
|
|
); |
|
113
|
|
|
$properties->default = new JsonBasicSchema(); |
|
114
|
|
|
$properties->maximum = JsonBasicSchema::number(); |
|
115
|
|
|
$properties->exclusiveMaximum = JsonBasicSchema::boolean(); |
|
116
|
|
|
$properties->exclusiveMaximum->default = false; |
|
117
|
|
|
$properties->minimum = JsonBasicSchema::number(); |
|
118
|
|
|
$properties->exclusiveMinimum = JsonBasicSchema::boolean(); |
|
119
|
|
|
$properties->exclusiveMinimum->default = false; |
|
120
|
|
|
$properties->maxLength = JsonBasicSchema::integer(); |
|
121
|
|
|
$properties->maxLength->minimum = 0; |
|
|
|
|
|
|
122
|
|
|
$properties->minLength = new JsonBasicSchema(); |
|
123
|
|
|
$properties->minLength->allOf[0] = JsonBasicSchema::integer(); |
|
124
|
|
|
$properties->minLength->allOf[0]->minimum = 0; |
|
125
|
|
|
$properties->minLength->allOf[1] = new JsonBasicSchema(); |
|
126
|
|
|
$properties->minLength->allOf[1]->default = 0; |
|
|
|
|
|
|
127
|
|
|
$properties->pattern = JsonBasicSchema::string(); |
|
128
|
|
|
$properties->pattern->format = 'regex'; |
|
129
|
|
|
$properties->maxItems = JsonBasicSchema::integer(); |
|
130
|
|
|
$properties->maxItems->minimum = 0; |
|
131
|
|
|
$properties->minItems = new JsonBasicSchema(); |
|
132
|
|
|
$properties->minItems->allOf[0] = JsonBasicSchema::integer(); |
|
133
|
|
|
$properties->minItems->allOf[0]->minimum = 0; |
|
134
|
|
|
$properties->minItems->allOf[1] = new JsonBasicSchema(); |
|
135
|
|
|
$properties->minItems->allOf[1]->default = 0; |
|
136
|
|
|
$properties->uniqueItems = JsonBasicSchema::boolean(); |
|
137
|
|
|
$properties->uniqueItems->default = false; |
|
138
|
|
|
$properties->enum = JsonBasicSchema::arr(); |
|
139
|
|
|
$properties->enum->minItems = 1; |
|
140
|
|
|
$properties->enum->uniqueItems = true; |
|
141
|
|
|
$properties->multipleOf = JsonBasicSchema::number(); |
|
142
|
|
|
$properties->multipleOf->minimum = 0; |
|
143
|
|
|
$properties->multipleOf->exclusiveMinimum = true; |
|
144
|
|
|
$ownerSchema = new JsonBasicSchema(); |
|
145
|
|
|
$ownerSchema->additionalProperties = false; |
|
146
|
|
|
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema(); |
|
147
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param bool $required Determines whether or not this parameter is required or optional. |
|
152
|
|
|
* @return $this |
|
153
|
|
|
*/ |
|
154
|
|
|
public function setRequired($required) |
|
155
|
|
|
{ |
|
156
|
|
|
$this->required = $required; |
|
157
|
|
|
return $this; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @param string $in Determines the location of the parameter. |
|
162
|
|
|
* @return $this |
|
163
|
|
|
*/ |
|
164
|
|
|
public function setIn($in) |
|
165
|
|
|
{ |
|
166
|
|
|
$this->in = $in; |
|
167
|
|
|
return $this; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param string $description A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. |
|
172
|
|
|
* @return $this |
|
173
|
|
|
*/ |
|
174
|
|
|
public function setDescription($description) |
|
175
|
|
|
{ |
|
176
|
|
|
$this->description = $description; |
|
177
|
|
|
return $this; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @param string $name The name of the parameter. |
|
182
|
|
|
* @return $this |
|
183
|
|
|
*/ |
|
184
|
|
|
public function setName($name) |
|
185
|
|
|
{ |
|
186
|
|
|
$this->name = $name; |
|
187
|
|
|
return $this; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @param string $type |
|
192
|
|
|
* @return $this |
|
193
|
|
|
*/ |
|
194
|
|
|
public function setType($type) |
|
195
|
|
|
{ |
|
196
|
|
|
$this->type = $type; |
|
197
|
|
|
return $this; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @param string $format |
|
202
|
|
|
* @return $this |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setFormat($format) |
|
205
|
|
|
{ |
|
206
|
|
|
$this->format = $format; |
|
207
|
|
|
return $this; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* @param PrimitivesItems $items |
|
212
|
|
|
* @return $this |
|
213
|
|
|
*/ |
|
214
|
|
|
public function setItems($items) |
|
215
|
|
|
{ |
|
216
|
|
|
$this->items = $items; |
|
217
|
|
|
return $this; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @param string $collectionFormat |
|
222
|
|
|
* @return $this |
|
223
|
|
|
*/ |
|
224
|
|
|
public function setCollectionFormat($collectionFormat) |
|
225
|
|
|
{ |
|
226
|
|
|
$this->collectionFormat = $collectionFormat; |
|
227
|
|
|
return $this; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
/** |
|
231
|
|
|
* @param $default |
|
232
|
|
|
* @return $this |
|
233
|
|
|
*/ |
|
234
|
|
|
public function setDefault($default) |
|
235
|
|
|
{ |
|
236
|
|
|
$this->default = $default; |
|
237
|
|
|
return $this; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
/** |
|
241
|
|
|
* @param float $maximum |
|
242
|
|
|
* @return $this |
|
243
|
|
|
*/ |
|
244
|
|
|
public function setMaximum($maximum) |
|
245
|
|
|
{ |
|
246
|
|
|
$this->maximum = $maximum; |
|
247
|
|
|
return $this; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
/** |
|
251
|
|
|
* @param bool $exclusiveMaximum |
|
252
|
|
|
* @return $this |
|
253
|
|
|
*/ |
|
254
|
|
|
public function setExclusiveMaximum($exclusiveMaximum) |
|
255
|
|
|
{ |
|
256
|
|
|
$this->exclusiveMaximum = $exclusiveMaximum; |
|
257
|
|
|
return $this; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* @param float $minimum |
|
262
|
|
|
* @return $this |
|
263
|
|
|
*/ |
|
264
|
|
|
public function setMinimum($minimum) |
|
265
|
|
|
{ |
|
266
|
|
|
$this->minimum = $minimum; |
|
267
|
|
|
return $this; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
/** |
|
271
|
|
|
* @param bool $exclusiveMinimum |
|
272
|
|
|
* @return $this |
|
273
|
|
|
*/ |
|
274
|
|
|
public function setExclusiveMinimum($exclusiveMinimum) |
|
275
|
|
|
{ |
|
276
|
|
|
$this->exclusiveMinimum = $exclusiveMinimum; |
|
277
|
|
|
return $this; |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* @param int $maxLength |
|
282
|
|
|
* @return $this |
|
283
|
|
|
*/ |
|
284
|
|
|
public function setMaxLength($maxLength) |
|
285
|
|
|
{ |
|
286
|
|
|
$this->maxLength = $maxLength; |
|
287
|
|
|
return $this; |
|
288
|
|
|
} |
|
289
|
|
|
|
|
290
|
|
|
/** |
|
291
|
|
|
* @param int $minLength |
|
292
|
|
|
* @return $this |
|
293
|
|
|
*/ |
|
294
|
|
|
public function setMinLength($minLength) |
|
295
|
|
|
{ |
|
296
|
|
|
$this->minLength = $minLength; |
|
297
|
|
|
return $this; |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
/** |
|
301
|
|
|
* @param string $pattern |
|
302
|
|
|
* @return $this |
|
303
|
|
|
*/ |
|
304
|
|
|
public function setPattern($pattern) |
|
305
|
|
|
{ |
|
306
|
|
|
$this->pattern = $pattern; |
|
307
|
|
|
return $this; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* @param int $maxItems |
|
312
|
|
|
* @return $this |
|
313
|
|
|
*/ |
|
314
|
|
|
public function setMaxItems($maxItems) |
|
315
|
|
|
{ |
|
316
|
|
|
$this->maxItems = $maxItems; |
|
317
|
|
|
return $this; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/** |
|
321
|
|
|
* @param int $minItems |
|
322
|
|
|
* @return $this |
|
323
|
|
|
*/ |
|
324
|
|
|
public function setMinItems($minItems) |
|
325
|
|
|
{ |
|
326
|
|
|
$this->minItems = $minItems; |
|
327
|
|
|
return $this; |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* @param bool $uniqueItems |
|
332
|
|
|
* @return $this |
|
333
|
|
|
*/ |
|
334
|
|
|
public function setUniqueItems($uniqueItems) |
|
335
|
|
|
{ |
|
336
|
|
|
$this->uniqueItems = $uniqueItems; |
|
337
|
|
|
return $this; |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* @param array $enum |
|
342
|
|
|
* @return $this |
|
343
|
|
|
*/ |
|
344
|
|
|
public function setEnum($enum) |
|
345
|
|
|
{ |
|
346
|
|
|
$this->enum = $enum; |
|
347
|
|
|
return $this; |
|
348
|
|
|
} |
|
349
|
|
|
|
|
350
|
|
|
/** |
|
351
|
|
|
* @param float $multipleOf |
|
352
|
|
|
* @return $this |
|
353
|
|
|
*/ |
|
354
|
|
|
public function setMultipleOf($multipleOf) |
|
355
|
|
|
{ |
|
356
|
|
|
$this->multipleOf = $multipleOf; |
|
357
|
|
|
return $this; |
|
358
|
|
|
} |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.