Commit 31c2d9f0 authored by Mark Canterbury's avatar Mark Canterbury
Browse files

Fixing merge conflict

parents f883ca8c 4eb7ec5f
Loading
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -279,7 +279,8 @@
      "required": [
        "etsi280:start",
        "etsi280:end"
      ]
      ],
      "additionalProperties": false
    },
    "UDPPortRange": {
      "type": "object",
@@ -294,7 +295,8 @@
      "required": [
        "etsi280:start",
        "etsi280:end"
      ]
      ],
      "additionalProperties": false
    },
    "Port": {
      "oneOf": [
@@ -361,7 +363,8 @@
      "required": [
        "etsi280:address",
        "etsi280:port"
      ]
      ],
      "additionalProperties": false
    },
    "IPAddressPortRange": {
      "type": "object",
@@ -376,7 +379,8 @@
      "required": [
        "etsi280:address",
        "etsi280:portRange"
      ]
      ],
      "additionalProperties": false
    },
    "WGS84CoordinateDecimal": {
      "type": "object",
@@ -391,7 +395,8 @@
      "required": [
        "etsi280:latitude",
        "etsi280:longitude"
      ]
      ],
      "additionalProperties": false
    },
    "WGS84CoordinateAngular": {
      "type": "object",
@@ -406,7 +411,8 @@
      "required": [
        "etsi280:latitude",
        "etsi280:longitude"
      ]
      ],
      "additionalProperties": false      
    },
    "H323URI": {
      "type": "string",
+3 −1
Original line number Diff line number Diff line
@@ -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)
                }
+10 −3
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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

+22 −1
Original line number Diff line number Diff line
@@ -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)')
@@ -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)