Skip to content

Commit 2d6cb4d

Browse files
authored
Updating collection self link for collections page. (stac-utils#297)
**Related Issue(s):** - stac-utils#296 **Description:** Updating `CollectionLinks` to generate correct `self` link for `collections` endpoint. **PR Checklist:** - [x] Code is formatted and linted (run `pre-commit run --all-files`) - [x] Tests pass (run `make test`) - [x] Documentation has been updated to reflect changes, if applicable - [x] Changes are added to the changelog
1 parent c25229e commit 2d6cb4d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313

1414
### Changed
1515

16+
- Updated CollectionLinks to generate correct `self` link for collections endpoint. [#297](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/297)
1617
- Refactored aggregation in database logic. [#294](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/294)
1718
- Fixed the `self` link for the `/collections/{collection_id}/aggregations` endpoint. [#295](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/295)
1819

stac_fastapi/core/stac_fastapi/core/models/links.py

+8
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ class CollectionLinks(BaseLinks):
114114
collection_id: str = attr.ib()
115115
extensions: List[str] = attr.ib(default=attr.Factory(list))
116116

117+
def link_self(self) -> Dict:
118+
"""Return the self link."""
119+
return dict(
120+
rel=Relations.self.value,
121+
type=MimeTypes.json.value,
122+
href=urljoin(self.base_url, f"collections/{self.collection_id}"),
123+
)
124+
117125
def link_parent(self) -> Dict[str, Any]:
118126
"""Create the `parent` link."""
119127
return dict(rel=Relations.parent, type=MimeTypes.json.value, href=self.base_url)

0 commit comments

Comments
 (0)