Skip to content

Releases: tiangolo/fastapi

0.100.1

27 Jul 19:17
Compare
Choose a tag to compare

Fixes

  • 🐛 Replace MultHostUrl to AnyUrl for compatibility with older versions of Pydantic v1. PR #9852 by @Kludex.

Docs

  • 📝 Update links for self-hosted Swagger UI, point to v5, for OpenAPI 31.0. PR #9834 by @tiangolo.

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 and docs/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

07 Jul 17:32
Compare
Choose a tag to compare

✨ 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 by pattern.

  • New Pydantic models use an improved and simplified attribute model_config that takes a simple dict instead of an internal class Config for their configuration.

  • The attribute schema_extra for the internal class Config has been replaced by the key json_schema_extra in the new model_config dict.

  • When you install "fastapi[all]" it now also includes:

  • Now Pydantic Settings is an additional optional package (included in "fastapi[all]"). To use settings you should now import from pydantic_settings import BaseSettings instead of importing from pydantic directly.

  • PR #9816 by @tiangolo, included all the work done (in multiple PRs) on the beta branch (main-pv2).

0.100.0-beta3

05 Jul 17:52
Compare
Choose a tag to compare
0.100.0-beta3 Pre-release
Pre-release

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

02 Jul 16:02
Compare
Choose a tag to compare

Fixes

  • 🐛 Fix JSON Schema accepting bools as valid JSON Schemas, e.g. additionalProperties: false. PR #9781 by @tiangolo.

Docs

  • 📝 Update source examples to use new JSON Schema examples field. PR #9776 by @tiangolo.

0.100.0-beta2

30 Jun 19:58
Compare
Choose a tag to compare
0.100.0-beta2 Pre-release
Pre-release

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

30 Jun 19:01
Compare
Choose a tag to compare

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 in Query(), 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 in jsonable_encoder. PR #9433 by @cranium.

Docs

  • 📝 Fix form for the FastAPI and friends newsletter. PR #9749 by @tiangolo.

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

22 Jun 18:08
Compare
Choose a tag to compare

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 disabling redirect_slashes at the FastAPI app level. PR #3432 by @cyberlis.

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 in docs/en/docs/tutorial/schema-extra-example.md. PR #9620 by @Alexandrhub.
  • ✏️ Fix typo Annotation -> Annotated in docs/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

0.100.0-beta1

20 Jun 17:28
6dc975d
Compare
Choose a tag to compare
0.100.0-beta1 Pre-release
Pre-release

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

11 Jun 22:54
Compare
Choose a tag to compare

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.6 AsyncExitStack is always available. PR #9657 by @tiangolo.

Upgrades

Internal

  • 💚 Update CI cache to fix installs when dependencies change. PR #9659 by @tiangolo.
  • ⬇️ Separate requirements for development into their own requirements.txt files, they shouldn't be extras. PR #9655 by @tiangolo.

0.96.1

10 Jun 21:56
Compare
Choose a tag to compare

Fixes

  • 🐛 Fix HTTPException header type annotations. PR #9648 by @tiangolo.
  • 🐛 Fix OpenAPI model fields int validations, gte to ge. 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 from ORJSONResponse as it's inherited from the parent class. PR #5805 by @Kludex.
  • ♻ Instantiate HTTPException only when needed, optimization refactor. PR #5356 by @pawamoy.

Docs

  • 🔥 Remove link to Pydantic's benchmark, as it was removed there. PR #5811 by @Kludex.

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 and docs/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.

Internal

  • 🔧 Add sponsor Platform.sh. PR #9650 by @tiangolo.
  • 👷 Add custom token to Smokeshow and Preview Docs for download-artifact, to prevent API rate limits. PR #9646 by @tiangolo.
  • 👷 Add custom tokens for GitHub Actions to avoid rate limits. PR #9647 by @tiangolo.