Skip to content

Releases: fastapi/fastapi

0.109.2

04 Feb 21:25
Compare
Choose a tag to compare

Upgrades

Translations

  • 🌐 Update Turkish translation fordocs/tr/docs/fastapi-people.md.PR#10547by@alperiox.

Internal

0.109.1

03 Feb 12:43
Compare
Choose a tag to compare

Security fixes

  • ⬆️ Upgrade minimum version ofpython-multipartto>=0.0.7to fix a vulnerability when using form data with a ReDos attack. You can also simply upgradepython-multipart.

Read more in theadvisory: Content-Type Header ReDoS.

Features

Refactors

  • ✅ Refactor tests for duplicate operation ID generation for compatibility with other tools running the FastAPI test suite. PR#10876by@emmettbutler.
  • ♻️ Simplify string format with f-strings infastapi/utils.py.PR#10576by@eukub.
  • 🔧 Fix Ruff configuration unintentionally enabling and re-disabling mccabe complexity check. PR#10893by@jiridanek.
  • ✅ Re-enable test intests/test_tutorial/test_header_params/test_tutorial003.pyafter fix in Starlette. PR#10904by@ooknimm.

Docs

  • 📝 Tweak wording inhelp-fastapi.md.PR#11040by@tiangolo.
  • 📝 Tweak docs for Behind a Proxy. PR#11038by@tiangolo.
  • 📝 Add External Link: 10 Tips for adding SQLAlchemy to FastAPI. PR#11036by@Donnype.
  • 📝 Add External Link: Tips on migrating from Flask to FastAPI and vice-versa. PR#11029by@jtemporal.
  • 📝 Deprecate old tutorials: Peewee, Couchbase, encode/databases. PR#10979by@tiangolo.
  • ✏️ Fix typo infastapi/security/oauth2.py.PR#10972by@RafalSkolasinski.
  • 📝 UpdateHTTPExceptiondetails indocs/en/docs/tutorial/handling-errors.md.PR#5418by@papb.
  • ✏️ A few tweaks indocs/de/docs/tutorial/first-steps.md.PR#10959by@nilslindemann.
  • ✏️ Fix link indocs/en/docs/advanced/async-tests.md.PR#10960by@nilslindemann.
  • ✏️ Fix typos for Spanish documentation. PR#10957by@jlopezlira.
  • 📝 Add warning about lifespan functions and backwards compatibility with events. PR#10734by@jacob-indigo.
  • ✏️ Fix broken link indocs/tutorial/sql-databases.mdin several languages. PR#10716by@theoohoho.
  • ✏️ Remove broken links fromexternal_links.yml.PR#10943by@Torabek.
  • 📝 Update template docs with more info abouturl_for.PR#5937by@EzzEddin.
  • 📝 Update usage of Token model in security docs. PR#9313by@piotrszacilowski.
  • ✏️ Update highlighted line indocs/en/docs/tutorial/bigger-applications.md.PR#5490by@papb.
  • 📝 Add External Link: Explore How to Effectively Use JWT With FastAPI. PR#10212by@aanchlia.
  • 📝 Add hyperlink todocs/en/docs/tutorial/static-files.md.PR#10243by@hungtsetse.
  • 📝 Add External Link: Instrument a FastAPI service adding tracing with OpenTelemetry and send/show traces in Grafana Tempo. PR#9440by@softwarebloat.
  • 📝 Review and rewording ofen/docs/contributing.md.PR#10480by@nilslindemann.
  • 📝 Add External Link: ML serving and monitoring with FastAPI and Evidently. PR#9701by@mnrozhkov.
  • 📝 Reword in docs, from "have in mind" to "keep in mind". PR#10376by@malicious.
  • 📝 Add External Link: Talk by Jeny Sadadia. PR#10265by@JenySadadia.
  • 📝 Add location info totutorial/bigger-applications.md.PR#10552by@nilslindemann.
  • ✏️ Fix Pydantic method name indocs/en/docs/advanced/path-operation-advanced-configuration.md.PR#10826by@ahmedabdou14.

