Fastapi: Error downloading http://127.0.0.1:8000/openapi.json HTTP ERROR 500Something went wrong... on http://127.0.0.1:8000/redoc or /docs

Created on 24 Nov 2020  路  8Comments  路  Source: tiangolo/fastapi

Something went wrong...
Error downloading http://127.0.0.1:8000/openapi.json HTTP ERROR 500
Stack trace
Error: Error downloading http://127.0.0.1:8000/openapi.json
HTTP ERROR 500
at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:29:28049
at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:80:36080

Error: HTTP ERROR 500
at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:29:28049
at https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:80:35658

_Originally posted by @akshaynarula in https://github.com/tiangolo/fastapi/issues/2082#issuecomment-733178552_

Most helpful comment

Unless you provide code, we cannot help you.

All 8 comments

HI,
we need more information to help you.

  • Sample Code
  • Python Version
  • FastApi Version

Can you reproduce how did you get this? I mean WDYM by downloading the openapi.json.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 389, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/fastapi/applications.py", line 179, in __call__
    await super().__call__(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/middleware/cors.py", line 78, in __call__
    await self.app(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/middleware/trustedhost.py", line 34, in __call__
    await self.app(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/fastapi/applications.py", line 128, in openapi
    return JSONResponse(self.openapi())
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/fastapi/applications.py", line 106, in openapi
    self.openapi_schema = get_openapi(
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/fastapi/openapi/utils.py", line 348, in get_openapi
    result = get_openapi_path(route=route, model_name_map=model_name_map)
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/fastapi/openapi/utils.py", line 177, in get_openapi_path
    operation_parameters = get_openapi_operation_parameters(
  File "/home/ubuntu/LambdaProjects/mustard/venv/lib/python3.8/site-packages/fastapi/openapi/utils.py", line 95, in get_openapi_operation_parameters
    "schema": field_schema(
  File "pydantic/schema.py", line 215, in pydantic.schema.field_schema
  File "pydantic/schema.py", line 183, in pydantic.schema.get_field_info_schema
  File "pydantic/schema.py", line 846, in pydantic.schema.encode_default
  File "pydantic/json.py", line 65, in pydantic.json.pydantic_encoder
TypeError: Object of type 'function' is not JSON serializable

Screenshot
Screenshot

It looks like you're incorrectly defining your endpoints and including a function where it isn't valid.

Perhaps you could provide some code?

I have few http endpoints and websocket endpoints, nothing else.

HI,
we need more information to help you.

  • Sample Code
  • Python Version
  • FastApi Version

Code contains few HTTP and WebSocket endpoints
Python 3.8
fastapi 0.61.1

Unless you provide code, we cannot help you.

Was this page helpful?
0 / 5 - 0 ratings