From cacba56d2cb432acabfc18b1cd712f43b4fcff2c Mon Sep 17 00:00:00 2001 From: Peter Steven Date: Sat, 21 Jan 2023 20:58:31 +1300 Subject: [PATCH] allow strings as well as class names for fields.Nested() --- typemallow2/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/typemallow2/__init__.py b/typemallow2/__init__.py index 24ba0a8..1c50c6b 100644 --- a/typemallow2/__init__.py +++ b/typemallow2/__init__.py @@ -106,7 +106,10 @@ def __get_ts_interface(schema): ts_fields = [] for key, value in schema._declared_fields.items(): if type(value) is fields.Nested: - ts_type = value.nested.__name__.replace('Schema', '') + if type(value.nested) is str: + ts_type = value.nested.replace('Schema', '') + else: + ts_type = value.nested.__name__.replace('Schema', '') if value.many: ts_type += '[]' elif type(value) is EnumField: