diff --git a/utils/translate/ChoiceMapping.py b/utils/translate/ChoiceMapping.py index 052bd45e3ceb987f0ebe18556f6afad2df9c6789..b477a3360e0a6a7b891f5854951eb4f37dce4b39 100644 --- a/utils/translate/ChoiceMapping.py +++ b/utils/translate/ChoiceMapping.py @@ -44,6 +44,4 @@ 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 9932c4667e9178a387f7b0ccddc3fe29cd942d6e..341ac51469a8b0f9ad5fd0c66ae9c45aac93f277 100644 --- a/utils/translate/SequenceMapping.py +++ b/utils/translate/SequenceMapping.py @@ -26,8 +26,7 @@ class SequenceMapping(ComplexTypeMapping): mapped_type = { 'type' : 'object', 'properties' : {}, - 'required' : [], - 'additionalProperties' : False, + 'required' : [] } # Not going to try and do all of this automatically for now @@ -76,17 +75,11 @@ 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 - } - ], - 'unevaluatedProperties' : False + {'oneOf' : inner_choice} + ] } else: return mapped_type diff --git a/utils/translate_spec.py b/utils/translate_spec.py index f2008595106b4edd7c606e6af9a5250c4bc7f15b..e950b4ae12cbd09066593774f8b560a2805cce4d 100644 --- a/utils/translate_spec.py +++ b/utils/translate_spec.py @@ -83,10 +83,9 @@ if __name__ == "__main__": continue js = translate_schema(schema_tuple[1], ns_map, schema_locations) - # Special case, get rid of XML Dsig signature and insert JSON signature, and XML attrib pattern property + # TODO - Special case, get rid of XML Dsig signature and insert JSON signature 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 diff --git a/utils/xml_to_json.py b/utils/xml_to_json.py index 3b8e6a107cfa254c3a6a9dbe6933dab076dd1544..86f8ad7ec394603683a3ce6fccd7a4e16aad330d 100644 --- a/utils/xml_to_json.py +++ b/utils/xml_to_json.py @@ -80,7 +80,6 @@ coerce_to_int = [ 'task:Order', 'ErrorCode', 'Generation', - 'tp:Order' ] coerce_to_bool = [ @@ -116,20 +115,6 @@ 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)') @@ -156,10 +141,4 @@ if __name__ == "__main__": postprocessor=postprocessor )['HI1Message'] - # 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) + print(json.dumps(d, indent=2))