diff --git a/import_specifications/schema/dts_manifest.json b/import_specifications/schema/dts_manifest.json index 07578596..1bf6dc80 100644 --- a/import_specifications/schema/dts_manifest.json +++ b/import_specifications/schema/dts_manifest.json @@ -6,7 +6,10 @@ "instructions": { "type": "object", "properties": { - "protocol": {"type": "string"}, + "protocol": { + "type": "string", + "const": "KBase narrative import" + }, "objects": { "type": "array", "items": { @@ -15,17 +18,14 @@ "data_type": {"type": "string"}, "parameters": { "type": "object", - "patternProperties": { - ".*": { - "oneOf": [ - {"type": "string"}, - {"type": "number"}, - {"type": "boolean"}, - {"type": "null"} - ] - } - }, - "additionalProperties": false + "additionalProperties": { + "oneOf": [ + {"type": "string"}, + {"type": "number"}, + {"type": "boolean"}, + {"type": "null"} + ] + } } }, "required": ["data_type", "parameters"] diff --git a/staging_service/import_specifications/individual_parsers.py b/staging_service/import_specifications/individual_parsers.py index c3f4b0c5..f5ca0b64 100644 --- a/staging_service/import_specifications/individual_parsers.py +++ b/staging_service/import_specifications/individual_parsers.py @@ -359,22 +359,9 @@ def parse_dts_manifest(path: Path, dts_manifest_schema: dict) -> ParseResults: validator = jsonschema.Draft202012Validator(dts_manifest_schema) for err in validator.iter_errors(manifest_json): err_str = err.message - err_path = err.absolute_path + err_path = list(err.absolute_path) if err_path: - # paths can look like, say, ["instructions", "objects", 0, "data_type"] - # convert that '0' to "item 0" to be slightly more readable to users. - # kind of a mouthful below, but does that conversion in place - # The error above gets translated into: - # " at instructions/objects/item 0/data_type" - # - # Another example would be if the path is just ["instructions"] and it's missing - # a property, the error might be: - # "missing property 'foo' for 'instructions'" - err_path = [f"item {elem}" if isinstance(elem, int) else elem for elem in err_path] - prep = "for" - if len(err_path) > 1: - prep = "at" - err_str += f" {prep} {'/'.join(err_path)}" + err_str += f" at {err_path}" errors.append(Error(ErrorType.PARSE_FAIL, err_str, spcsrc)) except jsonschema.exceptions.SchemaError: return _error(Error(ErrorType.OTHER, "Manifest schema is invalid", spcsrc)) diff --git a/tests/import_specifications/test_individual_parsers.py b/tests/import_specifications/test_individual_parsers.py index 4ef05d8b..87a63d41 100644 --- a/tests/import_specifications/test_individual_parsers.py +++ b/tests/import_specifications/test_individual_parsers.py @@ -926,7 +926,7 @@ def test_dts_manifest_fail_with_path( [ Error( ErrorType.PARSE_FAIL, - "'data_type' is a required property at instructions/objects/item 1", + "'data_type' is a required property at ['instructions', 'objects', 1]", SpecificationSource(manifest_path), ) ],