From dad1704237c4b30616e0eef88515466ec0ea17e2 Mon Sep 17 00:00:00 2001 From: Robin Mackaij Date: Fri, 5 Apr 2024 14:29:59 +0200 Subject: [PATCH 1/2] Support nested models in schema --- src/OpenApiLibCore/openapi_libcore.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/OpenApiLibCore/openapi_libcore.py b/src/OpenApiLibCore/openapi_libcore.py index 39f96d1..d941c7f 100644 --- a/src/OpenApiLibCore/openapi_libcore.py +++ b/src/OpenApiLibCore/openapi_libcore.py @@ -1083,8 +1083,17 @@ def get_dependent_id( properties_schema = schema["properties"][property_name] property_type = properties_schema.get("type") - if not property_type: - selected_type_schema = choice(properties_schema["types"]) + if property_type is None: + property_types = properties_schema.get("type") + if property_types is None: + if properties_schema.get("properties") is not None: + nested_data = self.get_json_data_for_dto_class( + schema=properties_schema, + dto_class=DefaultDto, + ) + json_data[property_name] = nested_data + continue + selected_type_schema = choice(property_types) property_type = selected_type_schema["type"] if properties_schema.get("readOnly", False): continue From 6dffd8a8de9cbd9b25f075366f70c8009cd8741f Mon Sep 17 00:00:00 2001 From: Robin Mackaij Date: Fri, 5 Apr 2024 13:44:59 +0000 Subject: [PATCH 2/2] fix plural typo --- src/OpenApiLibCore/openapi_libcore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenApiLibCore/openapi_libcore.py b/src/OpenApiLibCore/openapi_libcore.py index d941c7f..5a1f9f7 100644 --- a/src/OpenApiLibCore/openapi_libcore.py +++ b/src/OpenApiLibCore/openapi_libcore.py @@ -1084,7 +1084,7 @@ def get_dependent_id( property_type = properties_schema.get("type") if property_type is None: - property_types = properties_schema.get("type") + property_types = properties_schema.get("types") if property_types is None: if properties_schema.get("properties") is not None: nested_data = self.get_json_data_for_dto_class(