Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## [5.0.1] - 2025-03-27

### Fixed

- fix media type for `self` links in `/search` responses

## [5.0.0] - 2025-03-10

### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.0
5.0.1
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ignore = [


[tool.bumpversion]
current_version = "5.0.0"
current_version = "5.0.1"
parse = """(?x)
(?P<major>\\d+)\\.
(?P<minor>\\d+)\\.
Expand Down
11 changes: 11 additions & 0 deletions stac_fastapi/pgstac/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ItemCollectionLinks,
ItemLinks,
PagingLinks,
SearchLinks,
)
from stac_fastapi.pgstac.types.search import PgstacSearch
from stac_fastapi.pgstac.utils import filter_fields
Expand Down Expand Up @@ -466,6 +467,11 @@ async def post_search(
if fields.include or fields.exclude:
return JSONResponse(item_collection) # type: ignore

links = await SearchLinks(request=request).get_links(
extra_links=item_collection["links"]
)
item_collection["links"] = links

return ItemCollection(**item_collection)

async def get_search(
Expand Down Expand Up @@ -522,6 +528,11 @@ async def get_search(

item_collection = await self._search_base(search_request, request=request)

links = await SearchLinks(request=request).get_links(
extra_links=item_collection["links"]
)
item_collection["links"] = links

# If we have the `fields` extension enabled
# we need to avoid Pydantic validation because the
# Items might not be a valid STAC Item objects
Expand Down
13 changes: 13 additions & 0 deletions stac_fastapi/pgstac/models/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ def link_items(self) -> Dict:
}


@attr.s
class SearchLinks(BaseLinks):
"""Create inferred links specific to collections."""

def link_self(self) -> Dict:
"""Return the self link."""
return {
"rel": Relations.self.value,
"type": MimeTypes.geojson.value,
"href": self.resolve("search"),
}


@attr.s
class ItemCollectionLinks(CollectionLinksBase):
"""Create inferred links specific to collections."""
Expand Down
2 changes: 1 addition & 1 deletion stac_fastapi/pgstac/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""library version."""

__version__ = "5.0.0"
__version__ = "5.0.1"
19 changes: 19 additions & 0 deletions tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,3 +1662,22 @@ async def test_get_filter_extension(app_client, load_test_data, load_test_collec
fc = resp.json()
assert len(fc["features"]) == 1
assert fc["features"][0]["id"] == search_id


async def test_get_search_link_media(app_client):
"""Test Search request returned links"""
# GET
resp = await app_client.get("/search")
assert resp.status_code == 200
links = resp.json()["links"]
assert len(links) == 2
get_self_link = next((link for link in links if link["rel"] == "self"), None)
assert get_self_link["type"] == "application/geo+json"

# POST
resp = await app_client.post("/search", json={})
assert resp.status_code == 200
links = resp.json()["links"]
assert len(links) == 2
get_self_link = next((link for link in links if link["rel"] == "self"), None)
assert get_self_link["type"] == "application/geo+json"