Release Notes
The current page still doesn’t have a translation for this language.
But you can help translating it: Contributing.
0.85.0
- ⬆ Upgrade version required of Starlette from to
0.20.4
. Initial PR #4820 by .- This includes several bug fixes in Starlette.
- ⬆️ Upgrade Uvicorn max version in public extras: all. From
>=0.12.0,<0.18.0
to>=0.12.0,<0.19.0
. PR #5401 by .
Internal
- ⬆️ Upgrade dependencies for doc and dev internal extras: Typer, Uvicorn. PR by @tiangolo.
- ⬆️ Upgrade test dependencies: Black, HTTPX, databases, types-ujson. PR by @tiangolo.
- ⬆️ Upgrade mypy and tweak internal type annotations. PR by @tiangolo.
- 🔧 Update test dependencies, upgrade Pytest, move dependencies from dev to test. PR by @tiangolo.
0.84.0
Breaking Changes
This version of FastAPI drops support for Python 3.6. 🔥 Please upgrade to a supported version of Python (3.7 or above), Python 3.6 reached the end-of-life a long time ago. 😅☠
- 🔧 Update package metadata, drop support for Python 3.6, move build internals from Flit to Hatch. PR by @ofek.
0.83.0
🚨 This is probably the last release (or one of the last releases) to support Python 3.6. 🔥
Python 3.6 reached the end-of-life and is no longer supported by Python since around a year ago.
You hopefully updated to a supported version of Python a while ago. If you haven’t, you really should.
Features
- ✨ Add support in
jsonable_encoder
for include and exclude with dataclasses. PR #4923 by .
Fixes
- 🐛 Fix
RuntimeError
raised whenHTTPException
has a status code with no content. PR by @iudeen. - 🐛 Fix empty reponse body when default
status_code
is empty but the aResponse
parameter withresponse.status_code
is set. PR by @tmeckel.
Docs
- 📝 Update
SECURITY.md
. PR #5377 by .
Internal
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR by @pre-commit-ci[bot].
0.82.0
🚨 This is probably the last release (or one of the last releases) to support Python 3.6. 🔥
Python 3.6 reached the end-of-life and is no longer supported by Python since around a year ago.
You hopefully updated to a supported version of Python a while ago. If you haven’t, you really should.
Features
- ✨ Export
WebSocketState
infastapi.websockets
. PR #4376 by . - ✨ Support Python internal description on Pydantic model’s docstring. PR #3032 by .
- ✨ Update
ORJSONResponse
to support nonstr
keys and serializing Numpy arrays. PR #3892 by .
Fixes
- 🐛 Allow exit code for dependencies with
yield
to always execute, by removing capacity limiter for them, to e.g. allow closing DB connections without deadlocks. PR by @adriangb. - 🐛 Fix FastAPI People GitHub Action: set HTTPX timeout for GraphQL query request. PR by @iudeen.
- 🐛 Make sure a parameter defined as required is kept required in OpenAPI even if defined as optional in another dependency. PR by @cd17822.
- 🐛 Fix support for path parameters in WebSockets. PR by @davidbrochart.
Docs
- ✏ Update Hypercorn link, now pointing to GitHub. PR #5346 by .
- ✏ Tweak wording in
docs/en/docs/advanced/dataclasses.md
. PR #3698 by . - 📝 Add note about Python 3.10
X | Y
operator in explanation about Response Models. PR #5307 by . - 📝 Add link to New Relic article: “How to monitor FastAPI application performance using Python agent”. PR #5260 by .
- 📝 Update docs for
ORJSONResponse
with details about improving performance. PR #2615 by . - 📝 Add docs for creating a custom Response class. PR #5331 by .
- 📝 Add tip about using alias for form data fields. PR #5329 by .
Translations
- 🌐 Add Russian translation for
docs/ru/docs/features.md
. PR by @Xewus. - 🌐 Update Chinese translation for
docs/zh/docs/tutorial/request-files.md
. PR by @ASpathfinder. - 🌐 Add Chinese translation for
docs/zh/docs/tutorial/encoder.md
. PR by @Zssaer. - 🌐 Fix MkDocs file line for Portuguese translation of
background-task.md
. PR by @ComicShrimp.
Internal
- 👥 Update FastAPI People. PR #5347 by .
- ⬆ Bump dawidd6/action-download-artifact from 2.22.0 to 2.23.0. PR #5321 by .
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #5318 by .
- ✏ Fix a small code highlight line error. PR #5256 by .
- ♻ Internal small refactor, move
operation_id
parameter position in delete method for consistency with the code. PR #4474 by . - 🔧 Update sponsors, disable ImgWhale. PR #5338 by .
0.81.0
Features
- ✨ Add ReDoc
<noscript>
warning when JS is disabled. PR #5074 by . - ✨ Add support for
FrozenSet
in parameters (e.g. query). PR #2938 by . - ✨ Allow custom middlewares to raise
HTTPException
s and propagate them. PR #2036 by . - ✨ Preserve
json.JSONDecodeError
information when handling invalid JSON in request body, to support custom exception handlers that use its information. PR #4057 by .
Fixes
- 🐛 Fix
jsonable_encoder
for dataclasses with pydantic-compatible fields. PR by @himbeles. - 🐛 Fix support for extending
openapi_extras
with parameter lists. PR by @orilevari.
Docs
- ✏ Fix a simple typo in
docs/en/docs/python-types.md
. PR #5193 by . - ✏ Fix typos in
tests/test_schema_extra_examples.py
. PR #5126 by . - ✏ Fix typos in
docs/en/docs/tutorial/path-params-numeric-validations.md
. PR #5142 by . - 📝 Add step about upgrading pip in the venv to avoid errors when installing dependencies
docs/en/docs/contributing.md
. PR #5181 by . - ✏ Reword and clarify text in tutorial
docs/en/docs/tutorial/body-nested-models.md
. PR #5169 by . - ✏ Fix minor typo in
docs/en/docs/features.md
. PR #5206 by . - ✏ Fix minor typos in
docs/en/docs/async.md
. PR #5125 by . - 📝 Add external link to docs: “Fastapi, Docker(Docker compose) and Postgres”. PR #5033 by .
- 📝 Simplify example for docs for Additional Responses, remove unnecessary
else
. PR #4693 by . - 📝 Update docs, compare enums with identity instead of equality. PR #4905 by .
- ✏ Fix typo in
docs/en/docs/python-types.md
. PR #4886 by . - 🎨 Fix syntax highlighting in docs for OpenAPI Callbacks. PR #4368 by .
- ✏ Reword confusing sentence in docs file
typo-fix-path-params-numeric-validations.md
. PR #3219 by . - 📝 Update docs for handling HTTP Basic Auth with
secrets.compare_digest()
to account for non-ASCII characters. PR #3536 by . - 📝 Update docs for testing, fix examples with relative imports. PR #5302 by .
Translations
- 🌐 Add Russian translation for
docs/ru/docs/index.md
. PR by @impocode. - 🌐 Add Russian translation for
docs/ru/docs/deployment/versions.md
. PR by @emp7yhead. - 🌐 Add Portuguese translation for
docs/pt/docs/tutorial/header-params.md
. PR by @batlopes. - 🌐 Update
ko/mkdocs.yml
for a missing link. PR by @dalinaum.
Internal
- ⬆ Bump dawidd6/action-download-artifact from 2.21.1 to 2.22.0. PR #5258 by .
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #5196 by .
- 🔥 Delete duplicated tests in
tests/test_tutorial/test_sql_databases/test_sql_databases.py
. PR #5040 by . - ♻ Simplify internal RegEx in
fastapi/utils.py
. PR #5057 by . - 🔧 Fix Type hint of
auto_error
which does not need to beOptional[bool]
. PR #4933 by . - 🔧 Update mypy config, use
strict = true
instead of manual configs. PR #4605 by . - ♻ Change a
dict()
for{}
infastapi/utils.py
. PR #3138 by . - ♻ Move internal variable for errors in
jsonable_encoder
to put related code closer. PR #4560 by . - ♻ Simplify conditional assignment in
fastapi/dependencies/utils.py
. PR #4597 by . - ⬆ Upgrade version pin accepted for Flake8, for internal code, to
flake8 >=3.8.3,<6.0.0
. PR #4097 by . - 🍱 Update Jina banner, fix typo. PR #5301 by .
0.80.0
Breaking Changes - Fixes
- 🐛 Fix
response_model
not invalidatingNone
. PR #2725 by .
If you are using response_model
with some type that doesn’t include None
but the function is returning None
, it will now raise an internal server error, because you are returning invalid data that violates the contract in response_model
. Before this release it would allow breaking that contract returning None
.
For example, if you have an app like this:
…calling the path /items/invalidnone
will raise an error, because None
is not a valid type for the response_model
declared with Item
.
You could also be implicitly returning None
without realizing, for example:
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: Optional[float] = None
owner_ids: Optional[List[int]] = None
app = FastAPI()
@app.get("/items/invalidnone", response_model=Item)
def get_invalid_none():
if flag:
return {"name": "foo"}
# if flag is False, at this point the function will implicitly return None
If you have path operations using response_model
that need to be allowed to return None
, make it explicit in response_model
using Union[Something, None]
:
from typing import Union
from fastapi import FastAPI
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: Optional[float] = None
owner_ids: Optional[List[int]] = None
app = FastAPI()
@app.get("/items/invalidnone", response_model=Union[Item, None])
def get_invalid_none():
return None
This way the data will be correctly validated, you won’t have an internal server error, and the documentation will also reflect that this path operation could return None
(or null
in JSON).
Fixes
- ⬆ Upgrade Swagger UI copy of
oauth2-redirect.html
to include fixes for flavors of authorization code flows in Swagger UI. PR initial PR by @koonpeng. - ♻ Strip empty whitespace from description extracted from docstrings. PR by @and-semakin.
- 🐛 Fix cached dependencies when using a dependency in
Security()
and other places (e.g.Depends()
) with different OAuth2 scopes. PR by @laggardkernel. - 🎨 Update type annotations for
response_model
, allow things likeUnion[str, None]
. PR by @tiangolo.
Translations
- 🌐 Fix typos in German translation for
docs/de/docs/features.md
. PR #4533 by . - 🌐 Add missing navigator for
encoder.md
in Korean translation. PR #5238 by . - (Empty PR merge by accident) #4913.
0.79.1
Fixes
- 🐛 Fix
jsonable_encoder
usinginclude
andexclude
parameters for non-Pydantic objects. PR by @xaviml. - 🐛 Fix edge case with repeated aliases names not shown in OpenAPI. PR by @klaa97.
- 📝 Add misc dependency installs to tutorial docs. PR by @TeoZosa.
Docs
- 📝 Add note giving credit for illustrations to Ketrina Thompson. PR by @tiangolo.
- ✏ Fix typo in
python-types.md
. PR by @Kludex. - ✏ Fix typo in
docs/en/docs/python-types.md
. PR by @atiabbz. - 📝 Remove unneeded Django/Flask references from async topic intro. PR by @carltongibson.
- ✨ Add illustrations for Concurrent burgers and Parallel burgers. PR by @tiangolo. Updated docs at: .
Translations
- 🌐 Add Portuguese translation for
docs/pt/docs/tutorial/query-params.md
. PR by @batlopes. - 🌐 Add Portuguese translation for
docs/pt/docs/tutorial/security/first-steps.md
. PR by @FLAIR7. - 🌐 Add translation for
docs/zh/docs/advanced/response-cookies.md
. PR by @zhangbo2012. - 🌐 Add French translation for
docs/fr/docs/deployment/index.md
. PR by @rjNemo. - 🌐 Add Portuguese translation for
tutorial/handling-errors.md
. PR by @frnsimoes. - 🌐 Add French translation for
docs/fr/docs/history-design-future.md
. PR by @rjNemo. - 🌐 Add Russian translation for
docs/ru/docs/tutorial/background-tasks.md
. PR by @AdmiralDesu. - 🌐 Add Chinese translation for
docs/tutorial/security/first-steps.md
. PR by @jaystone776. - 🌐 Add Japanese translation for
docs/ja/docs/advanced/nosql-databases.md
. PR by @sUeharaE4. - 🌐 Add Indonesian translation for
docs/id/docs/tutorial/index.md
. PR by @bas-baskara. - 🌐 Add Persian translation for
docs/fa/docs/index.md
and tweak right-to-left CSS. PR by @mohsen-mahmoodi.
Internal
- 🔧 Update Jina sponsorship. PR #5283 by .
- 🔧 Update Jina sponsorship. PR #5272 by .
- 🔧 Update sponsors, Striveworks badge. PR #5179 by .
0.79.0
Fixes - Breaking Changes
- 🐛 Fix removing body from status codes that do not support it. PR #5145 by .
- Setting
status_code
to204
,304
, or any code below200
(1xx) will remove the body from the response. - This fixes an error in Uvicorn that otherwise would be thrown:
RuntimeError: Response content longer than Content-Length
. - This removes
fastapi.openapi.constants.STATUS_CODES_WITH_NO_BODY
, it is replaced by a function in utils.
- Setting
Translations
- 🌐 Start of Hebrew translation. PR by @itay-raveh.
- 🔧 Add config for Swedish translations notification. PR by @tiangolo.
- 🌐 Start of Swedish translation. PR by @MrRawbin.
- 🌐 Add Japanese translation for
docs/ja/docs/advanced/index.md
. PR by @wakabame. - 🌐🇵🇱 Add Polish translation for
docs/pl/docs/tutorial/first-steps.md
. PR by @Valaraucoo.
Internal
- 🔧 Update translations notification for Hebrew. PR #5158 by .
- 🔧 Update Dependabot commit message. PR #5156 by .
- ⬆ Bump actions/upload-artifact from 2 to 3. PR #5148 by .
- ⬆ Bump actions/cache from 2 to 3. PR #5149 by .
- 🔧 Update sponsors badge configs. PR #5155 by .
- 👥 Update FastAPI People. PR #5154 by .
- 🔧 Update Jina sponsor badges. PR #5151 by .
- ⬆ Bump actions/checkout from 2 to 3. PR #5133 by .
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #5030 by .
- ⬆ Bump nwtgck/actions-netlify from 1.1.5 to 1.2.3. PR #5132 by .
- ⬆ Bump codecov/codecov-action from 2 to 3. PR #5131 by .
- ⬆ Bump dawidd6/action-download-artifact from 2.9.0 to 2.21.1. PR #5130 by .
- ⬆ Bump actions/setup-python from 2 to 4. PR #5129 by .
- 👷 Add Dependabot. PR #5128 by .
- ♻️ Move from
Optional[X]
toUnion[X, None]
for internal utils. PR #5124 by . - 🔧 Update sponsors, remove Dropbase, add Doist. PR #5096 by .
- 🔧 Update sponsors, remove Classiq, add ImgWhale. PR #5079 by .
0.78.0
Features
✨ Add support for omitting
...
as default value when declaring required parameters with:Path()
Query()
Header()
Cookie()
Body()
Form()
File()
New docs at Tutorial - Query Parameters and String Validations - Make it required. PR by @tiangolo.
Up to now, declaring a required parameter while adding additional validation or metadata needed using ...
(Ellipsis).
For example:
…all these parameters are required because the default value is ...
(Ellipsis).
But now it’s possible and supported to just omit the default value, as would be done with Pydantic fields, and the parameters would still be required.
✨ For example, this is now supported:
from fastapi import Cookie, FastAPI, Header, Path, Query
app = FastAPI()
@app.get("/items/{item_id}")
def main(
item_id: int = Path(gt=0),
query: str = Query(max_length=10),
session: str = Cookie(min_length=3),
x_trace: str = Header(title="Tracing header"),
):
return {"message": "Hello World"}
To declare parameters as optional (not required), you can set a default value as always, for example using None
:
from typing import Union
from fastapi import Cookie, FastAPI, Header, Path, Query
app = FastAPI()
@app.get("/items/{item_id}")
def main(
item_id: int = Path(gt=0),
query: Union[str, None] = Query(default=None, max_length=10),
session: Union[str, None] = Cookie(default=None, min_length=3),
x_trace: Union[str, None] = Header(default=None, title="Tracing header"),
):
return {"message": "Hello World"}
Docs
- 📝 Add docs recommending
Union
overOptional
and migrate source examples. New docs at Python Types Intro - Using Union or Optional. PR by @tiangolo. - 🎨 Fix default value as set in tutorial for Path Operations Advanced Configurations. PR by @tiangolo.
- 📝 Add documentation for redefined path operations. PR by @madkinsz.
- 📝 Updates links for Celery documentation. PR by @sammyzord.
- ✏ Fix example code with sets in tutorial for body nested models. PR by @hitrust.
- ✏ Fix links to Pydantic docs. PR by @kinuax.
- 📝 Update docs about Swagger UI self-hosting with newer source links. PR by @Kastakin.
- 📝 Add link to external article: Building the Poll App From Django Tutorial With FastAPI And React. PR by @jbrocher.
- 📝 Add OpenAPI warning to “Body - Fields” docs with extra schema extensions. PR by @ml-evs.
Translations
- 🌐 Fix code examples in Japanese translation for
docs/ja/docs/tutorial/testing.md
. PR #4623 by .
Internal
- ♻ Refactor dict value extraction to minimize key lookups
fastapi/utils.py
. PR by @ShahriyarR. - ✅ Add tests for required nonable parameters and body fields. PR by @tiangolo.
- 👷 Fix installing Material for MkDocs Insiders in CI. PR by @tiangolo.
- 👷 Add pre-commit CI instead of custom GitHub Action. PR by @tiangolo.
- 👷 Add pre-commit GitHub Action workflow. PR by @tiangolo.
- 📝 Add dark mode auto switch to docs based on OS preference. PR by @ComicShrimp.
- 🔥 Remove un-used old pending tests, already covered in other places. PR by @tiangolo.
- 🔧 Add Python formatting hooks to pre-commit. PR by @tiangolo.
- 🔧 Add pre-commit with first config and first formatting pass. PR by @tiangolo.
- 👷 Disable CI installing Material for MkDocs in forks. PR by @dolfinus.
0.77.1
Upgrades
- ⬆ Upgrade Starlette from 0.19.0 to 0.19.1. PR by @Kludex.
Docs
- 📝 Add link to german article: REST-API Programmieren mittels Python und dem FastAPI Modul. PR #4624 by .
- 📝 Add external link: PyCharm Guide to FastAPI. PR #4512 by .
- 📝 Add external link to article: Building an API with FastAPI and Supabase and Deploying on Deta. PR #4440 by .
- ✏ Fix small typo in
docs/en/docs/tutorial/security/first-steps.md
. PR #4515 by .
Translations
- 🌐 Add Polish translation for
docs/pl/docs/tutorial/index.md
. PR by @MKaczkow. - ✏ Fix typo in deployment. PR by @raisulislam541.
- 🌐 Add Portuguese translation for
docs/pt/docs/help-fastapi.md
. PR by @mateusjs.
Internal
- 🔧 Add notifications in issue for Uzbek translations. PR #4884 by .
0.77.0
Upgrades
- ⬆ Upgrade Starlette from 0.18.0 to 0.19.0. PR #4488 by .
- When creating an explicit
JSONResponse
thecontent
argument is now required.
- When creating an explicit
Docs
- 📝 Add external link to article: Seamless FastAPI Configuration with ConfZ. PR by @silvanmelchior.
- 📝 Add external link to article: 5 Advanced Features of FastAPI You Should Try. PR by @kaustubhgupta.
- ✏ Reword to improve legibility of docs about
TestClient
. PR by @rgilton. - 📝 Add external link to blog post about Kafka, FastAPI, and Ably. PR by @Ugbot.
- ✏ Fix typo in
docs/en/docs/tutorial/sql-databases.md
. PR by @wpyoga. - ✏ Fix typo in
docs/en/docs/async.md
. PR by @Prezu.
Translations
- 🌐 Update source example highlights for
docs/zh/docs/tutorial/query-params-str-validations.md
. PR #4237 by . - 🌐 Remove translation docs references to aiofiles as it’s no longer needed since AnyIO. PR #3594 by .
- ✏ 🌐 Fix typo in Portuguese translation for
docs/pt/docs/tutorial/path-params.md
. PR #4722 by . - 🌐 Fix live docs server for translations for some languages. PR #4729 by .
- 🌐 Add Portuguese translation for
docs/pt/docs/tutorial/cookie-params.md
. PR #4112 by . - 🌐 Fix French translation for
docs/tutorial/body.md
. PR #4332 by . - 🌐 Add Japanese translation for
docs/ja/docs/advanced/conditional-openapi.md
. PR #2631 by . - 🌐 Fix Japanese translation of
docs/ja/docs/tutorial/body.md
. PR #3062 by . - 🌐 Add Portuguese translation for
docs/pt/docs/tutorial/background-tasks.md
. PR #2170 by . - 🌐 Add Portuguese translation for
docs/deployment/deta.md
. PR #4442 by . - 🌐 Add Russian translation for
docs/async.md
. PR #4036 by . - 🌐 Add Portuguese translation for
docs/tutorial/body.md
. PR #3960 by . - 🌐 Add Portuguese translation of
tutorial/extra-data-types.md
. PR #4077 by . - 🌐 Update German translation for
docs/features.md
. PR #3905 by .
0.76.0
Upgrades
- ⬆ Upgrade Starlette from 0.17.1 to 0.18.0. PR #4483 by .
Internal
- 👥 Update FastAPI People. PR by @github-actions[bot].
- 🔧 Add Budget Insight sponsor. PR by @tiangolo.
- 🍱 Update sponsor, ExoFlare badge. PR by @tiangolo.
- 🔧 Update sponsors, enable Dropbase again, update TalkPython link. PR by @tiangolo.
0.75.2
This release includes upgrades to third-party packages that handle security issues. Although there’s a chance these issues don’t affect you in particular, please upgrade as soon as possible.
Fixes
- ✅ Fix new/recent tests with new fixed
ValidationError
JSON Schema. PR by @tiangolo. - 🐛 Fix JSON Schema for
ValidationError
at fieldloc
. PR by @dconathan. - 🐛 Fix support for prefix on APIRouter WebSockets. PR by @Kludex.
- ⬆️ Update ujson ranges for CVE-2021-45958. PR #4804 by .
- ⬆️ Upgrade dependencies upper range for extras “all”. PR #4803 by .
- ⬆ Upgrade Swagger UI - swagger-ui-dist@4. This handles a security issue in Swagger UI itself where it could be possible to inject HTML into Swagger UI. Please upgrade as soon as you can, in particular if you expose your Swagger UI (
/docs
) publicly to non-expert users. PR #4347 by .
Internal
- 🔧 Update sponsors, add: ExoFlare, Ines Course; remove: Dropbase, Vim.so, Calmcode; update: Striveworks, TalkPython and TestDriven.io. PR by @tiangolo.
- ⬆️ Upgrade Codecov GitHub Action. PR by @tiangolo.
0.75.1
Translations
- 🌐 Start Dutch translations. PR by @tiangolo.
- 🌐 Start Persian/Farsi translations. PR by @aminalaee.
- ✏ Reword sentence about handling errors. PR by @khuhroproeza.
Internal
- 👥 Update FastAPI People. PR #4752 by .
- ➖ Temporarily remove typer-cli from dependencies and upgrade Black to unblock Pydantic CI. PR #4754 by .
- 🔧 Add configuration to notify Dutch translations. PR #4702 by .
- 👥 Update FastAPI People. PR #4699 by .
- 🐛 Fix FastAPI People generation to include missing file in commit. PR #4695 by .
- 🔧 Update Classiq sponsor links. PR #4688 by .
- 🔧 Add Classiq sponsor. PR #4671 by .
- 📝 Add Jina’s QA Bot to the docs to help people that want to ask quick questions. PR #4655 by based on original PR #4626 by .
0.75.0
Features
- ✨ Add support for custom
generate_unique_id_function
and docs for generating clients. New docs: Advanced - Generate Clients. PR by @tiangolo.
0.74.1
Features
- ✨ Include route in scope to allow middleware and other tools to extract its information. PR by @tiangolo.
0.74.0
Breaking Changes
- ✨ Update internal
AsyncExitStack
to fix context for dependencies withyield
. PR by @tiangolo.
Dependencies with yield
can now catch HTTPException
and custom exceptions. For example:
After the dependency with yield
handles the exception (or not) the exception is raised again. So that any exception handlers can catch it, or ultimately the default internal ServerErrorMiddleware
.
If you depended on exceptions not being received by dependencies with yield
, and receiving an exception breaks the code after yield
, you can use a block with try
and finally
:
async def do_something():
try:
yield something
finally:
some_cleanup()
…that way the finally
block is run regardless of any exception that might happen.
Features
This means that now, if you set a value in a context variable before yield
, the value would still be available after yield
(as you would intuitively expect). And it also means that you can reset the context variable with a token afterwards.
For example, this works correctly now:
from contextvars import ContextVar
from typing import Any, Dict, Optional
legacy_request_state_context_var: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
"legacy_request_state_context_var", default=None
)
async def set_up_request_state_dependency():
request_state = {"user": "deadpond"}
contextvar_token = legacy_request_state_context_var.set(request_state)
yield request_state
legacy_request_state_context_var.reset(contextvar_token)
…before this change it would raise an error when resetting the context variable, because the contextvars
context was different, because of the way it was implemented.
Note: You probably don’t need contextvars
, and you should probably avoid using them. But they are powerful and useful in some advanced scenarios, for example, migrating from code that used Flask’s g
semi-global variable.
Technical Details: If you want to know more of the technical details you can check out the PR description #4575.
Internal
- 🔧 Add Striveworks sponsor. PR #4596 by .
- 💚 Only build docs on push when on master to avoid duplicate runs from PRs. PR #4564 by .
- 👥 Update FastAPI People. PR #4502 by .
0.73.0
Features
- ✨ Add support for declaring
UploadFile
parameters without explicitFile()
. PR #4469 by . New docs: Request Files - File Parameters with UploadFile. - ✨ Add support for tags with Enums. PR by @tiangolo. New docs: .
- ✨ Allow hiding from OpenAPI (and Swagger UI)
Query
,Cookie
,Header
, andPath
parameters. PR #3144 by . New docs: Query Parameters and String Validations - Exclude from OpenAPI.
Docs
- 📝 Tweak and improve docs for Request Files. PR #4470 by .
Fixes
- 🐛 Fix bug preventing to use OpenAPI when using tuples. PR by @victorbenichoux.
- 🐛 Prefer custom encoder over defaults if specified in
jsonable_encoder
. PR by @viveksunder.- 💚 Duplicate PR to trigger CI. PR by @tiangolo.
Internal
- 🐛 Fix docs dependencies cache, to get the latest Material for MkDocs. PR #4466 by .
- 🔧 Add sponsor Dropbase. PR #4465 by .
0.72.0
Features
- ✨ Enable configuring Swagger UI parameters. Original PR #2568 by . Here are the new docs: Configuring Swagger UI.
Docs
- 📝 Update Python Types docs, add missing 3.6 / 3.9 example. PR #4434 by .
Translations
- 🌐 Update Chinese translation for
docs/help-fastapi.md
. PR by @jaystone776. - 🌐 Fix Korean translation for
docs/ko/docs/index.md
. PR by @kty4119. - 🌐 Add Polish translation for
docs/pl/docs/index.md
. PR by @MicroPanda123. - 🌐 Add Chinese translation for
docs\tutorial\path-operation-configuration.md
. PR by @jaystone776.
Internal
- 🔧 Enable MkDocs Material Insiders’
content.tabs.link
. PR #4399 by .
0.71.0
Features
- ✨ Add docs and tests for Python 3.9 and Python 3.10. PR #3712 by .
- You can start with Python Types Intro, it explains what changes between different Python versions, in Python 3.9 and in Python 3.10.
- All the FastAPI docs are updated. Each code example in the docs that could use different syntax in Python 3.9 or Python 3.10 now has all the alternatives in tabs.
- ⬆️ Upgrade Starlette to 0.17.1. PR by @simondale00.
Internal
- 👥 Update FastAPI People. PR #4354 by .
- 🔧 Add FastAPI Trove Classifier for PyPI as now there’s one 🤷😁. PR #4386 by .
- ⬆ Upgrade MkDocs Material and configs. PR #4385 by .
0.70.1
There’s nothing interesting in this particular FastAPI release. It is mainly to enable/unblock the release of the next version of Pydantic that comes packed with features and improvements. 🤩
Fixes
- 🐛 Fix JSON Schema for dataclasses, supporting the fixes in Pydantic 1.9. PR #4272 by .
Translations
- 🌐 Add Korean translation for
docs/tutorial/request-forms-and-files.md
. PR by @NinaHwang. - 🌐 Add Korean translation for
docs/tutorial/request-files.md
. PR by @NinaHwang. - 🌐 Add portuguese translation for
docs/tutorial/query-params-str-validations.md
. PR by @leandrodesouzadev. - 🌐 Add Korean translation for
docs/tutorial/response-status-code.md
. PR by @NinaHwang. - 🌐 Add Korean translation for Tutorial - JSON Compatible Encoder. PR by @NEONKID.
- 🌐 Add Korean translation for Tutorial - Path Parameters and Numeric Validations. PR by @hard-coders.
- 🌐 Add Korean translation for
docs/ko/docs/deployment/versions.md
. PR by @DevDae. - 🌐 Fix Korean translation for
docs/ko/docs/tutorial/index.md
. PR by @kimjaeyoonn. - 🔧 Add CryptAPI sponsor. PR by @tiangolo.
- 📝 Update
docs/tutorial/dependencies/classes-as-dependencies
: Add type of query parameters in a description ofClasses as dependencies
. PR by @0417taehyun. - 🌐 Add French translation for Tutorial - First steps. PR by @Smlep.
- 🌐 Add French translation for
docs/tutorial/path-params.md
. PR by @Smlep. - 🌐 Add French translation for . PR by @Smlep.
- 🌐 Add Turkish translation for
docs/python-types.md
. PR by @BilalAlpaslan.
Internal
- 👥 Update FastAPI People. PR #4274 by .
0.70.0
This release just upgrades Starlette to the latest version, 0.16.0
, which includes several bug fixes and some small breaking changes.
These last three consecutive releases are independent so that you can migrate gradually:
- First to FastAPI
0.68.2
, with no breaking changes, but upgrading all the sub-dependencies. - Next to FastAPI
0.69.0
, which upgrades Starlette to0.15.0
, with AnyIO support, and a higher chance of having breaking changes in your code. - Finally to FastAPI
0.70.0
, just upgrading Starlette to the latest version0.16.0
with additional bug fixes.
This way, in case there was a breaking change for your code in one of the releases, you can still benefit from the previous upgrades. ✨
Breaking Changes - Upgrade
- ⬆️ Upgrade Starlette to 0.16.0. PR #4016 by .
Also upgrades the ranges of optional dependencies:
"jinja2 >=2.11.2,<4.0.0"
"itsdangerous >=1.1.0,<3.0.0"
0.69.0
Breaking Changes - Upgrade
This release adds support for Trio. ✨
It upgrades the version of Starlette to 0.15.0
, now based on , and the internal async components in FastAPI are now based on AnyIO as well, making it compatible with both asyncio and Trio.
You can read the docs about running FastAPI with Trio using Hypercorn.
This release also removes graphene
as an optional dependency for GraphQL. If you need to work with GraphQL, the recommended library now is . You can read the new FastAPI with GraphQL docs.
Features
- ✨ Add support for Trio via AnyIO, upgrading Starlette to
0.15.0
. PR #3372 by . - ➖ Remove
graphene
as an optional dependency. PR #4007 by .
Docs
- 📝 Add docs for using Trio with Hypercorn. PR by @tiangolo.
- ✏ Fix typos in Deployment Guide. PR by @ghandic.
- 📝 Update docs with pip install calls when using extras with brackets, use quotes for compatibility with Zsh. PR by @tomwei7.
- 📝 Add external link to article: Deploying ML Models as API Using FastAPI and Heroku. PR by @kaustubhgupta.
- ✏ Fix typo in file paths in
docs/en/docs/contributing.md
. PR by @NinaHwang. - ✏ Fix a typo in
docs/en/docs/advanced/path-operation-advanced-configuration.md
anddocs/en/docs/release-notes.md
. PR by @saintmalik. - ✏️ Add a missing comma in the security tutorial. PR by @jalvaradosegura.
- ✏ Fix typo in
docs/en/docs/help-fastapi.md
. PR by @jaystone776. - ✏ Fix typo about file path in
docs/en/docs/tutorial/bigger-applications.md
. PR by @HolyDorus. - ✏ Re-word to clarify test client in
docs/en/docs/tutorial/testing.md
. PR by @Bharat123rox. - 📝 Fix incorrect highlighted code. PR by @paxcodes.
- 📝 Add external link to article: How-to deploy FastAPI app to Heroku. PR by @Jarmos-san.
- ✏ Fix typo (mistranslation) in
docs/en/docs/advanced/templates.md
. PR by @oerpli. - 📝 Remove note about (now supported) feature from Swagger UI in
docs/en/docs/tutorial/request-files.md
. PR by @gsganden. - ✏ Fix typo re-word in
docs/tutorial/handling-errors.md
. PR by @graue70.
Translations
- 🌐 Initialize Azerbaijani translations. PR #3941 by .
- 🌐 Add Turkish translation for
docs/fastapi-people.md
. PR #3848 by .
Internal
- 📝 Add supported Python versions badge. PR by @hramezani.
- ✏ Fix link in Japanese docs for
docs/ja/docs/deployment/docker.md
. PR by @utamori. - 🔧 Correct DeprecationWarning config and comment in pytest settings. PR by @graingert.
- 🔧 Swap light/dark theme button icon. PR by @eddsalkield.
- 🔧 Lint only in Python 3.7 and above. PR by @tiangolo.
- 🔧 Add GitHub Action notify-translations config for Azerbaijani. PR by @tiangolo.
0.68.2
This release has no breaking changes. 🎉
It upgrades the version ranges of sub-dependencies to allow applications using FastAPI to easily upgrade them.
Soon there will be a new FastAPI release upgrading Starlette to take advantage of recent improvements, but as that has a higher chance of having breaking changes, it will be in a separate release.
Features
- ⬆Increase supported version of aiofiles to suppress warnings. PR by @SnkSynthesis.
- ➖ Do not require backports in Python >= 3.7. PR by @FFY00.
- ⬆ Upgrade required Python version to >= 3.6.1, needed by typing.Deque, used by Pydantic. PR by @hukkin.
- ⬆️ Bump Uvicorn max range to 0.15.0. PR by @Kludex.
Docs
- 📝 Update GraphQL docs, recommend Strawberry. PR #3981 by .
- 📝 Re-write and extend Deployment guide: Concepts, Uvicorn, Gunicorn, Docker, Containers, Kubernetes. PR #3974 by .
- 📝 Upgrade HTTPS guide with more explanations and diagrams. PR #3950 by .
Translations
- 🌐 Add Turkish translation for
docs/features.md
. PR by @ycd. - 🌐 Add Turkish translation for
docs/benchmarks.md
. PR by @Telomeraz. - 🌐 Add Turkish translation for
docs/index.md
. PR by @ycd. - 🌐 Add French translation for
docs/tutorial/body.md
. PR by @Smlep. - 🌐 Add French translation for
deployment/docker.md
. PR by @rjNemo. - 🌐 Add Portuguese translation for
docs/tutorial/path-params.md
. PR by @FelipeSilva93. - 🌐 Add Portuguese translation for
docs/deployment/https.md
. PR by @lsglucas. - 🌐 Add German translation for
docs/features.md
. PR by @mawassk.
Internal
- ✨ Update GitHub Action: notify-translations, to avoid a race conditions. PR #3989 by .
- ⬆️ Upgrade development
autoflake
, supporting multi-line imports. PR #3988 by . - ⬆️ Increase dependency ranges for tests and docs: pytest-cov, pytest-asyncio, black, httpx, sqlalchemy, databases, mkdocs-markdownextradata-plugin. PR #3987 by .
- 👥 Update FastAPI People. PR #3986 by .
- 💚 Fix badges in README and main page. PR #3979 by .
- ⬆ Upgrade internal testing dependencies: mypy to version 0.910, add newly needed type packages. PR #3350 by .
- ✨ Add Deepset Sponsorship. PR #3976 by .
- 🎨 Tweak CSS styles for shell animations. PR #3888 by .
- 🔧 Add new Sponsor Calmcode.io. PR #3777 by .
0.68.1
- ✨ Add support for
read_with_orm_mode
, to support relationship attributes. PR #3757 by .
Translations
- 🌐 Add Portuguese translation of
docs/fastapi-people.md
. PR by @ComicShrimp. - 🌐 Add Chinese translation for
docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md
. PR by @jaystone776. - 🔧 Add new Translation tracking issues for German and Indonesian. PR by @tiangolo.
- 🌐 Add Chinese translation for
docs/tutorial/dependencies/sub-dependencies.md
. PR by @jaystone776. - 🌐 Add Portuguese translation for
docs/advanced/index.md
. PR by @ComicShrimp. - 🌐 Portuguese translation of
docs/async.md
. PR by @Serrones. - 🌐 Add French translation for
docs/async.md
. PR by @Smlep.
Internal
- ✨ Add GitHub Action: Notify Translations. PR #3715 by .
- ✨ Update computation of FastAPI People and sponsors. PR #3714 by .
- ✨ Enable recent Material for MkDocs Insiders features. PR #3710 by .
- 🔥 Remove/clean extra imports from examples in docs for features. PR #3709 by .
- ➕ Update docs library to include sources in Markdown. PR #3648 by .
- ⬆ Enable tests for Python 3.9. PR #2298 by .
- 👥 Update FastAPI People. PR #3642 by .
0.68.0
Features
- ✨ Add support for extensions and updates to the OpenAPI schema in each path operation. New docs: FastAPI Path Operation Advanced Configuration - OpenAPI Extra. Initial PR by @edouardlp.
- ✨ Add additional OpenAPI metadata parameters to
FastAPI
class, shown on the automatic API docs UI. New docs: . Initial PR #1812 by . - ✨ Add
description
parameter to all the security scheme classes, e.g.APIKeyQuery(name="key", description="A very cool API key")
. PR #1757 by . - ✨ Update OpenAPI models, supporting recursive models and extensions. PR #3628 by .
- ✨ Import and re-export data structures from Starlette, used by Request properties, on
fastapi.datastructures
. Initial PR #1872 by .
Docs
- 📝 Update docs about async and response-model with more gender neutral language. PR by @Edward-Knight.
Translations
- 🌐 Add Russian translation for
docs/python-types.md
. PR #3039 by . - 🌐 Add Chinese translation for
docs/tutorial/dependencies/index.md
. PR #3489 by . - 🌐 Add Russian translation for
docs/external-links.md
. PR #3036 by . - 🌐 Add Chinese translation for
docs/tutorial/dependencies/global-dependencies.md
. PR #3493 by . - 🌐 Add Portuguese translation for
docs/deployment/versions.md
. PR #3618 by . - 🌐 Add Japanese translation for
docs/tutorial/security/oauth2-jwt.md
. PR #3526 by .
Internal
- ✅ Add the
docs_src
directory to test coverage and update tests. Initial PR by @Kludex. - 🔧 Add new GitHub templates with forms for new issues. PR by @tiangolo.
- 📝 Add official FastAPI Twitter to docs: . PR #3578 by .
0.67.0
Features
- ✨ Add support for
dataclasses
in request bodies andresponse_model
. New documentation: Advanced User Guide - Using Dataclasses. PR by @tiangolo. - ✨ Support
dataclasses
in responses. PR by @tiangolo, continuation from initial PR by @amitlissack.
Docs
- 📝 Add external link: How to Create A Fake Certificate Authority And Generate TLS Certs for FastAPI. PR #2839 by .
- ✏ Fix code highlighted line in:
body-nested-models.md
. PR #3463 by . - ✏ Fix typo in
body-nested-models.md
. PR #3462 by . - ✏ Fix typo “might me” -> “might be” in
docs/en/docs/tutorial/schema-extra-example.md
. PR #3362 by . - 📝 Add external link: Building simple E-Commerce with NuxtJS and FastAPI. PR #3271 by .
- 📝 Add external link: Serve a machine learning model using Sklearn, FastAPI and Docker. PR #2974 by .
- ✏️ Fix typo on docstring in datastructures file. PR #2887 by .
- 📝 Add External Link: Deploy FastAPI on Ubuntu and Serve using Caddy 2 Web Server. PR #3572 by .
- 📝 Add External Link, replaces #1898. PR #3571 by .
Internal
- 🎨 Improve style for sponsors, add radius border. PR by @Kludex.
- 👷 Update GitHub Action latest-changes. PR by @tiangolo.
- 👷 Update GitHub Action latest-changes. PR by @tiangolo.
- 👷 Rename and clarify CI workflow job names. PR by @tiangolo.
- 👷 Update GitHub Action latest-changes, strike 2 ⚾. PR by @tiangolo.
- 🔧 Sort external links in docs to have the most recent at the top. PR by @tiangolo.
0.66.1
- 🌐 Add basic setup for German translations. PR by @0x4Dark.
- 🌐 Add Portuguese translation for
docs/tutorial/security/index.md
. PR by @oandersonmagalhaes. - 🌐 Add Portuguese translation for
docs/deployment/index.md
. PR by @lsglucas.
Internal
- 🔧 Configure strict pytest options and update/refactor tests. Upgrade pytest to
>=6.2.4,<7.0.0
and pytest-cov to>=2.12.0,<3.0.0
. Initial PR #2790 by . - ⬆️ Upgrade python-jose dependency to
>=3.3.0,<4.0.0
for tests. PR #3468 by .
0.66.0
Features
- ✨ Allow setting the
response_class
toRedirectResponse
orFileResponse
and returning the URL from the function. New and updated docs are in the tutorial section Custom Response - HTML, Stream, File, others, in RedirectResponse and in . PR #3457 by .
Fixes
- 🐛 Fix include/exclude for dicts in
jsonable_encoder
. PR by @Rubikoid. - 🐛 Support custom OpenAPI / JSON Schema fields in the generated output OpenAPI. PR by @jmagnusson.
Translations
- 🌐 Add Spanish translation for
tutorial/query-params.md
. PR #2243 by . - 🌐 Add Spanish translation for
advanced/response-directly.md
. PR #1253 by . - 🌐 Add Spanish translation for
advanced/additional-status-codes.md
. PR #1252 by . - 🌐 Add Spanish translation for
advanced/path-operation-advanced-configuration.md
. PR #1251 by .
0.65.3
Fixes
- ♻ Assume request bodies contain JSON when no Content-Type header is provided. This fixes a breaking change introduced by 0.65.2 with PR #2118. It should allow upgrading FastAPI applications with clients that send JSON data without a
Content-Type
header. And there’s still protection against CSRFs. PR by @tiangolo.
Translations
- 🌐 Initialize Indonesian translations. PR #3014 by .
- 🌐 Add Spanish translation of Tutorial - Path Parameters. PR #2219 by .
- 🌐 Add Spanish translation of Tutorial - First Steps. PR #2208 by .
- 🌐 Portuguese translation of Tutorial - Body - Fields. PR #3420 by .
- 🌐 Add Chinese translation for Tutorial - Request - Forms - and - Files. PR #3249 by .
- 🌐 Add Chinese translation for Tutorial - Handling - Errors. PR #3299 by .
- 🌐 Add Chinese translation for Tutorial - Form - Data. PR #3248 by .
- 🌐 Add Chinese translation for Tutorial - Body - Updates. PR #3237 by .
- 🌐 Add Chinese translation for FastAPI People. PR #3112 by .
- 🌐 Add French translation for Project Generation. PR #3197 by .
- 🌐 Add French translation for Python Types Intro. PR #3185 by .
- 🌐 Add French translation for External Links. PR #3103 by .
- 🌐 Add French translation for Alternatives, Inspiration and Comparisons. PR #3020 by .
- 🌐 Fix Chinese translation code snippet mismatch in Tutorial - Python Types Intro. PR #2573 by .
- 🌐 Add Portuguese translation for Development Contributing. PR #1364 by .
- 🌐 Add Chinese translation for Tutorial - Request - Files. PR #3244 by .
Internal
- 👥 Update FastAPI People. PR by @github-actions[bot].
- 👥 Update FastAPI People. PR by @github-actions[bot].
- ⬆ Upgrade docs development dependency on
typer-cli
to >=0.0.12 to fix conflicts. PR by @tiangolo.
0.65.2
Security fixes
- 🔒 Check Content-Type request header before assuming JSON. Initial PR by @patrickkwang.
This change fixes a security vulnerability when using cookies for authentication in path operations with JSON payloads sent by browsers.
In versions lower than 0.65.2
, FastAPI would try to read the request payload as JSON even if the content-type
header sent was not set to application/json
or a compatible JSON media type (e.g. application/geo+json
).
So, a request with a content type of text/plain
containing JSON data would be accepted and the JSON data would be extracted.
But requests with content type text/plain
are exempt from CORS preflights, for being considered . So, the browser would execute them right away including cookies, and the text content could be a JSON string that would be parsed and accepted by the FastAPI application.
See CVE-2021-32677 for more details.
Thanks to for the security report! 🙇🔒
Internal
- 🔧 Update sponsors badge, course bundle. PR by @tiangolo.
- 🔧 Add new gold sponsor Jina 🎉. PR by @tiangolo.
- 🔧 Add new banner sponsor badge for FastAPI courses bundle. PR by @tiangolo.
- 👷 Upgrade Issue Manager GitHub Action. PR by @tiangolo.
0.65.1
Security fixes
- 📌 Upgrade pydantic pin, to handle security vulnerability . PR #3213 by .
0.65.0
Breaking Changes - Upgrade
- ⬆️ Upgrade Starlette to
0.14.2
, including internalUJSONResponse
migrated from Starlette. This includes several bug fixes and features from Starlette. PR #2335 by .
Translations
- 🌐 Initialize new language Polish for translations. PR by @neternefer.
Internal
- 👷 Add GitHub Action cache to speed up CI installs. PR #3204 by .
- ⬆️ Upgrade setup-python GitHub Action to v2. PR #3203 by .
- 🐛 Fix docs script to generate a new translation language with
overrides
boilerplate. PR #3202 by . - ✨ Add new Deta banner badge with new sponsorship tier 🙇. PR #3194 by .
- 👥 Update FastAPI People. PR #3189 by .
- 🔊 Update FastAPI People to allow better debugging. PR #3188 by .
0.64.0
Features
- ✨ Add support for adding multiple
examples
in request bodies and path, query, cookie, and header params. New docs: Declare Request Example Data. Initial PR by @austinorr.
Fixes
- 📌 Pin SQLAlchemy range for tests, as it doesn’t use SemVer. PR #3001 by .
- 🎨 Add newly required type annotations for mypy. PR #2882 by .
- 🎨 Remove internal “type: ignore”, now unnecessary. PR #2424 by .
Docs
- 📝 Add link to article in Russian “FastAPI: знакомимся с фреймворком”. PR by @trkohler.
- 📝 Add external link to blog post “Authenticate Your FastAPI App with Auth0”. PR by @dompatmore.
- 📝 Fix broken link to article: Machine learning model serving in Python using FastAPI and Streamlit. PR by @davidefiocco.
- 📝 Add FastAPI Medium Article: Deploy a dockerized FastAPI application to AWS. PR by @vjanz.
- ✏ Fix typo in Tutorial - Handling Errors. PR by @johnthagen.
- ✏ Fix typo in Security OAuth2 scopes. PR by @jugmac00.
- ✏ Fix typo/clarify docs for SQL (Relational) Databases. PR by @kangni.
- 📝 Add external link to “FastAPI for Flask Users”. PR by @amitness.
Translations
- 🌐 Fix Chinese translation of Tutorial - Query Parameters, remove obsolete content. PR #3051 by .
- 🌐 Add French translation for Tutorial - Background Tasks. PR #3098 by .
- 🌐 Fix Korean translation for docs/ko/docs/index.md. PR #3159 by .
- 🌐 Add Korean translation for Tutorial - Query Parameters. PR #2390 by .
- 🌐 Add French translation for FastAPI People. PR #2232 by .
- 🌐 Add Korean translation for Tutorial - Path Parameters. PR #2355 by .
- 🌐 Add French translation for Features. PR #2157 by .
- 👥 Update FastAPI People. PR #3031 by .
- 🌐 Add Chinese translation for Tutorial - Debugging. PR #2737 by .
- 🌐 Add Chinese translation for Tutorial - Security - OAuth2 with Password (and hashing), Bearer with JWT tokens. PR #2642 by .
- 🌐 Add Korean translation for Tutorial - Header Parameters. PR #2589 by .
- 🌐 Add Chinese translation for Tutorial - Metadata and Docs URLs. PR #2559 by .
- 🌐 Add Korean translation for Tutorial - First Steps. PR #2323 by .
- 🌐 Add Chinese translation for Tutorial - CORS (Cross-Origin Resource Sharing). PR #2540 by .
- 🌐 Add Chinese translation for Tutorial - Middleware. PR #2334 by .
- 🌐 Add Korean translation for Tutorial - Intro. PR #2317 by .
- 🌐 Add Chinese translation for Tutorial - Bigger Applications - Multiple Files. PR #2453 by .
- 🌐 Add Chinese translation for Tutorial - Security - Security Intro. PR #2443 by .
- 🌐 Add Chinese translation for Tutorial - Header Parameters. PR #2412 by .
- 🌐 Add Chinese translation for Tutorial - Extra Data Types. PR #2410 by .
- 🌐 Add Japanese translation for Deployment - Docker. PR #2312 by .
- 🌐 Add Japanese translation for Deployment - Versions. PR #2310 by .
- 🌐 Add Chinese translation for Tutorial - Cookie Parameters. PR #2261 by .
- 🌐 Add Japanese translation for Tutorial - Static files. PR #2260 by .
- 🌐 Add Japanese translation for Tutorial - Testing. PR #2259 by .
- 🌐 Add Japanese translation for Tutorial - Debugging. PR #2256 by .
- 🌐 Add Japanese translation for Tutorial - Middleware. PR #2255 by .
- 🌐 Add Japanese translation for Concurrency and async / await. PR #2058 by .
- 🌐 Add Chinese translation for Tutorial - Security - Simple OAuth2 with Password and Bearer. PR #2514 by .
- 🌐 Add Japanese translation for Deployment - Deta. PR #2314 by .
- 🌐 Add Chinese translation for Tutorial - Security - Get Current User. PR #2474 by .
- 🌐 Add Japanese translation for Deployment - Manually. PR #2313 by .
- 🌐 Add Japanese translation for Deployment - Intro. PR #2309 by .
- 🌐 Add Japanese translation for FastAPI People. PR #2254 by .
- 🌐 Add Japanese translation for Advanced - Path Operation Advanced Configuration. PR #2124 by .
- 🌐 Add Japanese translation for External Links. PR #2070 by .
- 🌐 Add Japanese translation for Tutorial - Body - Updates. PR #1956 by .
- 🌐 Add Japanese translation for Tutorial - Form Data. PR #1943 by .
- 🌐 Add Japanese translation for Tutorial - Cookie Parameters. PR #1933 by .
Internal
- 🔧 Update top banner, point to newsletter. PR by @tiangolo.
- 🔧 Disable sponsor WeTransfer. PR by @tiangolo.
- 👥 Update FastAPI People. PR by @github-actions[bot].
- 👥 Update FastAPI People. PR by @github-actions[bot].
- 🔧 Add new Gold Sponsor Talk Python 🎉. PR by @tiangolo.
- 🔧 Add new Gold Sponsor vim.so 🎉. PR by @tiangolo.
- 🔧 Add FastAPI user survey banner. PR by @tiangolo.
- 🔧 Add new Bronze Sponsor(s) 🥉🎉. PR by @tiangolo.
- 📝 Update social links: add Discord, fix GitHub. PR by @tiangolo.
- 🔧 Update FastAPI People GitHub Sponsors order. PR by @tiangolo.
- 🔧 Update InvestSuite sponsor data. PR by @tiangolo.
- 👥 Update FastAPI People. PR by @github-actions[bot].
0.63.0
Features
- ✨ Improve type annotations, add support for mypy —strict, internally and for external packages. PR by @tiangolo.
Breaking changes
- ⬆️ Upgrade Uvicorn when installing
fastapi[all]
to the latest version includinguvloop
, the new range isuvicorn[standard] >=0.12.0,<0.14.0
. PR #2548 by .
Fixes
- 🐛 PR (read above) also fixes some false-positive mypy errors with
callbacks
parameters and when using theOAuth2
class.
Docs
- 📝 Update Uvicorn installation instructions to use uvicorn[standard] (includes uvloop). PR by @tiangolo.
- 📝 Update title for Deta tutorial. PR by @tiangolo.
- 👥 Update FastAPI People. PR by @github-actions[bot].
Translations
- 🌐 Add docs lang selector widget. PR #2542 by .
- 🌐 Add Chinese translation for Tutorial - Response Status Code. PR #2442 by .
- 🌐 Start translation of the documentation for the Albanian language. PR #2516 by .
- 🌐 Add Chinese translation for Tutorial - Extra Models. PR #2416 by .
- 🌐 Add Chinese translation for Tutorial - Response Model. PR #2414 by .
- 🌐 Add Chinese translation for Tutorial - Schema Extra Example. PR #2411 by .
- 🌐 Add Korean translation for Index. PR #2192 by .
- 🌐 Add Japanese translation for Advanced User Guide - Additional Status Codes. PR #2145 by .
Internal
- 🐛 Fix docs overrides directory for translations. PR by @tiangolo.
- ➖ Remove Typer as a docs building dependency (covered by typer-cli) to fix pip resolver conflicts. PR by @tiangolo.
- ✨ Add newsletter: FastAPI and friends. PR by @tiangolo.
- ✨ Add new Gold Sponsor: InvestSuite 🎉. PR by @tiangolo.
- 🔧 Add issue template configs. PR by @tiangolo.
0.62.0
Features
- ✨ Add support for shared/top-level parameters (dependencies, tags, etc). PR by @tiangolo.
Up to now, for several options, the only way to apply them to a group of path operations was in include_router
. That works well, but the call to app.include_router()
or router.include_router()
is normally done in another file.
That means that, for example, to apply authentication to all the path operations in a router it would end up being done in a different file, instead of keeping related logic together.
Setting options in include_router
still makes sense in some cases, for example, to override or increase configurations from a third party router included in an app. But in a router that is part of a bigger application, it would probably make more sense to add those settings when creating the APIRouter
.
In FastAPI
This allows setting the (mostly new) parameters (additionally to the already existing parameters):
default_response_class
: updated to handle defaults inAPIRouter
andinclude_router
.dependencies
: to include ✨ top-level dependencies ✨ that apply to the whole application. E.g. to add global authentication.callbacks
: OpenAPI callbacks that apply to all the path operations.deprecated
: to mark all the path operations as deprecated. 🤷include_in_schema
: to allow excluding all the path operations from the OpenAPI schema.responses
: OpenAPI responses that apply to all the path operations.
For example:
In APIRouter
This allows setting the (mostly new) parameters (additionally to the already existing parameters):
default_response_class
: updated to handle defaults inAPIRouter
andinclude_router
. For example, it’s not needed to set it explicitly when .dependencies
: to include ✨ router-level dependencies ✨ that apply to all the path operations in a router. Up to now, this was only possible withinclude_router
.callbacks
: OpenAPI callbacks that apply to all the path operations in this router.deprecated
: to mark all the path operations in a router as deprecated.include_in_schema
: to allow excluding all the path operations in a router from the OpenAPI schema.responses
: OpenAPI responses that apply to all the path operations in a router.prefix
: to set the path prefix for a router. Up to now, this was only possible when callinginclude_router
.tags
: OpenAPI tags to apply to all the path operations in this router.
For example:
from fastapi import APIRouter, Depends
async def some_dependency():
return
router = APIRouter(prefix="/users", dependencies=[Depends(some_dependency)])
In include_router
Most of these settings are now supported in APIRouter
, which normally lives closer to the related code, so it is recommended to use APIRouter
when possible.
But include_router
is still useful to, for example, adding options (like dependencies
, prefix
, and tags
) when including a third party router, or a generic router that is shared between several projects.
This PR allows setting the (mostly new) parameters (additionally to the already existing parameters):
default_response_class
: updated to handle defaults inAPIRouter
andFastAPI
.deprecated
: to mark all the path operations in a router as deprecated in OpenAPI.include_in_schema
: to allow disabling all the path operations from showing in the OpenAPI schema.callbacks
: OpenAPI callbacks that apply to all the path operations in this router.
Breaking Changes
- PR includes several improvements that shouldn’t affect normal use cases, but could affect in advanced scenarios:
- If you are testing the generated OpenAPI (you shouldn’t, FastAPI already tests it extensively for you): the order for
tags
ininclude_router
and path operations was updated for consistency, but it’s a simple order change. - If you have advanced custom logic to access each route’s
route.response_class
, or therouter.default_response_class
, or theapp.default_response_class
: the default value forresponse_class
inAPIRoute
and fordefault_response_class
inAPIRouter
andFastAPI
is now aDefaultPlaceholder
used internally to handle and solve default values and overrides. The actual response class inside theDefaultPlaceholder
is available atroute.response_class.value
.
- If you are testing the generated OpenAPI (you shouldn’t, FastAPI already tests it extensively for you): the order for
Docs
PR (above) includes new or updated docs:
📝 Add FastAPI monitoring blog post to External Links. PR #2324 by .
✏️ Fix typo in Deta tutorial. PR #2320 by .
- ✨ Add Discord chat. PR #2322 by .
- 📝 Fix image links for sponsors. PR #2304 by .
Translations
- 🌐 Add Japanese translation for Advanced - Custom Response. PR by @Attsun1031.
- 🌐 Add Chinese translation for Benchmarks. PR by @spaceack.
- 🌐 Add Chinese translation for Tutorial - Body - Nested Models. PR by @waynerv.
- 🌐 Add Chinese translation for Advanced - Custom Response. PR by @RunningIkkyu.
- 🌐 Add Chinese translation for Advanced - Return a Response Directly. PR by @RunningIkkyu.
- 🌐 Add Chinese translation for Advanced - Additional Status Codes. PR by @RunningIkkyu.
- 🌐 Add Chinese translation for Advanced - Path Operation Advanced Configuration. PR by @RunningIkkyu.
- 🌐 Add Chinese translation for Advanced User Guide - Intro. PR by @RunningIkkyu.
Internal
- 🔧 Update TestDriven link to course in sponsors section. PR #2435 by .
- 🍱 Update sponsor logos. PR #2418 by .
- 💚 Fix disabling install of Material for MkDocs Insiders in forks, strike 1 ⚾. PR #2340 by .
- 🐛 Fix disabling Material for MkDocs Insiders install in forks. PR #2339 by .
- ✨ Add silver sponsor WeTransfer. PR #2338 by .
- ✨ Set up and enable Material for MkDocs Insiders for the docs. PR #2325 by .
0.61.2
Fixes
- 📌 Relax Swagger UI version pin. PR #2089 by .
- 🐛 Fix bug overriding custom HTTPException and RequestValidationError from exception_handlers. PR #1924 by .
- ✏️ Fix typo on dependencies utils and cleanup unused variable. PR #1912 by .
Docs
- ✏️ Fix typo in Tutorial - Path Parameters. PR by @mariacamilagl.
- ✏ Fix a stylistic error in docs. PR by @ddobrinskiy.
- ✏ Fix capitalizaiton typo in docs. PR by @imba-tjd.
- ✏ Fix typo in docs. PR by @ammarasmro.
- 📝 Update/fix links in docs to use HTTPS. PR by @imba-tjd.
- ✏ Fix typos and add rewording in docs. PR by @nukopy.
- 📝 Fix code consistency in examples for Tutorial - User Guide - Path Parameters. PR by @nukopy.
- 📝 Fix renamed parameter
content_type
typo. PR by @TeoZosa. - ✏ Fix minor typos in docs. PR by @TeoZosa.
- ✏ Fix typos in docs and source examples. PR by @AdrianDeAnda.
- ✏ Fix incorrect Celery URLs in docs. PR by @CircleOnCircles.
- 📝 Simplify intro to Python Types, all currently supported Python versions include type hints 🎉. PR by @ninjaaron.
- 📝 Fix example code with sets in Tutorial - Body - Nested Models 3. PR by @hitrust.
- 📝 Fix example code with sets in Tutorial - Body - Nested Models 2. PR by @hitrust.
- 📝 Fix example code with sets in Tutorial - Body - Nested Models. PR by @hitrust.
- ✏ Fix typo in Benchmarks. PR by @AlejoAsd.
- 📝 Add note in CORS tutorial about allow_origins with [“*“] and allow_credentials. PR by @dsmurrell.
- 📝 Add deployment to Deta, the first gold sponsor 🎉. PR by @tiangolo.
- 👥 Update FastAPI People. PR by @github-actions[bot].
- ✏️ Fix uppercase in Tutorial - Query parameters. PR by @mariacamilagl.
- 📝 Add articles to External Links. PR by @tiangolo.
- ✏ Fix typo in Spanish tutorial index. PR by @aviloncho.
Translations
- 🌐 Add Japanese translation for Advanced Tutorial - Response Directly. PR #2191 by .
- 📝 Add Japanese translation for Tutorial - Security - First Steps. PR #2153 by .
- 🌐 Add Japanese translation for Tutorial - Query Parameters and String Validations. PR #1901 by .
- 🌐 Add Portuguese translation for External Links. PR #1443 by .
- 🌐 Add Japanese translation for Tutorial - CORS. PR #2125 by .
- 🌐 Add Japanese translation for Contributing. PR #2067 by .
- 🌐 Add Japanese translation for Project Generation. PR #2050 by .
- 🌐 Add Japanese translation for Alternatives. PR #2043 by .
- 🌐 Add Japanese translation for History Design and Future. PR #2002 by .
- 🌐 Add Japanese translation for Benchmarks. PR #1992 by .
- 🌐 Add Japanese translation for Tutorial - Header Parameters. PR #1935 by .
- 🌐 Add Portuguese translation for Tutorial - First Steps. PR #1861 by .
- 🌐 Add Portuguese translation for Python Types. PR #1796 by .
- 🌐 Add Japanese translation for Help FastAPI. PR #1692 by .
- 🌐 Add Japanese translation for Tutorial - Body. PR #1683 by .
- 🌐 Add Japanese translation for Tutorial - Query Params. PR #1674 by .
- 🌐 Add Japanese translation for tutorial/path-params.md. PR #1671 by .
- 🌐 Add Japanese translation for tutorial/first-steps.md. PR #1658 by .
- 🌐 Add Japanese translation for tutorial/index.md. PR #1656 by .
- 🌐 Add translation to Portuguese for Project Generation. PR #1602 by .
- 🌐 Add Japanese translation for Features. PR #1625 by .
- 🌐 Initialize new language Korean for translations. PR #2018 by .
- 🌐 Add Portuguese translation of Deployment. PR #1374 by .
Internal
- 🔥 Cleanup after upgrade for Docs Previews GitHub Action. PR by @tiangolo.
- 🐛 Fix CI docs preview, unzip docs. PR by @tiangolo.
- ✨ Add instant docs deploy previews for PRs from forks. PR by @tiangolo.
- ⚡️ Build docs for languages in parallel in subprocesses to speed up CI. PR by @tiangolo.
- 🐛 Fix docs order generation for partial translations. PR by @tiangolo.
- 👥 Update FastAPI People. PR by @github-actions[bot].
- ♻️ Update FastAPI People GitHub Action to send the PR as github-actions. PR by @tiangolo.
- 🔧 Update FastAPI People GitHub Action config, run monthly. PR by @tiangolo.
- 🐛 Fix FastAPI People GitHub Action Docker dependency, strike 1 ⚾. PR by @tiangolo.
- 🐛 Fix FastAPI People GitHub Action Docker dependencies. PR by @tiangolo.
- 🐛 Fix FastAPI People GitHub Action when there’s nothing to change. PR by @tiangolo.
- 👥 Add new section FastAPI People. PR by @tiangolo.
- ⬆️ Upgrade GitHub Action Latest Changes. PR by @tiangolo.
- ⬆️ Upgrade GitHub Action Label Approved. PR by @tiangolo.
- 🔧 Update GitHub Action Label Approved, run at 12:00. PR by @tiangolo.
- 👷 Upgrade GitHub Action Latest Changes. PR by @tiangolo.
- 👷 Set GitHub Action Label Approved to run daily, not every minute. PR by @tiangolo.
- 🔥 Remove pr-approvals GitHub Action as it’s not compatible with forks. Use the new one. PR by @tiangolo.
- 👷 Add GitHub Action Latest Changes. PR .
- 👷 Add GitHub Action Label Approved. PR #2161.
0.61.1
Fixes
- Fix issues using
jsonable_encoder
with SQLAlchemy models directly. PR .
Docs
- Fix typo in NoSQL docs. PR by @facundojmaero.
Translations
- Add translation for main page to Japanese PR by @ryuckel.
- Initialize French translations. PR by @JulianMaurin-BM.
- Initialize Turkish translations. PR by @ycd.
Internal
- Improve docs maintainability by updating
hl_lines
syntax to use ranges. PR #1863 by .
0.61.0
Features
- Add support for injecting
HTTPConnection
(asRequest
andWebSocket
). Useful for sharing app state in dependencies. PR #1827 by . - Export
WebSocketDisconnect
and add example handling WebSocket disconnections to docs. PR #1822 by .
Breaking Changes
- Require Pydantic >
1.0.0
.- Remove support for deprecated Pydantic
0.32.2
. This improves maintainability and allows new features. - In
FastAPI
andAPIRouter
:- Remove path operation decorators related/deprecated parameter
response_model_skip_defaults
(useresponse_model_exclude_unset
instead). - Change path operation decorators parameter default for
response_model_exclude
fromset()
toNone
(as is in Pydantic).
- Remove path operation decorators related/deprecated parameter
- In
encoders.jsonable_encoder
:- Remove deprecated
skip_defaults
, use insteadexclude_unset
. - Set default of
exclude
fromset()
toNone
(as is in Pydantic).
- Remove deprecated
- PR .
- Remove support for deprecated Pydantic
- In
encoders.jsonable_encoder
remove parametersqlalchemy_safe
.- It was an early hack to allow returning SQLAlchemy models, but it was never documented, and the recommended way is using Pydantic’s
orm_mode
as described in the tutorial: SQL (Relational) Databases. - PR .
- It was an early hack to allow returning SQLAlchemy models, but it was never documented, and the recommended way is using Pydantic’s
Docs
- Add link to the course by TestDriven.io: . PR #1860.
- Fix empty log message in docs example about handling errors. PR by @manlix.
- Reword text to reduce ambiguity while not being gender-specific. PR by @Mause.
- Add Flake8 linting. Original PR #1774 by .
- Disable Gitter bot, as it’s currently broken, and Gitter’s response doesn’t show the problem. PR #1853.
0.60.2
- Fix typo in docs for query parameters. PR #1832 by .
- Add docs about Async Tests. PR by @empicano.
- Raise an exception when using form data (
Form
,File
) without havingpython-multipart
installed.- Up to now the application would run, and raise an exception only when receiving a request with form data, the new behavior, raising early, will prevent from deploying applications with broken dependencies.
- It also detects if the correct package
python-multipart
is installed instead of the incorrectmultipart
(both importable asmultipart
). - PR based on original PR #1627 by , @YKo20010, .
- Re-enable Gitter releases bot. PR #1831.
- Add link to async SQL databases tutorial from main SQL tutorial. PR by @short2strings.
- Fix typo in tutorial about behind a proxy. PR by @toidi.
- Fix typo in Portuguese docs. PR by @izaguerreiro.
- Add translations setup for Ukrainian. PR .
- Add external link Build And Host Fast Data Science Applications Using FastAPI. PR by @Kludex.
- Fix encoding of Pydantic models that inherit from others models with custom
json_encoders
. PR by @henrybetts. - Simplify and improve
jsonable_encoder
. PR by @MashhadiNima. - Simplify internal code syntax in several points. PR by @uriyyo.
- Improve internal typing, declare
Optional
parameters. PR by @MashhadiNima. - Add external link to docs. PR #1726 by .
- Add link to Starlette docs about WebSocket testing. PR #1717 by .
- Refactor generating dependant, merge for loops. PR #1714 by .
- Update example for templates with Jinja to include HTML media type. PR #1690 by .
- Fix typos in docs for security. PR #1678 by .
- Fix typos in docs for dependencies. PR #1675 by .
- Fix type annotation for
**extra
parameters inFastAPI
. PR #1659 by . - Bump MkDocs Material to fix docs in browsers with dark mode. PR #1789 by .
- Remove docs preview comment from each commit. PR #1826.
- Update GitHub context extraction for Gitter notification bot. PR .
0.60.1
- Add debugging logs for GitHub actions to introspect GitHub hidden context. PR .
- Use OS preference theme for online docs. PR #1760 by .
- Upgrade Starlette to version
0.13.6
to handle a vulnerability when using static files in Windows. PR #1759 by . - Pin Swagger UI temporarily, waiting for a fix for swagger-api/swagger-ui#6249. PR .
- Update GitHub Actions, use commit from PR for docs preview, not commit from pre-merge. PR #1761.
- Update GitHub Actions, refactor Gitter bot. PR .
0.60.0
- Add GitHub Action to watch for missing preview docs and trigger a preview deploy. PR .
- Add custom GitHub Action to get artifact with docs preview. PR #1739.
- Add new GitHub Actions to preview docs from PRs. PR .
- Add XML test coverage to support GitHub Actions. PR #1737.
- Update badges and remove Travis now that GitHub Actions is the main CI. PR .
- Add GitHub Actions for CI, move from Travis. PR #1735.
- Add support for adding OpenAPI schema for GET requests with a body. PR by @victorphoenix3.
- Fix typo in docstring for OAuth2 utils. PR #1621 by .
- Update JWT docs to use Python-jose instead of PyJWT. Initial PR #1610 by .
- Fix/re-enable search bar in docs. PR #1703.
- Auto-generate a “server” in OpenAPI
servers
when there’s aroot_path
instead of prefixing all thepaths
:- Add a new parameter for
FastAPI
classes:root_path_in_servers
to disable the auto-generation ofservers
. - New docs about
root_path
andservers
in . - Update OAuth2 examples to use a relative URL for
tokenUrl="token"
to make sure those examples keep working as-is even when behind a reverse proxy. - Initial PR #1596 by .
- Add a new parameter for
- Fix typo/link in External Links. PR #1702.
- Update handling of to use a data file and allow translating the headers without becoming obsolete quickly when new links are added. PR #https://github.com/tiangolo/fastapi/pull/1701.
- Add external link to docs. PR #1669 by .
- Add note in docs on order in Pydantic Unions. PR #1591 by .
- Improve support for tests in editor. PR #1699.
- Pin dependencies. PR .
- Update isort to version 5.x.x. PR #1670 by .
0.58.1
- Add link in docs to Pydantic data types. PR by @tayoogunbiyi.
- Fix link in warning logs for
openapi_prefix
. PR by @bavaria95. - Fix bad link in docs. PR by @molto0504.
- Add Vim temporary files to
.gitignore
for contributors using Vim. PR by @asheux. - Fix typo in docs for sub-applications. PR by @schlpbch.
- Use
Optional
in all the examples in the docs. Original PR by @chrisngyn, , @YKo20010. Updated and merged PR . - Update tests and handling of
response_model_by_alias
. PR #1642. - Add translation to Chinese for . PR #1569 by .
- Update Chinese translation of main page. PR #1564 by .
- Add translation to Chinese for Body - Multiple Parameters - 请求体 - 多个参数. PR by @waynerv.
- Add translation to Chinese for . PR #1506 by .
- Add GitHub action to auto-label approved PRs (mainly for translations). PR #1638.
0.58.0
- Deep merge OpenAPI responses to preserve all the additional metadata. PR #1577.
- Mention in docs that only main app events are run (not sub-apps). PR by @amacfie.
- Fix body validation error response, do not include body variable when it is not embedded. PR by @amacfie.
- Fix testing OAuth2 security scopes when using dependency overrides. PR by @amacfie.
- Fix Model for JSON Schema keyword
not
as a JSON Schema instead of a list. PR by @v-do. - Add support for OpenAPI
servers
. PR by @mikaello.
0.57.0
- Remove broken link from “External Links”. PR #1565 by .
- Update/fix docs for WebSockets with dependencies. Original PR by @ChihSeanHsu.
- Add support for Python’s
http.HTTPStatus
instatus_code
parameters. PR by @retnikt. - When using Pydantic models with
__root__
, use the internal value injsonable_encoder
. PR by @patrickkwang. - Update docs for path parameters. PR by @yankeexe.
- Update docs for first steps, links and rewording. PR by @yankeexe.
- Enable
showCommonExtensions
in Swagger UI to show additional validations likemaxLength
, etc. PR by @TiewKH. - Make
OAuth2PasswordRequestFormStrict
importable directly fromfastapi.security
. PR by @RichardHoekstra. - Add docs about . PR #1455 by .
- Add note in docs about additional parameters
response_model_exclude_defaults
andresponse_model_exclude_none
in Response Model. PR by @wshayes. - Add note about to docs. PR #1420 by .
- Update and clarify testing function name. PR #1395 by .
- Fix duplicated headers created by indirect dependencies that use the request directly. PR #1386 by from tests by @scottsmith2gmail.
- Upgrade Starlette version to
0.13.4
. PR by @rushton. - Improve error handling and feedback for requests with invalid JSON. PR by @aviramha.
- Add support for declaring metadata for tags in OpenAPI. New docs at . PR #1348 by .
- Add basic setup for Russian translations. PR #1566.
- Remove obsolete Chinese articles after adding official community translations. PR by @waynerv.
- Add
__repr__
for path operation function parameter helpers (likeQuery
,Depends
, etc) to simplify debugging. PR by @rkbeatss and .
0.56.1
- Add link to advanced docs from tutorial. PR by @kx-chen.
- Remove internal unnecessary f-strings. PR by @kotamatsuoka.
- Add translation to Chinese for . PR #1500 by .
- Add translation to Chinese for Request Body - 请求体. PR by @waynerv.
- Add translation to Chinese for . PR #1465 by .
- Add translation to Chinese for Query Parameters - 查询参数. PR by @waynerv.
- Add translation to Chinese for . PR #1460 by .
- Add translation to Chinese for Path Parameters - 路径参数. PR by @waynerv.
- Add official Microsoft project generator for to Project Generators. PR by @kabirkhan.
- Update docs in to include info about
Optional
. Original PR #1377 by . - Fix/remove incorrect error logging when a client sends invalid payloads. PR #1351 by .
- Add translation to Chinese for First Steps - 第一步. PR by @waynerv.
- Fix generating OpenAPI for apps using callbacks with routers including Pydantic models. PR by @nsidnev.
- Optimize internal regex performance in
get_path_param_names()
. PR by @heckad. - Remove
*,
from functions in docs where it’s not needed. PR by @pankaj-giri. - Start translations for Italian. PR by @csr.
0.56.0
- Add support for ASGI
root_path
:- Use
root_path
internally for mounted applications, so that OpenAPI and the docs UI works automatically without extra configurations and parameters. - Add new
root_path
parameter forFastAPI
applications to provide it in cases where it can be set with the command line (e.g. for Uvicorn and Hypercorn, with the parameter--root-path
). - Deprecate
openapi_prefix
parameter in favor of the newroot_path
parameter. - Add new/updated docs for Sub Applications - Mounts, without
openapi_prefix
(as it is now handled automatically). - Add new/updated docs for , including how to setup a local testing proxy with Traefik and using
root_path
. - Update docs for Extending OpenAPI with the new
openapi_prefix
parameter passed (internally generated fromroot_path
). - Original PR by @iksteen.
- Use
- Update new issue templates and docs: . PR #1531.
- Update GitHub action issue-manager. PR .
- Add new links:
- English articles:
- Real-time Notifications with Python and Postgres by .
- Microservice in Python using FastAPI by .
- Build simple API service with Python FastAPI — Part 1 by .
- FastAPI + Zeit.co = 🚀 by .
- Build a web API from scratch with FastAPI - the workshop by .
- Build a Secure Twilio Webhook with Python and FastAPI by .
- Using FastAPI with Django by .
- Introducing Dispatch by .
- Podcasts:
- Talks:
- PR #1467.
- English articles:
- Add translation to Chinese for . PR #1197 by .
0.55.1
- Fix handling of enums with their own schema in path parameters. To support in FastAPI. PR #1463.
0.55.0
- Allow enums to allow them to have their own schemas in OpenAPI. To support samuelcolvin/pydantic#1432 in FastAPI. PR .
- Add links for funding through GitHub sponsors. PR .
- Update issue template for for questions. PR #1344 by .
- Update warning about storing passwords in docs. PR #1336 by .
- Fix typo. PR #1326 by .
- Add translation to Portuguese for Alternatives, Inspiration and Comparisons - Alternativas, Inspiração e Comparações. PR by @Serrones.
- Fix 2 typos in docs. PR by @waynerv.
- Update CORS docs, fix correct default of
max_age=600
. PR by @derekbekoe. - Add translation of . PR #1300 by .
- Re-word and clarify docs for extra info in fields. PR #1299 by .
- Make sure the
*
in short features in the docs is consistent (after.
) in all languages. PR #1424. - Update order of execution for
get_db
in SQLAlchemy tutorial. PR by @bcb. - Fix typos in Async docs. PR .
0.54.2
- Add translation to Spanish for . PR #1290 by .
- Remove obsolete vote link. PR #1289 by .
- Allow disabling docs UIs by just disabling OpenAPI with
openapi_url=None
. New example in docs: Advanced: Conditional OpenAPI. PR . - Add translation to Portuguese for Benchmarks - Comparações. PR by @Serrones.
- Add translation to Portuguese for . PR #1259 by .
- Allow using Unicode in MkDocs for translations. PR #1419.
- Add translation to Spanish for . PR #1250 by .
- Add translation to Portuguese for History, Design and Future - História, Design e Futuro. PR by @marcosmmb.
- Add translation to Portuguese for . PR #1248 by .
- Add translation to Spanish for Tutorial - User Guide - Intro - Tutorial - Guía de Usuario - Introducción. PR by @MartinEliasQ.
- Add translation to Chinese for . PR #1203 by .
- Add translation to Chinese for Tutorial - User Guide - Intro - 教程 - 用户指南 - 简介. PR by @waynerv.
- Add translation to Chinese for . PR #1192 by .
- Add translation for main page to Chinese PR by @waynerv.
- Update docs for project generation. PR .
- Add Spanish translation for Introducción a los Tipos de Python (Python Types Intro). PR by @mariacamilagl.
- Add Spanish translation for . PR #1220 by .
0.54.1
- Update database test setup. PR .
- Improve test debugging by showing response text in failing tests. PR #1222 by .
0.54.0
- Fix grammatical mistakes in async docs. PR by @mickeypash.
- Add support for
response_model_exclude_defaults
andresponse_model_exclude_none
:- Deprecate the parameter
include_none
injsonable_encoder
and add the invertedexclude_none
, to keep in sync with Pydantic. - PR by @voegtlel.
- Deprecate the parameter
- Add example about . Initial PR #1144 by .
- Update docs for Development - Contributing: Translations including note about reviewing translation PRs. .
- Update log style in README.md for GitHub Markdown compatibility. PR #1200 by .
- Add Python venv
env
to.gitignore
. PR #1212 by . - Start Portuguese translations. PR #1210 by .
- Update docs for Pydantic’s
Settings
using a dependency with@lru_cache()
. PR #1214. - Add first translation to Spanish . PR #1201 by .
- Add docs about Settings and Environment Variables. Initial PR by @alexmitelman.
0.53.2
- Fix automatic embedding of body fields for dependencies and sub-dependencies. Original PR #1079 by .
- Fix dependency overrides in WebSocket testing. PR #1122 by .
- Fix docs script to ensure languages are always sorted. PR #1189.
- Start translations for Chinese. PR by @RunningIkkyu.
- Add docs for . PR #1185.
0.53.1
- Fix included example after translations refactor. PR #1182.
- Add docs example for
example
inField
. Docs at . PR #1106 by . - Fix using recursive models in
response_model
. PR #1164 by . - Add docs for Pycharm Debugging. PR by @youngquan.
- Fix typo in docs. PR by @PLNech.
- Update Windows development environment instructions. PR .
0.53.0
- Update test coverage badge. PR .
- Add
orjson
topip install fastapi[all]
. PR #1161 by . - Fix included example for
GZipMiddleware
. PR #1138 by . - Fix class name in docstring for
OAuth2PasswordRequestFormStrict
. PR #1126 by . - Clarify function name in example in docs. PR #1121 by .
- Add external link Apache Kafka producer and consumer with FastAPI and aiokafka to docs. PR by @iwpnd.
- Fix serialization when using
by_alias
orexclude_unset
and returning data with Pydantic models. PR by @juhovh-aiven. - Add Gitter chat to docs. PR by @aakashnand.
- Update and simplify translations docs. PR .
- Update development of FastAPI docs, set address to
127.0.0.1
to improve Windows support. PR #1169 by . - Add support for docs translations. New docs: Development - Contributing: Docs: Translations. PR .
- Update terminal styles in docs and add note about Typer, the FastAPI of CLIs. PR .
0.52.0
- Add new high-performance JSON response class using
orjson
. New docs: . PR #1065.
0.51.0
- Re-export utils from Starlette:
- This allows using things like
from fastapi.responses import JSONResponse
instead offrom starlette.responses import JSONResponse
. - It’s mainly syntax sugar, a convenience for developer experience.
- Now
Request
,Response
, ,status
can be imported directly fromfastapi
as infrom fastapi import Response
. This is because those are frequently used, to use the request directly, to set headers and cookies, to get status codes, etc. - Documentation changes in many places, but new docs and noticeable improvements:
- PR .
- This allows using things like
0.50.0
- Add link to Release Notes from docs about pinning versions for deployment. PR .
- Upgrade code to use the latest version of Starlette, including:
- Several bug fixes.
- Optional redirects of slashes, with or without ending in
/
. - Events for routers,
"startup"
, and"shutdown"
. - PR #1057.
- Add docs about pinning FastAPI versions for deployment: . PR #1056.
0.49.2
- Fix links in release notes. PR #1052 by .
- Fix typo in release notes. PR #1051 by .
- Refactor/clarify
serialize_response
parameter name to avoid confusion. PR #1031 by . - Refactor calling each a path operation’s handler function in an isolated function, to simplify profiling. PR #1027 by .
- Add missing dependencies for testing. PR #1026 by .
- Fix accepting valid types for response models, including Python types like
List[int]
. PR #1017 by . - Fix format in SQL tutorial. PR #1015 by .
0.49.1
- Fix path operation duplicated parameters when used in dependencies and the path operation function. PR by @merowinger92.
- Update Netlify previews deployment GitHub action as the fix is already merged and there’s a new release. PR .
- Move mypy configurations to config file. PR #987 by .
- Temporary fix to Netlify previews not deployable from PRs from forks. PR #1046 by .
0.49.0
- Fix encoding of
pathlib
paths injsonable_encoder
. PR by @patrickmckenna. - Add articles to : PythonのWeb frameworkのパフォーマンス比較 (Django, Flask, responder, FastAPI, japronto) and . PR #974 by .
- Fix broken links in docs. PR #949 by .
- Fix small typos. PR #941 by .
- Update and clarify docs for dependencies with
yield
. PR #986. - Add Mermaid JS support for diagrams in docs. Add first diagrams to and Dependencies with yield and HTTPException. PR .
- Update CI to run docs deployment in GitHub actions. PR #983.
- Allow
callable
s in path operation functions, like functions modified withfunctools.partial
. PR .
0.48.0
- Run linters first in tests to error out faster. PR .
- Log warning about
email-validator
only when used. PR #946. - Simplify with double dependency with
yield
. PR #947. - Add article : Create and Deploy FastAPI app to Heroku. PR by @windson.
- Update description of Sanic, as it is now ASGI too. PR by @raphaelauv.
- Fix typo in main page. PR by @mMarzeta.
- Fix parsing of possibly invalid bodies. PR by @dmontagu.
- Fix typo by @adursun.
- Allow
Any
type for enums in OpenAPI. PR by @songzhi. - Add article to : How to continuously deploy a FastAPI to AWS Lambda with AWS SAM. PR by @iwpnd.
- Add note about using Body parameters without Pydantic. PR by @pawamoy.
- Fix Pydantic field clone logic. PR by @deuce2367.
- Fix link in middleware docs. PR by @linchiwei123.
- Rename default API title from “Fast API” to “FastAPI” for consistency. PR .
0.47.1
- Fix model filtering in
response_model
, cloning sub-models. PR . - Fix FastAPI serialization of Pydantic models using ORM mode blocking the event loop. PR #888.
0.47.0
- Refactor documentation to make a simpler and shorter Tutorial - User Guide and an additional with all the additional docs. PR #887.
- Tweak external links, Markdown format, typos. PR .
- Fix bug in tutorial handling HTTP Basic Auth
username
andpassword
. PR #865 by . - Fix handling form path operation parameters declared with pure classes like
list
,tuple
, etc. PR #856 by . - Add request
body
toRequestValidationError
, new docs: Use the RequestValidationError body. Initial PR by @aviramha. - Update with new links and dynamic GitHub projects with
fastapi
topic. PR #850. - Fix Peewee
contextvars
handling in docs: . PR #879. - Setup development environment with Python’s Venv and Flit, instead of requiring the extra Pipenv duplicating dependencies. Updated docs: . PR #877.
- Update docs for to improve security against timing attacks. Initial PR #807 by .
0.46.0
- Fix typos and tweak configs. PR .
- Add link to Chinese article in External Links. PR by @wxq0309.
- Implement
OAuth2AuthorizationCodeBearer
class. PR by @kuwv. - Update example upgrade in docs main page. PR by @cdeil.
- Fix callback handling for sub-routers. PR by @jekirl.
- Fix typos. PR by @kkinder.
- Add 4 Japanese articles to . PR #783 by .
- Add support for subtypes of main types in
jsonable_encoder
, e.g. asyncpg’s UUIDs. PR #756 by . - Fix usage of Pydantic’s
HttpUrl
in docs. PR #832 by . - Fix Twitter links in docs. PR #813 by .
- Add docs for correctly using FastAPI with Peewee ORM. Including how to overwrite parts of Peewee to correctly handle async threads. PR .
0.45.0
- Add support for OpenAPI Callbacks:
- New docs: .
- Refactor generation of
operationId
s to be valid Python names (also valid variables in most languages). - Add
default_response_class
parameter toAPIRouter
. - Original PR #722 by .
- Refactor logging to use the same logger everywhere, update log strings and levels. PR #781.
- Add article to : Почему Вы должны попробовать FastAPI?. PR by @prostomarkeloff.
- Remove gender bias in docs for handling errors. PR . Original idea in PR #761 by .
- Rename docs and references to
body-schema
tobody-fields
to keep in line with Pydantic. PR #746 by .
0.44.1
- Add GitHub social preview images to git. PR .
- Update PyPI “trove classifiers”. PR #751.
- Add full support for Python 3.8. Enable Python 3.8 in full in Travis. PR .
- Update “new issue” templates. PR #749.
- Fix serialization of errors for exotic Pydantic types. PR by @dmontagu.
0.44.0
- Add GitHub action Issue Manager. PR .
- Fix typos in docs. PR 734 by .
- Fix usage of
custom_encoder
injsonable_encoder
. PR #715 by . - Fix invalid XML example. PR 710 by .
- Fix typos and update wording in deployment docs. PR #700 by .
- Add note about dependencies in
APIRouter
docs. PR #698 by . - Add support for async class methods as dependencies #681 by .
- Add FastAPI with Swagger UI cheatsheet to external links. PR #671 by .
- Fix typo in HTTP protocol in CORS example. PR #647 by .
- Add support for Pydantic versions
1.0.0
and above, with temporary (deprecated) backwards compatibility for Pydantic0.32.2
. PR #646 by .
0.43.0
- Update docs to reduce gender bias. PR by @ticosax.
- Add docs about based on their function name. PR #642 by .
- Fix validators in models generating an incorrect key order. PR #637 by .
- Generate correct OpenAPI docs for responses with no content. PR #621 by .
- Remove
$
from Bash code blocks in docs for consistency. PR #613 by . - Add docs for self-serving docs’ (Swagger UI) static assets, e.g. to use the docs offline, or without Internet. Initial PR by @svalouch.
- Fix
black
linting after upgrade. PR by @frankie567.
0.42.0
- Add dependencies with
yield
, a.k.a. exit steps, context managers, cleanup, teardown, …- This allows adding extra code after a dependency is done. It can be used, for example, to close database connections.
- Dependencies with
yield
can be normal orasync
, FastAPI will run normal dependencies in a threadpool. - They can be combined with normal dependencies.
- It’s possible to have arbitrary trees/levels of dependencies with
yield
and exit steps are handled in the correct order automatically. - It works by default in Python 3.7 or above. For Python 3.6, it requires the extra backport dependencies:
async-exit-stack
async-generator
- New docs at Dependencies with yield.
- Updated database docs .
- PR #595.
- Fix
sitemap.xml
in website. PR by @samuelcolvin.
0.41.0
- Upgrade required Starlette to
0.12.9
, the new range is>=0.12.9,<=0.12.9
.- Add
State
to FastAPI apps atapp.state
. - PR #593.
- Add
- Improve handling of custom classes for
Request
s andAPIRoute
s.- This helps to more easily solve use cases like:
- Reading a body before and/or after a request (equivalent to a middleware).
- Run middleware-like code only for a subset of path operations.
- Process a request before passing it to a path operation function. E.g. decompressing, deserializing, etc.
- Processing a response after being generated by path operation functions but before returning it. E.g. adding custom headers, logging, adding extra metadata.
- New docs section: .
- PR #589 by .
- This helps to more easily solve use cases like:
- Fix preserving custom route class in routers when including other sub-routers. PR #538 by .
0.40.0
- Add notes to docs about installing
python-multipart
when using forms. PR by @sliptonic. - Generate OpenAPI schemas in alphabetical order. PR by @dmontagu.
- Add support for truncating docstrings from path operation functions.
- New docs at .
- PR #556 by .
- Fix
DOCTYPE
in HTML files generated for Swagger UI and ReDoc. PR #537 by . - Fix handling
4XX
responses overriding default422
validation error responses. PR #517 by . - Fix typo in documentation for Simple HTTP Basic Auth. PR by @prostomarkeloff.
- Fix incorrect documentation example in . PR #511 by .
- Add support for Swagger UI initOauth settings with the parameter
swagger_ui_init_oauth
. PR by @zamiramir.
0.39.0
- Allow path parameters to have default values (e.g.
None
) and discard them instead of raising an error.- This allows declaring a parameter like
user_id: str = None
that can be taken from a query parameter, but the same path operation can be included in a router with a path/users/{user_id}
, in which case will be taken from the path and will be required. - PR #464 by .
- This allows declaring a parameter like
- Add support for setting a
default_response_class
in theFastAPI
instance or ininclude_router
. Initial PR #467 by . - Add support for type annotations using strings and
from __future__ import annotations
. PR #451 by .
0.38.1
- Fix incorrect
Request
class import. PR by @kamalgill.
0.38.0
- Add recent articles to External Links and recent opinions. PR .
- Upgrade support range for Starlette to include
0.12.8
. The new range is>=0.11.1,<=0.12.8"
. PR #477 by . - Upgrade support to Pydantic version 0.32.2 and update internal code to use it (breaking change). PR #463 by .
0.37.0
- Add support for custom route classes for advanced use cases. PR by @dmontagu.
- Allow disabling Google fonts in ReDoc. PR by @b1-luettje.
- Fix security issue: when returning a sub-class of a response model and using
skip_defaults
it could leak information. PR by @dmontagu. - Enable tests for Python 3.8-dev. PR by @Jamim.
- Add support and tests for Pydantic dataclasses in
response_model
. PR by @dconathan. - Fix typo in OAuth2 JWT tutorial. PR by @pablogamboa.
- Use the
media_type
parameter inBody()
params to set the media type in OpenAPI forrequestBody
. PR by @divums. - Add article by https://www.linkedin.com/in/nico-axtmann. PR by @naxty.
- Allow setting custom
422
(validation error) response/schema in OpenAPI.- And use media type from response class instead of fixed
application/json
(the default). - PR by @divums.
- And use media type from response class instead of fixed
- Fix using
"default"
extra response with status codes at the same time. PR . - Allow additional responses to use status code ranges (like
5XX
and4XX
) and"default"
. PR #435 by .
0.36.0
- Fix implementation for
skip_defaults
when returning a Pydantic model. PR by @dmontagu. - Fix OpenAPI generation when using the same dependency in multiple places for the same path operation. PR by @dmontagu.
- Allow having empty paths in path operations used with
include_router
and aprefix
.- This allows having a router for
/cats
and all its path operations, while having one of them for/cats
. - Now it doesn’t have to be only
/cats/
(with a trailing slash). - To use it, declare the path in the path operation as the empty string (
""
). - PR by @vitalik.
- This allows having a router for
- Fix mypy error after merging PR #415. PR .
0.35.0
- Fix typo in routing
assert
. PR by @pablogamboa. - Fix typo in docs. PR by @bronsen.
- Fix parsing a body type declared with
Union
. PR by @koxudaxi.
0.34.0
Upgrade Starlette supported range to include the latest
0.12.7
. The new range is0.11.1,<=0.12.7
. PR #367 by .Add test for OpenAPI schema with duplicate models from PR #333 by . PR #385.
0.33.0
- Upgrade Pydantic version to
0.30.0
. PR #384 by .
0.32.0
Fix typo in docs for features. PR by @MartinoMensio.
Fix source code
limit
for example in . PR #366 by .Update wording in docs about OAuth2 scopes. PR by @cjw296.
Update docs for
Enum
s to inherit fromstr
and improve Swagger UI rendering. PR .Fix regression, add Swagger UI deep linking again. PR #350.
Add test for having path templates in
prefix
of.include_router
. PR .Add note to docs: Include the same router multiple times with different prefix. PR .
Fix OpenAPI/JSON Schema generation for two functions with the same name (in different modules) with the same composite bodies.
- Composite bodies’ IDs are now based on path, not only on route name, as the auto-generated name uses the function names, that can be duplicated in different modules.
- The same new ID generation applies to response models.
- This also changes the generated title for those models.
- Only composite bodies and response models are affected because those are generated dynamically, they don’t have a module (a Python file).
- This also adds the possibility of using
.include_router()
with the sameAPIRouter
multiple times, with different prefixes, e.g./api/v2
and/api/latest
, and it will now work correctly. - PR #347.
0.31.0
- Upgrade Pydantic supported version to
0.29.0
.- New supported version range is
"pydantic >=0.28,<=0.29.0"
. - This adds support for Pydantic Generic Models, kudos to .
- PR #344.
- New supported version range is
0.30.1
Add section in docs about External Links and Articles. PR .
Remove
Pipfile.lock
from the repository as it is only used by FastAPI contributors (developers of FastAPI itself). See the PR for more details. PR #340.Update section about . PR #339.
Refine internal type declarations to improve/remove Mypy errors in users’ code. PR .
Update and clarify SQL tutorial with SQLAlchemy. PR by @mariacamilagl.
Add SQLite . PR #330 by .
0.30.0
Add support for Pydantic’s ORM mode:
- Updated documentation about SQL with SQLAlchemy, using Pydantic models with ORM mode, SQLAlchemy models with relations, separation of files, simplification of code and other changes. New docs: .
- The new support for ORM mode fixes issues/adds features related to ORMs with lazy-loading, hybrid properties, dynamic/getters (using
@property
decorators) and several other use cases. - This applies to ORMs like SQLAlchemy, Peewee, Tortoise ORM, GINO ORM and virtually any other.
- If your path operations return an arbitrary object with attributes (e.g.
my_item.name
instead ofmy_item["name"]
) AND you use aresponse_model
, make sure to update the Pydantic models withorm_mode = True
as described in the docs (link above). - New documentation about receiving plain
dict
s as request bodies: Bodies of arbitrary dicts. - New documentation about returning arbitrary
dict
s in responses: . - Technical Details:
- When declaring a
response_model
it is used directly to generate the response content, from whatever was returned from the path operation function. - Before this, the return content was first passed through
jsonable_encoder
to ensure it was a “jsonable” object, like adict
, instead of an arbitrary object with attributes (like an ORM model). That’s why you should make sure to update your Pydantic models for objects with attributes to useorm_mode = True
. - If you don’t have a
response_model
, the return object will still be passed throughjsonable_encoder
first. - When a
response_model
is declared, the sameresponse_model
type declaration won’t be used as is, it will be “cloned” to create an new one (a cloned PydanticField
with all the submodels cloned as well). - This avoids/fixes a potential security issue: as the returned object is passed directly to Pydantic, if the returned object was a subclass of the
response_model
(e.g. you return aUserInDB
that inherits fromUser
but contains extra fields, likehashed_password
, andUser
is used in theresponse_model
), it would still pass the validation (becauseUserInDB
is a subclass ofUser
) and the object would be returned as-is, including thehashed_password
. To fix this, the declaredresponse_model
is cloned, if it is a Pydantic model class (or contains Pydantic model classes in it, e.g. in aList[Item]
), the Pydantic model class(es) will be a different one (the “cloned” one). So, an object that is a subclass won’t simply pass the validation and returned as-is, because it is no longer a sub-class of the clonedresponse_model
. Instead, a new Pydantic model object will be created with the contents of the returned object. So, it will be a new object (made with the data from the returned one), and will be filtered by the clonedresponse_model
, containing only the declared fields as normally.
- When declaring a
- PR #322.
Remove/clean unused RegEx code in routing. PR by @dmontagu.
Use default response status code descriptions for additional responses. PR by @duxiaoyao.
Upgrade Pydantic support to
0.28
. PR by @jekirl.
Fix handling an empty-body request with a required body param. PR #311.
Fix broken link in docs: . PR #306 by .
Fix docs discrepancy in docs for Response Model. PR by @awiddersheim.
0.29.0
- Add support for declaring a
Response
parameter:- This allows declaring:
- Response Cookies.
- .
- An HTTP Status Code different than the default: Response - Change Status Code.
- All of this while still being able to return arbitrary objects (
dict
, DB model, etc). - Update attribution to Hug, for inspiring the
response
parameter pattern. - PR .
- This allows declaring:
0.28.0
Implement dependency cache per request.
- This avoids calling each dependency multiple times for the same request.
- This is useful while calling external services, performing costly computation, etc.
- This also means that if a dependency was declared as a path operation decorator dependency, possibly at the router level (with
.include_router()
) and then it is declared again in a specific path operation, the dependency will be called only once. - The cache can be disabled per dependency declaration, using
use_cache=False
as inDepends(your_dependency, use_cache=False)
. - Updated docs at: .
- PR #292.
Implement dependency overrides for testing.
- This allows using overrides/mocks of dependencies during tests.
- New docs: .
- PR #291.
0.27.2
- Fix path and query parameters receiving
dict
as a valid type. It should be mapped to a body payload. PR #287. Updated docs at: .
0.27.1
Fix
auto_error=False
handling inHTTPBearer
security scheme. Do notraise
when there’s an incorrectAuthorization
header ifauto_error=False
. PR .Fix type declaration of
HTTPException
. PR #279.
0.27.0
Fix broken link in docs about OAuth 2.0 with scopes. PR #275 by .
Refactor param extraction using Pydantic
Field
:- Large refactor, improvement, and simplification of param extraction from path operations.
- Fix/add support for list query parameters with list defaults. New documentation: Query parameter list / multiple values with defaults.
- Add support for enumerations in path operation parameters. New documentation: .
- Add support for type annotations using
Optional
as inparam: Optional[str] = None
. New documentation: Optional type declarations. - PR .
0.26.0
Separate error handling for validation errors.
- This will allow developers to customize the exception handlers.
- Document better how to handle exceptions and use error handlers.
- Include
RequestValidationError
andWebSocketRequestValidationError
(this last one will be useful once or equivalent is merged). - New documentation about exceptions handlers:
- PR .
Fix support for paths in path parameters without needing explicit
Path(...)
.Update docs for testing FastAPI. Include using
POST
, sending JSON, testing headers, etc. New documentation: Testing. PR .Fix type declaration of
response_model
to allow generic Python types asList[Model]
. Mainly to fixmypy
for users. PR #266.
0.25.0
Add support for Pydantic’s
include
,exclude
,by_alias
.- Update documentation: Response Model.
- Add docs for: , using Pydantic’s
skip_defaults
. - Add method consistency tests.
- PR #264.
Add
CONTRIBUTING.md
file to GitHub, to help new contributors. PR by @wshayes.Add support for Pydantic’s
skip_defaults
:- There’s a new path operation decorator parameter
response_model_skip_defaults
.- The name of the parameter will most probably change in a future version to
response_skip_defaults
,model_skip_defaults
or something similar.
- The name of the parameter will most probably change in a future version to
- New .
- PR #248 by .
- There’s a new path operation decorator parameter
0.24.0
Add support for WebSockets with dependencies and parameters.
- Support included for:
Depends
Security
Cookie
Header
Path
Query
- …as these are compatible with the WebSockets protocol (e.g.
Body
is not).
- .
- PR #178 by .
- Support included for:
Upgrade the compatible version of Pydantic to
0.26.0
.- This includes JSON Schema support for IP address and network objects, bug fixes, and other features.
- PR #247 by .
0.23.0
Upgrade the compatible version of Starlette to
0.12.0
.- This includes support for ASGI 3 (the latest version of the standard).
- It’s now possible to use with iterators, like file-like objects (as those returned by
open()
). - It’s now possible to use the low level utility
iterate_in_threadpool
fromstarlette.concurrency
(for advanced scenarios). - PR .
Add OAuth2 redirect page for Swagger UI. This allows having delegated authentication in the Swagger UI docs. For this to work, you need to add
{your_origin}/docs/oauth2-redirect
to the allowed callbacks in your OAuth2 provider (in Auth0, Facebook, Google, etc).- For example, during development, it could be
http://localhost:8000/docs/oauth2-redirect
. - Have in mind that this callback URL is independent of whichever one is used by your frontend. You might also have another callback at
https://yourdomain.com/login/callback
. - This is only to allow delegated authentication in the API docs with Swagger UI.
- PR #198 by .
- For example, during development, it could be
Make Swagger UI and ReDoc route handlers (path operations) be
async
functions instead of lambdas to improve performance. PR #241 by .Make Swagger UI and ReDoc URLs parameterizable, allowing to host and serve local versions of them and have offline docs. PR #112 by .
0.22.0
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 .
- New documentation about dependencies in the include_router() method.
- PR .
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 .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 .Separate development scripts
test.sh
,lint.sh
, andformat.sh
. PR #232.Re-enable
black
formatting checks for Python 3.7. PR by @zamiramir.
0.21.0
On body parsing errors, raise
from
previous exception, to allow better introspection in logging code. PR #192 by .Use Python logger named “
fastapi
“ instead of root logger. PR #222 by .Upgrade Pydantic to version 0.25. PR #225 by .
Fix typo in routing. PR #221 by .
0.20.1
Add typing information to package including file
py.typed
. PR by @meadsteve.Add FastAPI bot for Gitter. To automatically announce new releases. PR .
0.20.0
Upgrade OAuth2:
- Upgrade Password flow using Bearer tokens to use the correct HTTP status code 401
UNAUTHORIZED
, withWWW-Authenticate
headers. - Update, simplify, and improve all the .
- Add new
scope_str
toSecurityScopes
and update docs: OAuth2 scopes. - Update docs, images, tests.
- PR .
- Upgrade Password flow using Bearer tokens to use the correct HTTP status code 401
Include Hypercorn as an alternative ASGI server in the docs. PR .
Add docs for Static Files and . PR #186.
Add docs for handling and Response Headers. PR .
Fix typos in docs. PR #176 by .
0.19.0
Rename path operation decorator parameter
content_type
toresponse_class
. PR .Add docs:
- How to use the
jsonable_encoder
in JSON compatible encoder. - How to .
- Update how to use a Custom Response Class.
- PR .
- How to use the
0.18.0
Add docs for . PR #177.
Upgrade HTTP Basic Auth handling with automatic headers (automatic browser login prompt). PR .
Update dependencies for security. PR #174.
0.17.0
Make Flit publish from CI. PR #170.
Add documentation about handling . PR #169.
By default, encode by alias. This allows using Pydantic
alias
parameters working by default. PR .
0.16.0
Upgrade path operation
docstring
parsing to support proper Markdown descriptions. New documentation at . PR #163.Refactor internal usage of Pydantic to use correct data types. PR .
Upgrade Pydantic to version
0.23
. PR #160 by .Fix typo in Tutorial about Extra Models. PR #159 by .
Fix Query Parameters URL examples in docs. PR by @hayata-yamamoto.
0.15.0
Add support for multiple file uploads (as a single form field). New docs at: Multiple file uploads. PR .
Add docs for: Additional Status Codes. PR .
0.14.0
Improve automatically generated names of path operations in OpenAPI (in API docs). A function
read_items
instead of having a generated name “Read Items Get” will have “Read Items”. PR .Add docs for: Testing FastAPI. PR .
Update
/docs
Swagger UI to enable deep linking. This allows sharing the URL pointing directly to the path operation documentation in the docs. PR #148 by .Update development dependencies,
Pipfile.lock
. PR #150.Include Falcon and Hug in: .
0.13.0
- Improve/upgrade OAuth2 scopes support with
SecurityScopes
:SecurityScopes
can be declared as a parameter likeRequest
, to get the scopes of all super-dependencies/dependants.- Improve
Security
handling, merging scopes when declaringSecurityScopes
. - Allow using
SecurityBase
(likeOAuth2
) classes withDepends
and still document them.Security
now is needed only to declarescopes
. - Updated docs about: .
- New docs about: OAuth2 scopes.
- PR .
0.12.1
Fix bug: handling additional
responses
inAPIRouter.include_router()
. PR .Fix typo in SQL tutorial. PR #138 by .
Fix typos in section about nested models and OAuth2 with JWT. PR #127 by .
0.12.0
- Add additional
responses
parameter to path operation decorators to extend responses in OpenAPI (and API docs).- It also allows extending existing responses generated from
response_model
, declare other media types (like images), etc. - The new documentation is here: .
responses
can also be added to.include_router()
, the updated docs are here: Bigger Applications.- PR originally initiated by @barsi.
- It also allows extending existing responses generated from
- Update
scripts/test-cov-html.sh
to allow passing extra parameters like-vv
, for development.
0.11.0
Add
auto_error
parameter to security utility functions. Allowing them to be optional. Also allowing to have multiple alternative security schemes that are then checked in a single dependency instead of each one verifying and returning the error to the client automatically when not satisfied. PR #134.Update to close database sessions even when there are exceptions. PR #89 by .
Fix duplicate dependency in
pyproject.toml
. PR #128 by .
0.10.3
Add Gitter chat, badge, links, etc. . PR #117.
Add docs about . PR #126.
Make Travis run Ubuntu Xenial (newer version) and Python 3.7 instead of Python 3.7-dev. PR by @blueyed.
Fix duplicated param variable creation. PR by @yihuang.
Add note in about why using a function parameter instead of a function return type annotation. PR #109 by .
Fix event docs (startup/shutdown) function name. PR #105 by .
0.10.2
Fix OpenAPI (JSON Schema) for declarations of Python
Union
(JSON SchemaadditionalProperties
). PR .Update Background Tasks with a note on Celery.
Document response models using unions and lists, updated at: . PR #108.
0.10.1
- Add docs and tests for encode/databases. New docs at: . PR #107.
0.10.0
Add support for Background Tasks in path operation functions and dependencies. New documentation about Background Tasks is here. PR .
Add support for
.websocket_route()
inAPIRouter
. PR #100 by .New docs section about Events: startup - shutdown. PR .
0.9.1
- Document receiving and Duplicate headers. PR .
0.9.0
Upgrade compatible Pydantic version to
0.21.0
. PR .Add documentation for: Application Configuration.
Fix typo in docs. PR by @matthewhegarty.
Fix link in “Deployment” to “Bigger Applications”.
0.8.0
Make development scripts executable. PR #76 by .
Add support for adding
tags
inapp.include_router()
. PR #55 by . Documentation updated in the section: Bigger Applications.Update docs related to Uvicorn to use new
--reload
option from version0.5.x
. PR .Update
isort
imports and scripts to be compatible with newer versions. PR #75.
0.7.1
Update technical details about async def handling with respect to previous frameworks. PR by @haizaar.
Add and other architectures.
Trigger Docker images build on Travis CI automatically. PR #65.
0.7.0
- Add support for
UploadFile
inFile
parameter annotations.- This includes a file-like interface.
- Here’s the updated documentation for declaring File parameters with UploadFile.
- And here’s the updated documentation for using at the same time.
- PR #63.
0.6.4
Add technical details about async def handling to docs. PR .
Add docs for Debugging FastAPI applications in editors.
Clarify .
Fix typos in docs.
Add section about History, Design and Future.
Add docs for using . PR #62.
0.6.3
- Add Favicons to docs. PR #53.
0.6.2
Introduce new project generator based on FastAPI and PostgreSQL: https://github.com/tiangolo/full-stack-fastapi-postgresql. PR .
Update SQL tutorial with SQLAlchemy, using Depends to improve editor support and reduce code repetition. PR .
Improve middleware naming in tutorial for SQL with SQLAlchemy https://fastapi.tiangolo.com/tutorial/sql-databases/.
0.6.1
- Add docs for GraphQL: https://fastapi.tiangolo.com/advanced/graphql/. PR .
0.6.0
Update SQL with SQLAlchemy tutorial at using the new official
request.state
. PR #45.Upgrade Starlette to version
0.11.1
and add required compatibility changes. PR .
0.5.1
Add section about .
Add note about path operations order in docs.
Update with more information and make relation with Starlette error handling utilities more explicit. PR #41.
Add . PR #42.
0.5.0
Add new
HTTPException
with support for custom headers. With new documentation for handling errors at: https://fastapi.tiangolo.com/tutorial/handling-errors/. PR .Add documentation to use Starlette Request object directly. Check by @euri10.
Add issue templates to simplify reporting bugs, getting help, etc: .
Update example for the SQLAlchemy tutorial at https://fastapi.tiangolo.com/tutorial/sql-databases/ using middleware and database session attached to request.
0.4.0
Add
openapi_prefix
, support for reverse proxy and mounting sub-applications. See the docs at https://fastapi.tiangolo.com/advanced/sub-applications-proxy/: by @kabirkhan.Update including note about DB Browser for SQLite.
0.3.0
- Fix/add SQLAlchemy support, including ORM, and update : #30.
0.2.1
- Fix
jsonable_encoder
for Pydantic models withConfig
but withoutjson_encoders
: #29.
Fix typos in Security section: #24 by .
0.1.19
- Upgrade Starlette version to the current latest : by @euri10.