diff --git a/oarepo_ui/utils.py b/oarepo_ui/utils.py index 8be6f1a8..6d849a23 100644 --- a/oarepo_ui/utils.py +++ b/oarepo_ui/utils.py @@ -60,7 +60,10 @@ def dump_empty(schema_or_field): return [] if isinstance(schema_or_field, (NestedAttribute, fields.Nested)): field = schema_or_field - return dump_empty(field.nested) + nested_schema = field.nested + if callable(nested_schema): + nested_schema = nested_schema() + return dump_empty(nested_schema) if isinstance(schema_or_field, fields.Str): return "" diff --git a/setup.cfg b/setup.cfg index 49c9c70d..42bf3f64 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-ui -version = 5.0.85 +version = 5.0.86 description = UI module for invenio 3.5+ long_description = file: README.md long_description_content_type = text/markdown diff --git a/tests/test_dump_empty.py b/tests/test_dump_empty.py index a53a99de..99525264 100644 --- a/tests/test_dump_empty.py +++ b/tests/test_dump_empty.py @@ -27,6 +27,7 @@ class SimpleMetadataSchema(ma.Schema): simple_arr = ma.fields.List(ma.fields.String()) object_arr = ma.fields.List(ma.fields.Nested(NestedSchema)) nested_obj = ma.fields.Nested(NestedSchema) + nested_via_func = ma.fields.Nested(lambda: NestedSchema()) class Meta: unknown = ma.INCLUDE @@ -57,6 +58,7 @@ def test_empty_dump(): "links": None, "metadata": { "nested_obj": {"count": None, "title": "", "valid": None}, + "nested_via_func": {"count": None, "title": "", "valid": None}, "object_arr": [], "simple_arr": [], "title": "",