Skip to content

Releases: fastapi/fastapi

0.114.0

06 Sep 17:42
Compare
Choose a tag to compare

You can restrict form fields to only include those declared in a Pydantic model and forbid any extra field sent in the request using Pydantic'smodel_config = { "extra": "forbid" }:

fromtypingimportAnnotated

fromfastapiimportFastAPI,Form
frompydanticimportBaseModel

app=FastAPI()


classFormData(BaseModel):
username:str
password:str
model_config={"extra":"forbid"}


@app.post("/login/")
asyncdeflogin(data:Annotated[FormData,Form()]):
returndata

Read the new docs:Form Models - Forbid Extra Form Fields.

Features

  • ✨ Add support for forbidding extra form fields with Pydantic models. PR#12134by@tiangolo.

Docs

  • 📝 Update docs, Form Models section title, to match config name. PR#12152by@tiangolo.

Internal

  • ✅ Update internal tests for latest Pydantic, including CI tweaks to install the latest Pydantic. PR#12147by@tiangolo.

0.113.0

05 Sep 15:32
Compare
Choose a tag to compare

Now you can declare form fields with Pydantic models:

fromtypingimportAnnotated

fromfastapiimportFastAPI,Form
frompydanticimportBaseModel

app=FastAPI()


classFormData(BaseModel):
username:str
password:str


@app.post("/login/")
asyncdeflogin(data:Annotated[FormData,Form()]):
returndata

Read the new docs:Form Models.

Features

  • ✨ Add support for Pydantic models inFormparameters. PR#12129by@tiangolo.

Internal

0.112.4

05 Sep 15:06
Compare
Choose a tag to compare

This release is mainly a big internal refactor to enable adding support for Pydantic models forFormfields, but that feature comes in the next release.

This release shouldn't affect apps using FastAPI in any way. You don't even have to upgrade to this version yet. It's just a checkpoint. 🤓

Refactors

  • ♻️ Refactor deciding ifembedbody fields, do not overwrite fields, compute once per router, refactor internals in preparation for Pydantic models inForm,Queryand others. PR#12117by@tiangolo.

Internal

  • ⏪️ Temporarily revert "✨ Add support for Pydantic models inFormparameters "to make a checkpoint release. PR#12128by@tiangolo.
  • ✨ Add support for Pydantic models inFormparameters. PR#12127by@tiangolo.Reverted to make a checkpoint release with only refactors.

0.112.3

05 Sep 09:16
Compare
Choose a tag to compare

This release is mainly internal refactors, it shouldn't affect apps using FastAPI in any way. You don't even have to upgrade to this version yet. There are a few bigger releases coming right after. 🚀

Refactors

  • ♻️ Refactor internalcheck_file_field(),rename toensure_multipart_is_installed()to clarify its purpose. PR#12106by@tiangolo.
  • ♻️ Rename internalcreate_response_field()tocreate_model_field()as it's used for more than response models. PR#12103by@tiangolo.
  • ♻️ Refactor and simplify internal data fromsolve_dependencies()using dataclasses. PR#12100by@tiangolo.
  • ♻️ Refactor and simplify internalanalyze_param()to structure data with dataclasses instead of tuple. PR#12099by@tiangolo.
  • ♻️ Refactor and simplify dependencies data structures with dataclasses. PR#12098by@tiangolo.

Docs

  • 📝 Add External Link: Techniques and applications of SQLAlchemy global filters in FastAPI. PR#12109by@TheShubhendra.
  • 📝 Add note abouttime.perf_counter()in middlewares. PR#12095by@tiangolo.
  • 📝 Tweak middleware code sampletime.time()totime.perf_counter().PR#11957by@domdent.
  • 🔧 Update sponsors: Coherence. PR#12093by@tiangolo.
  • 📝 Fix async test example not to trigger DeprecationWarning. PR#12084by@marcinsulikowski.
  • 📝 Updatedocs_src/path_params_numeric_validations/tutorial006.py.PR#11478by@MuhammadAshiqAmeer.
  • 📝 Update comma indocs/en/docs/async.md.PR#12062by@Alec-Gillis.
  • 📝 Update docs about serving FastAPI: ASGI servers, Docker containers, etc.. PR#12069by@tiangolo.
  • 📝 Clarifyresponse_classparameter, validations, and returning a response directly. PR#12067by@tiangolo.
  • 📝 Fix minor typos and issues in the documentation. PR#12063by@svlandeg.
  • 📝 Add note in Docker docs about ensuring graceful shutdowns and lifespan events withCMDexec form. PR#11960by@GPla.

