-
Add support for
dependencies
parameter:- A parameter in path operation decorators, for dependencies that should be executed but the return value is not important or not used in the path operation function.
- A parameter in the
.include_router()
method of FastAPI applications and routers, to include dependencies that should be executed in each path operation in a router.- This is useful, for example, to require authentication or permissions in specific group of path operations.
- Different
dependencies
can be applied to different routers.
- These
dependencies
are run before the normal parameter dependencies. And normal dependencies are run too. They can be combined. - Dependencies declared in a router are executed first, then the ones defined in path operation decorators, and then the ones declared in normal parameters. They are all combined and executed.
- All this also supports using
Security
withscopes
in thosedependencies
parameters, for more advanced OAuth 2.0 security scenarios with scopes. - New documentation about dependencies in path operation decorators.
- New documentation about dependencies in the
include_router()
method. - PR #235.
-
Fix OpenAPI documentation of Starlette URL convertors. Specially useful when using
path
convertors, to take a whole path as a parameter, like/some/url/{p:path}
. PR #234 by @euri10. -
Make default parameter utilities exported from
fastapi
be functions instead of classes (the new functions return instances of those classes). To be able to override the return types and fixmypy
errors in FastAPI's users' code. Applies toPath
,Query
,Header
,Cookie
,Body
,Form
,File
,Depends
, andSecurity
. PR #226 and PR #231. -
Separate development scripts
test.sh
,lint.sh
, andformat.sh
. PR #232. -
Re-enable
black
formatting checks for Python 3.7. PR #229 by @zamiramir.