diff --git a/CHANGES.md b/CHANGES.md index 9aebcfc..ba739ac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ - Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, ) - Add collection search extension ([#139](https://github.com/stac-utils/stac-fastapi-pgstac/pull/139)) - +- keep `/search` and `/collections` extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158)) - Fix `filter` extension implementation in `CoreCrudClient` ## [3.0.0] - 2024-08-02 diff --git a/stac_fastapi/pgstac/app.py b/stac_fastapi/pgstac/app.py index 5e28cd0..9ba27e0 100644 --- a/stac_fastapi/pgstac/app.py +++ b/stac_fastapi/pgstac/app.py @@ -49,6 +49,14 @@ "bulk_transactions": BulkTransactionExtension(client=BulkTransactionsClient()), } +# some extensions are supported in combination with the collection search extension +collection_extensions_map = { + "query": QueryExtension(), + "sort": SortExtension(), + "fields": FieldsExtension(), + "filter": FilterExtension(client=FiltersClient()), +} + enabled_extensions = ( os.environ["ENABLED_EXTENSIONS"].split(",") if "ENABLED_EXTENSIONS" in os.environ @@ -70,10 +78,17 @@ ) collection_search_extension = ( - CollectionSearchExtension.from_extensions(extensions) + CollectionSearchExtension.from_extensions( + [ + extension + for key, extension in collection_extensions_map.items() + if key in enabled_extensions + ] + ) if "collection_search" in enabled_extensions else None ) + collections_get_request_model = ( collection_search_extension.GET if collection_search_extension else EmptyRequest ) diff --git a/tests/api/test_api.py b/tests/api/test_api.py index b135dce..34c75f0 100644 --- a/tests/api/test_api.py +++ b/tests/api/test_api.py @@ -732,7 +732,9 @@ async def get_collection( get_request_model = create_get_request_model(extensions) collection_search_extension = CollectionSearchExtension.from_extensions( - extensions=extensions + extensions=[ + FieldsExtension(), + ] ) api = StacApi( diff --git a/tests/conftest.py b/tests/conftest.py index fc63514..e571cae 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -134,7 +134,16 @@ def api_client(request, database): FilterExtension(client=FiltersClient()), BulkTransactionExtension(client=BulkTransactionsClient()), ] - collection_search_extension = CollectionSearchExtension.from_extensions(extensions) + + collection_extensions = [ + QueryExtension(), + SortExtension(), + FieldsExtension(), + FilterExtension(client=FiltersClient()), + ] + collection_search_extension = CollectionSearchExtension.from_extensions( + collection_extensions + ) items_get_request_model = create_request_model( model_name="ItemCollectionUri",