Releases: tiangolo/fastapi
0.100.1
Fixes
- 🐛 Replace
MultHostUrl
toAnyUrl
for compatibility with older versions of Pydantic v1. PR #9852 by @Kludex.
Docs
Translations
- 🌐 Add Ukrainian translation for
docs/uk/docs/tutorial/body.md
. PR #4574 by @ss-o-furda. - 🌐 Add Vietnamese translation for
docs/vi/docs/features.md
anddocs/vi/docs/index.md
. PR #3006 by @magiskboy. - 🌐 Add Korean translation for
docs/ko/docs/async.md
. PR #4179 by @NinaHwang. - 🌐 Add Chinese translation for
docs/zh/docs/tutorial/background-tasks.md
. PR #9812 by @wdh99. - 🌐 Add French translation for
docs/fr/docs/tutorial/query-params-str-validations.md
. PR #4075 by @Smlep. - 🌐 Add French translation for
docs/fr/docs/tutorial/index.md
. PR #2234 by @JulianMaurin. - 🌐 Add French translation for
docs/fr/docs/contributing.md
. PR #2132 by @JulianMaurin. - 🌐 Add French translation for
docs/fr/docs/benchmarks.md
. PR #2155 by @clemsau. - 🌐 Update Chinese translations with new source files. PR #9738 by @mahone3297.
- 🌐 Add Russian translation for
docs/ru/docs/tutorial/request-forms.md
. PR #9841 by @dedkot01. - 🌐 Update Chinese translation for
docs/zh/docs/tutorial/handling-errors.md
. PR #9485 by @Creat55.
Internal
0.100.0
✨ Support for Pydantic v2 ✨
Pydantic version 2 has the core re-written in Rust and includes a lot of improvements and features, for example:
- Improved correctness in corner cases.
- Safer types.
- Better performance and less energy consumption.
- Better extensibility.
- etc.
...all this while keeping the same Python API. In most of the cases, for simple models, you can simply upgrade the Pydantic version and get all the benefits. 🚀
In some cases, for pure data validation and processing, you can get performance improvements of 20x or more. This means 2,000% or more. 🤯
When you use FastAPI, there's a lot more going on, processing the request and response, handling dependencies, executing your own code, and particularly, waiting for the network. But you will probably still get some nice performance improvements just from the upgrade.
The focus of this release is compatibility with Pydantic v1 and v2, to make sure your current apps keep working. Later there will be more focus on refactors, correctness, code improvements, and then performance improvements. Some third-party early beta testers that ran benchmarks on the beta releases of FastAPI reported improvements of 2x - 3x. Which is not bad for just doing pip install --upgrade fastapi pydantic
. This was not an official benchmark and I didn't check it myself, but it's a good sign.
Migration
Check out the Pydantic migration guide.
For the things that need changes in your Pydantic models, the Pydantic team built bump-pydantic
.
A command line tool that will process your code and update most of the things automatically for you. Make sure you have your code in git first, and review each of the changes to make sure everything is correct before committing the changes.
Pydantic v1
This version of FastAPI still supports Pydantic v1. And although Pydantic v1 will be deprecated at some point, ti will still be supported for a while.
This means that you can install the new Pydantic v2, and if something fails, you can install Pydantic v1 while you fix any problems you might have, but having the latest FastAPI.
There are tests for both Pydantic v1 and v2, and test coverage is kept at 100%.
Changes
-
There are new parameter fields supported by Pydantic
Field()
for:Path()
Query()
Header()
Cookie()
Body()
Form()
File()
-
The new parameter fields are:
default_factory
alias_priority
validation_alias
serialization_alias
discriminator
strict
multiple_of
allow_inf_nan
max_digits
decimal_places
json_schema_extra
...you can read about them in the Pydantic docs.
-
The parameter
regex
has been deprecated and replaced bypattern
.- You can read more about it in the docs for Query Parameters and String Validations: Add regular expressions.
-
New Pydantic models use an improved and simplified attribute
model_config
that takes a simple dict instead of an internal classConfig
for their configuration.- You can read more about it in the docs for Declare Request Example Data.
-
The attribute
schema_extra
for the internal classConfig
has been replaced by the keyjson_schema_extra
in the newmodel_config
dict.- You can read more about it in the docs for Declare Request Example Data.
-
When you install
"fastapi[all]"
it now also includes:pydantic-settings
- for settings management.pydantic-extra-types
- for extra types to be used with Pydantic.
-
Now Pydantic Settings is an additional optional package (included in
"fastapi[all]"
). To use settings you should now importfrom pydantic_settings import BaseSettings
instead of importing frompydantic
directly.- You can read more about it in the docs for Settings and Environment Variables.
-
PR #9816 by @tiangolo, included all the work done (in multiple PRs) on the beta branch (
main-pv2
).
0.100.0-beta3
Install with:
pip install --pre --upgrade fastapi pydantic
Features
✨ Beta support for Pydantic version 2 and OpenAPI 3.1.0 ✨
This is probably the last beta before the final release, probably in one or two days. So, please, test it out! 🤓 🚀 (before it's too late 😅).
The same details as in the previous beta releases below.
This has many features:
- Improved correctness in corner cases
- Safer types
- Better performance and less energy consumption
- Better extensibility
- etc.
Check out the Pydantic migration guide: https://docs.pydantic.dev/dev-v2/migration/
This version of FastAPI still supports Pydantic v1.
This means that you can install the new Pydantic v2, and if something fails, you can install Pydantic v1 while you fix any problems you might have, but having the latest FastAPI.
The focus of this release is compatibility with Pydantic v1 and v2, to make sure your current apps keep working. Later there will be more focus on refactors and code improvements, and then performance improvements. Although you will probably get nice performance improvements already.
There are tests for both Pydantic v1 and v2, and test coverage is kept at 100%.
You will probably still want to test this version in your code even if you don't plan to migrate to Pydantic v2 yet, to ensure that the changes of FastAPI don't break your app in any way.
If you install the beta, please let me know if everything is working or if you are having issues in this discussion: #9709
0.99.1
0.100.0-beta2
Install with:
pip install --pre --upgrade fastapi pydantic
Features
✨ Beta support for Pydantic version 2 ✨
Pydantic v2 was released a few hours ago. 🎉
The final (non-beta) release of Pydantic v2 had a few minor changes. This beta 2 of FastAPI fixes those minor changes in FastAPI (thanks @Lancetnik! PR #9771).
This means you can install Pydantic v2 stable, and try it with FastAPI 0.100.0 beta 2. 🎉
The next (and probably final) beta will include the latest changes in the main FastAPI branch, including OpenAPI 3.1.0. But meanwhile, with this quick fix beta you can start/keep trying FastAPI with the new Pydantic.
The same details as in the previous beta release below.
This has many features:
- Improved correctness in corner cases
- Safer types
- Better performance and less energy consumption
- Better extensibility
- etc.
Check out the Pydantic migration guide: https://docs.pydantic.dev/dev-v2/migration/
This version of FastAPI still supports Pydantic v1.
This means that you can install the new Pydantic v2, and if something fails, you can install Pydantic v1 while you fix any problems you might have, but having the latest FastAPI.
The focus of this release is compatibility with Pydantic v1 and v2, to make sure your current apps keep working. Later there will be more focus on refactors and code improvements, and then performance improvements. Although you will probably get nice performance improvements already.
There are tests for both Pydantic v1 and v2, and test coverage is kept at 100%.
You will probably still want to test this version in your code even if you don't plan to migrate to Pydantic v2 yet, to ensure that the changes of FastAPI don't break your app in any way.
If you install the beta, please let me know if everything is working or if you are having issues in this discussion: #9709
0.99.0
Note: this is the last release before supporting Pydantic v2. You can try out the beta with support for Pydantic v2 now, a new beta supporting Pydantic v2 with these same changes from this release will be available in the next hours/days. And the final version (0.100.0) with support for Pydantic v2 will be released in the next days (next week).
Now, back to this release (this one doesn't include the beta support for Pydantic v2).
This release has ✨ OpenAPI 3.1.0 ✨ 🎉
Features
-
✨ Add support for OpenAPI 3.1.0. PR #9770 by @tiangolo.
- New support for documenting webhooks, read the new docs here: Advanced User Guide: OpenAPI Webhooks.
- Upgrade OpenAPI 3.1.0, this uses JSON Schema 2020-12.
- Upgrade Swagger UI to version 5.x.x, that supports OpenAPI 3.1.0.
- Updated
examples
field inQuery()
,Cookie()
,Body()
, etc. based on the latest JSON Schema and OpenAPI. Now it takes a list of examples and they are included directly in the JSON Schema, not outside. Read more about it (including the historical technical details) in the updated docs: Tutorial: Declare Request Example Data.
-
✨ Add support for
deque
objects and children injsonable_encoder
. PR #9433 by @cranium.
Docs
Translations
- 🌐 Add Persian translation for
docs/fa/docs/advanced/sub-applications.md
. PR #9692 by @mojtabapaso. - 🌐 Add Russian translation for
docs/ru/docs/tutorial/response-model.md
. PR #9675 by @glsglsgls.
Internal
- 🔨 Enable linenums in MkDocs Material during local live development to simplify highlighting code. PR #9769 by @tiangolo.
- ⬆ Update httpx requirement from <0.24.0,>=0.23.0 to >=0.23.0,<0.25.0. PR #9724 by @dependabot[bot].
- ⬆ Bump mkdocs-material from 9.1.16 to 9.1.17. PR #9746 by @dependabot[bot].
- 🔥 Remove missing translation dummy pages, no longer necessary. PR #9751 by @tiangolo.
- ⬆ [pre-commit.ci] pre-commit autoupdate. PR #9259 by @pre-commit-ci[bot].
- ✨ Add Material for MkDocs Insiders features and cards. PR #9748 by @tiangolo.
- 🔥 Remove languages without translations. PR #9743 by @tiangolo.
- ✨ Refactor docs for building scripts, use MkDocs hooks, simplify (remove) configs for languages. PR #9742 by @tiangolo.
- 🔨 Add MkDocs hook that renames sections based on the first index file. PR #9737 by @tiangolo.
- 👷 Make cron jobs run only on main repo, not on forks, to avoid error notifications from missing tokens. PR #9735 by @tiangolo.
- 🔧 Update MkDocs for other languages. PR #9734 by @tiangolo.
- 👷 Refactor Docs CI, run in multiple workers with a dynamic matrix to optimize speed. PR #9732 by @tiangolo.
- 🔥 Remove old internal GitHub Action watch-previews that is no longer needed. PR #9730 by @tiangolo.
- ⬆️ Upgrade MkDocs and MkDocs Material. PR #9729 by @tiangolo.
- 👷 Build and deploy docs only on docs changes. PR #9728 by @tiangolo.
0.98.0
Note: please also help me try out the beta with support for Pydantic v2: https://github.com/tiangolo/fastapi/releases/tag/0.100.0-beta1
Now, back to this release (this one doesn't include the beta support for Pydantic v2).
Features
Docs
- 📝 Update docs on Pydantic using ujson internally. PR #5804 by @mvasilkov.
- ✏ Rewording in
docs/en/docs/tutorial/debugging.md
. PR #9581 by @ivan-abc. - 📝 Add german blog post (Domain-driven Design mit Python und FastAPI). PR #9261 by @msander.
- ✏️ Tweak wording in
docs/en/docs/tutorial/security/index.md
. PR #9561 by @jyothish-mohan. - 📝 Update
Annotated
notes indocs/en/docs/tutorial/schema-extra-example.md
. PR #9620 by @Alexandrhub. - ✏️ Fix typo
Annotation
->Annotated
indocs/en/docs/tutorial/query-params-str-validations.md
. PR #9625 by @mccricardo. - 📝 Use in memory database for testing SQL in docs. PR #1223 by @HarshaLaxman.
Translations
- 🌐 Add Russian translation for
docs/ru/docs/tutorial/metadata.md
. PR #9681 by @TabarakoAkula. - 🌐 Fix typo in Spanish translation for
docs/es/docs/tutorial/first-steps.md
. PR #9571 by @lilidl-nft. - 🌐 Add Russian translation for
docs/tutorial/path-operation-configuration.md
. PR #9696 by @TabarakoAkula. - 🌐 Add Chinese translation for
docs/zh/docs/advanced/security/index.md
. PR #9666 by @lordqyxz. - 🌐 Add Chinese translations for
docs/zh/docs/advanced/settings.md
. PR #9652 by @ChoyeonChern. - 🌐 Add Chinese translations for
docs/zh/docs/advanced/websockets.md
. PR #9651 by @ChoyeonChern. - 🌐 Add Chinese translation for
docs/zh/docs/tutorial/testing.md
. PR #9641 by @wdh99. - 🌐 Add Russian translation for
docs/tutorial/extra-models.md
. PR #9619 by @ivan-abc. - 🌐 Add Russian translation for
docs/tutorial/cors.md
. PR #9608 by @ivan-abc. - 🌐 Add Polish translation for
docs/pl/docs/features.md
. PR #5348 by @mbroton. - 🌐 Add Russian translation for
docs/ru/docs/tutorial/body-nested-models.md
. PR #9605 by @Alexandrhub.
Internal
- ⬆ Bump ruff from 0.0.272 to 0.0.275. PR #9721 by @dependabot[bot].
- ⬆ Update uvicorn[standard] requirement from <0.21.0,>=0.12.0 to >=0.12.0,<0.23.0. PR #9463 by @dependabot[bot].
- ⬆ Bump mypy from 1.3.0 to 1.4.0. PR #9719 by @dependabot[bot].
- ⬆ Update pre-commit requirement from <3.0.0,>=2.17.0 to >=2.17.0,<4.0.0. PR #9251 by @dependabot[bot].
- ⬆ Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6. PR #9482 by @dependabot[bot].
- ✏️ Fix tooltips for light/dark theme toggler in docs. PR #9588 by @pankaj1707k.
- 🔧 Set minimal hatchling version needed to build the package. PR #9240 by @mgorny.
- 📝 Add repo link to PyPI. PR #9559 by @JacobCoffee.
- ✏️ Fix typos in data for tests. PR #4958 by @ryanrussell.
- 🔧 Update sponsors, add Flint. PR #9699 by @tiangolo.
- 👷 Lint in CI only once, only with one version of Python, run tests with all of them. PR #9686 by @tiangolo.
0.100.0-beta1
Install with:
pip install --pre --upgrade fastapi pydantic
Features
✨ Beta support for Pydantic version 2 ✨
The internals of Pydantic v2 were rewritten in Rust and it's currently available in beta.
This has many features:
- Improved correctness in corner cases
- Safer types
- Better performance and less energy consumption
- Better extensibility
- etc.
Check out the Pydantic migration guide: https://docs.pydantic.dev/dev-v2/migration/
This version of FastAPI still supports Pydantic v1.
This means that you can install the new Pydantic v2, and if something fails, you can install Pydantic v1 while you fix any problems you might have, but having the latest FastAPI.
The focus of this release is compatibility with Pydantic v1 and v2, to make sure your current apps keep working. Later there will be more focus on refactors and code improvements, and then performance improvements. Although you will probably get nice performance improvements already.
There are tests for both Pydantic v1 and v2, and test coverage is kept at 100%.
You will probably still want to test this version in your code even if you don't plan to migrate to Pydantic v2 yet, to ensure that the changes of FastAPI don't break your app in any way.
If you install the beta, please let me know if everything is working or if you are having issues in this discussion: #9709
0.97.0
Features
- ✨ Add support for
dependencies
in WebSocket routes. PR #4534 by @paulo-raca. - ✨ Add exception handler for
WebSocketRequestValidationError
(which also allows to override it). PR #6030 by @kristjanvalur.
Refactors
- ⬆️ Upgrade and fully migrate to Ruff, remove isort, includes a couple of tweaks suggested by the new version of Ruff. PR #9660 by @tiangolo.
- ♻️ Update internal type annotations and upgrade mypy. PR #9658 by @tiangolo.
- ♻️ Simplify
AsyncExitStackMiddleware
as without Python 3.6AsyncExitStack
is always available. PR #9657 by @tiangolo.
Upgrades
Internal
0.96.1
Fixes
- 🐛 Fix
HTTPException
header type annotations. PR #9648 by @tiangolo. - 🐛 Fix OpenAPI model fields int validations,
gte
toge
. PR #9635 by @tiangolo.
Upgrades
- 📌 Update minimum version of Pydantic to >=1.7.4. This fixes an issue when trying to use an old version of Pydantic. PR #9567 by @Kludex.
Refactors
- ♻ Remove
media_type
fromORJSONResponse
as it's inherited from the parent class. PR #5805 by @Kludex. - ♻ Instantiate
HTTPException
only when needed, optimization refactor. PR #5356 by @pawamoy.
Docs
Translations
- 🌐 Fix spelling in Indonesian translation of
docs/id/docs/tutorial/index.md
. PR #5635 by @purwowd. - 🌐 Add Russian translation for
docs/ru/docs/tutorial/index.md
. PR #5896 by @Wilidon. - 🌐 Add Chinese translations for
docs/zh/docs/advanced/response-change-status-code.md
anddocs/zh/docs/advanced/response-headers.md
. PR #9544 by @ChoyeonChern. - 🌐 Add Russian translation for
docs/ru/docs/tutorial/schema-extra-example.md
. PR #9621 by @Alexandrhub.