From 525dc468800521c0c7efbc337720f73bd9c03a5f Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 10 Feb 2025 11:27:14 +0000 Subject: [PATCH] Adding JSON schema for dictionaries --- .../ts_103120_Dictionaries.schema.json | 65 +++++++++++++++++++ utils/translate_spec.py | 6 +- utils/ts103120_config.json | 4 ++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 103120/dictionaries/ts_103120_Dictionaries.schema.json diff --git a/103120/dictionaries/ts_103120_Dictionaries.schema.json b/103120/dictionaries/ts_103120_Dictionaries.schema.json new file mode 100644 index 00000000..d439cd6c --- /dev/null +++ b/103120/dictionaries/ts_103120_Dictionaries.schema.json @@ -0,0 +1,65 @@ +{ + "$id": "ts_103280_Dictionaries_2019_10", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "Dictionaries": { + "type": "object", + "properties": { + "dictionaries:Dictionary": { + "type": "array", + "items": { + "$ref": "#/$defs/Dictionary" + } + } + }, + "required": [] + }, + "Dictionary": { + "type": "object", + "properties": { + "dictionaries:Owner": { + "type": "string" + }, + "dictionaries:Name": { + "type": "string" + }, + "dictionaries:DictionaryEntries": { + "$ref": "#/$defs/DictionaryEntries" + } + }, + "required": [ + "dictionaries:Owner", + "dictionaries:Name", + "dictionaries:DictionaryEntries" + ] + }, + "DictionaryEntries": { + "type": "object", + "properties": { + "dictionaries:DictionaryEntry": { + "type": "array", + "items": { + "$ref": "#/$defs/DictionaryEntry" + } + } + }, + "required": [] + }, + "DictionaryEntry": { + "type": "object", + "properties": { + "dictionaries:Value": { + "type": "string" + }, + "dictionaries:Meaning": { + "type": "string" + } + }, + "required": [ + "dictionaries:Value", + "dictionaries:Meaning" + ] + } + }, + "$ref": "#/$defs/Dictionaries" +} diff --git a/utils/translate_spec.py b/utils/translate_spec.py index e950b4ae..6c19f43f 100644 --- a/utils/translate_spec.py +++ b/utils/translate_spec.py @@ -89,7 +89,11 @@ if __name__ == "__main__": js['$defs']['HI1Message']['properties'].pop('xmldsig:Signature') js['$defs']['HI1Message']['properties']['Signature'] = json_signature_struct - js_path = output_path / convert_xsd_to_filename(schema_tuple[1]) + + if 'output' in ns_map[schema_tuple[0]]: + js_path = Path(ns_map[schema_tuple[0]]['output']) / convert_xsd_to_filename(schema_tuple[1]) + else: + js_path = output_path / convert_xsd_to_filename(schema_tuple[1]) # TODO - Special case - abstract HI1Object if "Core" in schema_tuple[1]: diff --git a/utils/ts103120_config.json b/utils/ts103120_config.json index 1bc79d12..00043ffc 100644 --- a/utils/ts103120_config.json +++ b/utils/ts103120_config.json @@ -1,5 +1,9 @@ { "schemas" : { + "./103120/dictionaries/ts_103120_Dictionaries.xsd" : { + "prefix" : "dictionaries", + "output" : "./103120/dictionaries/" + }, "./103120/schema/xsd/ts_103120_Authorisation.xsd" : { "prefix" : "auth" }, -- GitLab