[Bugfix][Frontend] Expose completion response schemas in OpenAPI (#60926)

Signed-off-by: Guan Luo <gluo@nvidia.com>
Signed-off-by: sfeng33 <4florafeng@gmail.com>
Co-authored-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
GuanLuo
2026-10-13 18:54:06 +00:00
committed by GitHub
co-authored by sfeng33
parent c5bda658d2
commit 6d1daa9fe5
5 changed files with 220 additions and 15 deletions
@@ -1,9 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import asyncio
from argparse import Namespace
import pytest
from fastapi import FastAPI, Request
from vllm.entrypoints.generate.base.protocol import StreamOptions
from vllm.entrypoints.serve.utils import api_utils
@@ -14,6 +16,55 @@ from vllm.entrypoints.serve.utils.api_utils import (
)
@pytest.mark.asyncio
async def test_with_cancellation_disconnect_skips_response_validation():
"""A disconnect must cancel the handler without a response_model 500."""
app = FastAPI()
started = asyncio.Event()
cancelled = asyncio.Event()
@app.post("/", response_model=str)
@api_utils.with_cancellation
async def handler(body: dict, raw_request: Request):
started.set()
try:
await asyncio.Future()
finally:
cancelled.set()
messages = []
body_sent = False
async def receive():
nonlocal body_sent
if not body_sent:
body_sent = True
return {"type": "http.request", "body": b"{}", "more_body": False}
await started.wait()
return {"type": "http.disconnect"}
async def send(message):
messages.append(message)
scope = {
"type": "http",
"asgi": {"version": "3.0"},
"http_version": "1.1",
"method": "POST",
"scheme": "http",
"path": "/",
"raw_path": b"/",
"query_string": b"",
"headers": [(b"content-type", b"application/json")],
"client": ("127.0.0.1", 1234),
"server": ("test", 80),
}
await asyncio.wait_for(app(scope, receive, send), timeout=5)
assert messages[0]["status"] == 200
assert messages[1]["body"] == b""
await asyncio.wait_for(cancelled.wait(), timeout=5)
@pytest.mark.parametrize(
("stream_options", "expected"),
[