Translations

  • 🌐 Add Dutch translation fordocs/nl/docs/features.md.PR#12101by@maxscheijen.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/testing-events.md.PR#12108by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/security/index.md.PR#12114by@ceb10n.
  • 🌐 Add Dutch translation fordocs/nl/docs/index.md.PR#12042by@svlandeg.
  • 🌐 Update Chinese translation fordocs/zh/docs/how-to/index.md.PR#12070by@synthpop123.

Internal

0.112.2

24 Aug 19:37
Compare
Choose a tag to compare

Fixes

  • 🐛 Fixallow_inf_nanoption for Param and Body classes. PR#11867by@giunio-prc.
  • 🐛 Ensure thatapp.include_routermerges nested lifespans. PR#9630by@Lancetnik.

Refactors

Docs

  • 📝 Fix a typo indocs/en/docs/virtual-environments.md.PR#12064by@aymenkrifa.
  • 📝 Add docs about Environment Variables and Virtual Environments. PR#12054by@tiangolo.
  • 📝 Add Asyncer mention in async docs. PR#12037by@tiangolo.
  • 📝 Move the Features docs to the top level to improve the main page menu. PR#12036by@tiangolo.
  • ✏️ Fix import typo in reference example forSecurity.PR#11168by@0shah0.
  • 📝 Highlight correct line in tutorialdocs/en/docs/tutorial/body-multiple-params.md.PR#11978by@svlandeg.
  • 🔥 Remove Sentry link from Advanced Middleware docs. PR#12031by@alejsdev.
  • 📝 Clarify management tasks for translations, multiples files in one PR. PR#12030by@tiangolo.
  • 📝 Edit the link to the OpenAPI "Responses Object" and "Response Object" sections in the "Additional Responses in OpenAPI" section. PR#11996by@VaitoSoi.
  • 🔨 Specifyemail-validatordependency with dash. PR#11515by@jirikuncar.
  • 🌐 Add Spanish translation fordocs/es/docs/project-generation.md.PR#11947by@alejsdev.
  • 📝 Fix minor typo. PR#12026by@MicaelJarniac.
  • 📝 Several docs improvements, tweaks, and clarifications. PR#11390by@nilslindemann.
  • 📝 Add missingcompresslevelparameter on docs forGZipMiddleware.PR#11350by@junah201.
  • 📝 Fix inconsistent response code when item already exists in docs for testing. PR#11818by@lokomilo.
  • 📝 Updatedocs/en/docs/tutorial/body.mdwith Python 3.10 union type example. PR#11415by@rangzen.

Translations

  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/request_file.md.PR#12018by@Joao-Pedro-P-Holanda.
  • 🌐 Add Japanese translation fordocs/ja/docs/learn/index.md.PR#11592by@ukwhatn.
  • 📝 Update Spanish translation docs for consistency. PR#12044by@alejsdev.
  • 🌐 Update Chinese translation fordocs/zh/docs/tutorial/dependencies/dependencies-with-yield.md.PR#12028by@xuvjso.
  • 📝 Update FastAPI People, do not translate to have the most recent info. PR#12034by@tiangolo.
  • 🌐 Update Urdu translation fordocs/ur/docs/benchmarks.md.PR#10046by@AhsanSheraz.

Internal

0.112.1

15 Aug 21:09
Compare
Choose a tag to compare

Upgrades

Docs

  • 📝 Update docs section about "Don't Translate these Pages". PR#12022by@tiangolo.
  • 📝 Add documentation for non-translated pages and scripts to verify them. PR#12020by@tiangolo.
  • 📝 Update docs about discussions questions. PR#11985by@tiangolo.

