Skip to content
Snippets Groups Projects
Commit 66749a65 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

ENH: Raise error when `type` is missing

parent 00ec4ec8
Branches
Tags
2 merge requests!39Release 0.4.0,!33F json schema datamodel
Pipeline #21054 passed
...@@ -650,6 +650,10 @@ class JsonSchemaParser(Parser): ...@@ -650,6 +650,10 @@ class JsonSchemaParser(Parser):
force_list = False force_list = False
if name in self.model: if name in self.model:
return self.model[name], force_list return self.model[name], force_list
if "type" not in elt:
# Each element must have a specific type
raise JsonSchemaDefinitionError(
f"`type` is missing in element {name}.")
if "enum" in elt: if "enum" in elt:
ent = self._treat_enum(elt, name) ent = self._treat_enum(elt, name)
elif elt["type"] in JSON_SCHEMA_ATOMIC_TYPES: elif elt["type"] in JSON_SCHEMA_ATOMIC_TYPES:
......
...@@ -140,7 +140,8 @@ def test_missing_property_type(): ...@@ -140,7 +140,8 @@ def test_missing_property_type():
parse_model_from_json_schema( parse_model_from_json_schema(
os.path.join(FILEPATH, os.path.join(FILEPATH,
"datamodel_missing_property_type.schema.json")) "datamodel_missing_property_type.schema.json"))
assert "FIXME" in str(err.value) assert "`type` is missing" in str(err.value)
def test_enum(): def test_enum():
"""Enums are represented in references to records of a specific type.""" """Enums are represented in references to records of a specific type."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment