From a5d2c68d75cdfc89674d3db4100593f12e52d597 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 7 Apr 2022 17:38:34 +0200 Subject: [PATCH] TMSS-860: do keep local definitions --- LCS/PyCommon/json_utils.py | 4 ---- LCS/PyCommon/test/t_json_utils.py | 34 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/LCS/PyCommon/json_utils.py b/LCS/PyCommon/json_utils.py index e3a17edcc9d..4051c3e87e1 100644 --- a/LCS/PyCommon/json_utils.py +++ b/LCS/PyCommon/json_utils.py @@ -397,10 +397,6 @@ def resolved_local_refs(schema): # recursively resolve the schema resolved_schema = _recursive_resolved_local_refs(schema) - # definitions are no longer needed in the resolved schema, as all refs are resolved. - if 'definitions' in resolved_schema: - del resolved_schema['definitions'] - return resolved_schema diff --git a/LCS/PyCommon/test/t_json_utils.py b/LCS/PyCommon/test/t_json_utils.py index 116fca9744b..4dbadeead07 100755 --- a/LCS/PyCommon/test/t_json_utils.py +++ b/LCS/PyCommon/test/t_json_utils.py @@ -137,6 +137,40 @@ class TestJSONUtils(unittest.TestCase): expected_resolved_user_schema = { "type": "object", "default": {}, + 'definitions': {'account': {'properties': {'creation_at': {'description': 'A ' + 'timestamp ' + 'defined ' + 'in ' + 'UTC', + 'format': 'date-time', + 'pattern': '\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d(\\.\\d+)?Z?', + 'type': 'string'}, + 'email_address': { + 'format': 'email', + 'pattern': '@example\\.com$', + 'type': 'string'}}, + 'type': 'object'}, + 'accounts': {'items': { + 'properties': {'creation_at': {'description': 'A ' + 'timestamp ' + 'defined ' + 'in ' + 'UTC', + 'format': 'date-time', + 'pattern': '\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d(\\.\\d+)?Z?', + 'type': 'string'}, + 'email_address': {'format': 'email', + 'pattern': '@example\\.com$', + 'type': 'string'}}, + 'type': 'object'}, + 'type': 'array'}, + 'email': {'format': 'email', + 'pattern': '@example\\.com$', + 'type': 'string'}, + 'timestamp': {'description': 'A timestamp defined in UTC', + 'format': 'date-time', + 'pattern': '\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d(\\.\\d+)?Z?', + 'type': 'string'}}, "properties": { "name": { "type": "string", -- GitLab