File tree Expand file tree Collapse file tree 2 files changed +33
-19
lines changed
test/unit/module/jsonschema Expand file tree Collapse file tree 2 files changed +33
-19
lines changed Original file line number Diff line number Diff line change @@ -104,13 +104,14 @@ def anyOf(
104104 )
105105 )
106106 all_errors = []
107+ other_errors = []
107108 for index , subschema in enumerate (anyOf ):
108109 errs = []
109- # warning and informational errors need to be returned but shouldn't
110- # be part of if the anyOf is valid
110+ # warning and informational shouldn't count towards if anyOf is
111+ # valid. Save W, I errors and return if errors exist
111112 for err in validator .descend (instance , subschema , schema_path = index ):
112113 if err .rule is not None and not err .rule .id .startswith ("E" ):
113- yield err
114+ other_errors . append ( err )
114115 continue
115116 errs .append (err )
116117 if not errs :
@@ -119,7 +120,7 @@ def anyOf(
119120 else :
120121 yield ValidationError (
121122 f"{ instance !r} is not valid under any of the given schemas" ,
122- context = all_errors ,
123+ context = all_errors + other_errors ,
123124 )
124125
125126
Original file line number Diff line number Diff line change @@ -91,30 +91,43 @@ def validator():
9191 (
9292 "Valid anyOf with a warning validation error" ,
9393 "foo" ,
94- [{"warning" : True }, {"error" : True }],
94+ [{"warning" : True , "error" : True }, {"error" : True }],
9595 [
9696 ValidationError (
97- "Warning" ,
98- rule = Warning (),
97+ "'foo' is not valid under any of the given schemas" ,
9998 path = deque ([]),
100- validator = "warning" ,
101- schema_path = deque ([0 , "warning" ]),
99+ schema_path = deque ([]),
100+ context = [
101+ ValidationError (
102+ "Error" ,
103+ rule = Error (),
104+ path = deque ([]),
105+ validator = "error" ,
106+ schema_path = deque ([0 , "error" ]),
107+ ),
108+ ValidationError (
109+ "Error" ,
110+ rule = Error (),
111+ path = deque ([]),
112+ validator = "error" ,
113+ schema_path = deque ([1 , "error" ]),
114+ ),
115+ ValidationError (
116+ "Warning" ,
117+ rule = Warning (),
118+ path = deque ([]),
119+ validator = "warning" ,
120+ schema_path = deque ([0 , "warning" ]),
121+ ),
122+ ],
102123 ),
103124 ],
104125 ),
105126 (
106- "Valid anyOf with a warning validation error" ,
127+ "Valid anyOf without a warning validation error" ,
107128 "foo" ,
108129 [{"error" : True }, {"warning" : True }],
109- [
110- ValidationError (
111- "Warning" ,
112- rule = Warning (),
113- path = deque ([]),
114- validator = "warning" ,
115- schema_path = deque ([1 , "warning" ]),
116- ),
117- ],
130+ [],
118131 ),
119132 ],
120133)
You can’t perform that action at this time.
0 commit comments