Skip to content

Commit

Permalink
More thorough checks for conditional schema statements.
Browse files Browse the repository at this point in the history
This ensures that we don't try to fuse if/then clauses together.
  • Loading branch information
LTLA committed Oct 1, 2023
1 parent 5b73111 commit fff7b71
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/resolve_allOf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def combine_strings(arr):
return output


conditions = set([ "if", "then", "else", "not" ])


def resolve(obj, wd, all_schemas={}, top_level=False):
if isinstance(obj, list):
for i, v in enumerate(obj):
Expand All @@ -32,7 +35,14 @@ def resolve(obj, wd, all_schemas={}, top_level=False):
other = []
for v in obj["allOf"]:
res = resolve(v, wd, all_schemas)
if list(sorted(res.keys())) == [ "if", "then" ]:

conditions_only = True
for k in res.keys():
if k not in conditions:
conditions_only = False
break

if conditions_only:
other.append(res)
elif "$ref" in v or top_level:
included.append(res)
Expand Down

0 comments on commit fff7b71

Please sign in to comment.