FastUI
FastUI copied to clipboard
demo code /docs Fetch error Internal Server Error /openapi.json
Latest main code Reproduce: make dev http://localhost:8000/docs
INFO: 127.0.0.1:58664 - "GET /docs HTTP/1.1" 200 OK
INFO: 127.0.0.1:58664 - "GET /openapi.json HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/applications.py", line 1106, in __call__
await super().__call__(scope, receive, send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
raise e
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
await self.app(scope, receive, send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/applications.py", line 1061, in openapi
return JSONResponse(self.openapi())
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/applications.py", line 1033, in openapi
self.openapi_schema = get_openapi(
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/openapi/utils.py", line 475, in get_openapi
field_mapping, definitions = get_definitions(
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/fastapi/_compat.py", line 227, in get_definitions
field_mapping, definitions = schema_generator.generate_definitions(
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/json_schema.py", line 377, in generate_definitions
self.generate_inner(schema)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/json_schema.py", line 552, in generate_inner
json_schema = current_handler(schema)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/_internal/_schema_generation_shared.py", line 36, in __call__
return self.handler(__core_schema)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/json_schema.py", line 509, in handler_func
json_schema = generate_for_schema_type(schema_or_field)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/json_schema.py", line 1735, in definitions_schema
self.generate_inner(definition)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/json_schema.py", line 552, in generate_inner
json_schema = current_handler(schema)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/_internal/_schema_generation_shared.py", line 36, in __call__
return self.handler(__core_schema)
File "/home/ubuntu/FastUI/venv/lib/python3.10/site-packages/pydantic/json_schema.py", line 526, in new_handler_func
json_schema = js_modify_function(schema_or_field, current_handler)
File "/home/ubuntu/FastUI/src/python-fastui/fastui/components/__init__.py", line 188, in __get_pydantic_json_schema__
json_schema['required'].append('links')
KeyError: 'required'
Sorry I really can't read this, please format exceptions is a code block.
sorry, updated with code block now. I tried to comments out json_schema['required'].append('links') line, the docs show but hungs after click individual api .
Additional findings, it hungs like 1 minute or more then loaded successfully after comments out json_schema['required'].append('links') line, its not hungs forever, its just very very slow.
The key error should be easy to fix.
The slow loading docs is a problem with the swagger frontend code - it can't copy with the recursive union which is the fundamental construct of FastUI components.
See #58
PR welcome to fix the key error.
Cool. Thanks for sharing.
I've limited knowledge as for now for fastui code. might take a while like months to reach my skill level to fix this issue. When I know how to fix I will fix it :-)
It's a one line change, replace
json_schema['required'].append('links')
With
json_schema.setdefault('required', []).append('links')
allright, let me test it, if works i will open pull request and follow up with test!