pre-commit-ci-lite[bot]
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
4 deletions
-
fastapi/routing.py
-
tests/test_sse.py
|
|
|
@ -1795,7 +1795,10 @@ class APIRouter(routing.Router): |
|
|
|
), |
|
|
|
) |
|
|
|
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_field = create_model_field( |
|
|
|
name=f"StreamItem_{new_route.unique_id}", |
|
|
|
|
|
|
|
@ -261,9 +261,9 @@ def test_sse_on_router_included_in_app(client: TestClient): |
|
|
|
assert route.stream_item_field is not None |
|
|
|
|
|
|
|
openapi = app.openapi() |
|
|
|
item_schema = openapi["paths"]["/api/events"]["get"]["responses"]["200"][ |
|
|
|
"content" |
|
|
|
]["text/event-stream"]["itemSchema"] |
|
|
|
item_schema = openapi["paths"]["/api/events"]["get"]["responses"]["200"]["content"][ |
|
|
|
"text/event-stream" |
|
|
|
]["itemSchema"] |
|
|
|
assert "contentSchema" in item_schema["properties"]["data"] |
|
|
|
assert "Item" in openapi["components"]["schemas"] |
|
|
|
|
|
|
|
|