So I am trying to write simple function here, but everytime I run swagger I got above mentioned error.
Here's my function:
def authenticate_user(username: str, password: str, db: Session = Depends(bd.get_db)):
user = db.query(bd.User.username).filter(username == username).first()
if not user:
return False
if not verify_password(password, user.password_hash):
return False
return user
and here's my get_db function it is pretty standard:
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
I've noticed that Depends(bd.get_db) works perfectly fine within endpoint functions (the ones with @app.post/@app.get decorators), but somehow doesn't work within plain functions.
Apparently I don't quite understand the concept of dependency injections, but I can't quite grasp it yet.
Any help would be appreciated. Thank you kindly!