Translations

  • 🌐 Add Spanish translation fordocs/es/docs/external-links.md.PR#10933by@pablocm83.
  • 🌐 Update Korean translation fordocs/ko/docs/tutorial/first-steps.md,docs/ko/docs/tutorial/index.md,docs/ko/docs/tutorial/path-params.md,anddocs/ko/docs/tutorial/query-params.md.PR#4218by@SnowSuno.
  • 🌐 Add Chinese translation fordocs/zh/docs/tutorial/dependencies/dependencies-with-yield.md.PR#10870by@zhiquanchi.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/concepts.md.PR#10282by@xzmeng.
  • 🌐 Add Azerbaijani translation fordocs/az/docs/index.md.PR#11047by@aykhans.
  • 🌐 Add Korean translation fordocs/ko/docs/tutorial/middleware.md.PR#2829by@JeongHyeongKim.
  • 🌐 Add German translation fordocs/de/docs/tutorial/body-nested-models.md.PR#10313by@nilslindemann.
  • 🌐 Add Persian translation fordocs/fa/docs/tutorial/middleware.md.PR#9695by@mojtabapaso.
  • 🌐 Update Farsi translation fordocs/fa/docs/index.md.PR#10216by@theonlykingpin.
  • 🌐 Add German translation fordocs/de/docs/tutorial/body-fields.md.PR#10310by@nilslindemann.
  • 🌐 Add German translation fordocs/de/docs/tutorial/body.md.PR#10295by@nilslindemann.
  • 🌐 Add German translation fordocs/de/docs/tutorial/body-multiple-params.md.PR#10308by@nilslindemann.
  • 🌐 Add Japanese translation fordocs/ja/docs/tutorial/security/get-current-user.md.PR#2681by@sh0nk.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/advanced-dependencies.md.PR#3798by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/events.md.PR#3815by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/behind-a-proxy.md.PR#3820by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/testing-events.md.PR#3818by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/testing-websockets.md.PR#3817by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/testing-database.md.PR#3821by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/deta.md.PR#3837by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/history-design-future.md.PR#3832by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/project-generation.md.PR#3831by@jaystone776.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/docker.md.PR [#10296](https://gi...
Read more

0.109.0

11 Jan 15:35
Compare
Choose a tag to compare

Features

Upgrades

  • ⬆️ Upgrade Starlette to>=0.29.0,<0.33.0,update docs and usage of templates with new Starlette arguments. Remove pin of AnyIO>=3.7.1,<4.0.0,add support for AnyIO 4.x.x. PR#10846by@tiangolo.

Docs

  • ✏️ Fix typo indocs/en/docs/alternatives.md.PR#10931by@s111d.
  • 📝 Replaceemailwithusernameindocs_src/security/tutorial007code examples. PR#10649by@nilslindemann.
  • 📝 Add VS Code tutorial link. PR#10592by@nilslindemann.
  • 📝 Add notes about Pydantic v2's new.model_dump().PR#10929by@tiangolo.
  • 📝 Fix broken link indocs/en/docs/tutorial/sql-databases.md.PR#10765by@HurSungYun.
  • 📝 Add External Link: FastAPI application monitoring made easy. PR#10917by@tiangolo.
  • ✨ Generate automatic language names for docs translations. PR#5354by@jakul.
  • ✏️ Fix typos indocs/en/docs/alternatives.mdanddocs/en/docs/tutorial/dependencies/index.md.PR#10906by@s111d.
  • ✏️ Fix typos indocs/en/docs/tutorial/dependencies/dependencies-with-yield.md.PR#10834by@Molkree.
  • 📝 Add article: "Building a RESTful API with FastAPI: Secure Signup and Login Functionality Included". PR#9733by@dxphilo.
  • 📝 Add warning about lifecycle events withAsyncClient.PR#4167by@andrew-chang-dewitt.
  • ✏️ Fix typos in/docs/reference/exceptions.mdand/en/docs/reference/status.md.PR#10809by@clarencepenz.
  • ✏️ Fix typo inopenapi-callbacks.md.PR#10673by@kayjan.
  • ✏️ Fix typo infastapi/routing.py.PR#10520by@sepsh.
  • 📝 Replace HTTP code returned in case of existing user error in docs for testing. PR#4482by@TristanMarion.
  • 📝 Add blog for FastAPI & Supabase. PR#6018by@theinfosecguy.
  • 📝 Update example source files for SQL databases with SQLAlchemy. PR#9508by@s-mustafa.
  • 📝 Update code examples in docs for body, replace namecreate_itemwithupdate_itemwhen appropriate. PR#5913by@OttoAndrey.
  • ✏️ Fix typo in dependencies with yield source examples. PR#10847by@tiangolo.

