FastAPI - Dependency Injection
Which of the following is the correct way to declare a dependency in a FastAPI path operation function?
Dependencies are declared by assigning a parameter to Depends() with the dependency function inside.
def read_item(item_id: int, user=Depends(get_current_user)): correctly uses user=Depends(get_current_user). Others have syntax errors or call the function directly.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions