Skip to content
Snippets Groups Projects

jsex / yaml parser

Merged Daniel Hornung requested to merge f-more-jsonschema-export into dev
All threads resolved!
1 file
+ 6
3
Compare changes
  • Side-by-side
  • Inline
@@ -74,7 +74,7 @@ class JsonSchemaExporter:
additional `unit` key is added to the schema itself which is purely
annotational and ignored, e.g., in validation. Default is True.
do_not_create : list[str]
A list of RedcordType names, for which there should be no option
A list of reference Property names, for which there should be no option
to create them. Instead, only the choice of existing elements should
be given.
do_not_retrieve : list[str]
@@ -194,9 +194,12 @@ class JsonSchemaExporter:
name=prop.name, datatype=get_list_datatype(prop.datatype, strict=True))
json_prop["items"], inner_ui_schema = self._make_segment_from_prop(list_element_prop)
if prop.name in self._multiple_choice and prop.name in self._do_not_create:
# TODO: if not multiple_choice, but do_not_create:
# "ui:widget" = "radio" & "ui:inline" = true
# TODO: set threshold for number of items.
json_prop["uniqueItems"] = True
ui_schema["ui:widget"] = "checkboxes"
ui_schema["ui:options"] = {"inline": True}
ui_schema["ui:inline"] = True
if inner_ui_schema:
ui_schema["items"] = inner_ui_schema
elif prop.is_reference():
@@ -212,6 +215,7 @@ class JsonSchemaExporter:
is_list_datatype(prop.datatype) and
get_list_datatype(prop.datatype, strict=True) == db.FILE
):
# Singular FILE (wrapped or unwrapped), or wrapped LIST<FILE>
if self._wrap_files_in_objects:
# Workaround for react-jsonschema-form bug
# https://github.com/rjsf-team/react-jsonschema-form/issues/3957:
@@ -244,11 +248,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:
@@ -367,6 +371,8 @@ class JsonSchemaExporter:
schema["required"] = self._make_required_list(rt)
schema["additionalProperties"] = self._additional_properties
if rt.description:
schema["description"] = rt.description
if rt.name:
schema["title"] = rt.name
@@ -509,7 +515,7 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T
additional `unit` key is added to the schema itself which is purely
annotational and ignored, e.g., in validation. Default is True.
do_not_create : list[str], optional
A list of RedcordType names, for which there should be no option
A list of reference Property names, for which there should be no option
to create them. Instead, only the choice of existing elements should
be given.
do_not_retrieve : list[str], optional
Loading