@@ -73,6 +73,26 @@ def __init__(self, registry: "KeywordValidatorRegistry"):
7373 def default_validator (self ) -> ValueValidator :
7474 return cast (ValueValidator , self .registry ["default" ])
7575
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+
7696 def __call__ (
7797 self , schema : SchemaPath , require_properties : bool = True
7898 ) -> Iterator [ValidationError ]:
@@ -89,15 +109,9 @@ def __call__(
89109 if "allOf" in schema :
90110 all_of = schema / "allOf"
91111 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+
101115
102116 if "anyOf" in schema :
103117 any_of = schema / "anyOf"
0 commit comments