DeanWay / fastapi-versioning

api versioning for fastapi web applications
MIT License
642 stars 63 forks source link

Events not working if put before VersionedFastAPI initialization #63

Open arhen opened 2 years ago

arhen commented 2 years ago

Actual behavior I have events on startup and shutdown. When I put these configs before VersionedFastAPI initialization, the events does not working.

# App Event Setting
@app.on_event("startup")
async def startup():
    await database.connect()

@app.on_event("shutdown")
async def shutdown():
    await database.disconnect()

# versioning
app = VersionedFastAPI(app,
    version_format='{major}',
    prefix_format='/v{major}',
    enable_latest=True)

Expected behavior I hope it still working even all Events setting put before VersionedFastAPI initialization.

shailendrafaarms commented 2 years ago

We are also facing this issue. And it is very trivial.

mbengchan commented 1 year ago

I am still facing this issue.