From 038e267077aded980879ddcc5e5ef44a1979f3f4 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Thu, 30 Jan 2025 18:44:48 +0100 Subject: [PATCH 1/2] forward `prefix` to `ItemCollectionFilterExtension.router` --- CHANGES.md | 6 +++++ .../extensions/core/filter/filter.py | 1 + stac_fastapi/extensions/tests/test_filter.py | 26 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 91f88d31..8d7a3f2d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [5.0.2] - 2025-01-30 + +### Fixed + +- forward `prefix` to `ItemCollectionFilterExtension.router` + ## [5.0.1] - 2025-01-30 ### Fixed diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py b/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py index d182dcf3..7e8d7f57 100644 --- a/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py +++ b/stac_fastapi/extensions/stac_fastapi/extensions/core/filter/filter.py @@ -192,6 +192,7 @@ def register(self, app: FastAPI) -> None: Returns: None """ + self.router.prefix = app.state.router_prefix self.router.add_api_route( name="Collection Queryables", path="/collections/{collection_id}/queryables", diff --git a/stac_fastapi/extensions/tests/test_filter.py b/stac_fastapi/extensions/tests/test_filter.py index bc8b902e..8dc485e6 100644 --- a/stac_fastapi/extensions/tests/test_filter.py +++ b/stac_fastapi/extensions/tests/test_filter.py @@ -1,6 +1,7 @@ from typing import Iterator import pytest +from fastapi import APIRouter from starlette.testclient import TestClient from stac_fastapi.api.app import StacApi @@ -185,3 +186,28 @@ def test_search_filter_get(client_name, request): assert response.is_success, response.json() response_dict = response.json() assert response_dict["collections"] == ["collection1", "collection2"] + + +@pytest.mark.parametrize("prefix", ["", "/a_prefix"]) +def test_multi_ext_prefix(prefix): + settings = ApiSettings() + extensions = [ + SearchFilterExtension(), + ItemCollectionFilterExtension(), + # Technically `CollectionSearchFilterExtension` + # shouldn't be registered to the application but to the collection-search class + CollectionSearchFilterExtension(), + ] + + api = StacApi( + settings=settings, + router=APIRouter(prefix=prefix), + client=DummyCoreClient(), + extensions=extensions, + search_get_request_model=create_get_request_model([SearchFilterExtension()]), + search_post_request_model=create_post_request_model([SearchFilterExtension()]), + ) + with TestClient(api.app, base_url="http://stac.io") as client: + queryables = client.get(f"{prefix}/queryables") + assert queryables.status_code == 200, queryables.json() + assert queryables.headers["content-type"] == "application/schema+json" From b5575eb1ac2120cbdf46af89168e11d63c9607d9 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Thu, 30 Jan 2025 18:44:54 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Bump=20version:=205.0.1=20=E2=86=92=205.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- pyproject.toml | 2 +- stac_fastapi/api/stac_fastapi/api/version.py | 2 +- stac_fastapi/extensions/stac_fastapi/extensions/version.py | 2 +- stac_fastapi/types/stac_fastapi/types/version.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 6b244dcd..a1ef0cae 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.1 +5.0.2 diff --git a/pyproject.toml b/pyproject.toml index b566922d..eccaa956 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ section-order = ["future", "standard-library", "third-party", "first-party", "lo quote-style = "double" [tool.bumpversion] -current_version = "5.0.1" +current_version = "5.0.2" parse = """(?x) (?P\\d+)\\. (?P\\d+)\\. diff --git a/stac_fastapi/api/stac_fastapi/api/version.py b/stac_fastapi/api/stac_fastapi/api/version.py index b49655b3..59266165 100644 --- a/stac_fastapi/api/stac_fastapi/api/version.py +++ b/stac_fastapi/api/stac_fastapi/api/version.py @@ -1,3 +1,3 @@ """Library version.""" -__version__ = "5.0.1" +__version__ = "5.0.2" diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/version.py b/stac_fastapi/extensions/stac_fastapi/extensions/version.py index b49655b3..59266165 100644 --- a/stac_fastapi/extensions/stac_fastapi/extensions/version.py +++ b/stac_fastapi/extensions/stac_fastapi/extensions/version.py @@ -1,3 +1,3 @@ """Library version.""" -__version__ = "5.0.1" +__version__ = "5.0.2" diff --git a/stac_fastapi/types/stac_fastapi/types/version.py b/stac_fastapi/types/stac_fastapi/types/version.py index b49655b3..59266165 100644 --- a/stac_fastapi/types/stac_fastapi/types/version.py +++ b/stac_fastapi/types/stac_fastapi/types/version.py @@ -1,3 +1,3 @@ """Library version.""" -__version__ = "5.0.1" +__version__ = "5.0.2"