Skip to content

Configurable request models #602

@TomAugspurger

Description

@TomAugspurger

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 33611f7 added some class attributes like search_get_request_model. Any objections to expanding that to other endpoints?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions