Skip to content

Commit 8660a13

Browse files
authored
Merge pull request #241 from pedro-cf/pagination-links-issue
Always generate links for all searches
2 parents f797ed4 + bff0152 commit 8660a13

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixed issue where searches return an empty `links` array [#241](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/241)
1013

1114
## [v2.4.0]
1215

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ async def item_collection(
318318
if maybe_count is not None:
319319
context_obj["matched"] = maybe_count
320320

321-
links = []
322-
if next_token:
323-
links = await PagingLinks(request=request, next=next_token).get_links()
321+
links = await PagingLinks(request=request, next=next_token).get_links()
324322

325323
return ItemCollection(
326324
type="FeatureCollection",
@@ -619,9 +617,7 @@ async def post_search(
619617
if maybe_count is not None:
620618
context_obj["matched"] = maybe_count
621619

622-
links = []
623-
if next_token:
624-
links = await PagingLinks(request=request, next=next_token).get_links()
620+
links = await PagingLinks(request=request, next=next_token).get_links()
625621

626622
return ItemCollection(
627623
type="FeatureCollection",

stac_fastapi/tests/resources/test_item.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,15 @@ async def test_get_missing_item_collection(app_client):
570570
assert resp.status_code == 404
571571

572572

573+
@pytest.mark.asyncio
574+
async def test_pagination_base_links(app_client, ctx):
575+
"""Test that a search query always contains basic links"""
576+
page = await app_client.get(f"/collections/{ctx.item['collection']}/items")
577+
578+
page_data = page.json()
579+
assert {"self", "root"}.issubset({link["rel"] for link in page_data["links"]})
580+
581+
573582
@pytest.mark.asyncio
574583
async def test_pagination_item_collection(app_client, ctx, txn_client):
575584
"""Test item collection pagination links (paging extension)"""

0 commit comments

Comments
 (0)