diff --git a/CHANGES.md b/CHANGES.md index 7fdd6a5..dd70a31 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,9 +2,10 @@ ## [Unreleased] -- Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, https://github.com/stac-utils/stac-fastapi-pgstac/pull/142) +- Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, ) - Handle `next` and `dev` tokens now returned as links from pgstac>=0.9.0 (author @zstatmanweil, https://github.com/stac-utils/stac-fastapi-pgstac/pull/140) - 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` - update `pypgstac` requirement to `>=0.8,<0.10` - set `pypgstac==0.9.*` for test requirements 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..2bdcc0b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -136,6 +136,16 @@ def api_client(request, database): ] 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", base_model=ItemCollectionUri,