Browse Source

🎨 Auto format

pull/15445/head
pre-commit-ci-lite[bot] 1 month ago
committed by GitHub
parent
commit
41f5f96768
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      fastapi/routing.py
  2. 6
      tests/test_sse.py

5
fastapi/routing.py

@ -1795,7 +1795,10 @@ class APIRouter(routing.Router):
), ),
) )
new_route = self.routes[-1] new_route = self.routes[-1]
if isinstance(new_route, APIRoute) and route.stream_item_type is not None: if (
isinstance(new_route, APIRoute)
and route.stream_item_type is not None
):
new_route.stream_item_type = route.stream_item_type new_route.stream_item_type = route.stream_item_type
new_route.stream_item_field = create_model_field( new_route.stream_item_field = create_model_field(
name=f"StreamItem_{new_route.unique_id}", name=f"StreamItem_{new_route.unique_id}",

6
tests/test_sse.py

@ -261,9 +261,9 @@ def test_sse_on_router_included_in_app(client: TestClient):
assert route.stream_item_field is not None assert route.stream_item_field is not None
openapi = app.openapi() openapi = app.openapi()
item_schema = openapi["paths"]["/api/events"]["get"]["responses"]["200"][ item_schema = openapi["paths"]["/api/events"]["get"]["responses"]["200"]["content"][
"content" "text/event-stream"
]["text/event-stream"]["itemSchema"] ]["itemSchema"]
assert "contentSchema" in item_schema["properties"]["data"] assert "contentSchema" in item_schema["properties"]["data"]
assert "Item" in openapi["components"]["schemas"] assert "Item" in openapi["components"]["schemas"]

Loading…
Cancel
Save