From fff7b71e308a0be2d09dd2e12c8e1cb63692b000 Mon Sep 17 00:00:00 2001 From: LTLA Date: Sat, 30 Sep 2023 18:22:34 -0700 Subject: [PATCH] More thorough checks for conditional schema statements. This ensures that we don't try to fuse if/then clauses together. --- scripts/resolve_allOf.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/resolve_allOf.py b/scripts/resolve_allOf.py index 4b54749..fcd5a05 100644 --- a/scripts/resolve_allOf.py +++ b/scripts/resolve_allOf.py @@ -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): @@ -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)