From 57f748cfbce821680b1fbda8640105b8c27612d2 Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 31 May 2024 09:20:11 +0100 Subject: [PATCH 1/8] Adding $schema keyword, newline and fixing enum --- .../json/ts_103120_Authorisation.schema.json | 7 +++++-- 103120/schema/json/ts_103120_Common.schema.json | 3 ++- 103120/schema/json/ts_103120_Core.schema.json | 3 ++- 103120/schema/json/ts_103120_Delivery.schema.json | 7 +++++-- 103120/schema/json/ts_103120_Document.schema.json | 7 +++++-- .../json/ts_103120_Notification.schema.json | 7 +++++-- 103120/schema/json/ts_103120_Task.schema.json | 15 +++++++++++---- .../json/ts_103120_TrafficPolicy.schema.json | 11 ++++++++--- utils/translate/SequenceMapping.py | 2 +- utils/translate/__init__.py | 1 + utils/translate_spec.py | 2 +- 11 files changed, 46 insertions(+), 19 deletions(-) diff --git a/103120/schema/json/ts_103120_Authorisation.schema.json b/103120/schema/json/ts_103120_Authorisation.schema.json index 1c9a68f..942438f 100644 --- a/103120/schema/json/ts_103120_Authorisation.schema.json +++ b/103120/schema/json/ts_103120_Authorisation.schema.json @@ -1,12 +1,15 @@ { "$id": "ts_103120_Authorisation_2020_09", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "AuthorisationObject": { "type": "object", "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2020/09/Authorisation}AuthorisationObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2020/09/Authorisation}AuthorisationObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -145,4 +148,4 @@ ] } } -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_Common.schema.json b/103120/schema/json/ts_103120_Common.schema.json index d11b4b4..c13f91b 100644 --- a/103120/schema/json/ts_103120_Common.schema.json +++ b/103120/schema/json/ts_103120_Common.schema.json @@ -1,5 +1,6 @@ { "$id": "ts_103120_Common_2016_02", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "ETSIVersion": { "allOf": [ @@ -161,4 +162,4 @@ ] } } -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_Core.schema.json b/103120/schema/json/ts_103120_Core.schema.json index 63e2ad4..71e583d 100644 --- a/103120/schema/json/ts_103120_Core.schema.json +++ b/103120/schema/json/ts_103120_Core.schema.json @@ -1,5 +1,6 @@ { "$id": "ts_103120_Core_2019_10", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "ObjectIdentifier": { "$ref": "ts_103280_2017_07#/$defs/UUID" @@ -603,4 +604,4 @@ } }, "$ref": "#/$defs/HI1Message" -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_Delivery.schema.json b/103120/schema/json/ts_103120_Delivery.schema.json index f87f7f5..8362950 100644 --- a/103120/schema/json/ts_103120_Delivery.schema.json +++ b/103120/schema/json/ts_103120_Delivery.schema.json @@ -1,12 +1,15 @@ { "$id": "ts_103120_Delivery_2019_10", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "DeliveryObject": { "type": "object", "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2019/10/Delivery}DeliveryObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2019/10/Delivery}DeliveryObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -229,4 +232,4 @@ "EmbeddedXMLData": {}, "EmbeddedJSONData": {} } -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_Document.schema.json b/103120/schema/json/ts_103120_Document.schema.json index d844092..3bc734c 100644 --- a/103120/schema/json/ts_103120_Document.schema.json +++ b/103120/schema/json/ts_103120_Document.schema.json @@ -1,12 +1,15 @@ { "$id": "ts_103120_Document_2020_09", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "DocumentObject": { "type": "object", "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2020/09/Document}DocumentObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2020/09/Document}DocumentObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -145,4 +148,4 @@ ] } } -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_Notification.schema.json b/103120/schema/json/ts_103120_Notification.schema.json index 84fbf04..aadb989 100644 --- a/103120/schema/json/ts_103120_Notification.schema.json +++ b/103120/schema/json/ts_103120_Notification.schema.json @@ -1,12 +1,15 @@ { "$id": "ts_103120_Notification_2016_02", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "NotificationObject": { "type": "object", "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2016/02/Notification}NotificationObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2016/02/Notification}NotificationObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -100,4 +103,4 @@ ] } } -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_Task.schema.json b/103120/schema/json/ts_103120_Task.schema.json index 5bb92ac..7df2c44 100644 --- a/103120/schema/json/ts_103120_Task.schema.json +++ b/103120/schema/json/ts_103120_Task.schema.json @@ -1,12 +1,15 @@ { "$id": "ts_103120_Task_2020_09", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "LITaskObject": { "type": "object", "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2020/09/Task}LITaskObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2020/09/Task}LITaskObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -372,7 +375,9 @@ "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2020/09/Task}LDTaskObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2020/09/Task}LDTaskObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -604,7 +609,9 @@ "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2020/09/Task}LPTaskObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2020/09/Task}LPTaskObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -720,4 +727,4 @@ "required": [] } } -} \ No newline at end of file +} diff --git a/103120/schema/json/ts_103120_TrafficPolicy.schema.json b/103120/schema/json/ts_103120_TrafficPolicy.schema.json index 18bb9cf..ef30cca 100644 --- a/103120/schema/json/ts_103120_TrafficPolicy.schema.json +++ b/103120/schema/json/ts_103120_TrafficPolicy.schema.json @@ -1,12 +1,15 @@ { "$id": "ts_103120_TrafficPolicy_2022_07", + "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "TrafficPolicyObject": { "type": "object", "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2022/07/TrafficPolicy}TrafficPolicyObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2022/07/TrafficPolicy}TrafficPolicyObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -79,7 +82,9 @@ "properties": { "@xsi:type": { "type": "string", - "enum": "{http://uri.etsi.org/03120/common/2022/07/TrafficPolicy}TrafficRuleObject" + "enum": [ + "{http://uri.etsi.org/03120/common/2022/07/TrafficPolicy}TrafficRuleObject" + ] }, "ObjectIdentifier": { "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" @@ -307,4 +312,4 @@ ] } } -} \ No newline at end of file +} diff --git a/utils/translate/SequenceMapping.py b/utils/translate/SequenceMapping.py index 4dc5c93..341ac51 100644 --- a/utils/translate/SequenceMapping.py +++ b/utils/translate/SequenceMapping.py @@ -35,7 +35,7 @@ class SequenceMapping(ComplexTypeMapping): # mapped_type['__DESCENDENT_OF__'] = TypeMapping.get_ref_for(xst.base_type, xst.namespaces['']) mapped_type['properties']['@xsi:type'] = { "type" : "string", - "enum" : xst.name + "enum" : [xst.name] } mapped_type['required'].append('@xsi:type') # if xst.abstract: diff --git a/utils/translate/__init__.py b/utils/translate/__init__.py index ba05008..86a3346 100644 --- a/utils/translate/__init__.py +++ b/utils/translate/__init__.py @@ -20,6 +20,7 @@ mappings = [ def translate_schema (schema_path: str, ns_to_id_map: dict, schema_locations = []): js = { "$id" : "?", + "$schema" : "https://json-schema.org/draft/2020-12/schema", "$defs" : {} } diff --git a/utils/translate_spec.py b/utils/translate_spec.py index 01880ff..e950b4a 100644 --- a/utils/translate_spec.py +++ b/utils/translate_spec.py @@ -107,7 +107,7 @@ if __name__ == "__main__": ] } - json_string = json.dumps(js, indent=2) + json_string = json.dumps(js, indent=2) + "\n" if "Core" in schema_tuple[1]: json_string = json_string.replace('"$ref": "#/$defs/HI1Object"', '"$ref": "#/$defs/ConcreteHI1Object"') -- GitLab From 52f4dc9add33dcb52d7f5cc06c699888a9d5d2e6 Mon Sep 17 00:00:00 2001 From: kaufmannj Date: Sat, 8 Jun 2024 19:29:03 +0000 Subject: [PATCH 2/8] Transposing LI(24)P66009 CR to XSD. --- .../ts_103120_ETSIDictionaryDefinitions.xml | 50 +++++++++++++++ 103120/schema/xsd/ts_103120_Common.xsd | 5 ++ 103120/schema/xsd/ts_103120_Config.xsd | 62 +++++++++++++++++++ 103120/schema/xsd/ts_103120_Core.xsd | 15 ++++- 4 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 103120/schema/xsd/ts_103120_Config.xsd diff --git a/103120/dictionaries/ts_103120_ETSIDictionaryDefinitions.xml b/103120/dictionaries/ts_103120_ETSIDictionaryDefinitions.xml index 242ca81..383bccc 100644 --- a/103120/dictionaries/ts_103120_ETSIDictionaryDefinitions.xml +++ b/103120/dictionaries/ts_103120_ETSIDictionaryDefinitions.xml @@ -715,6 +715,56 @@ + + + ETSI + LIWorkflowEndpoint + + + NewAuthorisation + Implementer supports the "New Authorisation" Endpoint. + + + AuthorisationExtension + Implementer supports the "Authorisation Extension" Endpoint. + + + AuthorisationCancellation + Implementer supports the "Authorisation Cancellation" Endpoint. + + + TaskAddition + Implementer supports the "Task Addition" Endpoint. + + + TaskCancellation + Implementer supports the "Task Cancellation" Endpoint. + + + ChangeOfDelivery + Implementer supports the "Change of Delivery" Endpoint. + + + + + + ETSI + LPWorkflowEndpoint + + + NewPreservation + Implementer supports the "New Preservation" Endpoint. + + + PreservationExtension + Implementer supports the "Preservation Extension" Endpoint. + + + PreservationCancellation + Implementer supports the "Preservation Cancellation" Endpoint. + + + ETSI diff --git a/103120/schema/xsd/ts_103120_Common.xsd b/103120/schema/xsd/ts_103120_Common.xsd index 4bc2338..cea9e81 100644 --- a/103120/schema/xsd/ts_103120_Common.xsd +++ b/103120/schema/xsd/ts_103120_Common.xsd @@ -6,6 +6,11 @@ + + + + + diff --git a/103120/schema/xsd/ts_103120_Config.xsd b/103120/schema/xsd/ts_103120_Config.xsd new file mode 100644 index 0000000..308e18b --- /dev/null +++ b/103120/schema/xsd/ts_103120_Config.xsd @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/103120/schema/xsd/ts_103120_Core.xsd b/103120/schema/xsd/ts_103120_Core.xsd index e0b772c..eeb5562 100644 --- a/103120/schema/xsd/ts_103120_Core.xsd +++ b/103120/schema/xsd/ts_103120_Core.xsd @@ -1,6 +1,7 @@ - + + @@ -71,6 +72,7 @@ + @@ -84,6 +86,7 @@ + @@ -158,6 +161,16 @@ + + + + + + + + + + -- GitLab From c0087f3c6b8f31267e26f9e4d1b709b8d03417c2 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 10 Jun 2024 08:48:18 +0100 Subject: [PATCH 3/8] Adding new config xsd to testing config --- testing/xsd_compile_targets.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/xsd_compile_targets.json b/testing/xsd_compile_targets.json index bb4f13e..6f90cb7 100644 --- a/testing/xsd_compile_targets.json +++ b/testing/xsd_compile_targets.json @@ -19,6 +19,7 @@ "103280/TS_103_280.xsd", "103221-1/examples/ExampleGenericObjects.xsd", "103120/schema/xsd/ts_103120_Common.xsd", + "103120/schema/xsd/ts_103120_Config.xsd", "103120/schema/xsd/ts_103120_Core.xsd", "103120/schema/xsd/ts_103120_TrafficPolicy.xsd", "testing/deps/xmldsig/xmldsig-core-schema.xsd" @@ -39,6 +40,7 @@ "supportingSchemas" : [ "103120/schema/xsd/ts_103120_Authorisation.xsd", "103120/schema/xsd/ts_103120_Common.xsd", + "103120/schema/xsd/ts_103120_Config.xsd", "103120/schema/xsd/ts_103120_Delivery.xsd", "103120/schema/xsd/ts_103120_Document.xsd", "103120/schema/xsd/ts_103120_Notification.xsd", @@ -58,6 +60,7 @@ "103280/TS_103_280.xsd", "103120/schema/xsd/ts_103120_Common.xsd", "103120/schema/xsd/ts_103120_Core.xsd", + "103120/schema/xsd/ts_103120_Config.xsd", "103120/schema/xsd/ts_103120_Task.xsd", "testing/deps/xmldsig/xmldsig-core-schema.xsd", "103707/examples/FooServiceSchema.xsd" -- GitLab From 801814d8a61a2c26fb7925d07b683a2f319bc639 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 10 Jun 2024 09:13:07 +0100 Subject: [PATCH 4/8] Adding an example CONFIG request and response --- 103120/examples/xml/request_config.xml | 30 +++++++++ 103120/examples/xml/response_config.xml | 90 +++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 103120/examples/xml/request_config.xml create mode 100644 103120/examples/xml/response_config.xml diff --git a/103120/examples/xml/request_config.xml b/103120/examples/xml/request_config.xml new file mode 100644 index 0000000..99a9c5b --- /dev/null +++ b/103120/examples/xml/request_config.xml @@ -0,0 +1,30 @@ + + +
+ + XX + ACTOR01 + + + XX + ACTOR02 + + eb6b002d-15c3-4c3b-af6c-27ede73641e5 + 2024-06-10T08:50:31.000000Z + + V1.16.1 + XX + v1.0 + +
+ + + + + 0 + + + + + +
\ No newline at end of file diff --git a/103120/examples/xml/response_config.xml b/103120/examples/xml/response_config.xml new file mode 100644 index 0000000..23af8dd --- /dev/null +++ b/103120/examples/xml/response_config.xml @@ -0,0 +1,90 @@ + + +
+ + XX + ACTOR01 + + + XX + ACTOR02 + + eb6b002d-15c3-4c3b-af6c-27ede73641e5 + 2024-06-10T08:50:31.000000Z + + V1.16.1 + XX + v1.0 + +
+ + + + + 0 + + 2024-05-10T08:52:32Z + + ACTOR02 + + + ProprietaryIdentifier + This is an illustration of a proprietary identifier type specific to this CSP, which consists of the string "CSP" followed by 10 digits + ^CSP[0-9]{10}$ + + + + + + InternationalE164 + ETSI + This configuration entry tells the LEA that they can use the ETSI standard format E164 number for LI of service A + + + ACTOR02 + LIServerTypes + ServiceA + + + + + + + PropietaryIdentifier + ACTOR02 + This configuration entry tells the LEA that they can use the propietary identifier format type described in the TargetFormatTypeDefinitions for LI of both Service A and Service B + + + ACTOR02 + LIServerTypes + ServiceA + + + ACTOR02 + LIServerTypes + ServiceB + + + + + + + + + + ETSI + LIWorkflowEndpoint + NewAuthorisation + + This tells the LEA what endpoint to use for new warrants. For brevity, in this example, this is the only endpoint specified. + https://ts103120.example.com/li/authorisation/new + + + + + + + + + +
\ No newline at end of file -- GitLab From b9570edf5e31f44d0966b1c666c02f83ff9cab18 Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 10 Jun 2024 13:19:26 +0100 Subject: [PATCH 5/8] Adding dictionaries --- 103120/examples/xml/response_config.xml | 24 ++++++++++++++++++++---- 103120/schema/xsd/ts_103120_Core.xsd | 4 +++- testing/xsd_compile_targets.json | 3 +++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/103120/examples/xml/response_config.xml b/103120/examples/xml/response_config.xml index 23af8dd..e7007e9 100644 --- a/103120/examples/xml/response_config.xml +++ b/103120/examples/xml/response_config.xml @@ -1,5 +1,5 @@ - +
XX @@ -24,6 +24,22 @@ 0 2024-05-10T08:52:32Z + + + ACTOR2 + LIServiceTypes + + + ServiceA + This is a dictionary entry + + + ServiceB + This is a dictionary entry + + + + ACTOR02 @@ -42,7 +58,7 @@ ACTOR02 - LIServerTypes + LIServiceTypes ServiceA @@ -56,12 +72,12 @@ ACTOR02 - LIServerTypes + LIServiceTypes ServiceA ACTOR02 - LIServerTypes + LIServiceTypes ServiceB diff --git a/103120/schema/xsd/ts_103120_Core.xsd b/103120/schema/xsd/ts_103120_Core.xsd index eeb5562..bfd905d 100644 --- a/103120/schema/xsd/ts_103120_Core.xsd +++ b/103120/schema/xsd/ts_103120_Core.xsd @@ -1,7 +1,8 @@ - + + @@ -165,6 +166,7 @@ + diff --git a/testing/xsd_compile_targets.json b/testing/xsd_compile_targets.json index 6f90cb7..8aa1774 100644 --- a/testing/xsd_compile_targets.json +++ b/testing/xsd_compile_targets.json @@ -21,6 +21,7 @@ "103120/schema/xsd/ts_103120_Common.xsd", "103120/schema/xsd/ts_103120_Config.xsd", "103120/schema/xsd/ts_103120_Core.xsd", + "103120/dictionaries/ts_103120_Dictionaries.xsd", "103120/schema/xsd/ts_103120_TrafficPolicy.xsd", "testing/deps/xmldsig/xmldsig-core-schema.xsd" ], @@ -42,6 +43,7 @@ "103120/schema/xsd/ts_103120_Common.xsd", "103120/schema/xsd/ts_103120_Config.xsd", "103120/schema/xsd/ts_103120_Delivery.xsd", + "103120/dictionaries/ts_103120_Dictionaries.xsd", "103120/schema/xsd/ts_103120_Document.xsd", "103120/schema/xsd/ts_103120_Notification.xsd", "103120/schema/xsd/ts_103120_Task.xsd", @@ -61,6 +63,7 @@ "103120/schema/xsd/ts_103120_Common.xsd", "103120/schema/xsd/ts_103120_Core.xsd", "103120/schema/xsd/ts_103120_Config.xsd", + "103120/dictionaries/ts_103120_Dictionaries.xsd", "103120/schema/xsd/ts_103120_Task.xsd", "testing/deps/xmldsig/xmldsig-core-schema.xsd", "103707/examples/FooServiceSchema.xsd" -- GitLab From be911b8f75e7ef69a3154692d5d03e30436cee3b Mon Sep 17 00:00:00 2001 From: kaufmannj Date: Mon, 10 Jun 2024 19:09:14 +0000 Subject: [PATCH 6/8] Mark non-mandatory fields as such. --- 103120/schema/xsd/ts_103120_Config.xsd | 12 ++++++------ 103120/schema/xsd/ts_103120_Core.xsd | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/103120/schema/xsd/ts_103120_Config.xsd b/103120/schema/xsd/ts_103120_Config.xsd index 308e18b..bad5d2a 100644 --- a/103120/schema/xsd/ts_103120_Config.xsd +++ b/103120/schema/xsd/ts_103120_Config.xsd @@ -29,10 +29,10 @@ - - - - + + + + @@ -43,7 +43,7 @@ - + @@ -55,7 +55,7 @@ - + diff --git a/103120/schema/xsd/ts_103120_Core.xsd b/103120/schema/xsd/ts_103120_Core.xsd index bfd905d..ce8fb72 100644 --- a/103120/schema/xsd/ts_103120_Core.xsd +++ b/103120/schema/xsd/ts_103120_Core.xsd @@ -166,11 +166,11 @@ - - + + - - + + -- GitLab From 0ea7bc839f09bfa0f742b5527987814f310b7245 Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 11 Jun 2024 09:54:38 +0100 Subject: [PATCH 7/8] Testing JSON --- .../schema/json/ts_103120_Common.schema.json | 12 +++++ 103120/schema/json/ts_103120_Core.schema.json | 44 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/103120/schema/json/ts_103120_Common.schema.json b/103120/schema/json/ts_103120_Common.schema.json index d11b4b4..67fb16b 100644 --- a/103120/schema/json/ts_103120_Common.schema.json +++ b/103120/schema/json/ts_103120_Common.schema.json @@ -12,6 +12,18 @@ } ] }, + "DictionaryEntries": { + "type": "object", + "properties": { + "common:DictionaryEntry": { + "type": "array", + "items": { + "$ref": "#/$defs/DictionaryEntry" + } + } + }, + "required": [] + }, "DictionaryEntry": { "type": "object", "properties": { diff --git a/103120/schema/json/ts_103120_Core.schema.json b/103120/schema/json/ts_103120_Core.schema.json index 63e2ad4..d115073 100644 --- a/103120/schema/json/ts_103120_Core.schema.json +++ b/103120/schema/json/ts_103120_Core.schema.json @@ -253,6 +253,17 @@ "required": [ "DELIVER" ] + }, + { + "type": "object", + "properties": { + "CONFIG": { + "$ref": "#/$defs/CONFIGRequest" + } + }, + "required": [ + "CONFIG" + ] } ] } @@ -339,6 +350,17 @@ "required": [ "DELIVERResponse" ] + }, + { + "type": "object", + "properties": { + "CONFIGResponse": { + "$ref": "#/$defs/CONFIGResponse" + } + }, + "required": [ + "CONFIGResponse" + ] } ] } @@ -514,6 +536,28 @@ "Identifier" ] }, + "CONFIGRequest": { + "type": "object", + "properties": {}, + "required": [] + }, + "CONFIGResponse": { + "type": "object", + "properties": { + "LastChanged": { + "$ref": "ts_103280_2017_07#/$defs/QualifiedDateTime" + }, + "Dictionaries": {}, + "TargetFormatTypeDefinitions": {}, + "TargetingConfigurations": {}, + "SupportedLIWorkflowEndpoints": {}, + "SupportedLPWorkflowEndpoints": {} + }, + "required": [ + "LastChanged", + "TargetingConfigurations" + ] + }, "HI1Object": { "type": "object", "properties": { -- GitLab From e99fc92db1a6f6514e15fdfcc22bcd99c54574a2 Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 20 Jun 2024 09:38:07 +0100 Subject: [PATCH 8/8] Fixing JSON --- .../ts_103120_Dictionaries.schema.json | 65 ++++++++ 103120/examples/json/request_config.json | 36 +++++ 103120/examples/json/response_config.json | 126 +++++++++++++++ .../schema/json/ts_103120_Config.schema.json | 151 ++++++++++++++++++ 103120/schema/json/ts_103120_Core.schema.json | 20 ++- utils/json_validator.py | 22 ++- utils/ts103120_config.json | 7 + utils/ts103120_dictionaries.json | 8 + utils/xml_to_json.py | 24 ++- 9 files changed, 448 insertions(+), 11 deletions(-) create mode 100644 103120/dictionaries/ts_103120_Dictionaries.schema.json create mode 100644 103120/examples/json/request_config.json create mode 100644 103120/examples/json/response_config.json create mode 100644 103120/schema/json/ts_103120_Config.schema.json create mode 100644 utils/ts103120_dictionaries.json diff --git a/103120/dictionaries/ts_103120_Dictionaries.schema.json b/103120/dictionaries/ts_103120_Dictionaries.schema.json new file mode 100644 index 0000000..d439cd6 --- /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/103120/examples/json/request_config.json b/103120/examples/json/request_config.json new file mode 100644 index 0000000..00f1363 --- /dev/null +++ b/103120/examples/json/request_config.json @@ -0,0 +1,36 @@ +{ + "@xmlns": "http://uri.etsi.org/03120/common/2019/10/Core", + "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", + "@xmlns:common": "http://uri.etsi.org/03120/common/2016/02/Common", + "@xmlns:task": "http://uri.etsi.org/03120/common/2020/09/Task", + "@xmlns:auth": "http://uri.etsi.org/03120/common/2020/09/Authorisation", + "Header": { + "SenderIdentifier": { + "CountryCode": "XX", + "UniqueIdentifier": "ACTOR01" + }, + "ReceiverIdentifier": { + "CountryCode": "XX", + "UniqueIdentifier": "ACTOR02" + }, + "TransactionIdentifier": "eb6b002d-15c3-4c3b-af6c-27ede73641e5", + "Timestamp": "2024-06-10T08:50:31.000000Z", + "Version": { + "ETSIVersion": "V1.16.1", + "NationalProfileOwner": "XX", + "NationalProfileVersion": "v1.0" + } + }, + "Payload": { + "RequestPayload": { + "ActionRequests": { + "ActionRequest": [ + { + "ActionIdentifier": 0, + "CONFIG": {} + } + ] + } + } + } +} diff --git a/103120/examples/json/response_config.json b/103120/examples/json/response_config.json new file mode 100644 index 0000000..a5bc120 --- /dev/null +++ b/103120/examples/json/response_config.json @@ -0,0 +1,126 @@ +{ + "@xmlns": "http://uri.etsi.org/03120/common/2019/10/Core", + "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", + "@xmlns:common": "http://uri.etsi.org/03120/common/2016/02/Common", + "@xmlns:task": "http://uri.etsi.org/03120/common/2020/09/Task", + "@xmlns:config": "http://uri.etsi.org/03120/common/2024/06/Config", + "@xmlns:dictionaries": "http://uri.etsi.org/03280/common/2019/10/Dictionaries", + "Header": { + "SenderIdentifier": { + "CountryCode": "XX", + "UniqueIdentifier": "ACTOR01" + }, + "ReceiverIdentifier": { + "CountryCode": "XX", + "UniqueIdentifier": "ACTOR02" + }, + "TransactionIdentifier": "eb6b002d-15c3-4c3b-af6c-27ede73641e5", + "Timestamp": "2024-06-10T08:50:31.000000Z", + "Version": { + "ETSIVersion": "V1.16.1", + "NationalProfileOwner": "XX", + "NationalProfileVersion": "v1.0" + } + }, + "Payload": { + "ResponsePayload": { + "ActionResponses": { + "ActionResponse": [ + { + "ActionIdentifier": 0, + "CONFIGResponse": { + "LastChanged": "2024-05-10T08:52:32Z", + "Dictionaries": { + "dictionaries:Dictionary": [ + { + "dictionaries:Owner": "ACTOR2", + "dictionaries:Name": "LIServiceTypes", + "dictionaries:DictionaryEntries": { + "dictionaries:DictionaryEntry": [ + { + "dictionaries:Value": "ServiceA", + "dictionaries:Meaning": "This is a dictionary entry" + }, + { + "dictionaries:Value": "ServiceB", + "dictionaries:Meaning": "This is a dictionary entry" + } + ] + } + } + ] + }, + "TargetFormatTypeDefinitions": { + "config:FormatOwner": "ACTOR02", + "config:TargetFormatTypeDefinitionEntries": { + "config:TargetFormatTypeDefinitionEntry": [ + { + "config:FormatName": "ProprietaryIdentifier", + "config:Description": "This is an illustration of a proprietary identifier type specific to this CSP, which consists of the string \"CSP\" followed by 10 digits", + "config:FormatRegex": "^CSP[0-9]{10}$" + } + ] + } + }, + "TargetingConfigurations": { + "config:TargetingConfiguration": [ + { + "config:FormatName": "InternationalE164", + "config:FormatOwner": "ETSI", + "config:Guidance": "This configuration entry tells the LEA that they can use the ETSI standard format E164 number for LI of service A", + "config:AssociatedLIServiceTypes": { + "common:DictionaryEntry": [ + { + "common:Owner": "ACTOR02", + "common:Name": "LIServiceTypes", + "common:Value": "ServiceA" + } + ] + }, + "config:AssociatedLDRequestSubtypes": {}, + "config:AssociatedLPRequestSubtypes": {} + }, + { + "config:FormatName": "PropietaryIdentifier", + "config:FormatOwner": "ACTOR02", + "config:Guidance": "This configuration entry tells the LEA that they can use the propietary identifier format type described in the TargetFormatTypeDefinitions for LI of both Service A and Service B", + "config:AssociatedLIServiceTypes": { + "common:DictionaryEntry": [ + { + "common:Owner": "ACTOR02", + "common:Name": "LIServiceTypes", + "common:Value": "ServiceA" + }, + { + "common:Owner": "ACTOR02", + "common:Name": "LIServiceTypes", + "common:Value": "ServiceB" + } + ] + }, + "config:AssociatedLDRequestSubtypes": {}, + "config:AssociatedLPRequestSubtypes": {} + } + ] + }, + "SupportedLIWorkflowEndpoints": { + "config:SupportedLIWorkflowEndpoint": [ + { + "config:LIWorkflowEndpoint": { + "common:Owner": "ETSI", + "common:Name": "LIWorkflowEndpoint", + "common:Value": "NewAuthorisation" + }, + "config:Guidance": "This tells the LEA what endpoint to use for new warrants. For brevity, in this example, this is the only endpoint specified.", + "config:URL": "https://ts103120.example.com/li/authorisation/new" + } + ] + }, + "SupportedLPWorkflowEndpoints": {} + } + } + ] + } + } + } +} diff --git a/103120/schema/json/ts_103120_Config.schema.json b/103120/schema/json/ts_103120_Config.schema.json new file mode 100644 index 0000000..40cdf92 --- /dev/null +++ b/103120/schema/json/ts_103120_Config.schema.json @@ -0,0 +1,151 @@ +{ + "$id": "ts_103120_Config_2024_06", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "TargetFormatTypeDefinitions": { + "type": "object", + "properties": { + "config:FormatOwner": { + "$ref": "ts_103280_2017_07#/$defs/ShortString" + }, + "config:TargetFormatTypeDefinitionEntries": { + "$ref": "#/$defs/TargetFormatTypeDefinitionEntries" + } + }, + "required": [ + "config:FormatOwner", + "config:TargetFormatTypeDefinitionEntries" + ] + }, + "TargetFormatTypeDefinitionEntries": { + "type": "object", + "properties": { + "config:TargetFormatTypeDefinitionEntry": { + "type": "array", + "items": { + "$ref": "#/$defs/TargetFormatTypeDefinitionEntry" + } + } + }, + "required": [] + }, + "TargetFormatTypeDefinitionEntry": { + "type": "object", + "properties": { + "config:FormatName": { + "$ref": "ts_103280_2017_07#/$defs/ShortString" + }, + "config:Description": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + }, + "config:FormatRegex": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + } + }, + "required": [ + "config:FormatName", + "config:Description", + "config:FormatRegex" + ] + }, + "TargetingConfigurations": { + "type": "object", + "properties": { + "config:TargetingConfiguration": { + "type": "array", + "items": { + "$ref": "#/$defs/TargetingConfiguration" + } + } + }, + "required": [] + }, + "TargetingConfiguration": { + "type": "object", + "properties": { + "config:FormatName": { + "$ref": "ts_103280_2017_07#/$defs/ShortString" + }, + "config:FormatOwner": { + "$ref": "ts_103280_2017_07#/$defs/ShortString" + }, + "config:Guidance": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + }, + "config:AssociatedLIServiceTypes": { + "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntries" + }, + "config:AssociatedLDRequestSubtypes": { + "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntries" + }, + "config:AssociatedLPRequestSubtypes": { + "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntries" + } + }, + "required": [ + "config:FormatName", + "config:FormatOwner" + ] + }, + "SupportedLIWorkflowEndpoints": { + "type": "object", + "properties": { + "config:SupportedLIWorkflowEndpoint": { + "type": "array", + "items": { + "$ref": "#/$defs/SupportedLIWorkflowEndpoint" + } + } + }, + "required": [] + }, + "SupportedLIWorkflowEndpoint": { + "type": "object", + "properties": { + "config:LIWorkflowEndpoint": { + "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntry" + }, + "config:Guidance": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + }, + "config:URL": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + } + }, + "required": [ + "config:LIWorkflowEndpoint", + "config:URL" + ] + }, + "SupportedLPWorkflowEndpoints": { + "type": "object", + "properties": { + "config:SupportedLPWorkflowEndpoint": { + "type": "array", + "items": { + "$ref": "#/$defs/SupportedLPWorkflowEndpoint" + } + } + }, + "required": [] + }, + "SupportedLPWorkflowEndpoint": { + "type": "object", + "properties": { + "config:LIWorkflowEndpoint": { + "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntry" + }, + "config:Guidance": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + }, + "config:URL": { + "$ref": "ts_103280_2017_07#/$defs/LongString" + } + }, + "required": [ + "config:LIWorkflowEndpoint", + "config:URL" + ] + } + } +} diff --git a/103120/schema/json/ts_103120_Core.schema.json b/103120/schema/json/ts_103120_Core.schema.json index 2f60bd3..1208029 100644 --- a/103120/schema/json/ts_103120_Core.schema.json +++ b/103120/schema/json/ts_103120_Core.schema.json @@ -548,11 +548,21 @@ "LastChanged": { "$ref": "ts_103280_2017_07#/$defs/QualifiedDateTime" }, - "Dictionaries": {}, - "TargetFormatTypeDefinitions": {}, - "TargetingConfigurations": {}, - "SupportedLIWorkflowEndpoints": {}, - "SupportedLPWorkflowEndpoints": {} + "Dictionaries": { + "$ref": "ts_103280_Dictionaries_2019_10#/$defs/Dictionaries" + }, + "TargetFormatTypeDefinitions": { + "$ref": "ts_103120_Config_2024_06#/$defs/TargetFormatTypeDefinitions" + }, + "TargetingConfigurations": { + "$ref": "ts_103120_Config_2024_06#/$defs/TargetingConfigurations" + }, + "SupportedLIWorkflowEndpoints": { + "$ref": "ts_103120_Config_2024_06#/$defs/SupportedLIWorkflowEndpoints" + }, + "SupportedLPWorkflowEndpoints": { + "$ref": "ts_103120_Config_2024_06#/$defs/SupportedLPWorkflowEndpoints" + } }, "required": [ "LastChanged", diff --git a/utils/json_validator.py b/utils/json_validator.py index e9ff0c0..82ee191 100644 --- a/utils/json_validator.py +++ b/utils/json_validator.py @@ -38,7 +38,7 @@ class JsonValidator: class TS103120Validator (JsonValidator): def __init__ (self, path_to_repo): repo_path = Path(path_to_repo) - schema_dirs = [str(repo_path / "103120/schema/json"), str("103280/")] + schema_dirs = [str(repo_path / "103120/schema/json"), str("103120/dictionaries/"), str("103280/")] core_schema = str(repo_path / "103120/schema/json/ts_103120_Core.schema.json") JsonValidator.__init__(self, core_schema, schema_dirs) request_fragment_schema = { "$ref" : "ts_103120_Core_2019_10#/$defs/RequestPayload" } @@ -47,15 +47,18 @@ class TS103120Validator (JsonValidator): self._response_fragment_validator = Draft202012Validator(response_fragment_schema, resolver=self._resolver) def expand_request_response_exception (self, ex): + print(ex.schema_path) if list(ex.schema_path) == ['properties', 'Payload', 'oneOf']: logging.info ("Error detected validating payload oneOf - attempting explicit validation...") if 'RequestPayload' in instance_doc['Payload'].keys(): + logging.info("Error in RequestPayload") ret_list = list(chain(*[self.expand_action_exception(x) for x in self._request_fragment_validator.iter_errors(instance_doc['Payload']['RequestPayload'])])) for r in ret_list: r.path = ex.path + r.path return ret_list elif 'ResponsePayload' in instance_doc['Payload'].keys(): - ret_list = list(chain(*[self.expand_action_exception(x) for x in self._request_fragment_validator.iter_errors(instance_doc['Payload']['ResponsePayload'])])) + logging.info("Error in ResponsePayload") + ret_list = list(chain(*[self.expand_action_exception(x) for x in self._response_fragment_validator.iter_errors(instance_doc['Payload']['ResponsePayload'])])) for r in ret_list: r.path = ex.path + r.path return ret_list @@ -68,9 +71,18 @@ class TS103120Validator (JsonValidator): def expand_action_exception (self, ex): logging.error("Error detected in ActionRequests/ActionResponses") error_path = list(ex.schema_path) + if error_path == ['oneOf']: + logging.error('Failed validating verb ') + #temp + configResponse = ex.instance['ActionResponses']['ActionResponse'][0]['CONFIGResponse'] + temp_validator = Draft202012Validator({"$ref" : 'ts_103120_Core_2019_10#/$defs/CONFIGResponse'}, resolver=self._resolver) + inner_errors = list(temp_validator.iter_errors(configResponse)) + for error in inner_errors: + print(error) if error_path != ['properties', 'ActionRequests', 'properties', 'ActionRequest', 'items', 'allOf', 1, 'oneOf'] and error_path != ['properties', 'ActionResponses', 'properties', 'ActionResponse', 'items', 'allOf', 1, 'oneOf']: logging.error("Error not in inner Request/Response allOf/oneOf constraint") return[ex] + # TODO - look at this again, won't work for responses... j = ex.instance j.pop('ActionIdentifier') # Remove ActionIdentifier - one remaining key will be the verb verb = list(j.keys())[0] @@ -131,15 +143,15 @@ if __name__ == "__main__": logging.debug(f"Arguments: {args}") if (args.ts103120): - v = TS103120Validator("./") + validator = TS103120Validator("./") else: - v = JsonValidator(args.schema, args.schemadir) + validator = JsonValidator(args.schema, args.schemadir) logging.info(f"Taking instance doc input from {args.input.name}") instance_doc = json.loads(args.input.read()) args.input.close() - errors = v.validate(instance_doc) + errors = validator.validate(instance_doc) for error in errors: if args.printerror == 2: logging.error(error) diff --git a/utils/ts103120_config.json b/utils/ts103120_config.json index 4c8bce7..af7330c 100644 --- a/utils/ts103120_config.json +++ b/utils/ts103120_config.json @@ -6,11 +6,18 @@ "./103120/schema/xsd/ts_103120_Common.xsd" : { "prefix" : "common" }, + "./103120/schema/xsd/ts_103120_Config.xsd" : { + "prefix" : "config" + }, "./103120/schema/xsd/ts_103120_Core.xsd" : { }, "./103120/schema/xsd/ts_103120_Delivery.xsd" : { "prefix" : "delivery" }, + "./103120/dictionaries/ts_103120_Dictionaries.xsd" : { + "prefix" : "dictionaries", + "skip" : true + }, "./103120/schema/xsd/ts_103120_Document.xsd" : { "prefix" : "doc" }, diff --git a/utils/ts103120_dictionaries.json b/utils/ts103120_dictionaries.json new file mode 100644 index 0000000..1e779f8 --- /dev/null +++ b/utils/ts103120_dictionaries.json @@ -0,0 +1,8 @@ +{ + "schemas" : { + "./103120/dictionaries/ts_103120_Dictionaries.xsd" : { + "prefix" : "dictionaries" + } + }, + "output" : "./103120/dictionaries" +} diff --git a/utils/xml_to_json.py b/utils/xml_to_json.py index a89777f..6c7f126 100644 --- a/utils/xml_to_json.py +++ b/utils/xml_to_json.py @@ -66,7 +66,12 @@ coerce_to_list = [ 'task:LDTaskFlag', 'task:TrafficPolicyReference', 'tp:TrafficRuleReference', - 'tp:Criteria' + 'tp:Criteria', + 'common:DictionaryEntry', + 'dictionaries:Dictionary', + 'config:TargetFormatTypeDefinitionEntry', + 'config:SupportedLIWorkflowEndpoint', + 'config:SupportedLPWorkflowEndpoint', ] coerce_to_int = [ @@ -81,6 +86,18 @@ coerce_to_bool = [ 'delivery:LastSequence' ] +coerce_to_empty = [ + 'CONFIG' +] + +coerce_null_to_empty = [ + 'SupportedLIWorkflowEndpoints', + 'SupportedLPWorkflowEndpoints', + 'config:AssociatedLDRequestSubtypes', + 'config:AssociatedLPRequestSubtypes', + 'config:AssociatedLIRequestSubtypes', +] + def postprocessor (path, key, value): if key == "@xsi:type": object_name = value.split(":")[-1] @@ -91,6 +108,11 @@ def postprocessor (path, key, value): return key, int(value) if key in coerce_to_bool: return key, bool(value) + if key in coerce_to_empty: + return key, {} + if key in coerce_null_to_empty: + if value is None: + return key, {} return key, value if __name__ == "__main__": -- GitLab