Update dependency fastapi to v0.101.0
This MR contains the following updates:
Package | Type | Update | Change |
---|---|---|---|
fastapi | dependencies | minor |
0.95.1 -> 0.101.0
|
Release Notes
tiangolo/fastapi
v0.101.0
Features
-
✨ Enable Pydantic's serialization mode for responses, add support for Pydantic'scomputed_field
, better OpenAPI for response models, proper required attributes, better generated clients. MR #10011 by @tiangolo.
Refactors
-
✅ Fix tests for compatibility with pydantic 2.1.1. MR #9943 by @dmontagu. -
✅ Fix test error in Windows forjsonable_encoder
. MR #9840 by @iudeen.
Upgrades
-
📌 Do not allow Pydantic 2.1.0 that breaks (require 2.1.1). MR #10012 by @tiangolo.
Translations
-
🌐 Add Russian translation fordocs/ru/docs/tutorial/security/index.md
. MR #9963 by @eVery1337. -
🌐 Remove Vietnamese note about missing translation. MR #9957 by @tiangolo.
Internal
-
👷 Add GitHub Actions step dump context to debug external failures. MR #10008 by @tiangolo. -
🔧 Restore MkDocs Material pin after the fix. MR #10001 by @tiangolo. -
🔧 Update the Question template to ask for the Pydantic version. MR #10000 by @tiangolo. -
📍 Update MkDocs Material dependencies. MR #9986 by @tiangolo. -
👥 Update FastAPI People. MR #9999 by @tiangolo. -
🐳 Update Dockerfile with compatibility versions, to upgrade later. MR #9998 by @tiangolo. -
➕ Add pydantic-settings to FastAPI People dependencies. MR #9988 by @tiangolo. -
♻ ️ Update FastAPI People logic with new Pydantic. MR #9985 by @tiangolo. -
🍱 Update sponsors, Fern badge. MR #9982 by @tiangolo. -
👷 Deploy docs to Cloudflare Pages. MR #9978 by @tiangolo. -
🔧 Update sponsor Fern. MR #9979 by @tiangolo. -
👷 Update CI debug mode with Tmate. MR #9977 by @tiangolo.
v0.100.1
Fixes
-
🐛 ReplaceMultHostUrl
toAnyUrl
for compatibility with older versions of Pydantic v1. MR #9852 by @Kludex.
Docs
-
📝 Update links for self-hosted Swagger UI, point to v5, for OpenAPI 31.0. MR #9834 by @tiangolo.
Translations
-
🌐 Add Ukrainian translation fordocs/uk/docs/tutorial/body.md
. MR #4574 by @ss-o-furda. -
🌐 Add Vietnamese translation fordocs/vi/docs/features.md
anddocs/vi/docs/index.md
. MR #3006 by @magiskboy. -
🌐 Add Korean translation fordocs/ko/docs/async.md
. MR #4179 by @NinaHwang. -
🌐 Add Chinese translation fordocs/zh/docs/tutorial/background-tasks.md
. MR #9812 by @wdh99. -
🌐 Add French translation fordocs/fr/docs/tutorial/query-params-str-validations.md
. MR #4075 by @Smlep. -
🌐 Add French translation fordocs/fr/docs/tutorial/index.md
. MR #2234 by @JulianMaurin. -
🌐 Add French translation fordocs/fr/docs/contributing.md
. MR #2132 by @JulianMaurin. -
🌐 Add French translation fordocs/fr/docs/benchmarks.md
. MR #2155 by @clemsau. -
🌐 Update Chinese translations with new source files. MR #9738 by @mahone3297. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/request-forms.md
. MR #9841 by @dedkot01. -
🌐 Update Chinese translation fordocs/zh/docs/tutorial/handling-errors.md
. MR #9485 by @Creat55.
Internal
-
🔧 Update sponsors, add Fern. MR #9956 by @tiangolo. -
👷 Update FastAPI People token. MR #9844 by @tiangolo. -
👥 Update FastAPI People. MR #9775 by @tiangolo. -
👷 Update MkDocs Material token. MR #9843 by @tiangolo. -
👷 Update token for latest changes. MR #9842 by @tiangolo.
v0.100.0
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.
-
MR #9816 by @tiangolo, included all the work done (in multiple MRs) on the beta branch (
main-pv2
).
v0.99.1
Fixes
-
🐛 Fix JSON Schema accepting bools as valid JSON Schemas, e.g.additionalProperties: false
. MR #9781 by @tiangolo.
Docs
-
📝 Update source examples to use new JSON Schema examples field. MR #9776 by @tiangolo.
v0.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
Features
-
✨ Add support for OpenAPI 3.1.0. MR #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 fordeque
objects and children injsonable_encoder
. MR #9433 by @cranium.
Docs
-
📝 Fix form for the FastAPI and friends newsletter. MR #9749 by @tiangolo.
Translations
-
🌐 Add Persian translation fordocs/fa/docs/advanced/sub-applications.md
. MR #9692 by @mojtabapaso. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/response-model.md
. MR #9675 by @glsglsgls.
Internal
-
🔨 Enable linenums in MkDocs Material during local live development to simplify highlighting code. MR #9769 by @tiangolo. -
⬆ Update httpx requirement from <0.24.0,>=0.23.0 to >=0.23.0,<0.25.0. MR #9724 by @dependabot[bot]. -
⬆ Bump mkdocs-material from 9.1.16 to 9.1.17. MR #9746 by @dependabot[bot]. -
🔥 Remove missing translation dummy pages, no longer necessary. MR #9751 by @tiangolo. -
⬆ [pre-commit.ci] pre-commit autoupdate. MR #9259 by @pre-commit-ci[bot]. -
✨ Add Material for MkDocs Insiders features and cards. MR #9748 by @tiangolo. -
🔥 Remove languages without translations. MR #9743 by @tiangolo. -
✨ Refactor docs for building scripts, use MkDocs hooks, simplify (remove) configs for languages. MR #9742 by @tiangolo. -
🔨 Add MkDocs hook that renames sections based on the first index file. MR #9737 by @tiangolo. -
👷 Make cron jobs run only on main repo, not on forks, to avoid error notifications from missing tokens. MR #9735 by @tiangolo. -
🔧 Update MkDocs for other languages. MR #9734 by @tiangolo. -
👷 Refactor Docs CI, run in multiple workers with a dynamic matrix to optimize speed. MR #9732 by @tiangolo. -
🔥 Remove old internal GitHub Action watch-previews that is no longer needed. MR #9730 by @tiangolo. -
⬆ ️ Upgrade MkDocs and MkDocs Material. MR #9729 by @tiangolo. -
👷 Build and deploy docs only on docs changes. MR #9728 by @tiangolo.
v0.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
-
✨ Allow disablingredirect_slashes
at the FastAPI app level. MR #3432 by @cyberlis.
Docs
-
📝 Update docs on Pydantic using ujson internally. MR #5804 by @mvasilkov. -
✏ Rewording indocs/en/docs/tutorial/debugging.md
. MR #9581 by @ivan-abc. -
📝 Add german blog post (Domain-driven Design mit Python und FastAPI). MR #9261 by @msander. -
✏ ️ Tweak wording indocs/en/docs/tutorial/security/index.md
. MR #9561 by @jyothish-mohan. -
📝 UpdateAnnotated
notes indocs/en/docs/tutorial/schema-extra-example.md
. MR #9620 by @Alexandrhub. -
✏ ️ Fix typoAnnotation
->Annotated
indocs/en/docs/tutorial/query-params-str-validations.md
. MR #9625 by @mccricardo. -
📝 Use in memory database for testing SQL in docs. MR #1223 by @HarshaLaxman.
Translations
-
🌐 Add Russian translation fordocs/ru/docs/tutorial/metadata.md
. MR #9681 by @TabarakoAkula. -
🌐 Fix typo in Spanish translation fordocs/es/docs/tutorial/first-steps.md
. MR #9571 by @lilidl-nft. -
🌐 Add Russian translation fordocs/tutorial/path-operation-configuration.md
. MR #9696 by @TabarakoAkula. -
🌐 Add Chinese translation fordocs/zh/docs/advanced/security/index.md
. MR #9666 by @lordqyxz. -
🌐 Add Chinese translations fordocs/zh/docs/advanced/settings.md
. MR #9652 by @ChoyeonChern. -
🌐 Add Chinese translations fordocs/zh/docs/advanced/websockets.md
. MR #9651 by @ChoyeonChern. -
🌐 Add Chinese translation fordocs/zh/docs/tutorial/testing.md
. MR #9641 by @wdh99. -
🌐 Add Russian translation fordocs/tutorial/extra-models.md
. MR #9619 by @ivan-abc. -
🌐 Add Russian translation fordocs/tutorial/cors.md
. MR #9608 by @ivan-abc. -
🌐 Add Polish translation fordocs/pl/docs/features.md
. MR #5348 by @mbroton. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/body-nested-models.md
. MR #9605 by @Alexandrhub.
Internal
-
⬆ Bump ruff from 0.0.272 to 0.0.275. MR #9721 by @dependabot[bot]. -
⬆ Update uvicorn[standard] requirement from <0.21.0,>=0.12.0 to >=0.12.0,<0.23.0. MR #9463 by @dependabot[bot]. -
⬆ Bump mypy from 1.3.0 to 1.4.0. MR #9719 by @dependabot[bot]. -
⬆ Update pre-commit requirement from <3.0.0,>=2.17.0 to >=2.17.0,<4.0.0. MR #9251 by @dependabot[bot]. -
⬆ Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6. MR #9482 by @dependabot[bot]. -
✏ ️ Fix tooltips for light/dark theme toggler in docs. MR #9588 by @pankaj1707k. -
🔧 Set minimal hatchling version needed to build the package. MR #9240 by @mgorny. -
📝 Add repo link to PyPI. MR #9559 by @JacobCoffee. -
✏ ️ Fix typos in data for tests. MR #4958 by @ryanrussell. -
🔧 Update sponsors, add Flint. MR #9699 by @tiangolo. -
👷 Lint in CI only once, only with one version of Python, run tests with all of them. MR #9686 by @tiangolo.
v0.97.0
Features
-
✨ Add support fordependencies
in WebSocket routes. MR #4534 by @paulo-raca. -
✨ Add exception handler forWebSocketRequestValidationError
(which also allows to override it). MR #6030 by @kristjanvalur.
Refactors
-
⬆ ️ Upgrade and fully migrate to Ruff, remove isort, includes a couple of tweaks suggested by the new version of Ruff. MR #9660 by @tiangolo. -
♻ ️ Update internal type annotations and upgrade mypy. MR #9658 by @tiangolo. -
♻ ️ SimplifyAsyncExitStackMiddleware
as without Python 3.6AsyncExitStack
is always available. MR #9657 by @tiangolo.
Upgrades
-
⬆ ️ Upgrade Black. MR #9661 by @tiangolo.
Internal
-
💚 Update CI cache to fix installs when dependencies change. MR #9659 by @tiangolo. -
⬇ ️ Separate requirements for development into their own requirements.txt files, they shouldn't be extras. MR #9655 by @tiangolo.
v0.96.1
Fixes
-
🐛 FixHTTPException
header type annotations. MR #9648 by @tiangolo. -
🐛 Fix OpenAPI model fields int validations,gte
toge
. MR #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. MR #9567 by @Kludex.
Refactors
-
♻ Removemedia_type
fromORJSONResponse
as it's inherited from the parent class. MR #5805 by @Kludex. -
♻ InstantiateHTTPException
only when needed, optimization refactor. MR #5356 by @pawamoy.
Docs
Translations
-
🌐 Fix spelling in Indonesian translation ofdocs/id/docs/tutorial/index.md
. MR #5635 by @purwowd. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/index.md
. MR #5896 by @Wilidon. -
🌐 Add Chinese translations fordocs/zh/docs/advanced/response-change-status-code.md
anddocs/zh/docs/advanced/response-headers.md
. MR #9544 by @ChoyeonChern. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/schema-extra-example.md
. MR #9621 by @Alexandrhub.
Internal
-
🔧 Add sponsor Platform.sh. MR #9650 by @tiangolo. -
👷 Add custom token to Smokeshow and Preview Docs for download-artifact, to prevent API rate limits. MR #9646 by @tiangolo. -
👷 Add custom tokens for GitHub Actions to avoid rate limits. MR #9647 by @tiangolo.
v0.96.0
Features
-
⚡ Updatecreate_cloned_field
to use a global cache and improve startup performance. MR #4645 by @madkinsz and previous original MR by @huonw.
Docs
-
📝 Update Deta deployment tutorial for compatibility with Deta Space. MR #6004 by @mikBighne98. -
✏ ️ Fix typo in Deta deployment tutorial. MR #9501 by @lemonyte.
Translations
-
🌐 Add Russian translation fordocs/tutorial/body.md
. MR #3885 by @solomein-sv. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/static-files.md
. MR #9580 by @Alexandrhub. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/query-params.md
. MR #9584 by @Alexandrhub. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/first-steps.md
. MR #9471 by @AGolicyn. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/debugging.md
. MR #9579 by @Alexandrhub. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/path-params.md
. MR #9519 by @AGolicyn. -
🌐 Add Chinese translation fordocs/zh/docs/tutorial/static-files.md
. MR #9436 by @wdh99. -
🌐 Update Spanish translation including new illustrations indocs/es/docs/async.md
. MR #9483 by @andresbermeoq. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/path-params-numeric-validations.md
. MR #9563 by @ivan-abc. -
🌐 Add Russian translation fordocs/ru/docs/deployment/concepts.md
. MR #9577 by @Xewus. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/body-multiple-params.md
. MR #9586 by @Alexandrhub.
Internal
-
👥 Update FastAPI People. MR #9602 by @github-actions[bot]. -
🔧 Update sponsors, remove InvestSuite. MR #9612 by @tiangolo.
v0.95.2
-
⬆ ️ Upgrade Starlette version to>=0.27.0
for a security release. MR #9541 by @tiangolo. Details on Starlette's security advisory.
Translations
-
🌐 Add Portuguese translation fordocs/pt/docs/advanced/events.md
. MR #9326 by @oandersonmagalhaes. -
🌐 Add Russian translation fordocs/ru/docs/deployment/manually.md
. MR #9417 by @Xewus. -
🌐 Add setup for translations to Lao. MR #9396 by @TheBrown. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/testing.md
. MR #9403 by @Xewus. -
🌐 Add Russian translation fordocs/ru/docs/deployment/https.md
. MR #9428 by @Xewus. -
✏ Fix command to install requirements in Windows. MR #9445 by @MariiaRomanuik. -
🌐 Add French translation fordocs/fr/docs/advanced/response-directly.md
. MR #9415 by @axel584. -
🌐 Initiate Czech translation setup. MR #9288 by @3p1463k. -
✏ Fix typo in Portuguese docs fordocs/pt/docs/index.md
. MR #9337 by @lucasbalieiro. -
🌐 Add Russian translation fordocs/ru/docs/tutorial/response-status-code.md
. MR #9370 by @nadia3373.
Internal
-
🐛 Fixflask.escape
warning for internal tests. MR #9468 by @samuelcolvin. -
✅ Refactor 2 tests, for consistency and simplification. MR #9504 by @tiangolo. -
✅ Refactor OpenAPI tests, prepare for Pydantic v2. MR #9503 by @tiangolo. -
⬆ Bump dawidd6/action-download-artifact from 2.26.0 to 2.27.0. MR #9394 by @dependabot[bot]. -
💚 Disable setup-python pip cache in CI. MR #9438 by @tiangolo. -
⬆ Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.5. MR #9346 by @dependabot[bot].
Configuration
-
If you want to rebase/retry this MR, check this box
This MR has been generated by Renovate Bot.