Browse Source

Fix response_model being set to None for non-generator endpoints

pull/15093/head
Yurii Motov 2 weeks ago
parent
commit
3b0c595c2e
  1. 9
      fastapi/routing.py

9
fastapi/routing.py

@ -1022,10 +1022,11 @@ def _populate_api_route_state(
response_model = None
else:
stream_item = get_stream_item_type(return_annotation)
if stream_item is not None:
# Extract item type for JSONL or SSE streaming when
# response_class is DefaultPlaceholder (JSONL) or
# EventSourceResponse (SSE).
if stream_item is not None and is_generator:
# Extract item type for JSONL or SSE streaming for
# generator endpoints when response_class is
# DefaultPlaceholder (JSONL) or EventSourceResponse
# (SSE).
# ServerSentEvent is excluded: it's a transport
# wrapper, not a data model, so it shouldn't feed
# into validation or OpenAPI schema generation.

Loading…
Cancel
Save