I am trying to include a router in the main FastAPI router:
from fastapi import FastAPI
from test.main.app.google_calendar_wrapper import app as calendar_manager_router
app = FastAPI()
#
app.include_router(calendar_manager_router, prefix="/calendar_manager", tags=["calendar_manager"])
@app.get("/")
def root():
return {"message": "Home Page"}
However, when running
uvicorn test.main.app.webhook.router:app --port 8050 --reload
I get an error:
AttributeError: 'FastAPI' object has no attribute 'default_response_class'
My file structure is:
test
| main
| app
| google_calendar_wrapper
| endpoints.py
| __init__.py
| webhooks
| router.py
So far I have tried:
- Not including the router, in this case the application starts normally
google_calendar_wrapperwith and without__init__.py. If with an__init__.py, I tried exporting thegoogle_calendar_wrapperand it still raises the same error- Both routers work independently of each other but nothing has helped so far and I have not found any solutions.
Here is the calendar_manager_router definition:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello World"}
@app.get("/health")
def health():
"""Api health endpoint."""
return {"Api is up and running"}
calendar_manager_router? Since that's what's giving you the error, it would probably be helpful to add that as well.