From f201324cba46c88fb1c9e771be1d1c52fe4a4ac3 Mon Sep 17 00:00:00 2001 From: Renan Butkeraites Date: Wed, 27 Nov 2024 12:20:19 -0300 Subject: [PATCH] Refactor JSON schema type handling in KlaviyoStream to enforce string type for empty objects and simplify type definitions. This change improves schema consistency and clarity. --- tap_klaviyo/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tap_klaviyo/client.py b/tap_klaviyo/client.py index 9dcee0a..b477903 100644 --- a/tap_klaviyo/client.py +++ b/tap_klaviyo/client.py @@ -124,15 +124,17 @@ def get_jsonschema_type(self, obj): return th.ArrayType(self.get_jsonschema_type(obj[0])) else: return th.ArrayType( - th.CustomType({"type": ["number", "string", "object"]}) + th.CustomType({"type": ["string"]}) ) if dtype == dict: obj_props = [] for key in obj.keys(): obj_props.append(th.Property(key, self.get_jsonschema_type(obj[key]))) + if not obj_props: + return th.CustomType({"type": ["string"]}) return th.ObjectType(*obj_props) else: - return th.CustomType({"type": ["number", "string", "object"]}) + return th.CustomType({"type": ["string"]}) def get_schema(self) -> dict: """Dynamically detect the json schema for the stream.