@@ -76,30 +76,24 @@ def path_to_type_name(path):
7676 return name
7777
7878
79- def validate (schema , json_file , root_type = None , json_tweaks_callback = None ):
79+ def validate (schema , json_file , json_tweaks_callback = None ):
8080 """Validate a JSON file against an ASN.1 schema.
8181
82+ The root type for decoding is determined as follows:
83+ - If the schema contains "TestCase", use that type
84+ - Otherwise, derive the type from the filename (e.g., "my_type.json" → "MyType")
85+
8286 Args:
8387 schema: Compiled ASN.1 schema
8488 json_file: Path to JSON file to validate
85- root_type_name: Optional schema type name to be used to parse the json_file
8689 json_tweaks_callback: Optional callback to modify JSON before validation
87-
88- If the `root_type_name` arg is None or is not present in the schema, then the root
89- type for decoding is determined as follows:
90- - If the schema contains "TestCase", use that type
91- - Otherwise, derive the type from the filename (e.g., "my_type.json" → "MyType")
92-
9390 """
94- print ("* Validating:" , json_file )
95-
9691 # Determine root type used for decoding
97- if root_type is None :
98- if "TestCase" in schema .types :
99- root_type = "TestCase"
100- else :
101- # Auto-detect root type from filename
102- root_type = path_to_type_name (json_file )
92+ if "TestCase" in schema .types :
93+ root_type = "TestCase"
94+ else :
95+ # Auto-detect root type from filename
96+ root_type = path_to_type_name (json_file )
10397
10498 # Read and prepare JSON
10599 with open (json_file , "rb" ) as f :
@@ -127,7 +121,7 @@ def validate_group(group_name, group_schema, spec_name, json_tweaks_callback=Non
127121 Args:
128122 group_name: Name of the validation group (for display)
129123 group_schema: ASN.1 schema file name (or None for base schema only)
130- spec_name: Specification name ("tiny", "full")
124+ spec_name: Specification name ("tiny", "full", or "data" )
131125 json_tweaks_callback: Optional callback to modify JSON before validation
132126 """
133127 print (f"\n [Validating { group_name } ({ spec_name } )]" )
@@ -140,4 +134,5 @@ def validate_group(group_name, group_schema, spec_name, json_tweaks_callback=Non
140134 # Compile schema and validate all JSON files
141135 schema = asn1tools .compile_files (schema_files , codec = "jer" )
142136 for json_file in glob .glob (f"{ spec_name } /*.json" ):
143- validate (schema , json_file , None , json_tweaks_callback )
137+ print ("* Validating:" , json_file )
138+ validate (schema , json_file , json_tweaks_callback )
0 commit comments