Translations

  • 🌐 Add Bengali translation fordocs/bn/docs/index.md.PR#9177by@Fahad-Md-Kamal.
  • ✏️ Update Python version inindex.mdin several languages. PR#10711by@tamago3keran.
  • 🌐 Add Russian translation fordocs/ru/docs/tutorial/request-forms-and-files.md.PR#10347by@AlertRED.
  • 🌐 Add Ukrainian translation fordocs/uk/docs/index.md.PR#10362by@rostik1410.
  • ✏️ Update Python version indocs/ko/docs/index.md.PR#10680by@Eeap.
  • 🌐 Add Persian translation fordocs/fa/docs/features.md.PR#5887by@amirilf.
  • 🌐 Add Chinese translation fordocs/zh/docs/advanced/additional-responses.md.PR#10325by@ShuibeiC.
  • 🌐 Fix typos in Russian translations fordocs/ru/docs/tutorial/background-tasks.md,docs/ru/docs/tutorial/body-nested-models.md,docs/ru/docs/tutorial/debugging.md,docs/ru/docs/tutorial/testing.md.PR#10311by@AlertRED.
  • 🌐 Add Russian translation fordocs/ru/docs/tutorial/request-files.md.PR#10332by@AlertRED.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/server-workers.md.PR#10292by@xzmeng.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/cloud.md.PR#10291by@xzmeng.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/manually.md.PR#10279by@xzmeng.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/https.md.PR#10277by@xzmeng.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/index.md.PR#10275by@xzmeng.
  • 🌐 Add German translation fordocs/de/docs/tutorial/first-steps.md.PR#9530by@fhabers21.
  • 🌐 Update Turkish translation fordocs/tr/docs/index.md.PR#10444by@hasansezertasan.
  • 🌐 Add Chinese translation fordocs/zh/docs/learn/index.md.PR#10479by@KAZAMA-DREAM.
  • 🌐 Add Russian translation fordocs/ru/docs/learn/index.md.PR#10539by@AlertRED.
  • 🌐 Update SQLAlchemy instruction in Chinese translationdocs/zh/docs/tutorial/sql-databases.md.PR#9712by@Royc30ne.
  • 🌐 Add Turkish translation fordocs/tr/docs/external-links.md.PR#10549by@hasansezertasan.
  • 🌐 Add Spanish translation fordocs/es/docs/learn/index.md.PR#10885by@pablocm83.
  • 🌐 Add Ukrainian translation fordocs/uk/docs/tutorial/body-fields.md.PR#10670by@ArtemKhymenko.
  • 🌐 Add Hungarian translation for/docs/hu/docs/index.md.PR#10812by@takacs.
  • 🌐 Add Turkish translation fordocs/tr/docs/newsletter.md.PR#10550by@hasansezertasan.
  • 🌐 Add Spanish translation fordocs/es/docs/help/index.md.PR#10907by@pablocm83.
  • 🌐 Add Spanish translation fordocs/es/docs/about/index.md.PR#10908by@pablocm83.
  • 🌐 Add Spanish translation fordocs/es/docs/resources/index.md.PR#10909by@pablocm83.

Internal

0.108.0

26 Dec 20:24
Compare
Choose a tag to compare

Upgrades

  • ⬆️ Upgrade Starlette to>=0.29.0,<0.33.0,update docs and usage of templates with new Starlette arguments. PR#10846by@tiangolo.

0.107.0

26 Dec 19:09
Compare
Choose a tag to compare

Upgrades

Docs

  • 📝 Add docs: Node.js script alternative to update OpenAPI for generated clients. PR#10845by@alejsdev.
  • 📝 Restructure Docs section in Contributing page. PR#10844by@alejsdev.

0.106.0

25 Dec 18:06
Compare
Choose a tag to compare

Breaking Changes

Using resources from dependencies withyieldin background tasks is no longer supported.

This change is what supports the new features, read below. 🤓

Dependencies withyield,HTTPExceptionand Background Tasks

Dependencies withyieldnow can raiseHTTPExceptionand other exceptions afteryield.🎉

Read the new docs here:Dependencies withyieldandHTTPException.

fromfastapiimportDepends,FastAPI,HTTPException
fromtyping_extensionsimportAnnotated

app=FastAPI()


data={
"plumbus":{"description":"Freshly pickled plumbus","owner":"Morty"},
"portal-gun":{"description":"Gun to create portals","owner":"Rick"},
}


classOwnerError(Exception):
pass


defget_username():
try:
yield"Rick"
exceptOwnerErrorase:
raiseHTTPException(status_code=400,detail=f "Onwer error:{e}")


@app.get("/items/{item_id}")
defget_item(item_id:str,username:Annotated[str,Depends(get_username)]):
ifitem_idnotindata:
raiseHTTPException(status_code=404,detail="Item not found")
item=data[item_id]
ifitem["owner"]!=username:
raiseOwnerError(username)
returnitem

Before FastAPI 0.106.0, raising exceptions afteryieldwas not possible, the exit code in dependencies withyieldwas executedafterthe response was sent, soException Handlerswould have already run.

This was designed this way mainly to allow using the same objects "yielded" by dependencies inside of background tasks, because the exit code would be executed after the background tasks were finished.

Nevertheless, as this would mean waiting for the response to travel through the network while unnecessarily holding a resource in a dependency with yield (for example a database connection), this was changed in FastAPI 0.106.0.

