From 65ca8ddc6d897246c1f820edb3b135662e1bda2d Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 18 Jul 2024 17:34:55 -0400 Subject: [PATCH] fix(schema): Deduplicate enum values constructed from anyOfs (#1872) --- tools/schemacode/bidsschematools/schema.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/schemacode/bidsschematools/schema.py b/tools/schemacode/bidsschematools/schema.py index ed6b5da5f3..a00eaddac9 100644 --- a/tools/schemacode/bidsschematools/schema.py +++ b/tools/schemacode/bidsschematools/schema.py @@ -164,7 +164,10 @@ def flatten_enums(namespace, inplace=True): namespace = deepcopy(namespace) for struct in _find(namespace, lambda obj: "anyOf" in obj): try: - all_enum = [val for item in struct["anyOf"] for val in item["enum"]] + # Deduplicate because JSON schema validators may not like duplicates + # Long run, we should get rid of this function and have the rendering + # code handle anyOfs + all_enum = list(dict.fromkeys(val for item in struct["anyOf"] for val in item["enum"])) except KeyError: continue