Commit 1684e444 authored by Mark Canterbury's avatar Mark Canterbury Committed by Mark Canterbury
Browse files

Reverting non-120 changes

parent c44ed9c3
Loading
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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)}
+3 −10
Original line number Diff line number Diff line
@@ -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
+1 −2
Original line number Diff line number Diff line
@@ -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

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