Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@

## Changed

* use `stac_pydantic.version.STAC_VERSION` instead of `stac_pydantic.api.version.STAC_API_VERSION` as application `stac_version`
* Use `stac_pydantic.version.STAC_VERSION` instead of `stac_pydantic.api.version.STAC_API_VERSION` as application `stac_version`
* Return more informations from pydantic validation errors
* Add deprecation notice for `post_request_model` attribute in `BaseCoreClient` and `AsyncBaseCoreClient`

## [3.0.3] - 2024-10-09

Expand Down
6 changes: 2 additions & 4 deletions stac_fastapi/api/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ def get_search(
type="FeatureCollection", features=[stac.Item(**item_dict)]
)

post_request_model = create_post_request_model([FilterExtension()])

test_app = app.StacApi(
settings=ApiSettings(enable_response_models=validate),
client=FilterClient(post_request_model=post_request_model),
client=FilterClient(),
search_get_request_model=create_get_request_model([FilterExtension()]),
search_post_request_model=post_request_model,
search_post_request_model=create_post_request_model([FilterExtension()]),
extensions=[FilterExtension()],
)

Expand Down
31 changes: 29 additions & 2 deletions stac_fastapi/types/stac_fastapi/types/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Base clients."""

import abc
import warnings
from typing import Any, Dict, List, Optional, Union
from urllib.parse import urljoin

Expand Down Expand Up @@ -341,7 +342,20 @@ class BaseCoreClient(LandingPageMixin, abc.ABC):
factory=lambda: BASE_CONFORMANCE_CLASSES
)
extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
post_request_model = attr.ib(default=BaseSearchPostRequest)
post_request_model = attr.ib(default=None)

@post_request_model.validator
def _deprecate_post_model(self, attribute, value):
"""Check and raise warning if `post_request_model` is set."""
if value is not None:
warnings.warn(
"`post_request_model` attribute is deprecated and will be removed in 3.1",
DeprecationWarning,
)

def __attrs_post_init__(self):
"""Set default value for post_request_model."""
self.post_request_model = self.post_request_model or BaseSearchPostRequest

def conformance_classes(self) -> List[str]:
"""Generate conformance classes by adding extension conformance to base
Expand Down Expand Up @@ -573,7 +587,20 @@ class AsyncBaseCoreClient(LandingPageMixin, abc.ABC):
factory=lambda: BASE_CONFORMANCE_CLASSES
)
extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
post_request_model = attr.ib(default=BaseSearchPostRequest)
post_request_model = attr.ib(default=None)

@post_request_model.validator
def _deprecate_post_model(self, attribute, value):
"""Check and raise warning if `post_request_model` is set."""
if value is not None:
warnings.warn(
"`post_request_model` attribute is deprecated and will be removed in 3.1",
DeprecationWarning,
)

def __attrs_post_init__(self):
"""Set default value for post_request_model."""
self.post_request_model = self.post_request_model or BaseSearchPostRequest

def conformance_classes(self) -> List[str]:
"""Generate conformance classes by adding extension conformance to base
Expand Down
Loading