Translations

  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/bigger-applications.md.PR#11971by@marcelomarkus.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/testing-websockets.md.PR#11994by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/testing-dependencies.md.PR#11995by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/using-request-directly.md.PR#11956by@ceb10n.
  • 🌐 Add French translation fordocs/fr/docs/tutorial/body-multiple-params.md.PR#11796by@pe-brian.
  • 🌐 Update Chinese translation fordocs/zh/docs/tutorial/query-params.md.PR#11557by@caomingpei.
  • 🌐 Update typo in Chinese translation fordocs/zh/docs/advanced/testing-dependencies.md.PR#11944by@bestony.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/sub-applications.mdanddocs/pt/docs/advanced/behind-a-proxy.md.PR#11856by@marcelomarkus.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/cors.mdanddocs/pt/docs/tutorial/middleware.md.PR#11916by@wesinalves.
  • 🌐 Add French translation fordocs/fr/docs/tutorial/path-params-numeric-validations.md.PR#11788by@pe-brian.

Internal

0.112.0

02 Aug 06:13
Compare
Choose a tag to compare

Breaking Changes

  • ♻️ Add support forpip install "fastapi[standard]"with standard dependencies andpython -m fastapi.PR#11935by@tiangolo.

Summary

Install with:

pip install"fastapi[standard]"

Other Changes

  • This adds support for calling the CLI as:
python -m fastapi
  • And it upgradesfastapi-cli[standard] >=0.0.5.

Technical Details

Before this,fastapiwould include the standard dependencies, with Uvicorn and thefastapi-cli,etc.

Andfastapi-slimwould not include those standard dependencies.

Nowfastapidoesn't include those standard dependencies unless you install withpip install "fastapi[standard]".

Before, you would installpip install fastapi,now you should include thestandardoptional dependencies (unless you want to exclude one of those):pip install "fastapi[standard]".

This change is because having the standard optional dependencies installed by default was being inconvenient to several users, and having to install insteadfastapi-slimwas not being a feasible solution.

Discussed here:#11522and here:#11525

Docs

Translations

  • 🌐 Update Portuguese translation fordocs/pt/docs/alternatives.md.PR#11931by@ceb10n.
  • 🌐 Add Russian translation fordocs/ru/docs/tutorial/dependencies/sub-dependencies.md.PR#10515by@AlertRED.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/response-change-status-code.md.PR#11863by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/reference/background.md.PR#11849by@lucasbalieiro.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/dependencies/dependencies-with-yield.md.PR#11848by@Joao-Pedro-P-Holanda.
  • 🌐 Add Portuguese translation fordocs/pt/docs/reference/apirouter.md.PR#11843by@lucasbalieiro.

Internal

0.111.1

14 Jul 17:55
Compare
Choose a tag to compare

Upgrades

  • ➖ Removeorjsonandujsonfrom default dependencies. PR#11842by@tiangolo.
    • These dependencies are still installed when you install withpip install "fastapi[all]".But they not included inpip install fastapi.
  • 📝 Restored Swagger-UI links to use the latest version possible. PR#11459by@UltimateLobster.

Docs

