Skip to content
Snippets Groups Projects
Verified Commit e6a13890 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

FIX: jsex: Better do_not_create

parent de43e067
No related branches found
No related tags found
2 merge requests!89ENH: JsonSchemaExporter accepts do_not_create parameter.,!88jsex / yaml parser
Pipeline #44125 passed
......@@ -245,11 +245,11 @@ class JsonSchemaExporter:
prop_name = prop.datatype
if isinstance(prop.datatype, db.Entity):
prop_name = prop.datatype.name
if prop_name in self._do_not_retrieve:
if prop.name in self._do_not_retrieve:
values = []
else:
values = self._retrieve_enum_values(f"RECORD '{prop_name}'")
if prop_name in self._do_not_create:
if prop.name in self._do_not_create:
# Only a simple list of values
json_prop["enum"] = values
else:
......
......@@ -635,6 +635,12 @@ RT1:
RT2:
obligatory_properties:
RT1:
RT3:
obligatory_properties:
RT1_prop:
datatype: RT1
description: property description
"""
model = parse_model_from_string(model_str)
# First test: without reference
......@@ -735,6 +741,20 @@ RT2:
},
"$schema": "https://json-schema.org/draft/2020-12/schema"
}"""
# No effect of do_not_create (real property name should be used)
rt3_dict = rtjs(model.get_deep("RT3"), do_not_create=["RT1"])
rt1_prop = rt3_dict["properties"]["RT1_prop"]
assert rt1_prop["description"] == "property description"
assert "oneOf" in rt1_prop.keys()
assert "enum" not in rt1_prop.keys()
# Now we use the real property name
rt3_dict = rtjs(model.get_deep("RT3"), do_not_create=["RT1_prop"])
rt1_prop = rt3_dict["properties"]["RT1_prop"]
assert rt1_prop["description"] == "property description"
assert "oneOf" not in rt1_prop.keys()
assert "enum" in rt1_prop.keys()
assert rt1_prop["enum"][0] == "103"
def test_schema_modification():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment