From 11905765f9d8587ac4910defe62d7a3e44fbae14 Mon Sep 17 00:00:00 2001 From: vasileios Date: Tue, 17 Dec 2024 16:14:34 +0100 Subject: [PATCH] [#4832] Fixed json schema matcher in Objects API This change has been made because we are not able to know if the type is the correct one when no format is defined in the variable. This is left to the user and we assume that the mapping is valid. Backport-of: #4938 --- src/openforms/registrations/contrib/objects_api/json_schema.py | 2 +- .../registrations/contrib/objects_api/tests/test_json_schema.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openforms/registrations/contrib/objects_api/json_schema.py b/src/openforms/registrations/contrib/objects_api/json_schema.py index e41a72dbf8..8e454a37b9 100644 --- a/src/openforms/registrations/contrib/objects_api/json_schema.py +++ b/src/openforms/registrations/contrib/objects_api/json_schema.py @@ -200,7 +200,7 @@ def json_schema_matches( if "string" in target_types and (target_format := target_schema.get("format")): variable_format = variable_schema.get("format") if variable_format is None: - return False + return True return variable_format == target_format return True diff --git a/src/openforms/registrations/contrib/objects_api/tests/test_json_schema.py b/src/openforms/registrations/contrib/objects_api/tests/test_json_schema.py index 473ff62b1d..88994fe300 100644 --- a/src/openforms/registrations/contrib/objects_api/tests/test_json_schema.py +++ b/src/openforms/registrations/contrib/objects_api/tests/test_json_schema.py @@ -434,7 +434,7 @@ def test_json_schema_matches(self): variable_schema = {"type": "string"} target_schema = {"type": "string", "format": "email"} - self.assertFalse( + self.assertTrue( json_schema_matches( variable_schema=variable_schema, target_schema=target_schema )