Translations

  • 🌐 Add Spanish translation fordocs/es/docs/how-to/graphql.md.PR#11697by@camigomezdev.
  • 🌐 Add Portuguese translation fordocs/pt/docs/reference/index.md.PR#11840by@lucasbalieiro.
  • 🌐 Fix link in German translation. PR#11836by@anitahammer.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/dependencies/sub-dependencies.md.PR#11792by@Joao-Pedro-P-Holanda.
  • 🌐 Add Turkish translation fordocs/tr/docs/tutorial/request-forms.md.PR#11553by@hasansezertasan.
  • 🌐 Add Portuguese translation fordocs/pt/docs/reference/exceptions.md.PR#11834by@lucasbalieiro.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/dependencies/global-dependencies.md.PR#11826by@Joao-Pedro-P-Holanda.
  • 🌐 Add Portuguese translation fordocs/pt/docs/how-to/general.md.PR#11825by@lucasbalieiro.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/async-tests.md.PR#11808by@ceb10n.
  • 🌐 Add Ukrainian translation fordocs/uk/docs/tutorial/first-steps.md.PR#11809by@vkhoroshchak.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/dependencies/dependencies-in-path-operation-operators.md.PR#11804by@Joao-Pedro-P-Holanda.
  • 🌐 Add Chinese translation fordocs/zh/docs/fastapi-cli.md.PR#11786by@logan2d5.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/openapi-webhooks.md.PR#11791by@ceb10n.
  • 🌐 Update Chinese translation fordocs/tutorial/security/oauth2-jwt.md.PR#11781by@logan2d5.
  • 📝 Fix image missing in French translation fordocs/fr/docs/async.md.PR#11787by@pe-brian.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/advanced-dependencies.md.PR#11775by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/dependencies/classes-as-dependencies.md.PR#11768by@Joao-Pedro-P-Holanda.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/additional-status-codes.md.PR#11753by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/tutorial/dependencies/index.md.PR#11757by@Joao-Pedro-P-Holanda.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/settings.md.PR#11739by@Joao-Pedro-P-Holanda.
  • 🌐 Add French translation fordocs/fr/docs/learn/index.md.PR#11712by@benjaminvandammeholberton.
  • 🌐 Add Portuguese translation fordocs/pt/docs/how-to/index.md.PR#11731by@vhsenna.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/additional-responses.md.PR#11736by@ceb10n.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/benchmarks.md.PR#11713by@ceb10n.
  • 🌐 Fix Korean translation fordocs/ko/docs/tutorial/response-status-code.md.PR#11718by@nayeonkinn.
  • 🌐 Add Korean translation fordocs/ko/docs/tutorial/extra-data-types.md.PR#11711by@nayeonkinn.
  • 🌐 Fix Korean translation fordocs/ko/docs/tutorial/body-nested-models.md.PR#11710by@nayeonkinn.
  • 🌐 Add Portuguese translation fordocs/pt/docs/advanced/fastapi-cli.md.PR#11641by@ayr-ton.
  • 🌐 Add Traditional Chinese translation fordocs/zh-hant/docs/fastapi-people.md.PR#11639by@hsuanchi.
  • 🌐 Add Turkish translation fordocs/tr/docs/advanced/index.md.PR#11606by@hasansezertasan.
  • 🌐 Add Turkish translation fordocs/tr/docs/deployment/cloud.md.PR#11610by@hasansezertasan.
  • 🌐 Add Turkish translation fordocs/tr/docs/advanced/security/index.md.PR#11609by@hasansezertasan.
  • 🌐 Add Turkish translation fordocs/tr/docs/advanced/testing-websockets.md.PR#11608by@hasansezertasan.
  • 🌐 Add Turkish translation fordocs/tr/docs/how-to/general.md.PR [#11607](h...
Read more

0.111.0

03 May 00:21
Compare
Choose a tag to compare

Features

Try it out with:

$pip install --upgrade fastapi

$fastapi dev main.py


╭────────── FastAPI CLI - Development mode ───────────╮
│ │
│ Serving at: http://127.0.0.1:8000 │
│ │
│ API docs: http://127.0.0.1:8000/docs │
│ │
│ Running in development mode, for production use: │
│ │
│ fastapi run │
│ │
╰─────────────────────────────────────────────────────╯

INFO: Will watch for changes in these directories: ['/home/user/code/awesomeapp']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [2248755] using WatchFiles
INFO: Started server process [2248757]
INFO: Waiting for application startup.
INFO: Application startup complete.

Refactors

  • 🔧 Add configs and setup forfastapi-slimincluding optional extrasfastapi-slim[standard],andfastapiincluding by default the samestandardextras. PR#11503by@tiangolo.

0.110.3

30 Apr 00:37
Compare
Choose a tag to compare

Latest Changes

Docs

  • 📝 Update references to Python version, FastAPI supports all the current versions, no need to make the version explicit. PR#11496by@tiangolo.
  • ✏️ Fix typo infastapi/security/api_key.py.PR#11481by@ch33zer.
  • ✏️ Fix typo insecurity/http.py.PR#11455by@omarmoo5.

Translations

  • 🌐 Add Traditional Chinese translation fordocs/zh-hant/benchmarks.md.PR#11484by@KNChiu.
  • 🌐 Update Chinese translation fordocs/zh/docs/fastapi-people.md.PR#11476by@billzhong.
  • 🌐 Add Chinese translation fordocs/zh/docs/how-to/index.mdanddocs/zh/docs/how-to/general.md.PR#11443by@billzhong.
  • 🌐 Add Spanish translation for cookie-paramsdocs/es/docs/tutorial/cookie-params.md.PR#11410by@fabianfalon.

Internal