Skip to content

Commit

Permalink
fix: FastAPI 0.112.4+ compatibility (#1766)
Browse files Browse the repository at this point in the history
* fix: FastAPI 0.112.4+ compatibility

* lint: fix mypy

* chore: bump version
  • Loading branch information
Lancetnik authored Sep 5, 2024
1 parent c50e054 commit c273500
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion faststream/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Simple and fast framework to create message brokers based microservices."""

__version__ = "0.5.21"
__version__ = "0.5.22"

SERVICE_NAME = f"faststream-{__version__}"
4 changes: 4 additions & 0 deletions faststream/broker/fastapi/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
FASTAPI_V2 = major > 0 or minor > 100
FASTAPI_V106 = major > 0 or minor >= 106
FASTAPI_v102_3 = major > 0 or minor > 112 or (minor == 112 and patch > 2)
FASTAPI_v102_4 = major > 0 or minor > 112 or (minor == 112 and patch > 3)

__all__ = (
"create_response_field",
Expand Down Expand Up @@ -56,6 +57,8 @@ def raise_fastapi_validation_error(errors: List[Any], body: AnyDict) -> Never:
create_model_field as create_response_field,
)

extra = {"embed_body_fields": False} if FASTAPI_v102_4 else {}

async def solve_faststream_dependency(
request: "Request",
dependant: "Dependant",
Expand All @@ -67,6 +70,7 @@ async def solve_faststream_dependency(
body=request._body, # type: ignore[arg-type]
dependant=dependant,
dependency_overrides_provider=dependency_overrides_provider,
**extra, # type: ignore[arg-type]
**kwargs,
)
values, errors, background = (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test-core = [

testing = [
"faststream[test-core]",
"fastapi==0.112.3",
"fastapi==0.113.0",
"pydantic-settings>=2.0.0,<3.0.0",
"httpx==0.27.2",
"PyYAML==6.0.2",
Expand Down

0 comments on commit c273500

Please sign in to comment.