@@ -38,6 +38,11 @@ class SchemaLoader extends Base
38
38
const MIN_LENGTH = 'minLength ' ;
39
39
const MAX_LENGTH = 'maxLength ' ;
40
40
41
+ const NOT = 'not ' ;
42
+ const ALL_OF = 'allOf ' ;
43
+ const ANY_OF = 'anyOf ' ;
44
+ const ONE_OF = 'oneOf ' ;
45
+
41
46
/** @var Schema */
42
47
private $ rootSchema ;
43
48
@@ -53,7 +58,6 @@ public function readSchema($schemaData)
53
58
}
54
59
55
60
56
-
57
61
protected function readSchemaDeeper ($ schemaArray , Schema $ parentSchema = null )
58
62
{
59
63
$ schema = new Schema ();
@@ -153,7 +157,6 @@ protected function readSchemaDeeper($schemaArray, Schema $parentSchema = null)
153
157
}
154
158
155
159
156
-
157
160
// Number
158
161
if (isset ($ schemaArray [self ::MINIMUM ])) {
159
162
$ schema ->minimum = $ schemaArray [self ::MINIMUM ];
@@ -189,6 +192,26 @@ protected function readSchemaDeeper($schemaArray, Schema $parentSchema = null)
189
192
$ schema ->enum = $ schemaArray [self ::ENUM ];
190
193
}
191
194
195
+ // Logic
196
+ if (isset ($ schemaArray [self ::ALL_OF ])) {
197
+ foreach ($ schemaArray [self ::ALL_OF ] as $ item ) {
198
+ $ schema ->allOf [] = $ this ->readSchemaDeeper ($ item );
199
+ }
200
+ }
201
+ if (isset ($ schemaArray [self ::ANY_OF ])) {
202
+ foreach ($ schemaArray [self ::ANY_OF ] as $ item ) {
203
+ $ schema ->anyOf [] = $ this ->readSchemaDeeper ($ item );
204
+ }
205
+ }
206
+ if (isset ($ schemaArray [self ::ONE_OF ])) {
207
+ foreach ($ schemaArray [self ::ONE_OF ] as $ item ) {
208
+ $ schema ->oneOf [] = $ this ->readSchemaDeeper ($ item );
209
+ }
210
+ }
211
+ if (isset ($ schemaArray [self ::NOT ])) {
212
+ $ schema ->not = $ this ->readSchemaDeeper ($ schemaArray [self ::NOT ]);
213
+ }
214
+
192
215
// should resolve references on load
193
216
if (isset ($ schemaArray [self ::REF ])) {
194
217
$ schema ->ref = $ this ->resolveReference ($ schemaArray [self ::REF ]);
@@ -212,13 +235,9 @@ private function resolveReference($referencePath)
212
235
$ referencePath ,
213
236
SchemaLoader::create ()->readSchema (json_decode (file_get_contents (__DIR__ . '/../spec/json-schema.json ' )))
214
237
);
215
- }
216
-
217
- elseif ($ referencePath === '# ' ) {
238
+ } elseif ($ referencePath === '# ' ) {
218
239
$ ref = new Ref ($ referencePath , $ this ->rootSchema );
219
- }
220
-
221
- elseif ($ referencePath [0 ] === '# ' ) {
240
+ } elseif ($ referencePath [0 ] === '# ' ) {
222
241
$ path = explode ('/ ' , trim ($ referencePath , '#/ ' ));
223
242
$ branch = &$ this ->rootData ;
224
243
while ($ path ) {
@@ -249,4 +268,6 @@ public function writeSchema()
249
268
/**
250
269
* @property $minimum
251
270
*/
252
- class __stubJsonSchema {}
271
+ class __stubJsonSchema
272
+ {
273
+ }
0 commit comments