Skip to content

Commit 970f610

Browse files
committed
Merge branch 'norm-type' of github.com:stac-extensions/mlm into norm-type
2 parents 0cc32e9 + 1bbb828 commit 970f610

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
Otherwise, the amount of `value_scaling` objects should match the number of bands or channels involved in the input.
3535

3636
### Fixed
37-
- n/a
37+
- Fix check of disallowed unknown/undefined `mlm:`-prefixed fields
38+
(fixes [#41](https://github.com/stac-extensions/mlm/issues/41)).
3839

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ unavailable from [Band Statistics][stac-1.1-stats], such as `value`-specific sca
352352

353353
| Field Name | Type | Description |
354354
|------------|--------|----------------------------------------------------------------------------------------------------------------------------------------|
355-
| name | string | **REQUIRED** Name of the band referring to an extended band definition (see [Bands](#bands-and-statistics). |
355+
| name | string | **REQUIRED** Name of the band referring to an extended band definition (see [Bands](#bands-and-statistics) details). |
356356
| format | string | The type of expression that is specified in the `expression` property. |
357357
| expression | \* | An expression compliant with the `format` specified. The expression can be applied to any data type and depends on the `format` given. |
358358

best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ A potential representation of a STAC Asset could be as follows:
116116
Furthermore, the STAC Item representing the derived product could also include
117117
a [Link Object](https://github.com/radiantearth/stac-spec/tree/master/item-spec/item-spec.md#link-object)
118118
referring back to the MLM definition using `rel: derived_from`, as described in
119-
[MLM Relation Types](README.md#relation-types). Such a link would like something like the following:
119+
[MLM Relation Types](README.md#relation-types). Such a link would look something like the following:
120120

121121
```json
122122
{

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)