Skip to content

Commit

Permalink
validator: Decend allOf/anyOf/oneOf keywords when extracting properties
Browse files Browse the repository at this point in the history
Properties in a schema like this were not getting parsed:

additionalProperties:
  anyOf:
    - properties:
        foo:
          ...

The property walking code was only handling allOf/anyOf/oneOf as
part of a property sub-schema. Handle allOf/anyOf/oneOf keywords
occurring before a property is encountered.

Signed-off-by: Rob Herring (Arm) <[email protected]>
  • Loading branch information
robherring committed Aug 8, 2024
1 parent f13c181 commit 69c4839
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dtschema/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def _extract_subschema_types(props, schema, subschema):
if 'additionalProperties' in subschema:
_extract_subschema_types(props, schema, subschema['additionalProperties'])

for k in subschema.keys() & {'allOf', 'oneOf', 'anyOf'}:
for v in subschema[k]:
_extract_subschema_types(props, schema, v)

for k in subschema.keys() & {'properties', 'patternProperties'}:
if isinstance(subschema[k], dict):
for p, v in subschema[k].items():
Expand Down

0 comments on commit 69c4839

Please sign in to comment.