Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## [Unreleased]

### Changed

* Make sure FastAPI use Pydantic validatio and serialization by no wrapping endpoint output with a Response object ([#650](https://github.com/stac-utils/stac-fastapi/pull/650))

### Removed

* Deprecate `response_class` option in `stac_fastapi.api.routes.create_async_endpoint` method ([#650](https://github.com/stac-utils/stac-fastapi/pull/650))

### Added

* Add benchmark in CI ([#650](https://github.com/stac-utils/stac-fastapi/pull/650))

## [2.4.9] - 2023-11-17

### Added
Expand Down
10 changes: 10 additions & 0 deletions stac_fastapi/api/stac_fastapi/api/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Route factories."""

import functools
import inspect
import warnings
from typing import Any, Callable, Dict, List, Optional, Type, TypedDict, Union

from fastapi import Depends, params
Expand Down Expand Up @@ -35,11 +37,19 @@ async def run(*args, **kwargs):
def create_async_endpoint(
func: Callable,
request_model: Union[Type[APIRequest], Type[BaseModel], Dict],
response_class: Optional[Type[Response]] = None,
):
"""Wrap a function in a coroutine which may be used to create a FastAPI endpoint.

Synchronous functions are executed asynchronously using a background thread.
"""

if response_class:
warnings.warns(
"`response_class` option is deprecated, please set the Response class directly in the endpoint.", # noqa: E501
DeprecationWarning,
)

if not inspect.iscoroutinefunction(func):
func = sync_to_async(func)

Expand Down