From 1b79781eb31df163e99d8bae3a94e8ecf7a9e5a3 Mon Sep 17 00:00:00 2001 From: rechain Date: Wed, 25 Feb 2026 23:27:09 -0500 Subject: [PATCH] cov --- tests/test_asyncapi.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_asyncapi.py b/tests/test_asyncapi.py index 5dff11cb0c..7000c4cf97 100644 --- a/tests/test_asyncapi.py +++ b/tests/test_asyncapi.py @@ -427,3 +427,27 @@ def test_asyncapi_url_none_no_link_in_swagger(): # AsyncAPI endpoint should not exist response = client.get("/asyncapi-docs") assert response.status_code == 404 + + +def test_asyncapi_with_root_path_in_servers(): + """Test AsyncAPI schema includes root_path in servers when root_path_in_servers is True.""" + app = FastAPI( + title="Test API", + version="1.0.0", + root_path_in_servers=True, + ) + + @app.websocket("/ws") + async def websocket_endpoint(websocket: WebSocket): + await websocket.accept() + await websocket.close() + + # Use TestClient with root_path to trigger the root_path logic + client = TestClient(app, root_path="/api/v1") + response = client.get("/asyncapi.json") + assert response.status_code == 200, response.text + schema = response.json() + assert "servers" in schema + # Root path should be added to servers + server_urls = [s["url"] for s in schema["servers"]] + assert "/api/v1" in server_urls