from typing import List, Dict, Tuple
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Answers(BaseModel):
answers: Dict[str, List[Tuple[str, float]]] = {}
@app.get("/qa", response_model=Answers)
async def qatask(request: str):
return Answers()
if __name__ == "__main__":
import uvicorn
uvicorn.run("bugfind:app", host="0.0.0.0", port=5000, reload=True,
workers=1) # , debug=True)
Traceback (most recent call last):
File "//home/name/.local/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "//home/name/.local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "//home/name/.local/lib/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
await super().__call__(scope, receive, send)
File "//home/name/.local/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "//home/name/.local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "//home/name/.local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "//home/name/.local/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "//home/name/.local/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "//home/name/.local/lib/python3.8/site-packages/starlette/routing.py", line 580, in __call__
await route.handle(scope, receive, send)
File "//home/name/.local/lib/python3.8/site-packages/starlette/routing.py", line 241, in handle
await self.app(scope, receive, send)
File "//home/name/.local/lib/python3.8/site-packages/starlette/routing.py", line 52, in app
response = await func(request)
File "//home/name/.local/lib/python3.8/site-packages/fastapi/applications.py", line 161, in openapi
return JSONResponse(self.openapi())
File "//home/name/.local/lib/python3.8/site-packages/fastapi/applications.py", line 136, in openapi
self.openapi_schema = get_openapi(
File "//home/name/.local/lib/python3.8/site-packages/fastapi/openapi/utils.py", line 410, in get_openapi
return jsonable_encoder(OpenAPI(**output), by_alias=True, exclude_none=True) # type: ignore
File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 4 validation errors for OpenAPI
components -> schemas -> Answers -> properties -> answers -> additionalProperties -> items -> items
value is not a valid dict (type=type_error.dict)
components -> schemas -> Answers -> properties -> answers -> additionalProperties -> $ref
field required (type=value_error.missing)
components -> schemas -> Answers -> properties -> answers -> additionalProperties
value could not be parsed to a boolean (type=type_error.bool)
components -> schemas -> Answers -> $ref
field required (type=value_error.missing)
First Check
Commit to Help
Example Code
Description
open http://localhost:5000/docs or http://localhost:5000/openapi.json and you will see the error in the logs.
Operating System
Linux
Operating System Details
ubuntu 20.04
FastAPI Version
0.68.1
Python Version
3.8.10
Additional Context
There was a bug #383 a while ago reporting the same problem but closed. This new issue here is in order to reopen that bug as it still isn't solved or reappeared since then. Fell free to close this new issue and reopen the old bug if that is preferred.
this is the error: