stac-fastapi icon indicating copy to clipboard operation
stac-fastapi copied to clipboard

Configurable request models

Open TomAugspurger opened this issue 2 years ago • 1 comments

I'd like to add an additional parameter to the /collections/collection/items/item endpoint. IIUC, doing that currently requires something like this:

    def register_get_item(self):
        """Register get item endpoint (GET /collections/{collection_id}/items/{item_id}).

        Returns:
            None
        """
        # This matches the implementation in stac-fastapi, aside from
        # swapping the request_model passed to create_async_endpoint.
        self.router.add_api_route(
            name="Get Item",
            path="/collections/{collection_id}/items/{item_id}",
            response_model=Item if self.settings.enable_response_models else None,
            response_class=GeoJSONResponse,
            response_model_exclude_unset=True,
            response_model_exclude_none=True,
            methods=["GET"],
            endpoint=create_async_endpoint(
                self.client.get_item,
                MyItemUri,  # <----- only change, to swap the request model
                GeoJSONResponse
            ),
        )

I see that https://github.com/stac-utils/stac-fastapi/commit/33611f7da569488641dac7bb23efd43feb219f98 added some class attributes like search_get_request_model. Any objections to expanding that to other endpoints?

TomAugspurger avatar Sep 14 '23 19:09 TomAugspurger

Any objections to expanding that to other endpoints?

Not from my side!

gadomski avatar Sep 15 '23 11:09 gadomski