@@ -73,6 +73,26 @@ def __init__(self, registry: "KeywordValidatorRegistry"):
73
73
def default_validator (self ) -> ValueValidator :
74
74
return cast (ValueValidator , self .registry ["default" ])
75
75
76
+ def _collect_properties (self , schema : SchemaPath ) -> set [str ]:
77
+ """Return *all* property names reachable from this schema."""
78
+ props : set [str ] = set ()
79
+
80
+ if "properties" in schema :
81
+ props .update ((schema / "properties" ).keys ())
82
+
83
+ for kw in ("allOf" , "anyOf" , "oneOf" ):
84
+ if kw in schema :
85
+ for sub in schema / kw :
86
+ props .update (self ._collect_properties (sub ))
87
+
88
+ if "items" in schema :
89
+ props .update (self ._collect_properties (schema / "items" ))
90
+
91
+ if "not" in schema :
92
+ props .update (self ._collect_properties (schema / "not" ))
93
+
94
+ return props
95
+
76
96
def __call__ (
77
97
self , schema : SchemaPath , require_properties : bool = True
78
98
) -> Iterator [ValidationError ]:
@@ -89,15 +109,9 @@ def __call__(
89
109
if "allOf" in schema :
90
110
all_of = schema / "allOf"
91
111
for inner_schema in all_of :
92
- yield from self (
93
- inner_schema ,
94
- require_properties = False ,
95
- )
96
- if "properties" not in inner_schema :
97
- continue
98
- inner_schema_props = inner_schema / "properties"
99
- inner_schema_props_keys = inner_schema_props .keys ()
100
- nested_properties += list (inner_schema_props_keys )
112
+ yield from self (inner_schema , require_properties = False )
113
+ nested_properties += list (self ._collect_properties (inner_schema ))
114
+
101
115
102
116
if "anyOf" in schema :
103
117
any_of = schema / "anyOf"
0 commit comments