|
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 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; |
|
|
|
|
|
|
11
|
|
|
use Swaggest\JsonSchema\Structure\ClassStructure; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class Header extends ClassStructure { |
|
15
|
|
|
/** @var string */ |
|
16
|
|
|
public $type; |
|
17
|
|
|
|
|
18
|
|
|
/** @var string */ |
|
19
|
|
|
public $format; |
|
20
|
|
|
|
|
21
|
|
|
/** @var PrimitivesItems */ |
|
22
|
|
|
public $items; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
public $collectionFormat; |
|
26
|
|
|
|
|
27
|
|
|
public $default; |
|
28
|
|
|
|
|
29
|
|
|
/** @var float */ |
|
30
|
|
|
public $maximum; |
|
31
|
|
|
|
|
32
|
|
|
/** @var bool */ |
|
33
|
|
|
public $exclusiveMaximum; |
|
34
|
|
|
|
|
35
|
|
|
/** @var float */ |
|
36
|
|
|
public $minimum; |
|
37
|
|
|
|
|
38
|
|
|
/** @var bool */ |
|
39
|
|
|
public $exclusiveMinimum; |
|
40
|
|
|
|
|
41
|
|
|
/** @var int */ |
|
42
|
|
|
public $maxLength; |
|
43
|
|
|
|
|
44
|
|
|
/** @var int */ |
|
45
|
|
|
public $minLength; |
|
46
|
|
|
|
|
47
|
|
|
/** @var string */ |
|
48
|
|
|
public $pattern; |
|
49
|
|
|
|
|
50
|
|
|
/** @var int */ |
|
51
|
|
|
public $maxItems; |
|
52
|
|
|
|
|
53
|
|
|
/** @var int */ |
|
54
|
|
|
public $minItems; |
|
55
|
|
|
|
|
56
|
|
|
/** @var bool */ |
|
57
|
|
|
public $uniqueItems; |
|
58
|
|
|
|
|
59
|
|
|
/** @var array */ |
|
60
|
|
|
public $enum; |
|
61
|
|
|
|
|
62
|
|
|
/** @var float */ |
|
63
|
|
|
public $multipleOf; |
|
64
|
|
|
|
|
65
|
|
|
/** @var string */ |
|
66
|
|
|
public $description; |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param Properties|static $properties |
|
70
|
|
|
* @param Schema $ownerSchema |
|
71
|
|
|
*/ |
|
72
|
|
|
public static function setUpProperties($properties, Schema $ownerSchema) |
|
73
|
|
|
{ |
|
74
|
|
|
$properties->type = Schema::string(); |
|
75
|
|
|
$properties->type->enum = array ( |
|
76
|
|
|
0 => 'string', |
|
77
|
|
|
1 => 'number', |
|
78
|
|
|
2 => 'integer', |
|
79
|
|
|
3 => 'boolean', |
|
80
|
|
|
4 => 'array', |
|
81
|
|
|
); |
|
82
|
|
|
$properties->format = Schema::string(); |
|
83
|
|
|
$properties->items = PrimitivesItems::schema(); |
|
84
|
|
|
$properties->collectionFormat = Schema::string(); |
|
85
|
|
|
$properties->collectionFormat->default = 'csv'; |
|
|
|
|
|
|
86
|
|
|
$properties->collectionFormat->enum = array ( |
|
87
|
|
|
0 => 'csv', |
|
88
|
|
|
1 => 'ssv', |
|
89
|
|
|
2 => 'tsv', |
|
90
|
|
|
3 => 'pipes', |
|
91
|
|
|
); |
|
92
|
|
|
$properties->default = new Schema(); |
|
93
|
|
|
$properties->maximum = Schema::number(); |
|
94
|
|
|
$properties->exclusiveMaximum = Schema::boolean(); |
|
95
|
|
|
$properties->exclusiveMaximum->default = false; |
|
|
|
|
|
|
96
|
|
|
$properties->minimum = Schema::number(); |
|
97
|
|
|
$properties->exclusiveMinimum = Schema::boolean(); |
|
98
|
|
|
$properties->exclusiveMinimum->default = false; |
|
|
|
|
|
|
99
|
|
|
$properties->maxLength = Schema::integer(); |
|
100
|
|
|
$properties->maxLength->minimum = 0; |
|
101
|
|
|
$properties->minLength = new Schema(); |
|
102
|
|
|
$properties->minLength->allOf[0] = Schema::integer(); |
|
103
|
|
|
$properties->minLength->allOf[0]->minimum = 0; |
|
104
|
|
|
$properties->minLength->allOf[1] = new Schema(); |
|
105
|
|
|
$properties->minLength->allOf[1]->default = 0; |
|
|
|
|
|
|
106
|
|
|
$properties->pattern = Schema::string(); |
|
107
|
|
|
$properties->pattern->format = 'regex'; |
|
108
|
|
|
$properties->maxItems = Schema::integer(); |
|
109
|
|
|
$properties->maxItems->minimum = 0; |
|
110
|
|
|
$properties->minItems = new Schema(); |
|
111
|
|
|
$properties->minItems->allOf[0] = Schema::integer(); |
|
112
|
|
|
$properties->minItems->allOf[0]->minimum = 0; |
|
113
|
|
|
$properties->minItems->allOf[1] = new Schema(); |
|
114
|
|
|
$properties->minItems->allOf[1]->default = 0; |
|
|
|
|
|
|
115
|
|
|
$properties->uniqueItems = Schema::boolean(); |
|
116
|
|
|
$properties->uniqueItems->default = false; |
|
|
|
|
|
|
117
|
|
|
$properties->enum = Schema::arr(); |
|
118
|
|
|
$properties->enum->minItems = 1; |
|
119
|
|
|
$properties->enum->uniqueItems = true; |
|
120
|
|
|
$properties->multipleOf = Schema::number(); |
|
121
|
|
|
$properties->multipleOf->minimum = 0; |
|
122
|
|
|
$properties->multipleOf->exclusiveMinimum = true; |
|
123
|
|
|
$properties->description = Schema::string(); |
|
124
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
|
|
125
|
|
|
$ownerSchema->additionalProperties = false; |
|
126
|
|
|
$ownerSchema->patternProperties['^x-'] = new Schema(); |
|
127
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
|
|
|
|
|
|
128
|
|
|
$ownerSchema->required = array ( |
|
129
|
|
|
0 => 'type', |
|
130
|
|
|
); |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
|
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: