Skip to content

Commit c71a355

Browse files
[Patch] forward prefix to ItemCollectionFilterExtension.router (#796)
* forward `prefix` to `ItemCollectionFilterExtension.router` * Bump version: 5.0.1 → 5.0.2
1 parent 00cb445 commit c71a355

File tree

8 files changed

+38
-5
lines changed

8 files changed

+38
-5
lines changed

CHANGES.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## [Unreleased]
44

5+
## [5.0.2] - 2025-01-30
6+
7+
### Fixed
8+
9+
- forward `prefix` to `ItemCollectionFilterExtension.router`
10+
511
## [5.0.1] - 2025-01-30
612

713
### Fixed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.0.1
1+
5.0.2

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ section-order = ["future", "standard-library", "third-party", "first-party", "lo
2424
quote-style = "double"
2525

2626
[tool.bumpversion]
27-
current_version = "5.0.1"
27+
current_version = "5.0.2"
2828
parse = """(?x)
2929
(?P<major>\\d+)\\.
3030
(?P<minor>\\d+)\\.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Library version."""
22

3-
__version__ = "5.0.1"
3+
__version__ = "5.0.2"

stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def register(self, app: FastAPI) -> None:
192192
Returns:
193193
None
194194
"""
195+
self.router.prefix = app.state.router_prefix
195196
self.router.add_api_route(
196197
name="Collection Queryables",
197198
path="/collections/{collection_id}/queryables",
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Library version."""
22

3-
__version__ = "5.0.1"
3+
__version__ = "5.0.2"

stac_fastapi/extensions/tests/test_filter.py

+26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Iterator
22

33
import pytest
4+
from fastapi import APIRouter
45
from starlette.testclient import TestClient
56

67
from stac_fastapi.api.app import StacApi
@@ -185,3 +186,28 @@ def test_search_filter_get(client_name, request):
185186
assert response.is_success, response.json()
186187
response_dict = response.json()
187188
assert response_dict["collections"] == ["collection1", "collection2"]
189+
190+
191+
@pytest.mark.parametrize("prefix", ["", "/a_prefix"])
192+
def test_multi_ext_prefix(prefix):
193+
settings = ApiSettings()
194+
extensions = [
195+
SearchFilterExtension(),
196+
ItemCollectionFilterExtension(),
197+
# Technically `CollectionSearchFilterExtension`
198+
# shouldn't be registered to the application but to the collection-search class
199+
CollectionSearchFilterExtension(),
200+
]
201+
202+
api = StacApi(
203+
settings=settings,
204+
router=APIRouter(prefix=prefix),
205+
client=DummyCoreClient(),
206+
extensions=extensions,
207+
search_get_request_model=create_get_request_model([SearchFilterExtension()]),
208+
search_post_request_model=create_post_request_model([SearchFilterExtension()]),
209+
)
210+
with TestClient(api.app, base_url="http://stac.io") as client:
211+
queryables = client.get(f"{prefix}/queryables")
212+
assert queryables.status_code == 200, queryables.json()
213+
assert queryables.headers["content-type"] == "application/schema+json"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Library version."""
22

3-
__version__ = "5.0.1"
3+
__version__ = "5.0.2"

0 commit comments

Comments
 (0)