Pydantic models, dependency injection, async endpoints and OpenAPI.
A code-review bot for a FastAPI service flags handlers that will stall
the event loop. Write entryPoint(handlers) that classifies every path
operation function and dependency.
A travel-booking endpoint calls several upstream services. Calls in
the same stage are started together with asyncio.gather; a stage
starts only after the previous stage has fully finished. Write
entryPoint(stages) that returns how long the endpoint spends waiting
In FastAPI you can declare a path operation with def or with
async def. What does FastAPI do differently with each, and how do you
decide which to use for an endpoint in a library-catalogue API?
A junior developer's async def endpoint in a weather-alert service
calls requests.get(...) to an upstream API and time.sleep(1) between
retries. Under load, even the /health endpoint becomes slow. Why, and
how do you fix it?
A partner integration for a parcel-tracking service needs machine-to-machine access with a static API key. How do you accept API keys in FastAPI, and where should the key travel (header, query string or cookie)?
A junior developer on a library-loans API writes
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="auth/token") and
protects an endpoint with token: Annotated[str, Depends(oauth2_scheme)],
believing the endpoint is now secure. What does OAuth2PasswordBearer