From 8ff56da54e05957c56592f90964534ba7cd34e88 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 9 Jul 2024 09:19:39 +0200 Subject: [PATCH] more doc --- docs/src/migrations/v3.0.0.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/src/migrations/v3.0.0.md b/docs/src/migrations/v3.0.0.md index 5b618386..e9b2ee64 100644 --- a/docs/src/migrations/v3.0.0.md +++ b/docs/src/migrations/v3.0.0.md @@ -84,6 +84,37 @@ stac = StacApi( ) ``` +## APIRequest - GET Request Model + +Most of the **GET** endpoints are configured with `stac_fastapi.types.search.APIRequest` base class. + +e.g the BaseSearchGetRequest, default for the `GET - /search` endpoint: + +```python +@attr.s +class BaseSearchGetRequest(APIRequest): + """Base arguments for GET Request.""" + + collections: Annotated[Optional[str], Query()] = attr.ib( + default=None, converter=str2list + ) + ids: Annotated[Optional[str], Query()] = attr.ib(default=None, converter=str2list) + bbox: Annotated[Optional[BBox], Query()] = attr.ib(default=None, converter=str2bbox) + intersects: Annotated[Optional[str], Query()] = attr.ib(default=None) + datetime: Annotated[Optional[DateTimeType], Query()] = attr.ib( + default=None, converter=str_to_interval + ) + limit: Annotated[Optional[int], Query()] = attr.ib(default=10) +``` + +We use [*python attrs*](https://www.attrs.org/en/stable/) to construct those classes. **Type Hint** for each attribute is important and should be defined using `Annotated[{type}, fastapi.Query()]` form. + +```python +@attr.s +class SomeRequest(APIRequest): + user_number: Annotated[Optional[int], Query(alias="user-number")] = attr.ib(default=None) +``` + ## Filter extension `default_includes` attribute has been removed from the `ApiSettings` object. If you need `defaults` includes you can overwrite the `FieldExtension` models (see https://github.com/stac-utils/stac-fastapi/pull/706).