@@ -366,21 +366,26 @@ private function validateObject(array $schema, array $value) : array
366
366
}
367
367
$ validator = new Validator ();
368
368
$ validator ->setFormats ($ this ->formatContainer );
369
- try {
370
- $ value = json_decode (json_encode ($ value ));
371
- $ schema = json_decode (json_encode ($ schema ));
372
- $ result = $ validator ->dataValidation ($ value , $ schema , 99 );
373
- } catch (Exception $ e ) {
374
- return [[
375
- 'name ' => 'server ' ,
376
- 'code ' => 'error_server ' ,
377
- 'message ' => $ e ->getMessage (),
378
- ]];
379
- return [$ e ->getMessage ()];
380
- }
381
- if (!$ result ->isValid ()) {
382
- foreach ($ result ->getErrors () as $ error ) {
383
- $ errors = array_merge ($ errors , $ this ->parseErrors ($ error ));
369
+
370
+ // TODO support for anyOf, oneOf, not, discriminator property
371
+ $ schemas = isset ($ schema ['allOf ' ]) ? $ schema ['allOf ' ] : [$ schema ];
372
+ foreach ($ schemas as $ schema ) {
373
+ try {
374
+ $ value = json_decode (json_encode ($ value ));
375
+ $ schema = json_decode (json_encode ($ schema ));
376
+ $ result = $ validator ->dataValidation ($ value , $ schema , 99 );
377
+ } catch (Exception $ e ) {
378
+ return [[
379
+ 'name ' => 'server ' ,
380
+ 'code ' => 'error_server ' ,
381
+ 'message ' => $ e ->getMessage (),
382
+ ]];
383
+ return [$ e ->getMessage ()];
384
+ }
385
+ if (!$ result ->isValid ()) {
386
+ foreach ($ result ->getErrors () as $ error ) {
387
+ $ errors = array_merge ($ errors , $ this ->parseErrors ($ error ));
388
+ }
384
389
}
385
390
}
386
391
return $ errors ;
0 commit comments