chainlit
chainlit copied to clipboard
Swagger docs UI returns error
trafficstars
Describe the bug
Opening URL for Swagger documentation http://localhost:8000/docs returns error
To Reproduce Steps to reproduce the behavior:
- Install chainlit using
pip install chainlit - Run chainlit using
chainlit hello - Go to the URL
http://localhost:8000/docsin the browser. The page shows Fetch error Internal Server Error /openapi.json. - The following error shows on the terminal:
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/applications.py", line 113, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 85, in __call__
await self.app(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/routing.py", line 715, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1009, in openapi
return JSONResponse(self.openapi())
^^^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 981, in openapi
self.openapi_schema = get_openapi(
^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/fastapi/openapi/utils.py", line 501, in get_openapi
result = get_openapi_path(
^^^^^^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/fastapi/openapi/utils.py", line 261, in get_openapi_path
security_definitions, operation_security = get_openapi_security_definitions(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pb/Documents/experiments/chainlit-poc/.venv/lib/python3.11/site-packages/fastapi/openapi/utils.py", line 84, in get_openapi_security_definitions
security_requirement.security_scheme.model,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'OAuth2PasswordBearerWithCookie' object has no attribute 'model'
Expected behavior
The URL http://localhost:8000/docs should open the Swagger documentation UI
Additional context Chainlit version: 2.2.1