Skip to content

Commit 8f7590f

Browse files
authored
Add id to path item collection (#263)
* Fixed missing item id in the url path with --item-collection output
1 parent 23a0c9d commit 8f7590f

File tree

4 files changed

+196
-293
lines changed

4 files changed

+196
-293
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
66

77
## [Unreleased]
88

9+
### Added
10+
11+
### Changed
12+
13+
### Removed
14+
15+
## [v3.9.2] - 2025-06-18
16+
17+
### Fixed
18+
- Fixed missing item id in the url path with --item-collection output [#263](https://github.com/stac-utils/stac-validator/pull/263)
919

1020
## [v3.9.1] - 2025-06-13
1121

@@ -272,7 +282,8 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
272282
- With the newest version - 1.0.0-beta.2 - items will run through jsonchema validation before the PySTAC validation. The reason for this is that jsonschema will give more informative error messages. This should be addressed better in the future. This is not the case with the --recursive option as time can be a concern here with larger collections.
273283
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.
274284

275-
[Unreleased]: https://github.com/sparkgeo/stac-validator/compare/v3.9.1..main
285+
[Unreleased]: https://github.com/sparkgeo/stac-validator/compare/v3.9.2..main
286+
[v3.9.2]: https://github.com/sparkgeo/stac-validator/compare/v3.9.1..v3.9.2
276287
[v3.9.1]: https://github.com/sparkgeo/stac-validator/compare/v3.9.0..v3.9.1
277288
[v3.9.0]: https://github.com/sparkgeo/stac-validator/compare/v3.8.1..v3.9.0
278289
[v3.8.1]: https://github.com/sparkgeo/stac-validator/compare/v3.8.0..v3.8.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup
44

5-
__version__ = "3.9.1"
5+
__version__ = "3.9.2"
66

77
with open("README.md", "r") as fh:
88
long_description = fh.read()

stac_validator/validate.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,22 @@ def validate_item_collection_dict(self, item_collection: Dict) -> None:
681681
Args:
682682
item_collection (dict): The dictionary representation of the item collection.
683683
"""
684+
# Store the original stac_file to restore it later
685+
original_stac_file = self.stac_file
686+
684687
for item in item_collection["features"]:
688+
# Update the path to include the item ID for better traceability
689+
if isinstance(original_stac_file, str) and "id" in item:
690+
# Remove any query string from the URL before appending the item ID
691+
base_url = original_stac_file.split("?")[0]
692+
self.stac_file = f"{base_url}/{item['id']}"
693+
685694
self.schema = ""
686695
self.validate_dict(item)
687696

697+
# Restore the original stac_file
698+
self.stac_file = original_stac_file
699+
688700
def validate_collections(self) -> None:
689701
"""
690702
Validate STAC Collections from a /collections endpoint.

0 commit comments

Comments
 (0)