From 2a1e6ba674f5ce080e392a577f99e9ea8ffe10d4 Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 10 Oct 2024 15:18:22 +0100 Subject: [PATCH 1/2] Translation fixes --- 103120/examples/json/request1_bad.json | 97 +++++++++++++++++++ .../json/request7-TrafficPolicyObject.json | 18 ++-- .../json/ts_103120_Authorisation.schema.json | 15 ++- .../schema/json/ts_103120_Common.schema.json | 24 +++-- 103120/schema/json/ts_103120_Core.schema.json | 83 +++++++++++----- .../json/ts_103120_Delivery.schema.json | 12 ++- .../json/ts_103120_Document.schema.json | 18 ++-- .../json/ts_103120_Notification.schema.json | 12 ++- 103120/schema/json/ts_103120_Task.schema.json | 84 ++++++++++------ .../json/ts_103120_TrafficPolicy.schema.json | 33 ++++--- utils/translate/ChoiceMapping.py | 4 +- utils/translate/SequenceMapping.py | 13 ++- utils/translate_spec.py | 3 +- 13 files changed, 310 insertions(+), 106 deletions(-) create mode 100644 103120/examples/json/request1_bad.json diff --git a/103120/examples/json/request1_bad.json b/103120/examples/json/request1_bad.json new file mode 100644 index 00000000..70fc486f --- /dev/null +++ b/103120/examples/json/request1_bad.json @@ -0,0 +1,97 @@ +{ + "@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": { + "bad" : "bad", + "SenderIdentifier": { + "CountryCode": "XX", + "UniqueIdentifier": "ACTOR01" + }, + "ReceiverIdentifier": { + "CountryCode": "XX", + "UniqueIdentifier": "ACTOR02" + }, + "TransactionIdentifier": "c02358b2-76cf-4ba4-a8eb-f6436ccaea2e", + "Timestamp": "2015-09-01T12:00:00.000000Z", + "Version": { + "ETSIVersion": "V1.13.1", + "NationalProfileOwner": "XX", + "NationalProfileVersion": "v1.0" + } + }, + "Payload": { + "RequestPayload": { + "ActionRequests": { + "ActionRequest": [ + { + "ActionIdentifier": 0, + "CREATE": { + "HI1Object": { + "@xsi:type": "{http://uri.etsi.org/03120/common/2020/09/Authorisation}AuthorisationObject", + "ObjectIdentifier": "7dbbc880-8750-4d3c-abe7-ea4a17646045", + "CountryCode": "XX", + "OwnerIdentifier": "ACTOR01", + "auth:AuthorisationReference": "W000001", + "auth:AuthorisationTimespan": { + "auth:StartTime": "2015-09-01T12:00:00Z", + "auth:EndTime": "2015-12-01T12:00:00Z" + } + } + } + }, + { + "ActionIdentifier": 1, + "CREATE": { + "HI1Object": { + "@xsi:type": "{http://uri.etsi.org/03120/common/2020/09/Task}LITaskObject", + "ObjectIdentifier": "2b36a78b-b628-416d-bd22-404e68a0cd36", + "CountryCode": "XX", + "OwnerIdentifier": "ACTOR01", + "AssociatedObjects": { + "AssociatedObject": [ + "7dbbc880-8750-4d3c-abe7-ea4a17646045" + ] + }, + "task:Reference": "LIID1", + "task:TargetIdentifier": { + "task:TargetIdentifierValues": { + "task:TargetIdentifierValue": [ + { + "task:FormatType": { + "task:FormatOwner": "ETSI", + "task:FormatName": "InternationalE164" + }, + "task:Value": "442079460223" + } + ] + } + }, + "task:DeliveryType": { + "common:Owner": "ETSI", + "common:Name": "TaskDeliveryType", + "common:Value": "IRIandCC" + }, + "task:DeliveryDetails": { + "task:DeliveryDestination": [ + { + "task:DeliveryAddress": { + "task:IPv4Address": "192.0.2.0" + } + } + ] + }, + "task:CSPID": { + "CountryCode": "XX", + "UniqueIdentifier": "RECVER01" + } + } + } + } + ] + } + } + } +} diff --git a/103120/examples/json/request7-TrafficPolicyObject.json b/103120/examples/json/request7-TrafficPolicyObject.json index 09afd84e..0e6ca37d 100644 --- a/103120/examples/json/request7-TrafficPolicyObject.json +++ b/103120/examples/json/request7-TrafficPolicyObject.json @@ -2,7 +2,7 @@ "@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:policy": "http://uri.etsi.org/03120/common/2022/07/TrafficPolicy", + "@xmlns:tp": "http://uri.etsi.org/03120/common/2022/07/TrafficPolicy", "@xmlns:etsi": "http://uri.etsi.org/03280/common/2017/07", "@xmlns:task": "http://uri.etsi.org/03120/common/2020/09/Task", "Header": { @@ -34,16 +34,16 @@ "ObjectIdentifier": "f69eb93b-a85b-4ff7-abaa-6f3aead286d5", "CountryCode": "XX", "OwnerIdentifier": "ACTOR01", - "policy:Criteria": { - "policy:Criteria": { - "policy:IPPolicyCriteria": { - "policy:SourceIPRange": { + "tp:Criteria": { + "tp:Criteria": [{ + "tp:IPPolicyCriteria": { + "tp:SourceIPRange": { "etsi:IPv4CIDR": "203.0.113.0/24" } } - } + }] }, - "policy:Action": { + "tp:Action": { "common:Owner": "ETSI", "common:Name": "PolicyAction", "common:Value": "PDSR" @@ -59,8 +59,8 @@ "ObjectIdentifier": "55e25c0a-787b-4049-b7fb-518a13a9483b", "CountryCode": "XX", "OwnerIdentifier": "ACTOR01", - "policy:TrafficPolicyName": "Template Rule 1", - "policy:TrafficRules": { + "tp:TrafficPolicyName": "Template Rule 1", + "tp:TrafficRules": { "policy:TrafficRuleReference": { "policy:Order": "1", "policy:ObjectIdentifier": "f69eb93b-a85b-4ff7-abaa-6f3aead286d5" diff --git a/103120/schema/json/ts_103120_Authorisation.schema.json b/103120/schema/json/ts_103120_Authorisation.schema.json index 942438fa..0fc3e10f 100644 --- a/103120/schema/json/ts_103120_Authorisation.schema.json +++ b/103120/schema/json/ts_103120_Authorisation.schema.json @@ -97,7 +97,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "AuthorisationFlags": { "type": "object", @@ -109,7 +110,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "AuthorisationTimespan": { "type": "object", @@ -121,7 +123,8 @@ "$ref": "ts_103280_2017_07#/$defs/QualifiedDateTime" } }, - "required": [] + "required": [], + "additionalProperties": false }, "AuthorisationCSPID": { "type": "object", @@ -134,7 +137,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "NationalAuthorisationParameters": { "type": "object", @@ -145,7 +149,8 @@ }, "required": [ "auth:CountryCode" - ] + ], + "additionalProperties": false } } } diff --git a/103120/schema/json/ts_103120_Common.schema.json b/103120/schema/json/ts_103120_Common.schema.json index d5c94ea2..21009361 100644 --- a/103120/schema/json/ts_103120_Common.schema.json +++ b/103120/schema/json/ts_103120_Common.schema.json @@ -23,7 +23,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "DictionaryEntry": { "type": "object", @@ -42,7 +43,8 @@ "common:Owner", "common:Name", "common:Value" - ] + ], + "additionalProperties": false }, "ApprovalDetails": { "type": "object", @@ -72,7 +74,8 @@ "$ref": "#/$defs/ApprovalNationalDetails" } }, - "required": [] + "required": [], + "additionalProperties": false }, "ApproverDetails": { "type": "object", @@ -93,7 +96,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "ApproverIdentity": { "oneOf": [ @@ -123,7 +127,8 @@ "$ref": "ts_103280_2017_07#/$defs/InternationalE164" } }, - "required": [] + "required": [], + "additionalProperties": false }, "NationalApproverIdentity": { "type": "object", @@ -134,7 +139,8 @@ }, "required": [ "common:CountryCode" - ] + ], + "additionalProperties": false }, "ApprovalDigitalSignature": { "oneOf": [ @@ -160,7 +166,8 @@ }, "required": [ "common:CountryCode" - ] + ], + "additionalProperties": false }, "NationalDigitalSignature": { "type": "object", @@ -171,7 +178,8 @@ }, "required": [ "common:CountryCode" - ] + ], + "additionalProperties": false } } } diff --git a/103120/schema/json/ts_103120_Core.schema.json b/103120/schema/json/ts_103120_Core.schema.json index 8ac79cfe..0b1d90f4 100644 --- a/103120/schema/json/ts_103120_Core.schema.json +++ b/103120/schema/json/ts_103120_Core.schema.json @@ -32,7 +32,13 @@ "required": [ "Header", "Payload" - ] + ], + "additionalProperties": false, + "patternProperties": { + "^@": { + "type": "string" + } + } }, "MessageHeader": { "type": "object", @@ -59,7 +65,8 @@ "TransactionIdentifier", "Timestamp", "Version" - ] + ], + "additionalProperties": false }, "Version": { "type": "object", @@ -78,7 +85,8 @@ "ETSIVersion", "NationalProfileOwner", "NationalProfileVersion" - ] + ], + "additionalProperties": false }, "EndpointID": { "type": "object", @@ -93,7 +101,8 @@ "required": [ "CountryCode", "UniqueIdentifier" - ] + ], + "additionalProperties": false }, "MessagePayload": { "oneOf": [ @@ -130,7 +139,8 @@ }, "required": [ "ActionRequests" - ] + ], + "additionalProperties": false }, "ActionRequests": { "type": "object", @@ -143,7 +153,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "ResponsePayload": { "oneOf": [ @@ -182,7 +193,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "ActionRequest": { "allOf": [ @@ -268,7 +280,8 @@ } ] } - ] + ], + "unevaluatedProperties": false }, "ActionResponse": { "allOf": [ @@ -365,7 +378,8 @@ } ] } - ] + ], + "unevaluatedProperties": false }, "GETRequest": { "type": "object", @@ -376,7 +390,8 @@ }, "required": [ "Identifier" - ] + ], + "additionalProperties": false }, "GETResponse": { "type": "object", @@ -387,7 +402,8 @@ }, "required": [ "HI1Object" - ] + ], + "additionalProperties": false }, "CREATERequest": { "type": "object", @@ -398,7 +414,8 @@ }, "required": [ "HI1Object" - ] + ], + "additionalProperties": false }, "CREATEResponse": { "type": "object", @@ -412,7 +429,8 @@ }, "required": [ "Identifier" - ] + ], + "additionalProperties": false }, "UPDATERequest": { "type": "object", @@ -423,7 +441,8 @@ }, "required": [ "HI1Object" - ] + ], + "additionalProperties": false }, "UPDATEResponse": { "type": "object", @@ -437,7 +456,8 @@ }, "required": [ "Identifier" - ] + ], + "additionalProperties": false }, "LISTRequest": { "type": "object", @@ -449,7 +469,8 @@ "$ref": "ts_103280_2017_07#/$defs/QualifiedDateTime" } }, - "required": [] + "required": [], + "additionalProperties": false }, "LISTResponse": { "type": "object", @@ -461,7 +482,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "ListResponseRecord": { "type": "object", @@ -493,7 +515,8 @@ "ObjectType", "Identifier", "Generation" - ] + ], + "additionalProperties": false }, "ActionUnsuccesfulInformation": { "type": "object", @@ -509,7 +532,8 @@ "required": [ "ErrorCode", "ErrorDescription" - ] + ], + "additionalProperties": false }, "DELIVERRequest": { "type": "object", @@ -524,7 +548,8 @@ "required": [ "Identifier", "HI1Object" - ] + ], + "additionalProperties": false }, "DELIVERResponse": { "type": "object", @@ -535,12 +560,14 @@ }, "required": [ "Identifier" - ] + ], + "additionalProperties": false }, "GETCSPCONFIGRequest": { "type": "object", "properties": {}, - "required": [] + "required": [], + "additionalProperties": false }, "GETCSPCONFIGResponse": { "type": "object", @@ -565,7 +592,8 @@ "required": [ "LastChanged", "TargetingConfigurations" - ] + ], + "additionalProperties": false }, "HI1Object": { "type": "object", @@ -598,7 +626,8 @@ }, "required": [ "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "AssociatedObjects": { "type": "object", @@ -610,7 +639,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "NationalHandlingParameters": { "type": "object", @@ -621,7 +651,8 @@ }, "required": [ "CountryCode" - ] + ], + "additionalProperties": false }, "ConcreteHI1Object": { "oneOf": [ diff --git a/103120/schema/json/ts_103120_Delivery.schema.json b/103120/schema/json/ts_103120_Delivery.schema.json index 6b417629..6ca0ffa2 100644 --- a/103120/schema/json/ts_103120_Delivery.schema.json +++ b/103120/schema/json/ts_103120_Delivery.schema.json @@ -65,7 +65,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "Reference": { "oneOf": [ @@ -129,7 +130,8 @@ "$ref": "#/$defs/ManifestContents" } }, - "required": [] + "required": [], + "additionalProperties": false }, "ManifestContents": { "oneOf": [ @@ -175,7 +177,8 @@ }, "required": [ "delivery:schema" - ] + ], + "additionalProperties": false }, "Delivery": { "oneOf": [ @@ -236,7 +239,8 @@ }, "required": [ "delivery:Data" - ] + ], + "additionalProperties": false }, "ListOfChecksumAndType": { "type": "object", diff --git a/103120/schema/json/ts_103120_Document.schema.json b/103120/schema/json/ts_103120_Document.schema.json index 3bc734ca..5adf5aa0 100644 --- a/103120/schema/json/ts_103120_Document.schema.json +++ b/103120/schema/json/ts_103120_Document.schema.json @@ -76,7 +76,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "DocumentTimespan": { "type": "object", @@ -88,7 +89,8 @@ "$ref": "ts_103280_2017_07#/$defs/QualifiedDateTime" } }, - "required": [] + "required": [], + "additionalProperties": false }, "DocumentProperties": { "type": "object", @@ -100,7 +102,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "DocumentProperty": { "type": "object", @@ -115,7 +118,8 @@ "required": [ "doc:PropertyType", "doc:PropertyValue" - ] + ], + "additionalProperties": false }, "DocumentBody": { "type": "object", @@ -134,7 +138,8 @@ "$ref": "ts_103280_2017_07#/$defs/ShortString" } }, - "required": [] + "required": [], + "additionalProperties": false }, "NationalDocumentParameters": { "type": "object", @@ -145,7 +150,8 @@ }, "required": [ "doc:CountryCode" - ] + ], + "additionalProperties": false } } } diff --git a/103120/schema/json/ts_103120_Notification.schema.json b/103120/schema/json/ts_103120_Notification.schema.json index aadb9890..3654fa3e 100644 --- a/103120/schema/json/ts_103120_Notification.schema.json +++ b/103120/schema/json/ts_103120_Notification.schema.json @@ -58,7 +58,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "ListOfAssociatedObjectStatus": { "type": "object", @@ -71,7 +72,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "AssociatedObjectStatus": { "type": "object", @@ -89,7 +91,8 @@ "required": [ "notification:AssociatedObject", "notification:Status" - ] + ], + "additionalProperties": false }, "NationalNotificationParameters": { "type": "object", @@ -100,7 +103,8 @@ }, "required": [ "notification:CountryCode" - ] + ], + "additionalProperties": false } } } diff --git a/103120/schema/json/ts_103120_Task.schema.json b/103120/schema/json/ts_103120_Task.schema.json index fc2ad0c0..5ced7ab9 100644 --- a/103120/schema/json/ts_103120_Task.schema.json +++ b/103120/schema/json/ts_103120_Task.schema.json @@ -85,7 +85,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "TaskTimespan": { "type": "object", @@ -106,7 +107,8 @@ "$ref": "ts_103280_2017_07#/$defs/QualifiedDateTime" } }, - "required": [] + "required": [], + "additionalProperties": false }, "TargetIdentifier": { "type": "object", @@ -121,7 +123,8 @@ "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntry" } }, - "required": [] + "required": [], + "additionalProperties": false }, "TargetIdentifierValues": { "type": "object", @@ -134,7 +137,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "TargetIdentifierValue": { "type": "object", @@ -149,7 +153,8 @@ "required": [ "task:FormatType", "task:Value" - ] + ], + "additionalProperties": false }, "FormatType": { "type": "object", @@ -164,7 +169,8 @@ "required": [ "task:FormatOwner", "task:FormatName" - ] + ], + "additionalProperties": false }, "TaskDeliveryDetails": { "type": "object", @@ -177,7 +183,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "DeliveryDestination": { "type": "object", @@ -201,7 +208,8 @@ "$ref": "#/$defs/NationalDeliveryParameters" } }, - "required": [] + "required": [], + "additionalProperties": false }, "DeliveryAddress": { "oneOf": [ @@ -338,7 +346,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "NationalLITaskingParameters": { "type": "object", @@ -349,7 +358,8 @@ }, "required": [ "task:CountryCode" - ] + ], + "additionalProperties": false }, "NationalDeliveryParameters": { "type": "object", @@ -360,7 +370,8 @@ }, "required": [ "task:CountryCode" - ] + ], + "additionalProperties": false }, "NationalEncryptionDetails": { "type": "object", @@ -371,7 +382,8 @@ }, "required": [ "task:CountryCode" - ] + ], + "additionalProperties": false }, "LDTaskObject": { "type": "object", @@ -450,7 +462,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "RequestDetails": { "type": "object", @@ -483,7 +496,8 @@ "$ref": "ts_103120_Common_2016_02#/$defs/DictionaryEntry" } }, - "required": [] + "required": [], + "additionalProperties": false }, "RequestValues": { "type": "object", @@ -496,7 +510,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "RequestValue": { "type": "object", @@ -511,7 +526,8 @@ "required": [ "task:FormatType", "task:Value" - ] + ], + "additionalProperties": false }, "RequestSubtype": { "type": "object", @@ -524,7 +540,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "LDDeliveryDetails": { "type": "object", @@ -537,7 +554,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "LDDeliveryDestination": { "type": "object", @@ -558,7 +576,8 @@ "$ref": "#/$defs/NationalDeliveryParameters" } }, - "required": [] + "required": [], + "additionalProperties": false }, "LDTaskFlags": { "type": "object", @@ -570,7 +589,8 @@ } } }, - "required": [] + "required": [], + "additionalProperties": false }, "ListOfAlternativePreservationReferences": { "type": "object", @@ -583,7 +603,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "AlternativePreservationReference": { "type": "object", @@ -597,7 +618,8 @@ }, "required": [ "task:ReferenceValue" - ] + ], + "additionalProperties": false }, "NationalLDTaskingParameters": { "type": "object", @@ -608,7 +630,8 @@ }, "required": [ "task:CountryCode" - ] + ], + "additionalProperties": false }, "LPTaskObject": { "type": "object", @@ -672,7 +695,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "LPRequestDetails": { "type": "object", @@ -693,7 +717,8 @@ "$ref": "#/$defs/RequestSubtype" } }, - "required": [] + "required": [], + "additionalProperties": false }, "NationalLPTaskingParameters": { "type": "object", @@ -704,7 +729,8 @@ }, "required": [ "task:CountryCode" - ] + ], + "additionalProperties": false }, "ListOfTrafficPolicyReferences": { "type": "object", @@ -717,7 +743,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "TrafficPolicyReference": { "type": "object", @@ -730,7 +757,8 @@ "$ref": "ts_103120_Core_2019_10#/$defs/ObjectIdentifier" } }, - "required": [] + "required": [], + "additionalProperties": false } } } diff --git a/103120/schema/json/ts_103120_TrafficPolicy.schema.json b/103120/schema/json/ts_103120_TrafficPolicy.schema.json index ef30ccae..b209a838 100644 --- a/103120/schema/json/ts_103120_TrafficPolicy.schema.json +++ b/103120/schema/json/ts_103120_TrafficPolicy.schema.json @@ -46,7 +46,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "ListOfTrafficRuleReferences": { "type": "object", @@ -59,7 +60,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "TrafficRuleReference": { "type": "object", @@ -75,7 +77,8 @@ "required": [ "tp:Order", "tp:ObjectIdentifier" - ] + ], + "additionalProperties": false }, "TrafficRuleObject": { "type": "object", @@ -124,7 +127,8 @@ "required": [ "@xsi:type", "ObjectIdentifier" - ] + ], + "additionalProperties": false }, "ListOfTrafficCriteria": { "type": "object", @@ -137,7 +141,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "TrafficCriteria": { "oneOf": [ @@ -210,7 +215,8 @@ "type": "boolean" } }, - "required": [] + "required": [], + "additionalProperties": false }, "MobileAccessPolicyCriteria": { "type": "object", @@ -222,7 +228,8 @@ "$ref": "ts_103280_2017_07#/$defs/ShortString" } }, - "required": [] + "required": [], + "additionalProperties": false }, "EthernetPolicyCriteria": { "type": "object", @@ -240,7 +247,8 @@ "$ref": "#/$defs/VLANCriteria" } }, - "required": [] + "required": [], + "additionalProperties": false }, "VLANCriteria": { "oneOf": [ @@ -268,7 +276,8 @@ "minItems": 1 } }, - "required": [] + "required": [], + "additionalProperties": false }, "RCSPolicyCriteria": { "type": "object", @@ -279,7 +288,8 @@ }, "required": [ "tp:CommunicationServiceID" - ] + ], + "additionalProperties": false }, "ActionParameters": { "oneOf": [ @@ -309,7 +319,8 @@ }, "required": [ "tp:NumberOfOctets" - ] + ], + "additionalProperties": false } } } diff --git a/utils/translate/ChoiceMapping.py b/utils/translate/ChoiceMapping.py index b477a336..052bd45e 100644 --- a/utils/translate/ChoiceMapping.py +++ b/utils/translate/ChoiceMapping.py @@ -44,4 +44,6 @@ class ChoiceMapping(ComplexTypeMapping): if (content.model != 'choice'): log.debug("Not a choice, giving up") return None - return { 'oneOf' : ChoiceMapping.process_choice(content, xst.namespaces[''], self.ns_to_id_map)} + return { + 'oneOf' : ChoiceMapping.process_choice(content, xst.namespaces[''], self.ns_to_id_map) + } diff --git a/utils/translate/SequenceMapping.py b/utils/translate/SequenceMapping.py index 341ac514..9932c466 100644 --- a/utils/translate/SequenceMapping.py +++ b/utils/translate/SequenceMapping.py @@ -26,7 +26,8 @@ class SequenceMapping(ComplexTypeMapping): mapped_type = { 'type' : 'object', 'properties' : {}, - 'required' : [] + 'required' : [], + 'additionalProperties' : False, } # Not going to try and do all of this automatically for now @@ -75,11 +76,17 @@ class SequenceMapping(ComplexTypeMapping): else: raise Exception(f"Unknown element type {c}") if (inner_choice): + for inner_thing in inner_choice: + inner_thing.pop('additionalProperties', None) + mapped_type.pop('additionalProperties', None) return { 'allOf' : [ mapped_type, - {'oneOf' : inner_choice} - ] + { + 'oneOf' : inner_choice + } + ], + 'unevaluatedProperties' : False } else: return mapped_type diff --git a/utils/translate_spec.py b/utils/translate_spec.py index e950b4ae..f2008595 100644 --- a/utils/translate_spec.py +++ b/utils/translate_spec.py @@ -83,9 +83,10 @@ if __name__ == "__main__": continue js = translate_schema(schema_tuple[1], ns_map, schema_locations) - # TODO - Special case, get rid of XML Dsig signature and insert JSON signature + # Special case, get rid of XML Dsig signature and insert JSON signature, and XML attrib pattern property if schema_tuple[0] == 'http://uri.etsi.org/03120/common/2019/10/Core': logging.info ("Modifying signature elements") + js['$defs']['HI1Message']['patternProperties'] = { "^@" : { "type" : "string"}} js['$defs']['HI1Message']['properties'].pop('xmldsig:Signature') js['$defs']['HI1Message']['properties']['Signature'] = json_signature_struct -- GitLab From 2f3892a8d55d6234e089f7900def15afc18020da Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 14 Oct 2024 12:38:06 +0100 Subject: [PATCH 2/2] Hack to fix TP criteria coercion to list --- .../json/request7-TrafficPolicyObject.json | 31 ++++++++---- .../xml/request7_TrafficPolicyObject.xml | 49 +++++++++++-------- 103280/TS_103_280.schema.json | 2 +- utils/xml_to_json.py | 25 +++++++++- 4 files changed, 73 insertions(+), 34 deletions(-) diff --git a/103120/examples/json/request7-TrafficPolicyObject.json b/103120/examples/json/request7-TrafficPolicyObject.json index 0e6ca37d..be0fc884 100644 --- a/103120/examples/json/request7-TrafficPolicyObject.json +++ b/103120/examples/json/request7-TrafficPolicyObject.json @@ -3,7 +3,7 @@ "@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "@xmlns:common": "http://uri.etsi.org/03120/common/2016/02/Common", "@xmlns:tp": "http://uri.etsi.org/03120/common/2022/07/TrafficPolicy", - "@xmlns:etsi": "http://uri.etsi.org/03280/common/2017/07", + "@xmlns:etsi280": "http://uri.etsi.org/03280/common/2017/07", "@xmlns:task": "http://uri.etsi.org/03120/common/2020/09/Task", "Header": { "SenderIdentifier": { @@ -35,13 +35,22 @@ "CountryCode": "XX", "OwnerIdentifier": "ACTOR01", "tp:Criteria": { - "tp:Criteria": [{ - "tp:IPPolicyCriteria": { - "tp:SourceIPRange": { - "etsi:IPv4CIDR": "203.0.113.0/24" + "tp:Criteria": [ + { + "tp:IPPolicyCriteria": { + "tp:SourceIPRange": { + "etsi280:IPv4CIDR": "203.0.113.0/24" + } + } + }, + { + "tp:IPPolicyCriteria": { + "tp:SourceIPRange": { + "etsi280:IPv4CIDR": "203.0.113.0/24" + } } } - }] + ] }, "tp:Action": { "common:Owner": "ETSI", @@ -61,10 +70,12 @@ "OwnerIdentifier": "ACTOR01", "tp:TrafficPolicyName": "Template Rule 1", "tp:TrafficRules": { - "policy:TrafficRuleReference": { - "policy:Order": "1", - "policy:ObjectIdentifier": "f69eb93b-a85b-4ff7-abaa-6f3aead286d5" - } + "tp:TrafficRuleReference": [ + { + "tp:Order": 1, + "tp:ObjectIdentifier": "f69eb93b-a85b-4ff7-abaa-6f3aead286d5" + } + ] } } } diff --git a/103120/examples/xml/request7_TrafficPolicyObject.xml b/103120/examples/xml/request7_TrafficPolicyObject.xml index 7ee2e5ef..bbcd6881 100644 --- a/103120/examples/xml/request7_TrafficPolicyObject.xml +++ b/103120/examples/xml/request7_TrafficPolicyObject.xml @@ -1,5 +1,5 @@ - +
XX @@ -23,41 +23,48 @@ 0 - + f69eb93b-a85b-4ff7-abaa-6f3aead286d5 XX ACTOR01 - - - - - 203.0.113.0/24 - - - - - + + + + + 203.0.113.0/24 + + + + + + + 203.0.113.0/24 + + + + + ETSI PolicyAction PDSR - + 1 - + 55e25c0a-787b-4049-b7fb-518a13a9483b XX ACTOR01 - Template Rule 1 - - - 1 - f69eb93b-a85b-4ff7-abaa-6f3aead286d5 - - + Template Rule 1 + + + 1 + f69eb93b-a85b-4ff7-abaa-6f3aead286d5 + + diff --git a/103280/TS_103_280.schema.json b/103280/TS_103_280.schema.json index aa63f818..b6824a99 100644 --- a/103280/TS_103_280.schema.json +++ b/103280/TS_103_280.schema.json @@ -56,7 +56,7 @@ }, "IPv4CIDR": { "type": "string", - "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])/([1-2]?[0-9]|3[0-2])$" + "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\/([1-2]?[0-9]|3[0-2])$" }, "IPv6Address": { "type": "string", diff --git a/utils/xml_to_json.py b/utils/xml_to_json.py index 86f8ad7e..e9609c79 100644 --- a/utils/xml_to_json.py +++ b/utils/xml_to_json.py @@ -80,6 +80,7 @@ coerce_to_int = [ 'task:Order', 'ErrorCode', 'Generation', + 'tp:Order' ] coerce_to_bool = [ @@ -115,6 +116,20 @@ def postprocessor (path, key, value): return key, {} return key, value +def recursively_fix_tpcriteria (d: dict): + if isinstance(d, dict): + if ("tp:Criteria" in d + and isinstance(d["tp:Criteria"], list) + and len(d["tp:Criteria"]) == 1 + ): + d["tp:Criteria"] = d["tp:Criteria"][0] + else: + for k,v in d.items(): + recursively_fix_tpcriteria(v) + elif isinstance(d, list): + for d_item in d: + recursively_fix_tpcriteria(d_item) + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('-v', '--verbose', action='count', help='Verbose logging (can be specified multiple times)') @@ -132,7 +147,7 @@ if __name__ == "__main__": logging.debug(f"Arguments: {args}") s = args.input.read() - args.input.close() + args.input.close() logging.debug(s) @@ -141,4 +156,10 @@ if __name__ == "__main__": postprocessor=postprocessor )['HI1Message'] - print(json.dumps(d, indent=2)) + # HACK + # Needed because TrafficPolicy.xsd has two nested fields both called tp:Criteria + # but only the outer one needs to be coerced into a list + recursively_fix_tpcriteria(d) + out_str = json.dumps(d, indent=2) + + print(out_str) -- GitLab