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; |
8
|
|
|
|
9
|
|
|
use Swaggest\JsonSchema\Constraint\Properties; |
10
|
|
|
use Swaggest\JsonSchema\Structure\ClassStructure; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class JsonSchema extends ClassStructure { |
14
|
|
|
/** @var string */ |
15
|
|
|
public $id; |
16
|
|
|
|
17
|
|
|
/** @var string */ |
18
|
|
|
public $schema; |
19
|
|
|
|
20
|
|
|
/** @var string */ |
21
|
|
|
public $title; |
22
|
|
|
|
23
|
|
|
/** @var string */ |
24
|
|
|
public $description; |
25
|
|
|
|
26
|
|
|
public $default; |
27
|
|
|
|
28
|
|
|
/** @var float */ |
29
|
|
|
public $multipleOf; |
30
|
|
|
|
31
|
|
|
/** @var float */ |
32
|
|
|
public $maximum; |
33
|
|
|
|
34
|
|
|
/** @var bool */ |
35
|
|
|
public $exclusiveMaximum; |
36
|
|
|
|
37
|
|
|
/** @var float */ |
38
|
|
|
public $minimum; |
39
|
|
|
|
40
|
|
|
/** @var bool */ |
41
|
|
|
public $exclusiveMinimum; |
42
|
|
|
|
43
|
|
|
/** @var int */ |
44
|
|
|
public $maxLength; |
45
|
|
|
|
46
|
|
|
/** @var int */ |
47
|
|
|
public $minLength; |
48
|
|
|
|
49
|
|
|
/** @var string */ |
50
|
|
|
public $pattern; |
51
|
|
|
|
52
|
|
|
/** @var bool|JsonSchema */ |
53
|
|
|
public $additionalItems; |
54
|
|
|
|
55
|
|
|
/** @var JsonSchema|JsonSchema[]|array */ |
56
|
|
|
public $items; |
57
|
|
|
|
58
|
|
|
/** @var int */ |
59
|
|
|
public $maxItems; |
60
|
|
|
|
61
|
|
|
/** @var int */ |
62
|
|
|
public $minItems; |
63
|
|
|
|
64
|
|
|
/** @var bool */ |
65
|
|
|
public $uniqueItems; |
66
|
|
|
|
67
|
|
|
/** @var int */ |
68
|
|
|
public $maxProperties; |
69
|
|
|
|
70
|
|
|
/** @var int */ |
71
|
|
|
public $minProperties; |
72
|
|
|
|
73
|
|
|
/** @var string[]|array */ |
74
|
|
|
public $required; |
75
|
|
|
|
76
|
|
|
/** @var bool|JsonSchema */ |
77
|
|
|
public $additionalProperties; |
78
|
|
|
|
79
|
|
|
/** @var JsonSchema[] */ |
80
|
|
|
public $definitions; |
81
|
|
|
|
82
|
|
|
/** @var JsonSchema[] */ |
83
|
|
|
public $properties; |
84
|
|
|
|
85
|
|
|
/** @var JsonSchema[] */ |
86
|
|
|
public $patternProperties; |
87
|
|
|
|
88
|
|
|
/** @var JsonSchema[]|string[][]|array[] */ |
89
|
|
|
public $dependencies; |
90
|
|
|
|
91
|
|
|
/** @var array */ |
92
|
|
|
public $enum; |
93
|
|
|
|
94
|
|
|
/** @var array */ |
95
|
|
|
public $type; |
96
|
|
|
|
97
|
|
|
/** @var string */ |
98
|
|
|
public $format; |
99
|
|
|
|
100
|
|
|
/** @var string */ |
101
|
|
|
public $ref; |
102
|
|
|
|
103
|
|
|
/** @var JsonSchema[]|array */ |
104
|
|
|
public $allOf; |
105
|
|
|
|
106
|
|
|
/** @var JsonSchema[]|array */ |
107
|
|
|
public $anyOf; |
108
|
|
|
|
109
|
|
|
/** @var JsonSchema[]|array */ |
110
|
|
|
public $oneOf; |
111
|
|
|
|
112
|
|
|
/** @var JsonSchema Core schema meta-schema */ |
113
|
|
|
public $not; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param Properties|static $properties |
117
|
|
|
* @param Schema $ownerSchema |
118
|
|
|
*/ |
119
|
|
|
public static function setUpProperties($properties, Schema $ownerSchema) |
120
|
|
|
{ |
121
|
|
|
$properties->id = Schema::string(); |
122
|
|
|
$properties->id->format = 'uri'; |
123
|
|
|
$properties->schema = Schema::string(); |
124
|
|
|
$properties->schema->format = 'uri'; |
125
|
|
|
$ownerSchema->addPropertyMapping('$schema', self::names()->schema); |
|
|
|
|
126
|
|
|
$properties->title = Schema::string(); |
127
|
|
|
$properties->description = Schema::string(); |
128
|
|
|
$properties->default = new Schema(); |
129
|
|
|
$properties->multipleOf = Schema::number(); |
130
|
|
|
$properties->multipleOf->minimum = 0; |
|
|
|
|
131
|
|
|
$properties->multipleOf->exclusiveMinimum = true; |
132
|
|
|
$properties->maximum = Schema::number(); |
133
|
|
|
$properties->exclusiveMaximum = Schema::boolean(); |
134
|
|
|
$properties->exclusiveMaximum->default = false; |
135
|
|
|
$properties->minimum = Schema::number(); |
136
|
|
|
$properties->exclusiveMinimum = Schema::boolean(); |
137
|
|
|
$properties->exclusiveMinimum->default = false; |
138
|
|
|
$properties->maxLength = Schema::integer(); |
139
|
|
|
$properties->maxLength->minimum = 0; |
140
|
|
|
$properties->minLength = new Schema(); |
141
|
|
|
$properties->minLength->allOf[0] = Schema::integer(); |
142
|
|
|
$properties->minLength->allOf[0]->minimum = 0; |
143
|
|
|
$properties->minLength->allOf[1] = new Schema(); |
144
|
|
|
$properties->minLength->allOf[1]->default = 0; |
|
|
|
|
145
|
|
|
$properties->pattern = Schema::string(); |
146
|
|
|
$properties->pattern->format = 'regex'; |
147
|
|
|
$properties->additionalItems = new Schema(); |
148
|
|
|
$properties->additionalItems->anyOf[0] = Schema::boolean(); |
149
|
|
|
$properties->additionalItems->anyOf[1] = Schema::schema(); |
150
|
|
|
$properties->additionalItems->default = (object)array ( |
151
|
|
|
); |
152
|
|
|
$properties->items = new Schema(); |
153
|
|
|
$properties->items->anyOf[0] = Schema::schema(); |
154
|
|
|
$properties->items->anyOf[1] = Schema::arr(); |
155
|
|
|
$properties->items->anyOf[1]->items = Schema::schema(); |
156
|
|
|
$properties->items->anyOf[1]->minItems = 1; |
157
|
|
|
$properties->items->default = (object)array ( |
158
|
|
|
); |
159
|
|
|
$properties->maxItems = Schema::integer(); |
160
|
|
|
$properties->maxItems->minimum = 0; |
161
|
|
|
$properties->minItems = new Schema(); |
162
|
|
|
$properties->minItems->allOf[0] = Schema::integer(); |
163
|
|
|
$properties->minItems->allOf[0]->minimum = 0; |
164
|
|
|
$properties->minItems->allOf[1] = new Schema(); |
165
|
|
|
$properties->minItems->allOf[1]->default = 0; |
166
|
|
|
$properties->uniqueItems = Schema::boolean(); |
167
|
|
|
$properties->uniqueItems->default = false; |
168
|
|
|
$properties->maxProperties = Schema::integer(); |
169
|
|
|
$properties->maxProperties->minimum = 0; |
170
|
|
|
$properties->minProperties = new Schema(); |
171
|
|
|
$properties->minProperties->allOf[0] = Schema::integer(); |
172
|
|
|
$properties->minProperties->allOf[0]->minimum = 0; |
173
|
|
|
$properties->minProperties->allOf[1] = new Schema(); |
174
|
|
|
$properties->minProperties->allOf[1]->default = 0; |
175
|
|
|
$properties->required = Schema::arr(); |
176
|
|
|
$properties->required->items = Schema::string(); |
177
|
|
|
$properties->required->minItems = 1; |
178
|
|
|
$properties->required->uniqueItems = true; |
179
|
|
|
$properties->additionalProperties = new Schema(); |
180
|
|
|
$properties->additionalProperties->anyOf[0] = Schema::boolean(); |
181
|
|
|
$properties->additionalProperties->anyOf[1] = Schema::schema(); |
182
|
|
|
$properties->additionalProperties->default = (object)array ( |
183
|
|
|
); |
184
|
|
|
$properties->definitions = Schema::object(); |
185
|
|
|
$properties->definitions->additionalProperties = Schema::schema(); |
186
|
|
|
$properties->definitions->default = (object)array ( |
187
|
|
|
); |
188
|
|
|
$properties->properties = Schema::object(); |
189
|
|
|
$properties->properties->additionalProperties = Schema::schema(); |
190
|
|
|
$properties->properties->default = (object)array ( |
191
|
|
|
); |
192
|
|
|
$properties->patternProperties = Schema::object(); |
193
|
|
|
$properties->patternProperties->additionalProperties = Schema::schema(); |
194
|
|
|
$properties->patternProperties->default = (object)array ( |
195
|
|
|
); |
196
|
|
|
$properties->dependencies = Schema::object(); |
197
|
|
|
$properties->dependencies->additionalProperties = new Schema(); |
198
|
|
|
$properties->dependencies->additionalProperties->anyOf[0] = Schema::schema(); |
199
|
|
|
$properties->dependencies->additionalProperties->anyOf[1] = Schema::arr(); |
200
|
|
|
$properties->dependencies->additionalProperties->anyOf[1]->items = Schema::string(); |
201
|
|
|
$properties->dependencies->additionalProperties->anyOf[1]->minItems = 1; |
202
|
|
|
$properties->dependencies->additionalProperties->anyOf[1]->uniqueItems = true; |
203
|
|
|
$properties->enum = Schema::arr(); |
204
|
|
|
$properties->enum->minItems = 1; |
205
|
|
|
$properties->enum->uniqueItems = true; |
206
|
|
|
$properties->type = new Schema(); |
207
|
|
|
$properties->type->anyOf[0] = new Schema(); |
208
|
|
|
$properties->type->anyOf[0]->enum = array ( |
209
|
|
|
0 => 'array', |
210
|
|
|
1 => 'boolean', |
211
|
|
|
2 => 'integer', |
212
|
|
|
3 => 'null', |
213
|
|
|
4 => 'number', |
214
|
|
|
5 => 'object', |
215
|
|
|
6 => 'string', |
216
|
|
|
); |
217
|
|
|
$properties->type->anyOf[1] = Schema::arr(); |
218
|
|
|
$properties->type->anyOf[1]->items = new Schema(); |
219
|
|
|
$properties->type->anyOf[1]->items->enum = array ( |
220
|
|
|
0 => 'array', |
221
|
|
|
1 => 'boolean', |
222
|
|
|
2 => 'integer', |
223
|
|
|
3 => 'null', |
224
|
|
|
4 => 'number', |
225
|
|
|
5 => 'object', |
226
|
|
|
6 => 'string', |
227
|
|
|
); |
228
|
|
|
$properties->type->anyOf[1]->minItems = 1; |
229
|
|
|
$properties->type->anyOf[1]->uniqueItems = true; |
230
|
|
|
$properties->format = Schema::string(); |
231
|
|
|
$properties->ref = Schema::string(); |
232
|
|
|
$ownerSchema->addPropertyMapping('$ref', self::names()->ref); |
|
|
|
|
233
|
|
|
$properties->allOf = Schema::arr(); |
234
|
|
|
$properties->allOf->items = Schema::schema(); |
235
|
|
|
$properties->allOf->minItems = 1; |
236
|
|
|
$properties->anyOf = Schema::arr(); |
237
|
|
|
$properties->anyOf->items = Schema::schema(); |
238
|
|
|
$properties->anyOf->minItems = 1; |
239
|
|
|
$properties->oneOf = Schema::arr(); |
240
|
|
|
$properties->oneOf->items = Schema::schema(); |
241
|
|
|
$properties->oneOf->minItems = 1; |
242
|
|
|
$properties->not = Schema::schema(); |
243
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
244
|
|
|
$ownerSchema->id = 'http://json-schema.org/draft-04/schema#'; |
245
|
|
|
$ownerSchema->schema = 'http://json-schema.org/draft-04/schema#'; |
246
|
|
|
$ownerSchema->description = 'Core schema meta-schema'; |
247
|
|
|
$ownerSchema->default = (object)array ( |
248
|
|
|
); |
249
|
|
|
$ownerSchema->dependencies = (object)array ( |
250
|
|
|
'exclusiveMaximum' => |
251
|
|
|
array ( |
252
|
|
|
0 => 'maximum', |
253
|
|
|
), |
254
|
|
|
'exclusiveMinimum' => |
255
|
|
|
array ( |
256
|
|
|
0 => 'minimum', |
257
|
|
|
), |
258
|
|
|
); |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.