Skip to content

Commit a93bbec

Browse files
authored
Merge pull request #44 from stac-extensions/fix-dlm-mlm-prefix
2 parents 443d32b + b750dec commit a93bbec

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- n/a
2121

2222
### Fixed
23-
- n/a
23+
- Fix check of disallowed unknown/undefined `mlm:`-prefixed fields
24+
(fixes [#41](https://github.com/stac-extensions/mlm/issues/41)).
2425

2526
## [v1.3.0](https://github.com/stac-extensions/mlm/tree/v1.3.0)
2627

json-schema/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
},
315315
"$comment": "Allow properties not defined by MLM prefix to allow combination with other extensions.",
316316
"patternProperties": {
317-
"^(?!dlm:)": {}
317+
"^(?!mlm:)": {}
318318
},
319319
"additionalProperties": false
320320
},

tests/test_schema.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ def test_mlm_schema(
2727
assert SCHEMA_URI in validated
2828

2929

30+
@pytest.mark.parametrize(
31+
"mlm_example",
32+
["item_raster_bands.json"],
33+
indirect=True,
34+
)
35+
def test_mlm_no_undefined_prefixed_field(
36+
mlm_validator: STACValidator,
37+
mlm_example: Dict[str, JSON],
38+
) -> None:
39+
mlm_data = copy.deepcopy(mlm_example)
40+
mlm_item = pystac.Item.from_dict(mlm_data)
41+
pystac.validation.validate(mlm_item, validator=mlm_validator) # ensure original is valid
42+
43+
mlm_data["properties"]["mlm:unknown"] = "random" # type: ignore
44+
with pytest.raises(pystac.errors.STACValidationError) as exc:
45+
mlm_item = pystac.Item.from_dict(mlm_data)
46+
pystac.validation.validate(mlm_item, validator=mlm_validator)
47+
assert all(
48+
field in str(exc.value.source)
49+
for field in ["mlm:unknown", "^(?!mlm:)"]
50+
)
51+
52+
3053
@pytest.mark.parametrize(
3154
"mlm_example",
3255
["item_raster_bands.json"],

0 commit comments

Comments
 (0)