Additionally, a background task is normally an independent set of logic that should be handled separately, with its own resources (e.g. its own database connection).

If you used to rely on this behavior, now you should create the resources for background tasks inside the background task itself, and use internally only data that doesn't depend on the resources of dependencies withyield.

For example, instead of using the same database session, you would create a new database session inside of the background task, and you would obtain the objects from the database using this new session. And then instead of passing the object from the database as a parameter to the background task function, you would pass the ID of that object and then obtain the object again inside the background task function.

The sequence of execution before FastAPI 0.106.0 was like the diagram in theRelease Notes for FastAPI 0.106.0.

The new execution flow can be found in the docs:Execution of dependencies withyield.

0.105.0

12 Dec 00:38
Compare
Choose a tag to compare

Features

  • ✨ Add support for multiple Annotated annotations, e.g.Annotated[str, Field(), Query()].PR#10773by@tiangolo.

Refactors

Docs

  • 📝 Tweak default suggested configs for generating clients. PR#10736by@tiangolo.

Internal

0.104.1

30 Oct 10:05
Compare
Choose a tag to compare

Fixes

  • 📌 Pin Swagger UI version to 5.9.0 temporarily to handle a bug crashing it in 5.9.1. PR#10529by@alejandraklachquin.
    • This is not really a bug in FastAPI but in Swagger UI, nevertheless pinning the version will work while a solution is found on theSwagger UI side.

Docs

  • 📝 Update data structure and render for external-links. PR#10495by@tiangolo.
  • ✏️ Fix link to SPDX license identifier indocs/en/docs/tutorial/metadata.md.PR#10433by@worldworm.
  • 📝 Update example validation error from Pydantic v1 to match Pydantic v2 indocs/en/docs/tutorial/path-params.md.PR#10043by@giuliowaitforitdavide.
  • ✏️ Fix typos in emoji docs and in some source examples. PR#10438by@afuetterer.
  • ✏️ Fix typo indocs/en/docs/reference/dependencies.md.PR#10465by@suravshresth.
  • ✏️ Fix typos and rewordings indocs/en/docs/tutorial/body-nested-models.md.PR#10468by@yogabonito.
  • 📝 Update docs, remove references to removedpydantic.Requiredindocs/en/docs/tutorial/query-params-str-validations.md.PR#10469by@yogabonito.
  • ✏️ Fix typo indocs/en/docs/reference/index.md.PR#10467by@tarsil.
  • 🔥 Remove unnecessary duplicated docstrings. PR#10484by@tiangolo.

Internal

0.104.0

18 Oct 12:52
Compare
Choose a tag to compare

Features

Upgrades

  • ⬆️ Drop support for Python 3.7, require Python 3.8 or above. PR#10442by@tiangolo.

Internal

0.103.2

28 Sep 20:02
Compare
Choose a tag to compare

Refactors

  • ⬆️ Upgrade compatibility with Pydantic v2.4, new renamed functions and JSON Schema input/output models with default values. PR#10344by@tiangolo.

Translations

  • 🌐 Add Ukrainian translation fordocs/uk/docs/tutorial/extra-data-types.md.PR#10132by@ArtemKhymenko.
  • 🌐 Fix typos in French translations fordocs/fr/docs/advanced/path-operation-advanced-configuration.md,docs/fr/docs/alternatives.md,docs/fr/docs/async.md,docs/fr/docs/features.md,docs/fr/docs/help-fastapi.md,docs/fr/docs/index.md,docs/fr/docs/python-types.md,docs/fr/docs/tutorial/body.md,docs/fr/docs/tutorial/first-steps.md,docs/fr/docs/tutorial/query-params.md.PR#10154by@s-rigaud.
  • 🌐 Add Chinese translation fordocs/zh/docs/async.md.PR#5591by@mkdir700.
  • 🌐 Update Chinese translation fordocs/tutorial/security/simple-oauth2.md.PR#3844by@jaystone776.
  • 🌐 Add Korean translation fordocs/ko/docs/deployment/cloud.md.PR#10191by@Sion99.
  • 🌐 Add Japanese translation fordocs/ja/docs/deployment/https.md.PR#10298by@tamtam-fitness.
  • 🌐 Fix typo in Russian translation fordocs/ru/docs/tutorial/body-fields.md.PR#10224by@AlertRED.
  • 🌐 Add Polish translation fordocs/pl/docs/help-fastapi.md.PR#10121by@romabozhanovgithub.
  • 🌐 Add Russian translation fordocs/ru/docs/tutorial/header-params.md.PR#10226by@AlertRED.
  • 🌐 Add Chinese translation fordocs/zh/docs/deployment/versions.md.PR#10276by@xzmeng.

Internal