codejump

Dependencies & API Design — Series 3

Preview — 3 of 10 questions

A POST route takes item: Item and user: User, both Pydantic models. What JSON shape is expected?

AAn object with item and user keys
BOnly the fields of Item at the top level
CA JSON array of two models
DTwo independent HTTP request bodies

What does Body(embed=True) change when there is only one model parameter item?

AIt reads item from a cookie
BIt bypasses model validation
CIt converts JSON to multipart form data
DIt expects an outer item key

What is the main purpose of Depends(check_user) listed in a route decorator's dependencies=[...]?

ASkip its sub-dependencies
BRun it only during startup
CRun the dependency without injecting its return value into the handler
DTurn the dependency into the response body

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.