Skip to content

Commit

Permalink
fix(schema): Deduplicate enum values constructed from anyOfs (bids-st…
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies authored Jul 18, 2024
1 parent c0917c3 commit 65ca8dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/schemacode/bidsschematools/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 65ca8dd

Please sign in to comment.