diff --git a/CHANGELOG.md b/CHANGELOG.md index 75d12221..e6fd124f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed +- Updated CollectionLinks to generate correct `self` link for collections endpoint. [#297](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/297) - Refactored aggregation in database logic. [#294](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/294) - Fixed the `self` link for the `/collections/{collection_id}/aggregations` endpoint. [#295](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/295) diff --git a/stac_fastapi/core/stac_fastapi/core/models/links.py b/stac_fastapi/core/stac_fastapi/core/models/links.py index f12ad98f..76f0ce5b 100644 --- a/stac_fastapi/core/stac_fastapi/core/models/links.py +++ b/stac_fastapi/core/stac_fastapi/core/models/links.py @@ -114,6 +114,14 @@ class CollectionLinks(BaseLinks): collection_id: str = attr.ib() extensions: List[str] = attr.ib(default=attr.Factory(list)) + def link_self(self) -> Dict: + """Return the self link.""" + return dict( + rel=Relations.self.value, + type=MimeTypes.json.value, + href=urljoin(self.base_url, f"collections/{self.collection_id}"), + ) + def link_parent(self) -> Dict[str, Any]: """Create the `parent` link.""" return dict(rel=Relations.parent, type=MimeTypes.json.value, href=self.base_url)