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