Skip to content

Commit

Permalink
pycodgen: fix loading of long form secondaryfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Sep 3, 2021
1 parent e2479c4 commit 97c5e51
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions schema_salad/metaschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None):
raise ValidationException(
"Expected a string or sequence of (strings or mappings)."
)
elif isinstance(doc, MutableMapping):
new_dict = {}
if "pattern" in doc:
new_dict["pattern"] = doc.pop("pattern")
else:
raise ValidationException(
"Missing pattern in secondaryFiles specification entry: {}".format(
doc
)
)
new_dict["required"] = doc.pop("required") if "required" in doc else None

if len(doc):
raise ValidationException(
"Unallowed values in secondaryFiles specification entry: {}".format(
doc
)
)

elif isinstance(doc, str):
if doc.endswith("?"):
r.append({"pattern": doc[:-1], "required": False})
Expand Down
19 changes: 19 additions & 0 deletions schema_salad/python_codegen_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,25 @@ def load(self, doc, baseuri, loadingOptions, docRoot=None):
raise ValidationException(
"Expected a string or sequence of (strings or mappings)."
)
elif isinstance(doc, MutableMapping):
new_dict = {}
if "pattern" in doc:
new_dict["pattern"] = doc.pop("pattern")
else:
raise ValidationException(
"Missing pattern in secondaryFiles specification entry: {}".format(
doc
)
)
new_dict["required"] = doc.pop("required") if "required" in doc else None

if len(doc):
raise ValidationException(
"Unallowed values in secondaryFiles specification entry: {}".format(
doc
)
)

elif isinstance(doc, str):
if doc.endswith("?"):
r.append({"pattern": doc[:-1], "required": False})
Expand Down

0 comments on commit 97c5e51

Please sign in to comment.