diff --git a/CHANGES.md b/CHANGES.md index 8856da996..18f01c0e5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ * Add benchmark in CI ([#650](https://github.com/stac-utils/stac-fastapi/pull/650)) * Add `/queryables` link to the landing page ([#587](https://github.com/stac-utils/stac-fastapi/pull/587)) - `id`, `title`, `description` and `api_version` fields can be customized via env variables +* Add `DeprecationWarning` for the `ContextExtension` ### Changed diff --git a/docs/src/tips-and-tricks.md b/docs/src/tips-and-tricks.md index a42ce98b2..a5ca8cb68 100644 --- a/docs/src/tips-and-tricks.md +++ b/docs/src/tips-and-tricks.md @@ -22,6 +22,10 @@ If needed, you can edit the `allow_origins` parameter to only allow CORS request ## Enable the Context extension +!!! Warning + + The `ContextExtension` is deprecated and will be removed in 3.0. See https://github.com/radiantearth/stac-api-spec/issues/396 + The Context STAC extension provides information on the number of items matched and returned from a STAC search. This is required by various other STAC-related tools, such as the pystac command-line client. To enable the extension, edit your backend's `app.py` and add the following import: @@ -30,6 +34,7 @@ To enable the extension, edit your backend's `app.py` and add the following impo from stac_fastapi.extensions.core.context import ContextExtension ``` + and then edit the `api = StacApi(...` call to add `ContextExtension()` to the list given as the `extensions` parameter. ## Set API title, description and version diff --git a/stac_fastapi/extensions/stac_fastapi/extensions/core/context.py b/stac_fastapi/extensions/stac_fastapi/extensions/core/context.py index 90faae914..b65394875 100644 --- a/stac_fastapi/extensions/stac_fastapi/extensions/core/context.py +++ b/stac_fastapi/extensions/stac_fastapi/extensions/core/context.py @@ -1,4 +1,6 @@ """Context extension.""" + +import warnings from typing import List, Optional import attr @@ -24,6 +26,14 @@ class ContextExtension(ApiExtension): default="https://raw.githubusercontent.com/stac-api-extensions/context/v1.0.0-rc.2/json-schema/schema.json" ) + def __attrs_post_init__(self): + """init.""" + warnings.warm( + "The ContextExtension is deprecated and will be removed in 3.0.", + DeprecationWarning, + stacklevel=1, + ) + def register(self, app: FastAPI) -> None: """Register the extension with a FastAPI application.