Skip to content

Commit f7d2eb3

Browse files
add deprecation warning for the ContextExtension (#658)
1 parent 96de0e2 commit f7d2eb3

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Add benchmark in CI ([#650](https://github.com/stac-utils/stac-fastapi/pull/650))
88
* Add `/queryables` link to the landing page ([#587](https://github.com/stac-utils/stac-fastapi/pull/587))
99
- `id`, `title`, `description` and `api_version` fields can be customized via env variables
10+
* Add `DeprecationWarning` for the `ContextExtension`
1011

1112
### Changed
1213

docs/src/tips-and-tricks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ If needed, you can edit the `allow_origins` parameter to only allow CORS request
2222

2323
## Enable the Context extension
2424

25+
!!! Warning
26+
27+
The `ContextExtension` is deprecated and will be removed in 3.0. See https://github.com/radiantearth/stac-api-spec/issues/396
28+
2529
The Context STAC extension provides information on the number of items matched and returned from a STAC search.
2630
This is required by various other STAC-related tools, such as the pystac command-line client.
2731
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
3034
from stac_fastapi.extensions.core.context import ContextExtension
3135
```
3236

37+
3338
and then edit the `api = StacApi(...` call to add `ContextExtension()` to the list given as the `extensions` parameter.
3439

3540
## Set API title, description and version

stac_fastapi/extensions/stac_fastapi/extensions/core/context.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Context extension."""
2+
3+
import warnings
24
from typing import List, Optional
35

46
import attr
@@ -24,6 +26,14 @@ class ContextExtension(ApiExtension):
2426
default="https://raw.githubusercontent.com/stac-api-extensions/context/v1.0.0-rc.2/json-schema/schema.json"
2527
)
2628

29+
def __attrs_post_init__(self):
30+
"""init."""
31+
warnings.warm(
32+
"The ContextExtension is deprecated and will be removed in 3.0.",
33+
DeprecationWarning,
34+
stacklevel=1,
35+
)
36+
2737
def register(self, app: FastAPI) -> None:
2838
"""Register the extension with a FastAPI application.
2939

0 commit comments

Comments
 (0)