Release Notes

Warning

The current page still doesn’t have a translation for this language.

But you can help translating it: Contributing.

Latest Changes

0.85.0

Features

  • ⬆ Upgrade version required of Starlette from 0.19.1 to 0.20.4. Initial PR #4820 by @Kludex.
    • This includes several bug fixes in Starlette.
  • ⬆️ Upgrade Uvicorn max version in public extras: all. From >=0.12.0,<0.18.0 to >=0.12.0,<0.19.0. PR #5401 by @tiangolo.

Internal

  • ⬆️ Upgrade dependencies for doc and dev internal extras: Typer, Uvicorn. PR #5400 by @tiangolo.
  • ⬆️ Upgrade test dependencies: Black, HTTPX, databases, types-ujson. PR #5399 by @tiangolo.
  • ⬆️ Upgrade mypy and tweak internal type annotations. PR #5398 by @tiangolo.
  • 🔧 Update test dependencies, upgrade Pytest, move dependencies from dev to test. PR #5396 by @tiangolo.

0.84.0

Breaking Changes

This version of FastAPI drops support for Python 3.6. 🔥 Please upgrade to a supported version of Python (3.7 or above), Python 3.6 reached the end-of-life a long time ago. 😅☠

  • 🔧 Update package metadata, drop support for Python 3.6, move build internals from Flit to Hatch. PR #5240 by @ofek.

0.83.0

🚨 This is probably the last release (or one of the last releases) to support Python 3.6. 🔥

Python 3.6 reached the end-of-life and is no longer supported by Python since around a year ago.

You hopefully updated to a supported version of Python a while ago. If you haven’t, you really should.

Features

  • ✨ Add support in jsonable_encoder for include and exclude with dataclasses. PR #4923 by @DCsunset.

Fixes

  • 🐛 Fix RuntimeError raised when HTTPException has a status code with no content. PR #5365 by @iudeen.
  • 🐛 Fix empty reponse body when default status_code is empty but the a Response parameter with response.status_code is set. PR #5360 by @tmeckel.

Docs

Internal

0.82.0

🚨 This is probably the last release (or one of the last releases) to support Python 3.6. 🔥

Python 3.6 reached the end-of-life and is no longer supported by Python since around a year ago.

You hopefully updated to a supported version of Python a while ago. If you haven’t, you really should.

Features

  • ✨ Export WebSocketState in fastapi.websockets. PR #4376 by @matiuszka.
  • ✨ Support Python internal description on Pydantic model’s docstring. PR #3032 by @Kludex.
  • ✨ Update ORJSONResponse to support non str keys and serializing Numpy arrays. PR #3892 by @baby5.

Fixes

  • 🐛 Allow exit code for dependencies with yield to always execute, by removing capacity limiter for them, to e.g. allow closing DB connections without deadlocks. PR #5122 by @adriangb.
  • 🐛 Fix FastAPI People GitHub Action: set HTTPX timeout for GraphQL query request. PR #5222 by @iudeen.
  • 🐛 Make sure a parameter defined as required is kept required in OpenAPI even if defined as optional in another dependency. PR #4319 by @cd17822.
  • 🐛 Fix support for path parameters in WebSockets. PR #3879 by @davidbrochart.

Docs

  • ✏ Update Hypercorn link, now pointing to GitHub. PR #5346 by @baconfield.
  • ✏ Tweak wording in docs/en/docs/advanced/dataclasses.md. PR #3698 by @pfackeldey.
  • 📝 Add note about Python 3.10 X | Y operator in explanation about Response Models. PR #5307 by @MendyLanda.
  • 📝 Add link to New Relic article: “How to monitor FastAPI application performance using Python agent”. PR #5260 by @sjyothi54.
  • 📝 Update docs for ORJSONResponse with details about improving performance. PR #2615 by @falkben.
  • 📝 Add docs for creating a custom Response class. PR #5331 by @tiangolo.
  • 📝 Add tip about using alias for form data fields. PR #5329 by @tiangolo.

Translations

  • 🌐 Add Russian translation for docs/ru/docs/features.md. PR #5315 by @Xewus.
  • 🌐 Update Chinese translation for docs/zh/docs/tutorial/request-files.md. PR #4529 by @ASpathfinder.
  • 🌐 Add Chinese translation for docs/zh/docs/tutorial/encoder.md. PR #4969 by @Zssaer.
  • 🌐 Fix MkDocs file line for Portuguese translation of background-task.md. PR #5242 by @ComicShrimp.

Internal

0.81.0

Features

  • ✨ Add ReDoc <noscript> warning when JS is disabled. PR #5074 by @evroon.
  • ✨ Add support for FrozenSet in parameters (e.g. query). PR #2938 by @juntatalor.
  • ✨ Allow custom middlewares to raise HTTPExceptions and propagate them. PR #2036 by @ghandic.
  • ✨ Preserve json.JSONDecodeError information when handling invalid JSON in request body, to support custom exception handlers that use its information. PR #4057 by @UKnowWhoIm.

Fixes

  • 🐛 Fix jsonable_encoder for dataclasses with pydantic-compatible fields. PR #3607 by @himbeles.
  • 🐛 Fix support for extending openapi_extras with parameter lists. PR #4267 by @orilevari.

Docs

  • ✏ Fix a simple typo in docs/en/docs/python-types.md. PR #5193 by @GlitchingCore.
  • ✏ Fix typos in tests/test_schema_extra_examples.py. PR #5126 by @supraaxdd.
  • ✏ Fix typos in docs/en/docs/tutorial/path-params-numeric-validations.md. PR #5142 by @invisibleroads.
  • 📝 Add step about upgrading pip in the venv to avoid errors when installing dependencies docs/en/docs/contributing.md. PR #5181 by @edisnake.
  • ✏ Reword and clarify text in tutorial docs/en/docs/tutorial/body-nested-models.md. PR #5169 by @papb.
  • ✏ Fix minor typo in docs/en/docs/features.md. PR #5206 by @OtherBarry.
  • ✏ Fix minor typos in docs/en/docs/async.md. PR #5125 by @Ksenofanex.
  • 📝 Add external link to docs: “Fastapi, Docker(Docker compose) and Postgres”. PR #5033 by @krishnardt.
  • 📝 Simplify example for docs for Additional Responses, remove unnecessary else. PR #4693 by @adriangb.
  • 📝 Update docs, compare enums with identity instead of equality. PR #4905 by @MicaelJarniac.
  • ✏ Fix typo in docs/en/docs/python-types.md. PR #4886 by @MicaelJarniac.
  • 🎨 Fix syntax highlighting in docs for OpenAPI Callbacks. PR #4368 by @xncbf.
  • ✏ Reword confusing sentence in docs file typo-fix-path-params-numeric-validations.md. PR #3219 by @ccrenfroe.
  • 📝 Update docs for handling HTTP Basic Auth with secrets.compare_digest() to account for non-ASCII characters. PR #3536 by @lewoudar.
  • 📝 Update docs for testing, fix examples with relative imports. PR #5302 by @tiangolo.

Translations

  • 🌐 Add Russian translation for docs/ru/docs/index.md. PR #5289 by @impocode.
  • 🌐 Add Russian translation for docs/ru/docs/deployment/versions.md. PR #4985 by @emp7yhead.
  • 🌐 Add Portuguese translation for docs/pt/docs/tutorial/header-params.md. PR #4921 by @batlopes.
  • 🌐 Update ko/mkdocs.yml for a missing link. PR #5020 by @dalinaum.

Internal

  • ⬆ Bump dawidd6/action-download-artifact from 2.21.1 to 2.22.0. PR #5258 by @dependabot[bot].
  • ⬆ [pre-commit.ci] pre-commit autoupdate. PR #5196 by @pre-commit-ci[bot].
  • 🔥 Delete duplicated tests in tests/test_tutorial/test_sql_databases/test_sql_databases.py. PR #5040 by @raccoonyy.
  • ♻ Simplify internal RegEx in fastapi/utils.py. PR #5057 by @pylounge.
  • 🔧 Fix Type hint of auto_error which does not need to be Optional[bool]. PR #4933 by @DavidKimDY.
  • 🔧 Update mypy config, use strict = true instead of manual configs. PR #4605 by @michaeloliverx.
  • ♻ Change a dict() for {} in fastapi/utils.py. PR #3138 by @ShahriyarR.
  • ♻ Move internal variable for errors in jsonable_encoder to put related code closer. PR #4560 by @GuilleQP.
  • ♻ Simplify conditional assignment in fastapi/dependencies/utils.py. PR #4597 by @cikay.
  • ⬆ Upgrade version pin accepted for Flake8, for internal code, to flake8 >=3.8.3,<6.0.0. PR #4097 by @jamescurtin.
  • 🍱 Update Jina banner, fix typo. PR #5301 by @tiangolo.

0.80.0

Breaking Changes - Fixes

  • 🐛 Fix response_model not invalidating None. PR #2725 by @hukkin.

If you are using response_model with some type that doesn’t include None but the function is returning None, it will now raise an internal server error, because you are returning invalid data that violates the contract in response_model. Before this release it would allow breaking that contract returning None.

For example, if you have an app like this:

  1. from fastapi import FastAPI
  2. from pydantic import BaseModel
  3. class Item(BaseModel):
  4. name: str
  5. price: Optional[float] = None
  6. owner_ids: Optional[List[int]] = None
  7. app = FastAPI()
  8. @app.get("/items/invalidnone", response_model=Item)
  9. def get_invalid_none():
  10. return None

…calling the path /items/invalidnone will raise an error, because None is not a valid type for the response_model declared with Item.

You could also be implicitly returning None without realizing, for example:

  1. from fastapi import FastAPI
  2. from pydantic import BaseModel
  3. class Item(BaseModel):
  4. name: str
  5. price: Optional[float] = None
  6. owner_ids: Optional[List[int]] = None
  7. app = FastAPI()
  8. @app.get("/items/invalidnone", response_model=Item)
  9. def get_invalid_none():
  10. if flag:
  11. return {"name": "foo"}
  12. # if flag is False, at this point the function will implicitly return None

If you have path operations using response_model that need to be allowed to return None, make it explicit in response_model using Union[Something, None]:

  1. from typing import Union
  2. from fastapi import FastAPI
  3. from pydantic import BaseModel
  4. class Item(BaseModel):
  5. name: str
  6. price: Optional[float] = None
  7. owner_ids: Optional[List[int]] = None
  8. app = FastAPI()
  9. @app.get("/items/invalidnone", response_model=Union[Item, None])
  10. def get_invalid_none():
  11. return None

This way the data will be correctly validated, you won’t have an internal server error, and the documentation will also reflect that this path operation could return None (or null in JSON).

Fixes

  • ⬆ Upgrade Swagger UI copy of oauth2-redirect.html to include fixes for flavors of authorization code flows in Swagger UI. PR #3439 initial PR by @koonpeng.
  • ♻ Strip empty whitespace from description extracted from docstrings. PR #2821 by @and-semakin.
  • 🐛 Fix cached dependencies when using a dependency in Security() and other places (e.g. Depends()) with different OAuth2 scopes. PR #2945 by @laggardkernel.
  • 🎨 Update type annotations for response_model, allow things like Union[str, None]. PR #5294 by @tiangolo.

Translations

  • 🌐 Fix typos in German translation for docs/de/docs/features.md. PR #4533 by @0xflotus.
  • 🌐 Add missing navigator for encoder.md in Korean translation. PR #5238 by @joonas-yoon.
  • (Empty PR merge by accident) #4913.

0.79.1

Fixes

  • 🐛 Fix jsonable_encoder using include and exclude parameters for non-Pydantic objects. PR #2606 by @xaviml.
  • 🐛 Fix edge case with repeated aliases names not shown in OpenAPI. PR #2351 by @klaa97.
  • 📝 Add misc dependency installs to tutorial docs. PR #2126 by @TeoZosa.

Docs

Translations

  • 🌐 Add Portuguese translation for docs/pt/docs/tutorial/query-params.md. PR #4775 by @batlopes.
  • 🌐 Add Portuguese translation for docs/pt/docs/tutorial/security/first-steps.md. PR #4954 by @FLAIR7.
  • 🌐 Add translation for docs/zh/docs/advanced/response-cookies.md. PR #4638 by @zhangbo2012.
  • 🌐 Add French translation for docs/fr/docs/deployment/index.md. PR #3689 by @rjNemo.
  • 🌐 Add Portuguese translation for tutorial/handling-errors.md. PR #4769 by @frnsimoes.
  • 🌐 Add French translation for docs/fr/docs/history-design-future.md. PR #3451 by @rjNemo.
  • 🌐 Add Russian translation for docs/ru/docs/tutorial/background-tasks.md. PR #4854 by @AdmiralDesu.
  • 🌐 Add Chinese translation for docs/tutorial/security/first-steps.md. PR #3841 by @jaystone776.
  • 🌐 Add Japanese translation for docs/ja/docs/advanced/nosql-databases.md. PR #4205 by @sUeharaE4.
  • 🌐 Add Indonesian translation for docs/id/docs/tutorial/index.md. PR #4705 by @bas-baskara.
  • 🌐 Add Persian translation for docs/fa/docs/index.md and tweak right-to-left CSS. PR #2395 by @mohsen-mahmoodi.

Internal

0.79.0

Fixes - Breaking Changes

  • 🐛 Fix removing body from status codes that do not support it. PR #5145 by @tiangolo.
    • Setting status_code to 204, 304, or any code below 200 (1xx) will remove the body from the response.
    • This fixes an error in Uvicorn that otherwise would be thrown: RuntimeError: Response content longer than Content-Length.
    • This removes fastapi.openapi.constants.STATUS_CODES_WITH_NO_BODY, it is replaced by a function in utils.

Translations

  • 🌐 Start of Hebrew translation. PR #5050 by @itay-raveh.
  • 🔧 Add config for Swedish translations notification. PR #5147 by @tiangolo.
  • 🌐 Start of Swedish translation. PR #5062 by @MrRawbin.
  • 🌐 Add Japanese translation for docs/ja/docs/advanced/index.md. PR #5043 by @wakabame.
  • 🌐🇵🇱 Add Polish translation for docs/pl/docs/tutorial/first-steps.md. PR #5024 by @Valaraucoo.

Internal

0.78.0

Features

  • ✨ Add support for omitting ... as default value when declaring required parameters with:

  • Path()

  • Query()

  • Header()
  • Cookie()
  • Body()
  • Form()
  • File()

New docs at Tutorial - Query Parameters and String Validations - Make it required. PR #4906 by @tiangolo.

Up to now, declaring a required parameter while adding additional validation or metadata needed using ... (Ellipsis).

For example:

  1. from fastapi import Cookie, FastAPI, Header, Path, Query
  2. app = FastAPI()
  3. @app.get("/items/{item_id}")
  4. def main(
  5. item_id: int = Path(default=..., gt=0),
  6. query: str = Query(default=..., max_length=10),
  7. session: str = Cookie(default=..., min_length=3),
  8. x_trace: str = Header(default=..., title="Tracing header"),
  9. ):
  10. return {"message": "Hello World"}

…all these parameters are required because the default value is ... (Ellipsis).

But now it’s possible and supported to just omit the default value, as would be done with Pydantic fields, and the parameters would still be required.

✨ For example, this is now supported:

  1. from fastapi import Cookie, FastAPI, Header, Path, Query
  2. app = FastAPI()
  3. @app.get("/items/{item_id}")
  4. def main(
  5. item_id: int = Path(gt=0),
  6. query: str = Query(max_length=10),
  7. session: str = Cookie(min_length=3),
  8. x_trace: str = Header(title="Tracing header"),
  9. ):
  10. return {"message": "Hello World"}

To declare parameters as optional (not required), you can set a default value as always, for example using None:

  1. from typing import Union
  2. from fastapi import Cookie, FastAPI, Header, Path, Query
  3. app = FastAPI()
  4. @app.get("/items/{item_id}")
  5. def main(
  6. item_id: int = Path(gt=0),
  7. query: Union[str, None] = Query(default=None, max_length=10),
  8. session: Union[str, None] = Cookie(default=None, min_length=3),
  9. x_trace: Union[str, None] = Header(default=None, title="Tracing header"),
  10. ):
  11. return {"message": "Hello World"}

Docs

  • 📝 Add docs recommending Union over Optional and migrate source examples. New docs at Python Types Intro - Using Union or Optional. PR #4908 by @tiangolo.
  • 🎨 Fix default value as set in tutorial for Path Operations Advanced Configurations. PR #4899 by @tiangolo.
  • 📝 Add documentation for redefined path operations. PR #4864 by @madkinsz.
  • 📝 Updates links for Celery documentation. PR #4736 by @sammyzord.
  • ✏ Fix example code with sets in tutorial for body nested models. PR #3030 by @hitrust.
  • ✏ Fix links to Pydantic docs. PR #4670 by @kinuax.
  • 📝 Update docs about Swagger UI self-hosting with newer source links. PR #4813 by @Kastakin.
  • 📝 Add link to external article: Building the Poll App From Django Tutorial With FastAPI And React. PR #4778 by @jbrocher.
  • 📝 Add OpenAPI warning to “Body - Fields” docs with extra schema extensions. PR #4846 by @ml-evs.

Translations

  • 🌐 Fix code examples in Japanese translation for docs/ja/docs/tutorial/testing.md. PR #4623 by @hirotoKirimaru.

Internal

  • ♻ Refactor dict value extraction to minimize key lookups fastapi/utils.py. PR #3139 by @ShahriyarR.
  • ✅ Add tests for required nonable parameters and body fields. PR #4907 by @tiangolo.
  • 👷 Fix installing Material for MkDocs Insiders in CI. PR #4897 by @tiangolo.
  • 👷 Add pre-commit CI instead of custom GitHub Action. PR #4896 by @tiangolo.
  • 👷 Add pre-commit GitHub Action workflow. PR #4895 by @tiangolo.
  • 📝 Add dark mode auto switch to docs based on OS preference. PR #4869 by @ComicShrimp.
  • 🔥 Remove un-used old pending tests, already covered in other places. PR #4891 by @tiangolo.
  • 🔧 Add Python formatting hooks to pre-commit. PR #4890 by @tiangolo.
  • 🔧 Add pre-commit with first config and first formatting pass. PR #4888 by @tiangolo.
  • 👷 Disable CI installing Material for MkDocs in forks. PR #4410 by @dolfinus.

0.77.1

Upgrades

  • ⬆ Upgrade Starlette from 0.19.0 to 0.19.1. PR #4819 by @Kludex.

Docs

  • 📝 Add link to german article: REST-API Programmieren mittels Python und dem FastAPI Modul. PR #4624 by @fschuermeyer.
  • 📝 Add external link: PyCharm Guide to FastAPI. PR #4512 by @mukulmantosh.
  • 📝 Add external link to article: Building an API with FastAPI and Supabase and Deploying on Deta. PR #4440 by @aUnicornDev.
  • ✏ Fix small typo in docs/en/docs/tutorial/security/first-steps.md. PR #4515 by @KikoIlievski.

Translations

Internal

  • 🔧 Add notifications in issue for Uzbek translations. PR #4884 by @tiangolo.

0.77.0

Upgrades

  • ⬆ Upgrade Starlette from 0.18.0 to 0.19.0. PR #4488 by @Kludex.
    • When creating an explicit JSONResponse the content argument is now required.

Docs

  • 📝 Add external link to article: Seamless FastAPI Configuration with ConfZ. PR #4414 by @silvanmelchior.
  • 📝 Add external link to article: 5 Advanced Features of FastAPI You Should Try. PR #4436 by @kaustubhgupta.
  • ✏ Reword to improve legibility of docs about TestClient. PR #4389 by @rgilton.
  • 📝 Add external link to blog post about Kafka, FastAPI, and Ably. PR #4044 by @Ugbot.
  • ✏ Fix typo in docs/en/docs/tutorial/sql-databases.md. PR #4875 by @wpyoga.
  • ✏ Fix typo in docs/en/docs/async.md. PR #4726 by @Prezu.

Translations

  • 🌐 Update source example highlights for docs/zh/docs/tutorial/query-params-str-validations.md. PR #4237 by @caimaoy.
  • 🌐 Remove translation docs references to aiofiles as it’s no longer needed since AnyIO. PR #3594 by @alonme.
  • ✏ 🌐 Fix typo in Portuguese translation for docs/pt/docs/tutorial/path-params.md. PR #4722 by @CleoMenezesJr.
  • 🌐 Fix live docs server for translations for some languages. PR #4729 by @wakabame.
  • 🌐 Add Portuguese translation for docs/pt/docs/tutorial/cookie-params.md. PR #4112 by @lbmendes.
  • 🌐 Fix French translation for docs/tutorial/body.md. PR #4332 by @Smlep.
  • 🌐 Add Japanese translation for docs/ja/docs/advanced/conditional-openapi.md. PR #2631 by @sh0nk.
  • 🌐 Fix Japanese translation of docs/ja/docs/tutorial/body.md. PR #3062 by @a-takahashi223.
  • 🌐 Add Portuguese translation for docs/pt/docs/tutorial/background-tasks.md. PR #2170 by @izaguerreiro.
  • 🌐 Add Portuguese translation for docs/deployment/deta.md. PR #4442 by @lsglucas.
  • 🌐 Add Russian translation for docs/async.md. PR #4036 by @Winand.
  • 🌐 Add Portuguese translation for docs/tutorial/body.md. PR #3960 by @leandrodesouzadev.
  • 🌐 Add Portuguese translation of tutorial/extra-data-types.md. PR #4077 by @luccasmmg.
  • 🌐 Update German translation for docs/features.md. PR #3905 by @jomue.

0.76.0

Upgrades

  • ⬆ Upgrade Starlette from 0.17.1 to 0.18.0. PR #4483 by @Kludex.

Internal

0.75.2

This release includes upgrades to third-party packages that handle security issues. Although there’s a chance these issues don’t affect you in particular, please upgrade as soon as possible.

Fixes

  • ✅ Fix new/recent tests with new fixed ValidationError JSON Schema. PR #4806 by @tiangolo.
  • 🐛 Fix JSON Schema for ValidationError at field loc. PR #3810 by @dconathan.
  • 🐛 Fix support for prefix on APIRouter WebSockets. PR #2640 by @Kludex.

Upgrades

  • ⬆️ Update ujson ranges for CVE-2021-45958. PR #4804 by @tiangolo.
  • ⬆️ Upgrade dependencies upper range for extras “all”. PR #4803 by @tiangolo.
  • ⬆ Upgrade Swagger UI - swagger-ui-dist@4. This handles a security issue in Swagger UI itself where it could be possible to inject HTML into Swagger UI. Please upgrade as soon as you can, in particular if you expose your Swagger UI (/docs) publicly to non-expert users. PR #4347 by @RAlanWright.

Internal

  • 🔧 Update sponsors, add: ExoFlare, Ines Course; remove: Dropbase, Vim.so, Calmcode; update: Striveworks, TalkPython and TestDriven.io. PR #4805 by @tiangolo.
  • ⬆️ Upgrade Codecov GitHub Action. PR #4801 by @tiangolo.

0.75.1

Translations

Internal

0.75.0

Features

0.74.1

Features

  • ✨ Include route in scope to allow middleware and other tools to extract its information. PR #4603 by @tiangolo.

0.74.0

Breaking Changes

  • ✨ Update internal AsyncExitStack to fix context for dependencies with yield. PR #4575 by @tiangolo.

Dependencies with yield can now catch HTTPException and custom exceptions. For example:

  1. async def get_database():
  2. with Session() as session:
  3. try:
  4. yield session
  5. except HTTPException:
  6. session.rollback()
  7. raise
  8. finally:
  9. session.close()

After the dependency with yield handles the exception (or not) the exception is raised again. So that any exception handlers can catch it, or ultimately the default internal ServerErrorMiddleware.

If you depended on exceptions not being received by dependencies with yield, and receiving an exception breaks the code after yield, you can use a block with try and finally:

  1. async def do_something():
  2. try:
  3. yield something
  4. finally:
  5. some_cleanup()

…that way the finally block is run regardless of any exception that might happen.

Features

  • The same PR #4575 from above also fixes the contextvars context for the code before and after yield. This was the main objective of that PR.

This means that now, if you set a value in a context variable before yield, the value would still be available after yield (as you would intuitively expect). And it also means that you can reset the context variable with a token afterwards.

For example, this works correctly now:

  1. from contextvars import ContextVar
  2. from typing import Any, Dict, Optional
  3. legacy_request_state_context_var: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
  4. "legacy_request_state_context_var", default=None
  5. )
  6. async def set_up_request_state_dependency():
  7. request_state = {"user": "deadpond"}
  8. contextvar_token = legacy_request_state_context_var.set(request_state)
  9. yield request_state
  10. legacy_request_state_context_var.reset(contextvar_token)

…before this change it would raise an error when resetting the context variable, because the contextvars context was different, because of the way it was implemented.

Note: You probably don’t need contextvars, and you should probably avoid using them. But they are powerful and useful in some advanced scenarios, for example, migrating from code that used Flask’s g semi-global variable.

Technical Details: If you want to know more of the technical details you can check out the PR description #4575.

Internal

0.73.0

Features

Docs

  • 📝 Tweak and improve docs for Request Files. PR #4470 by @tiangolo.

Fixes

Internal

  • 🐛 Fix docs dependencies cache, to get the latest Material for MkDocs. PR #4466 by @tiangolo.
  • 🔧 Add sponsor Dropbase. PR #4465 by @tiangolo.

0.72.0

Features

Docs

  • 📝 Update Python Types docs, add missing 3.6 / 3.9 example. PR #4434 by @tiangolo.

Translations

  • 🌐 Update Chinese translation for docs/help-fastapi.md. PR #3847 by @jaystone776.
  • 🌐 Fix Korean translation for docs/ko/docs/index.md. PR #4195 by @kty4119.
  • 🌐 Add Polish translation for docs/pl/docs/index.md. PR #4245 by @MicroPanda123.
  • 🌐 Add Chinese translation for docs\tutorial\path-operation-configuration.md. PR #3312 by @jaystone776.

Internal

  • 🔧 Enable MkDocs Material Insiders’ content.tabs.link. PR #4399 by @tiangolo.

0.71.0

Features

  • ✨ Add docs and tests for Python 3.9 and Python 3.10. PR #3712 by @tiangolo.
    • You can start with Python Types Intro, it explains what changes between different Python versions, in Python 3.9 and in Python 3.10.
    • All the FastAPI docs are updated. Each code example in the docs that could use different syntax in Python 3.9 or Python 3.10 now has all the alternatives in tabs.
  • ⬆️ Upgrade Starlette to 0.17.1. PR #4145 by @simondale00.

Internal

0.70.1

There’s nothing interesting in this particular FastAPI release. It is mainly to enable/unblock the release of the next version of Pydantic that comes packed with features and improvements. 🤩

Fixes

  • 🐛 Fix JSON Schema for dataclasses, supporting the fixes in Pydantic 1.9. PR #4272 by @PrettyWood.

Translations

  • 🌐 Add Korean translation for docs/tutorial/request-forms-and-files.md. PR #3744 by @NinaHwang.
  • 🌐 Add Korean translation for docs/tutorial/request-files.md. PR #3743 by @NinaHwang.
  • 🌐 Add portuguese translation for docs/tutorial/query-params-str-validations.md. PR #3965 by @leandrodesouzadev.
  • 🌐 Add Korean translation for docs/tutorial/response-status-code.md. PR #3742 by @NinaHwang.
  • 🌐 Add Korean translation for Tutorial - JSON Compatible Encoder. PR #3152 by @NEONKID.
  • 🌐 Add Korean translation for Tutorial - Path Parameters and Numeric Validations. PR #2432 by @hard-coders.
  • 🌐 Add Korean translation for docs/ko/docs/deployment/versions.md. PR #4121 by @DevDae.
  • 🌐 Fix Korean translation for docs/ko/docs/tutorial/index.md. PR #4193 by @kimjaeyoonn.
  • 🔧 Add CryptAPI sponsor. PR #4264 by @tiangolo.
  • 📝 Update docs/tutorial/dependencies/classes-as-dependencies: Add type of query parameters in a description of Classes as dependencies. PR #4015 by @0417taehyun.
  • 🌐 Add French translation for Tutorial - First steps. PR #3455 by @Smlep.
  • 🌐 Add French translation for docs/tutorial/path-params.md. PR #3548 by @Smlep.
  • 🌐 Add French translation for docs/tutorial/query-params.md. PR #3556 by @Smlep.
  • 🌐 Add Turkish translation for docs/python-types.md. PR #3926 by @BilalAlpaslan.

Internal

0.70.0

This release just upgrades Starlette to the latest version, 0.16.0, which includes several bug fixes and some small breaking changes.

These last three consecutive releases are independent so that you can migrate gradually:

  • First to FastAPI 0.68.2, with no breaking changes, but upgrading all the sub-dependencies.
  • Next to FastAPI 0.69.0, which upgrades Starlette to 0.15.0, with AnyIO support, and a higher chance of having breaking changes in your code.
  • Finally to FastAPI 0.70.0, just upgrading Starlette to the latest version 0.16.0 with additional bug fixes.

This way, in case there was a breaking change for your code in one of the releases, you can still benefit from the previous upgrades. ✨

Breaking Changes - Upgrade

Also upgrades the ranges of optional dependencies:

  • "jinja2 >=2.11.2,<4.0.0"
  • "itsdangerous >=1.1.0,<3.0.0"

0.69.0

Breaking Changes - Upgrade

This release adds support for Trio. ✨

It upgrades the version of Starlette to 0.15.0, now based on AnyIO, and the internal async components in FastAPI are now based on AnyIO as well, making it compatible with both asyncio and Trio.

You can read the docs about running FastAPI with Trio using Hypercorn.

This release also removes graphene as an optional dependency for GraphQL. If you need to work with GraphQL, the recommended library now is Strawberry. You can read the new FastAPI with GraphQL docs.

Features

  • ✨ Add support for Trio via AnyIO, upgrading Starlette to 0.15.0. PR #3372 by @graingert.
  • ➖ Remove graphene as an optional dependency. PR #4007 by @tiangolo.

Docs

  • 📝 Add docs for using Trio with Hypercorn. PR #4014 by @tiangolo.
  • ✏ Fix typos in Deployment Guide. PR #3975 by @ghandic.
  • 📝 Update docs with pip install calls when using extras with brackets, use quotes for compatibility with Zsh. PR #3131 by @tomwei7.
  • 📝 Add external link to article: Deploying ML Models as API Using FastAPI and Heroku. PR #3904 by @kaustubhgupta.
  • ✏ Fix typo in file paths in docs/en/docs/contributing.md. PR #3752 by @NinaHwang.
  • ✏ Fix a typo in docs/en/docs/advanced/path-operation-advanced-configuration.md and docs/en/docs/release-notes.md. PR #3750 by @saintmalik.
  • ✏️ Add a missing comma in the security tutorial. PR #3564 by @jalvaradosegura.
  • ✏ Fix typo in docs/en/docs/help-fastapi.md. PR #3760 by @jaystone776.
  • ✏ Fix typo about file path in docs/en/docs/tutorial/bigger-applications.md. PR #3285 by @HolyDorus.
  • ✏ Re-word to clarify test client in docs/en/docs/tutorial/testing.md. PR #3382 by @Bharat123rox.
  • 📝 Fix incorrect highlighted code. PR #3325 by @paxcodes.
  • 📝 Add external link to article: How-to deploy FastAPI app to Heroku. PR #3241 by @Jarmos-san.
  • ✏ Fix typo (mistranslation) in docs/en/docs/advanced/templates.md. PR #3211 by @oerpli.
  • 📝 Remove note about (now supported) feature from Swagger UI in docs/en/docs/tutorial/request-files.md. PR #2803 by @gsganden.
  • ✏ Fix typo re-word in docs/tutorial/handling-errors.md. PR #2700 by @graue70.

Translations

Internal

  • 📝 Add supported Python versions badge. PR #2794 by @hramezani.
  • ✏ Fix link in Japanese docs for docs/ja/docs/deployment/docker.md. PR #3245 by @utamori.
  • 🔧 Correct DeprecationWarning config and comment in pytest settings. PR #4008 by @graingert.
  • 🔧 Swap light/dark theme button icon. PR #3246 by @eddsalkield.
  • 🔧 Lint only in Python 3.7 and above. PR #4006 by @tiangolo.
  • 🔧 Add GitHub Action notify-translations config for Azerbaijani. PR #3995 by @tiangolo.

0.68.2

This release has no breaking changes. 🎉

It upgrades the version ranges of sub-dependencies to allow applications using FastAPI to easily upgrade them.

Soon there will be a new FastAPI release upgrading Starlette to take advantage of recent improvements, but as that has a higher chance of having breaking changes, it will be in a separate release.

Features

  • ⬆Increase supported version of aiofiles to suppress warnings. PR #2899 by @SnkSynthesis.
  • ➖ Do not require backports in Python >= 3.7. PR #1880 by @FFY00.
  • ⬆ Upgrade required Python version to >= 3.6.1, needed by typing.Deque, used by Pydantic. PR #2733 by @hukkin.
  • ⬆️ Bump Uvicorn max range to 0.15.0. PR #3345 by @Kludex.

Docs

  • 📝 Update GraphQL docs, recommend Strawberry. PR #3981 by @tiangolo.
  • 📝 Re-write and extend Deployment guide: Concepts, Uvicorn, Gunicorn, Docker, Containers, Kubernetes. PR #3974 by @tiangolo.
  • 📝 Upgrade HTTPS guide with more explanations and diagrams. PR #3950 by @tiangolo.

Translations

  • 🌐 Add Turkish translation for docs/features.md. PR #1950 by @ycd.
  • 🌐 Add Turkish translation for docs/benchmarks.md. PR #2729 by @Telomeraz.
  • 🌐 Add Turkish translation for docs/index.md. PR #1908 by @ycd.
  • 🌐 Add French translation for docs/tutorial/body.md. PR #3671 by @Smlep.
  • 🌐 Add French translation for deployment/docker.md. PR #3694 by @rjNemo.
  • 🌐 Add Portuguese translation for docs/tutorial/path-params.md. PR #3664 by @FelipeSilva93.
  • 🌐 Add Portuguese translation for docs/deployment/https.md. PR #3754 by @lsglucas.
  • 🌐 Add German translation for docs/features.md. PR #3699 by @mawassk.

Internal

  • ✨ Update GitHub Action: notify-translations, to avoid a race conditions. PR #3989 by @tiangolo.
  • ⬆️ Upgrade development autoflake, supporting multi-line imports. PR #3988 by @tiangolo.
  • ⬆️ Increase dependency ranges for tests and docs: pytest-cov, pytest-asyncio, black, httpx, sqlalchemy, databases, mkdocs-markdownextradata-plugin. PR #3987 by @tiangolo.
  • 👥 Update FastAPI People. PR #3986 by @github-actions[bot].
  • 💚 Fix badges in README and main page. PR #3979 by @ghandic.
  • ⬆ Upgrade internal testing dependencies: mypy to version 0.910, add newly needed type packages. PR #3350 by @ArcLightSlavik.
  • ✨ Add Deepset Sponsorship. PR #3976 by @tiangolo.
  • 🎨 Tweak CSS styles for shell animations. PR #3888 by @tiangolo.
  • 🔧 Add new Sponsor Calmcode.io. PR #3777 by @tiangolo.

0.68.1

Translations

  • 🌐 Add Portuguese translation of docs/fastapi-people.md. PR #3461 by @ComicShrimp.
  • 🌐 Add Chinese translation for docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md. PR #3492 by @jaystone776.
  • 🔧 Add new Translation tracking issues for German and Indonesian. PR #3718 by @tiangolo.
  • 🌐 Add Chinese translation for docs/tutorial/dependencies/sub-dependencies.md. PR #3491 by @jaystone776.
  • 🌐 Add Portuguese translation for docs/advanced/index.md. PR #3460 by @ComicShrimp.
  • 🌐 Portuguese translation of docs/async.md. PR #1330 by @Serrones.
  • 🌐 Add French translation for docs/async.md. PR #3416 by @Smlep.

Internal

0.68.0

Features

Docs

  • 📝 Update docs about async and response-model with more gender neutral language. PR #1869 by @Edward-Knight.

Translations

  • 🌐 Add Russian translation for docs/python-types.md. PR #3039 by @dukkee.
  • 🌐 Add Chinese translation for docs/tutorial/dependencies/index.md. PR #3489 by @jaystone776.
  • 🌐 Add Russian translation for docs/external-links.md. PR #3036 by @dukkee.
  • 🌐 Add Chinese translation for docs/tutorial/dependencies/global-dependencies.md. PR #3493 by @jaystone776.
  • 🌐 Add Portuguese translation for docs/deployment/versions.md. PR #3618 by @lsglucas.
  • 🌐 Add Japanese translation for docs/tutorial/security/oauth2-jwt.md. PR #3526 by @sattosan.

Internal

  • ✅ Add the docs_src directory to test coverage and update tests. Initial PR #1904 by @Kludex.
  • 🔧 Add new GitHub templates with forms for new issues. PR #3612 by @tiangolo.
  • 📝 Add official FastAPI Twitter to docs: @fastapi. PR #3578 by @tiangolo.

0.67.0

Features

Docs

  • 📝 Add external link: How to Create A Fake Certificate Authority And Generate TLS Certs for FastAPI. PR #2839 by @aitoehigie.
  • ✏ Fix code highlighted line in: body-nested-models.md. PR #3463 by @jaystone776.
  • ✏ Fix typo in body-nested-models.md. PR #3462 by @jaystone776.
  • ✏ Fix typo “might me” -> “might be” in docs/en/docs/tutorial/schema-extra-example.md. PR #3362 by @dbrakman.
  • 📝 Add external link: Building simple E-Commerce with NuxtJS and FastAPI. PR #3271 by @ShahriyarR.
  • 📝 Add external link: Serve a machine learning model using Sklearn, FastAPI and Docker. PR #2974 by @rodrigo-arenas.
  • ✏️ Fix typo on docstring in datastructures file. PR #2887 by @Kludex.
  • 📝 Add External Link: Deploy FastAPI on Ubuntu and Serve using Caddy 2 Web Server. PR #3572 by @tiangolo.
  • 📝 Add External Link, replaces #1898. PR #3571 by @tiangolo.

Internal

  • 🎨 Improve style for sponsors, add radius border. PR #2388 by @Kludex.
  • 👷 Update GitHub Action latest-changes. PR #3574 by @tiangolo.
  • 👷 Update GitHub Action latest-changes. PR #3573 by @tiangolo.
  • 👷 Rename and clarify CI workflow job names. PR #3570 by @tiangolo.
  • 👷 Update GitHub Action latest-changes, strike 2 ⚾. PR #3575 by @tiangolo.
  • 🔧 Sort external links in docs to have the most recent at the top. PR #3568 by @tiangolo.

0.66.1

Translations

Internal

  • 🔧 Configure strict pytest options and update/refactor tests. Upgrade pytest to >=6.2.4,<7.0.0 and pytest-cov to >=2.12.0,<3.0.0. Initial PR #2790 by @graingert.
  • ⬆️ Upgrade python-jose dependency to >=3.3.0,<4.0.0 for tests. PR #3468 by @tiangolo.

0.66.0

Features

  • ✨ Allow setting the response_class to RedirectResponse or FileResponse and returning the URL from the function. New and updated docs are in the tutorial section Custom Response - HTML, Stream, File, others, in RedirectResponse and in FileResponse. PR #3457 by @tiangolo.

Fixes

  • 🐛 Fix include/exclude for dicts in jsonable_encoder. PR #2016 by @Rubikoid.
  • 🐛 Support custom OpenAPI / JSON Schema fields in the generated output OpenAPI. PR #1429 by @jmagnusson.

Translations

  • 🌐 Add Spanish translation for tutorial/query-params.md. PR #2243 by @mariacamilagl.
  • 🌐 Add Spanish translation for advanced/response-directly.md. PR #1253 by @jfunez.
  • 🌐 Add Spanish translation for advanced/additional-status-codes.md. PR #1252 by @jfunez.
  • 🌐 Add Spanish translation for advanced/path-operation-advanced-configuration.md. PR #1251 by @jfunez.

0.65.3

Fixes

  • ♻ Assume request bodies contain JSON when no Content-Type header is provided. This fixes a breaking change introduced by 0.65.2 with PR #2118. It should allow upgrading FastAPI applications with clients that send JSON data without a Content-Type header. And there’s still protection against CSRFs. PR #3456 by @tiangolo.

Translations

  • 🌐 Initialize Indonesian translations. PR #3014 by @pace-noge.
  • 🌐 Add Spanish translation of Tutorial - Path Parameters. PR #2219 by @mariacamilagl.
  • 🌐 Add Spanish translation of Tutorial - First Steps. PR #2208 by @mariacamilagl.
  • 🌐 Portuguese translation of Tutorial - Body - Fields. PR #3420 by @ComicShrimp.
  • 🌐 Add Chinese translation for Tutorial - Request - Forms - and - Files. PR #3249 by @jaystone776.
  • 🌐 Add Chinese translation for Tutorial - Handling - Errors. PR #3299 by @jaystone776.
  • 🌐 Add Chinese translation for Tutorial - Form - Data. PR #3248 by @jaystone776.
  • 🌐 Add Chinese translation for Tutorial - Body - Updates. PR #3237 by @jaystone776.
  • 🌐 Add Chinese translation for FastAPI People. PR #3112 by @hareru.
  • 🌐 Add French translation for Project Generation. PR #3197 by @Smlep.
  • 🌐 Add French translation for Python Types Intro. PR #3185 by @Smlep.
  • 🌐 Add French translation for External Links. PR #3103 by @Smlep.
  • 🌐 Add French translation for Alternatives, Inspiration and Comparisons. PR #3020 by @rjNemo.
  • 🌐 Fix Chinese translation code snippet mismatch in Tutorial - Python Types Intro. PR #2573 by @BoYanZh.
  • 🌐 Add Portuguese translation for Development Contributing. PR #1364 by @Serrones.
  • 🌐 Add Chinese translation for Tutorial - Request - Files. PR #3244 by @jaystone776.

Internal

0.65.2

Security fixes

  • 🔒 Check Content-Type request header before assuming JSON. Initial PR #2118 by @patrickkwang.

This change fixes a CSRF security vulnerability when using cookies for authentication in path operations with JSON payloads sent by browsers.

In versions lower than 0.65.2, FastAPI would try to read the request payload as JSON even if the content-type header sent was not set to application/json or a compatible JSON media type (e.g. application/geo+json).

So, a request with a content type of text/plain containing JSON data would be accepted and the JSON data would be extracted.

But requests with content type text/plain are exempt from CORS preflights, for being considered Simple requests. So, the browser would execute them right away including cookies, and the text content could be a JSON string that would be parsed and accepted by the FastAPI application.

See CVE-2021-32677 for more details.

Thanks to Dima Boger for the security report! 🙇🔒

Internal

0.65.1

Security fixes

0.65.0

Breaking Changes - Upgrade

  • ⬆️ Upgrade Starlette to 0.14.2, including internal UJSONResponse migrated from Starlette. This includes several bug fixes and features from Starlette. PR #2335 by @hanneskuettner.

Translations

Internal

  • 👷 Add GitHub Action cache to speed up CI installs. PR #3204 by @tiangolo.
  • ⬆️ Upgrade setup-python GitHub Action to v2. PR #3203 by @tiangolo.
  • 🐛 Fix docs script to generate a new translation language with overrides boilerplate. PR #3202 by @tiangolo.
  • ✨ Add new Deta banner badge with new sponsorship tier 🙇. PR #3194 by @tiangolo.
  • 👥 Update FastAPI People. PR #3189 by @github-actions[bot].
  • 🔊 Update FastAPI People to allow better debugging. PR #3188 by @tiangolo.

0.64.0

Features

Fixes

  • 📌 Pin SQLAlchemy range for tests, as it doesn’t use SemVer. PR #3001 by @tiangolo.
  • 🎨 Add newly required type annotations for mypy. PR #2882 by @tiangolo.
  • 🎨 Remove internal “type: ignore”, now unnecessary. PR #2424 by @AsakuraMizu.

Docs

  • 📝 Add link to article in Russian “FastAPI: знакомимся с фреймворком”. PR #2564 by @trkohler.
  • 📝 Add external link to blog post “Authenticate Your FastAPI App with Auth0”. PR #2172 by @dompatmore.
  • 📝 Fix broken link to article: Machine learning model serving in Python using FastAPI and Streamlit. PR #2557 by @davidefiocco.
  • 📝 Add FastAPI Medium Article: Deploy a dockerized FastAPI application to AWS. PR #2515 by @vjanz.
  • ✏ Fix typo in Tutorial - Handling Errors. PR #2486 by @johnthagen.
  • ✏ Fix typo in Security OAuth2 scopes. PR #2407 by @jugmac00.
  • ✏ Fix typo/clarify docs for SQL (Relational) Databases. PR #2393 by @kangni.
  • 📝 Add external link to “FastAPI for Flask Users”. PR #2280 by @amitness.

Translations

  • 🌐 Fix Chinese translation of Tutorial - Query Parameters, remove obsolete content. PR #3051 by @louis70109.
  • 🌐 Add French translation for Tutorial - Background Tasks. PR #3098 by @Smlep.
  • 🌐 Fix Korean translation for docs/ko/docs/index.md. PR #3159 by @SueNaEunYang.
  • 🌐 Add Korean translation for Tutorial - Query Parameters. PR #2390 by @hard-coders.
  • 🌐 Add French translation for FastAPI People. PR #2232 by @JulianMaurin.
  • 🌐 Add Korean translation for Tutorial - Path Parameters. PR #2355 by @hard-coders.
  • 🌐 Add French translation for Features. PR #2157 by @Jefidev.
  • 👥 Update FastAPI People. PR #3031 by @github-actions[bot].
  • 🌐 Add Chinese translation for Tutorial - Debugging. PR #2737 by @blt232018.
  • 🌐 Add Chinese translation for Tutorial - Security - OAuth2 with Password (and hashing), Bearer with JWT tokens. PR #2642 by @waynerv.
  • 🌐 Add Korean translation for Tutorial - Header Parameters. PR #2589 by @mode9.
  • 🌐 Add Chinese translation for Tutorial - Metadata and Docs URLs. PR #2559 by @blt232018.
  • 🌐 Add Korean translation for Tutorial - First Steps. PR #2323 by @hard-coders.
  • 🌐 Add Chinese translation for Tutorial - CORS (Cross-Origin Resource Sharing). PR #2540 by @blt232018.
  • 🌐 Add Chinese translation for Tutorial - Middleware. PR #2334 by @lpdswing.
  • 🌐 Add Korean translation for Tutorial - Intro. PR #2317 by @hard-coders.
  • 🌐 Add Chinese translation for Tutorial - Bigger Applications - Multiple Files. PR #2453 by @waynerv.
  • 🌐 Add Chinese translation for Tutorial - Security - Security Intro. PR #2443 by @waynerv.
  • 🌐 Add Chinese translation for Tutorial - Header Parameters. PR #2412 by @maoyibo.
  • 🌐 Add Chinese translation for Tutorial - Extra Data Types. PR #2410 by @maoyibo.
  • 🌐 Add Japanese translation for Deployment - Docker. PR #2312 by @tokusumi.
  • 🌐 Add Japanese translation for Deployment - Versions. PR #2310 by @tokusumi.
  • 🌐 Add Chinese translation for Tutorial - Cookie Parameters. PR #2261 by @alicrazy1947.
  • 🌐 Add Japanese translation for Tutorial - Static files. PR #2260 by @tokusumi.
  • 🌐 Add Japanese translation for Tutorial - Testing. PR #2259 by @tokusumi.
  • 🌐 Add Japanese translation for Tutorial - Debugging. PR #2256 by @tokusumi.
  • 🌐 Add Japanese translation for Tutorial - Middleware. PR #2255 by @tokusumi.
  • 🌐 Add Japanese translation for Concurrency and async / await. PR #2058 by @tokusumi.
  • 🌐 Add Chinese translation for Tutorial - Security - Simple OAuth2 with Password and Bearer. PR #2514 by @waynerv.
  • 🌐 Add Japanese translation for Deployment - Deta. PR #2314 by @tokusumi.
  • 🌐 Add Chinese translation for Tutorial - Security - Get Current User. PR #2474 by @waynerv.
  • 🌐 Add Japanese translation for Deployment - Manually. PR #2313 by @tokusumi.
  • 🌐 Add Japanese translation for Deployment - Intro. PR #2309 by @tokusumi.
  • 🌐 Add Japanese translation for FastAPI People. PR #2254 by @tokusumi.
  • 🌐 Add Japanese translation for Advanced - Path Operation Advanced Configuration. PR #2124 by @Attsun1031.
  • 🌐 Add Japanese translation for External Links. PR #2070 by @tokusumi.
  • 🌐 Add Japanese translation for Tutorial - Body - Updates. PR #1956 by @SwftAlpc.
  • 🌐 Add Japanese translation for Tutorial - Form Data. PR #1943 by @SwftAlpc.
  • 🌐 Add Japanese translation for Tutorial - Cookie Parameters. PR #1933 by @SwftAlpc.

Internal

0.63.0

Features

  • ✨ Improve type annotations, add support for mypy —strict, internally and for external packages. PR #2547 by @tiangolo.

Breaking changes

  • ⬆️ Upgrade Uvicorn when installing fastapi[all] to the latest version including uvloop, the new range is uvicorn[standard] >=0.12.0,<0.14.0. PR #2548 by @tiangolo.

Fixes

  • 🐛 PR #2547 (read above) also fixes some false-positive mypy errors with callbacks parameters and when using the OAuth2 class.

Docs

Translations

  • 🌐 Add docs lang selector widget. PR #2542 by @tiangolo.
  • 🌐 Add Chinese translation for Tutorial - Response Status Code. PR #2442 by @waynerv.
  • 🌐 Start translation of the documentation for the Albanian language. PR #2516 by @vjanz.
  • 🌐 Add Chinese translation for Tutorial - Extra Models. PR #2416 by @waynerv.
  • 🌐 Add Chinese translation for Tutorial - Response Model. PR #2414 by @waynerv.
  • 🌐 Add Chinese translation for Tutorial - Schema Extra Example. PR #2411 by @maoyibo.
  • 🌐 Add Korean translation for Index. PR #2192 by @hard-coders.
  • 🌐 Add Japanese translation for Advanced User Guide - Additional Status Codes. PR #2145 by @Attsun1031.

Internal

  • 🐛 Fix docs overrides directory for translations. PR #2541 by @tiangolo.
  • ➖ Remove Typer as a docs building dependency (covered by typer-cli) to fix pip resolver conflicts. PR #2539 by @tiangolo.
  • ✨ Add newsletter: FastAPI and friends. PR #2509 by @tiangolo.
  • ✨ Add new Gold Sponsor: InvestSuite 🎉. PR #2508 by @tiangolo.
  • 🔧 Add issue template configs. PR #2476 by @tiangolo.

0.62.0

Features

  • ✨ Add support for shared/top-level parameters (dependencies, tags, etc). PR #2434 by @tiangolo.

Up to now, for several options, the only way to apply them to a group of path operations was in include_router. That works well, but the call to app.include_router() or router.include_router() is normally done in another file.

That means that, for example, to apply authentication to all the path operations in a router it would end up being done in a different file, instead of keeping related logic together.

Setting options in include_router still makes sense in some cases, for example, to override or increase configurations from a third party router included in an app. But in a router that is part of a bigger application, it would probably make more sense to add those settings when creating the APIRouter.

In FastAPI

This allows setting the (mostly new) parameters (additionally to the already existing parameters):

  • default_response_class: updated to handle defaults in APIRouter and include_router.
  • dependencies: to include ✨ top-level dependencies ✨ that apply to the whole application. E.g. to add global authentication.
  • callbacks: OpenAPI callbacks that apply to all the path operations.
  • deprecated: to mark all the path operations as deprecated. 🤷
  • include_in_schema: to allow excluding all the path operations from the OpenAPI schema.
  • responses: OpenAPI responses that apply to all the path operations.

For example:

  1. from fastapi import FastAPI, Depends
  2. async def some_dependency():
  3. return
  4. app = FastAPI(dependencies=[Depends(some_dependency)])

In APIRouter

This allows setting the (mostly new) parameters (additionally to the already existing parameters):

  • default_response_class: updated to handle defaults in APIRouter and include_router. For example, it’s not needed to set it explicitly when creating callbacks.
  • dependencies: to include ✨ router-level dependencies ✨ that apply to all the path operations in a router. Up to now, this was only possible with include_router.
  • callbacks: OpenAPI callbacks that apply to all the path operations in this router.
  • deprecated: to mark all the path operations in a router as deprecated.
  • include_in_schema: to allow excluding all the path operations in a router from the OpenAPI schema.
  • responses: OpenAPI responses that apply to all the path operations in a router.
  • prefix: to set the path prefix for a router. Up to now, this was only possible when calling include_router.
  • tags: OpenAPI tags to apply to all the path operations in this router.

For example:

  1. from fastapi import APIRouter, Depends
  2. async def some_dependency():
  3. return
  4. router = APIRouter(prefix="/users", dependencies=[Depends(some_dependency)])

In include_router

Most of these settings are now supported in APIRouter, which normally lives closer to the related code, so it is recommended to use APIRouter when possible.

But include_router is still useful to, for example, adding options (like dependencies, prefix, and tags) when including a third party router, or a generic router that is shared between several projects.

This PR allows setting the (mostly new) parameters (additionally to the already existing parameters):

  • default_response_class: updated to handle defaults in APIRouter and FastAPI.
  • deprecated: to mark all the path operations in a router as deprecated in OpenAPI.
  • include_in_schema: to allow disabling all the path operations from showing in the OpenAPI schema.
  • callbacks: OpenAPI callbacks that apply to all the path operations in this router.

Note: all the previous parameters are still there, so it’s still possible to declare dependencies in include_router.

Breaking Changes

  • PR #2434 includes several improvements that shouldn’t affect normal use cases, but could affect in advanced scenarios:
    • If you are testing the generated OpenAPI (you shouldn’t, FastAPI already tests it extensively for you): the order for tags in include_router and path operations was updated for consistency, but it’s a simple order change.
    • If you have advanced custom logic to access each route’s route.response_class, or the router.default_response_class, or the app.default_response_class: the default value for response_class in APIRoute and for default_response_class in APIRouter and FastAPI is now a DefaultPlaceholder used internally to handle and solve default values and overrides. The actual response class inside the DefaultPlaceholder is available at route.response_class.value.

Docs

Translations

  • 🌐 Add Japanese translation for Advanced - Custom Response. PR #2193 by @Attsun1031.
  • 🌐 Add Chinese translation for Benchmarks. PR #2119 by @spaceack.
  • 🌐 Add Chinese translation for Tutorial - Body - Nested Models. PR #1609 by @waynerv.
  • 🌐 Add Chinese translation for Advanced - Custom Response. PR #1459 by @RunningIkkyu.
  • 🌐 Add Chinese translation for Advanced - Return a Response Directly. PR #1452 by @RunningIkkyu.
  • 🌐 Add Chinese translation for Advanced - Additional Status Codes. PR #1451 by @RunningIkkyu.
  • 🌐 Add Chinese translation for Advanced - Path Operation Advanced Configuration. PR #1447 by @RunningIkkyu.
  • 🌐 Add Chinese translation for Advanced User Guide - Intro. PR #1445 by @RunningIkkyu.

Internal

  • 🔧 Update TestDriven link to course in sponsors section. PR #2435 by @tiangolo.
  • 🍱 Update sponsor logos. PR #2418 by @tiangolo.
  • 💚 Fix disabling install of Material for MkDocs Insiders in forks, strike 1 ⚾. PR #2340 by @tiangolo.
  • 🐛 Fix disabling Material for MkDocs Insiders install in forks. PR #2339 by @tiangolo.
  • ✨ Add silver sponsor WeTransfer. PR #2338 by @tiangolo.
  • ✨ Set up and enable Material for MkDocs Insiders for the docs. PR #2325 by @tiangolo.

0.61.2

Fixes

  • 📌 Relax Swagger UI version pin. PR #2089 by @jmriebold.
  • 🐛 Fix bug overriding custom HTTPException and RequestValidationError from exception_handlers. PR #1924 by @uriyyo.
  • ✏️ Fix typo on dependencies utils and cleanup unused variable. PR #1912 by @Kludex.

Docs

Translations

  • 🌐 Add Japanese translation for Advanced Tutorial - Response Directly. PR #2191 by @Attsun1031.
  • 📝 Add Japanese translation for Tutorial - Security - First Steps. PR #2153 by @komtaki.
  • 🌐 Add Japanese translation for Tutorial - Query Parameters and String Validations. PR #1901 by @SwftAlpc.
  • 🌐 Add Portuguese translation for External Links. PR #1443 by @Serrones.
  • 🌐 Add Japanese translation for Tutorial - CORS. PR #2125 by @tokusumi.
  • 🌐 Add Japanese translation for Contributing. PR #2067 by @komtaki.
  • 🌐 Add Japanese translation for Project Generation. PR #2050 by @tokusumi.
  • 🌐 Add Japanese translation for Alternatives. PR #2043 by @Attsun1031.
  • 🌐 Add Japanese translation for History Design and Future. PR #2002 by @komtaki.
  • 🌐 Add Japanese translation for Benchmarks. PR #1992 by @komtaki.
  • 🌐 Add Japanese translation for Tutorial - Header Parameters. PR #1935 by @SwftAlpc.
  • 🌐 Add Portuguese translation for Tutorial - First Steps. PR #1861 by @jessicapaz.
  • 🌐 Add Portuguese translation for Python Types. PR #1796 by @izaguerreiro.
  • 🌐 Add Japanese translation for Help FastAPI. PR #1692 by @tokusumi.
  • 🌐 Add Japanese translation for Tutorial - Body. PR #1683 by @tokusumi.
  • 🌐 Add Japanese translation for Tutorial - Query Params. PR #1674 by @tokusumi.
  • 🌐 Add Japanese translation for tutorial/path-params.md. PR #1671 by @tokusumi.
  • 🌐 Add Japanese translation for tutorial/first-steps.md. PR #1658 by @tokusumi.
  • 🌐 Add Japanese translation for tutorial/index.md. PR #1656 by @tokusumi.
  • 🌐 Add translation to Portuguese for Project Generation. PR #1602 by @Serrones.
  • 🌐 Add Japanese translation for Features. PR #1625 by @tokusumi.
  • 🌐 Initialize new language Korean for translations. PR #2018 by @hard-coders.
  • 🌐 Add Portuguese translation of Deployment. PR #1374 by @Serrones.

Internal

  • 🔥 Cleanup after upgrade for Docs Previews GitHub Action. PR #2248 by @tiangolo.
  • 🐛 Fix CI docs preview, unzip docs. PR #2246 by @tiangolo.
  • ✨ Add instant docs deploy previews for PRs from forks. PR #2244 by @tiangolo.
  • ⚡️ Build docs for languages in parallel in subprocesses to speed up CI. PR #2242 by @tiangolo.
  • 🐛 Fix docs order generation for partial translations. PR #2238 by @tiangolo.
  • 👥 Update FastAPI People. PR #2202 by @github-actions[bot].
  • ♻️ Update FastAPI People GitHub Action to send the PR as github-actions. PR #2201 by @tiangolo.
  • 🔧 Update FastAPI People GitHub Action config, run monthly. PR #2199 by @tiangolo.
  • 🐛 Fix FastAPI People GitHub Action Docker dependency, strike 1 ⚾. PR #2198 by @tiangolo.
  • 🐛 Fix FastAPI People GitHub Action Docker dependencies. PR #2197 by @tiangolo.
  • 🐛 Fix FastAPI People GitHub Action when there’s nothing to change. PR #2196 by @tiangolo.
  • 👥 Add new section FastAPI People. PR #2195 by @tiangolo.
  • ⬆️ Upgrade GitHub Action Latest Changes. PR #2190 by @tiangolo.
  • ⬆️ Upgrade GitHub Action Label Approved. PR #2189 by @tiangolo.
  • 🔧 Update GitHub Action Label Approved, run at 12:00. PR #2185 by @tiangolo.
  • 👷 Upgrade GitHub Action Latest Changes. PR #2184 by @tiangolo.
  • 👷 Set GitHub Action Label Approved to run daily, not every minute. PR #2163 by @tiangolo.
  • 🔥 Remove pr-approvals GitHub Action as it’s not compatible with forks. Use the new one. PR #2162 by @tiangolo.
  • 👷 Add GitHub Action Latest Changes. PR #2160.
  • 👷 Add GitHub Action Label Approved. PR #2161.

0.61.1

Fixes

  • Fix issues using jsonable_encoder with SQLAlchemy models directly. PR #1987.

Docs

Translations

Internal

  • Improve docs maintainability by updating hl_lines syntax to use ranges. PR #1863 by @la-mar.

0.61.0

Features

  • Add support for injecting HTTPConnection (as Request and WebSocket). Useful for sharing app state in dependencies. PR #1827 by @nsidnev.
  • Export WebSocketDisconnect and add example handling WebSocket disconnections to docs. PR #1822 by @rkbeatss.

Breaking Changes

  • Require Pydantic > 1.0.0.
    • Remove support for deprecated Pydantic 0.32.2. This improves maintainability and allows new features.
    • In FastAPI and APIRouter:
      • Remove path operation decorators related/deprecated parameter response_model_skip_defaults (use response_model_exclude_unset instead).
      • Change path operation decorators parameter default for response_model_exclude from set() to None (as is in Pydantic).
    • In encoders.jsonable_encoder:
      • Remove deprecated skip_defaults, use instead exclude_unset.
      • Set default of exclude from set() to None (as is in Pydantic).
    • PR #1862.
  • In encoders.jsonable_encoder remove parameter sqlalchemy_safe.
    • It was an early hack to allow returning SQLAlchemy models, but it was never documented, and the recommended way is using Pydantic’s orm_mode as described in the tutorial: SQL (Relational) Databases.
    • PR #1864.

Docs

Internal

  • Add Flake8 linting. Original PR #1774 by @MashhadiNima.
  • Disable Gitter bot, as it’s currently broken, and Gitter’s response doesn’t show the problem. PR #1853.

0.60.2

0.60.1

  • Add debugging logs for GitHub actions to introspect GitHub hidden context. PR #1764.
  • Use OS preference theme for online docs. PR #1760 by @adriencaccia.
  • Upgrade Starlette to version 0.13.6 to handle a vulnerability when using static files in Windows. PR #1759 by @jamesag26.
  • Pin Swagger UI temporarily, waiting for a fix for swagger-api/swagger-ui#6249. PR #1763.
  • Update GitHub Actions, use commit from PR for docs preview, not commit from pre-merge. PR #1761.
  • Update GitHub Actions, refactor Gitter bot. PR #1746.

0.60.0

  • Add GitHub Action to watch for missing preview docs and trigger a preview deploy. PR #1740.
  • Add custom GitHub Action to get artifact with docs preview. PR #1739.
  • Add new GitHub Actions to preview docs from PRs. PR #1738.
  • Add XML test coverage to support GitHub Actions. PR #1737.
  • Update badges and remove Travis now that GitHub Actions is the main CI. PR #1736.
  • Add GitHub Actions for CI, move from Travis. PR #1735.
  • Add support for adding OpenAPI schema for GET requests with a body. PR #1626 by @victorphoenix3.

0.59.0

0.58.1

0.58.0

  • Deep merge OpenAPI responses to preserve all the additional metadata. PR #1577.
  • Mention in docs that only main app events are run (not sub-apps). PR #1554 by @amacfie.
  • Fix body validation error response, do not include body variable when it is not embedded. PR #1553 by @amacfie.
  • Fix testing OAuth2 security scopes when using dependency overrides. PR #1549 by @amacfie.
  • Fix Model for JSON Schema keyword not as a JSON Schema instead of a list. PR #1548 by @v-do.
  • Add support for OpenAPI servers. PR #1547 by @mikaello.

0.57.0

0.56.1

0.56.0

0.55.1

0.55.0

0.54.2

0.54.1

  • Update database test setup. PR #1226.
  • Improve test debugging by showing response text in failing tests. PR #1222 by @samuelcolvin.

0.54.0

0.53.2

0.53.1

0.53.0

0.52.0

0.51.0

  • Re-export utils from Starlette:
    • This allows using things like from fastapi.responses import JSONResponse instead of from starlette.responses import JSONResponse.
    • It’s mainly syntax sugar, a convenience for developer experience.
    • Now Request, Response, WebSocket, status can be imported directly from fastapi as in from fastapi import Response. This is because those are frequently used, to use the request directly, to set headers and cookies, to get status codes, etc.
    • Documentation changes in many places, but new docs and noticeable improvements:
    • PR #1064.

0.50.0

  • Add link to Release Notes from docs about pinning versions for deployment. PR #1058.
  • Upgrade code to use the latest version of Starlette, including:
    • Several bug fixes.
    • Optional redirects of slashes, with or without ending in /.
    • Events for routers, "startup", and "shutdown".
    • PR #1057.
  • Add docs about pinning FastAPI versions for deployment: Deployment: FastAPI versions. PR #1056.

0.49.2

0.49.1

  • Fix path operation duplicated parameters when used in dependencies and the path operation function. PR #994 by @merowinger92.
  • Update Netlify previews deployment GitHub action as the fix is already merged and there’s a new release. PR #1047.
  • Move mypy configurations to config file. PR #987 by @hukkinj1.
  • Temporary fix to Netlify previews not deployable from PRs from forks. PR #1046 by @mariacamilagl.

0.49.0

0.48.0

0.47.1

  • Fix model filtering in response_model, cloning sub-models. PR #889.
  • Fix FastAPI serialization of Pydantic models using ORM mode blocking the event loop. PR #888.

0.47.0

0.46.0

0.45.0

0.44.1

  • Add GitHub social preview images to git. PR #752.
  • Update PyPI “trove classifiers”. PR #751.
  • Add full support for Python 3.8. Enable Python 3.8 in full in Travis. PR 749.
  • Update “new issue” templates. PR #749.
  • Fix serialization of errors for exotic Pydantic types. PR #748 by @dmontagu.

0.44.0

0.43.0

0.42.0

  • Add dependencies with yield, a.k.a. exit steps, context managers, cleanup, teardown, …
    • This allows adding extra code after a dependency is done. It can be used, for example, to close database connections.
    • Dependencies with yield can be normal or async, FastAPI will run normal dependencies in a threadpool.
    • They can be combined with normal dependencies.
    • It’s possible to have arbitrary trees/levels of dependencies with yield and exit steps are handled in the correct order automatically.
    • It works by default in Python 3.7 or above. For Python 3.6, it requires the extra backport dependencies:
      • async-exit-stack
      • async-generator
    • New docs at Dependencies with yield.
    • Updated database docs SQL (Relational) Databases: Main FastAPI app.
    • PR #595.
  • Fix sitemap.xml in website. PR #598 by @samuelcolvin.

0.41.0

  • Upgrade required Starlette to 0.12.9, the new range is >=0.12.9,<=0.12.9.
    • Add State to FastAPI apps at app.state.
    • PR #593.
  • Improve handling of custom classes for Requests and APIRoutes.
    • This helps to more easily solve use cases like:
      • Reading a body before and/or after a request (equivalent to a middleware).
      • Run middleware-like code only for a subset of path operations.
      • Process a request before passing it to a path operation function. E.g. decompressing, deserializing, etc.
      • Processing a response after being generated by path operation functions but before returning it. E.g. adding custom headers, logging, adding extra metadata.
    • New docs section: Custom Request and APIRoute class.
    • PR #589 by @dmontagu.
  • Fix preserving custom route class in routers when including other sub-routers. PR #538 by @dmontagu.

0.40.0

0.39.0

  • Allow path parameters to have default values (e.g. None) and discard them instead of raising an error.
    • This allows declaring a parameter like user_id: str = None that can be taken from a query parameter, but the same path operation can be included in a router with a path /users/{user_id}, in which case will be taken from the path and will be required.
    • PR #464 by @jonathanunderwood.
  • Add support for setting a default_response_class in the FastAPI instance or in include_router. Initial PR #467 by @toppk.
  • Add support for type annotations using strings and from __future__ import annotations. PR #451 by @dmontagu.

0.38.1

0.38.0

  • Add recent articles to External Links and recent opinions. PR #490.
  • Upgrade support range for Starlette to include 0.12.8. The new range is >=0.11.1,<=0.12.8". PR #477 by @dmontagu.
  • Upgrade support to Pydantic version 0.32.2 and update internal code to use it (breaking change). PR #463 by @dmontagu.

0.37.0

0.36.0

  • Fix implementation for skip_defaults when returning a Pydantic model. PR #422 by @dmontagu.
  • Fix OpenAPI generation when using the same dependency in multiple places for the same path operation. PR #417 by @dmontagu.
  • Allow having empty paths in path operations used with include_router and a prefix.
    • This allows having a router for /cats and all its path operations, while having one of them for /cats.
    • Now it doesn’t have to be only /cats/ (with a trailing slash).
    • To use it, declare the path in the path operation as the empty string ("").
    • PR #415 by @vitalik.
  • Fix mypy error after merging PR #415. PR #462.

0.35.0

0.34.0

  • Upgrade Starlette supported range to include the latest 0.12.7. The new range is 0.11.1,<=0.12.7. PR #367 by @dedsm.

  • Add test for OpenAPI schema with duplicate models from PR #333 by @dmontagu. PR #385.

0.33.0

  • Upgrade Pydantic version to 0.30.0. PR #384 by @jekirl.

0.32.0

  • Fix typo in docs for features. PR #380 by @MartinoMensio.

  • Fix source code limit for example in Query Parameters. PR #366 by @Smashman.

  • Update wording in docs about OAuth2 scopes. PR #371 by @cjw296.

  • Update docs for Enums to inherit from str and improve Swagger UI rendering. PR #351.

  • Fix regression, add Swagger UI deep linking again. PR #350.

  • Add test for having path templates in prefix of .include_router. PR #349.

  • Add note to docs: Include the same router multiple times with different prefix. PR #348.

  • Fix OpenAPI/JSON Schema generation for two functions with the same name (in different modules) with the same composite bodies.

    • Composite bodies’ IDs are now based on path, not only on route name, as the auto-generated name uses the function names, that can be duplicated in different modules.
    • The same new ID generation applies to response models.
    • This also changes the generated title for those models.
    • Only composite bodies and response models are affected because those are generated dynamically, they don’t have a module (a Python file).
    • This also adds the possibility of using .include_router() with the same APIRouter multiple times, with different prefixes, e.g. /api/v2 and /api/latest, and it will now work correctly.
    • PR #347.

0.31.0

  • Upgrade Pydantic supported version to 0.29.0.

0.30.1

0.30.0

  • Add support for Pydantic’s ORM mode:

    • Updated documentation about SQL with SQLAlchemy, using Pydantic models with ORM mode, SQLAlchemy models with relations, separation of files, simplification of code and other changes. New docs: SQL (Relational) Databases.
    • The new support for ORM mode fixes issues/adds features related to ORMs with lazy-loading, hybrid properties, dynamic/getters (using @property decorators) and several other use cases.
    • This applies to ORMs like SQLAlchemy, Peewee, Tortoise ORM, GINO ORM and virtually any other.
    • If your path operations return an arbitrary object with attributes (e.g. my_item.name instead of my_item["name"]) AND you use a response_model, make sure to update the Pydantic models with orm_mode = True as described in the docs (link above).
    • New documentation about receiving plain dicts as request bodies: Bodies of arbitrary dicts.
    • New documentation about returning arbitrary dicts in responses: Response with arbitrary dict.
    • Technical Details:
      • When declaring a response_model it is used directly to generate the response content, from whatever was returned from the path operation function.
      • Before this, the return content was first passed through jsonable_encoder to ensure it was a “jsonable” object, like a dict, instead of an arbitrary object with attributes (like an ORM model). That’s why you should make sure to update your Pydantic models for objects with attributes to use orm_mode = True.
      • If you don’t have a response_model, the return object will still be passed through jsonable_encoder first.
      • When a response_model is declared, the same response_model type declaration won’t be used as is, it will be “cloned” to create an new one (a cloned Pydantic Field with all the submodels cloned as well).
      • This avoids/fixes a potential security issue: as the returned object is passed directly to Pydantic, if the returned object was a subclass of the response_model (e.g. you return a UserInDB that inherits from User but contains extra fields, like hashed_password, and User is used in the response_model), it would still pass the validation (because UserInDB is a subclass of User) and the object would be returned as-is, including the hashed_password. To fix this, the declared response_model is cloned, if it is a Pydantic model class (or contains Pydantic model classes in it, e.g. in a List[Item]), the Pydantic model class(es) will be a different one (the “cloned” one). So, an object that is a subclass won’t simply pass the validation and returned as-is, because it is no longer a sub-class of the cloned response_model. Instead, a new Pydantic model object will be created with the contents of the returned object. So, it will be a new object (made with the data from the returned one), and will be filtered by the cloned response_model, containing only the declared fields as normally.
    • PR #322.
  • Remove/clean unused RegEx code in routing. PR #314 by @dmontagu.

  • Use default response status code descriptions for additional responses. PR #313 by @duxiaoyao.

  • Upgrade Pydantic support to 0.28. PR #320 by @jekirl.

0.29.1

0.29.0

  • Add support for declaring a Response parameter:

0.28.0

  • Implement dependency cache per request.

    • This avoids calling each dependency multiple times for the same request.
    • This is useful while calling external services, performing costly computation, etc.
    • This also means that if a dependency was declared as a path operation decorator dependency, possibly at the router level (with .include_router()) and then it is declared again in a specific path operation, the dependency will be called only once.
    • The cache can be disabled per dependency declaration, using use_cache=False as in Depends(your_dependency, use_cache=False).
    • Updated docs at: Using the same dependency multiple times.
    • PR #292.
  • Implement dependency overrides for testing.

0.27.2

0.27.1

  • Fix auto_error=False handling in HTTPBearer security scheme. Do not raise when there’s an incorrect Authorization header if auto_error=False. PR #282.

  • Fix type declaration of HTTPException. PR #279.

0.27.0

0.26.0

0.25.0

  • Add support for Pydantic’s include, exclude, by_alias.

  • Add CONTRIBUTING.md file to GitHub, to help new contributors. PR #255 by @wshayes.

  • Add support for Pydantic’s skip_defaults:

0.24.0

  • Add support for WebSockets with dependencies and parameters.

  • Upgrade the compatible version of Pydantic to 0.26.0.

    • This includes JSON Schema support for IP address and network objects, bug fixes, and other features.
    • PR #247 by @euri10.

0.23.0

  • Upgrade the compatible version of Starlette to 0.12.0.

    • This includes support for ASGI 3 (the latest version of the standard).
    • It’s now possible to use Starlette’s StreamingResponse with iterators, like file-like objects (as those returned by open()).
    • It’s now possible to use the low level utility iterate_in_threadpool from starlette.concurrency (for advanced scenarios).
    • PR #243.
  • Add OAuth2 redirect page for Swagger UI. This allows having delegated authentication in the Swagger UI docs. For this to work, you need to add {your_origin}/docs/oauth2-redirect to the allowed callbacks in your OAuth2 provider (in Auth0, Facebook, Google, etc).

    • For example, during development, it could be http://localhost:8000/docs/oauth2-redirect.
    • Have in mind that this callback URL is independent of whichever one is used by your frontend. You might also have another callback at https://yourdomain.com/login/callback.
    • This is only to allow delegated authentication in the API docs with Swagger UI.
    • PR #198 by @steinitzu.
  • Make Swagger UI and ReDoc route handlers (path operations) be async functions instead of lambdas to improve performance. PR #241 by @Trim21.

  • Make Swagger UI and ReDoc URLs parameterizable, allowing to host and serve local versions of them and have offline docs. PR #112 by @euri10.

0.22.0

  • Add support for dependencies parameter:

    • A parameter in path operation decorators, for dependencies that should be executed but the return value is not important or not used in the path operation function.
    • A parameter in the .include_router() method of FastAPI applications and routers, to include dependencies that should be executed in each path operation in a router.
      • This is useful, for example, to require authentication or permissions in specific group of path operations.
      • Different dependencies can be applied to different routers.
    • These dependencies are run before the normal parameter dependencies. And normal dependencies are run too. They can be combined.
    • Dependencies declared in a router are executed first, then the ones defined in path operation decorators, and then the ones declared in normal parameters. They are all combined and executed.
    • All this also supports using Security with scopes in those dependencies parameters, for more advanced OAuth 2.0 security scenarios with scopes.
    • New documentation about dependencies in path operation decorators.
    • New documentation about dependencies in the include_router() method.
    • PR #235.
  • Fix OpenAPI documentation of Starlette URL convertors. Specially useful when using path convertors, to take a whole path as a parameter, like /some/url/{p:path}. PR #234 by @euri10.

  • Make default parameter utilities exported from fastapi be functions instead of classes (the new functions return instances of those classes). To be able to override the return types and fix mypy errors in FastAPI’s users’ code. Applies to Path, Query, Header, Cookie, Body, Form, File, Depends, and Security. PR #226 and PR #231.

  • Separate development scripts test.sh, lint.sh, and format.sh. PR #232.

  • Re-enable black formatting checks for Python 3.7. PR #229 by @zamiramir.

0.21.0

  • On body parsing errors, raise from previous exception, to allow better introspection in logging code. PR #192 by @ricardomomm.

  • Use Python logger named “fastapi“ instead of root logger. PR #222 by @euri10.

  • Upgrade Pydantic to version 0.25. PR #225 by @euri10.

  • Fix typo in routing. PR #221 by @djlambert.

0.20.1

  • Add typing information to package including file py.typed. PR #209 by @meadsteve.

  • Add FastAPI bot for Gitter. To automatically announce new releases. PR #189.

0.20.0

0.19.0

0.18.0

  • Add docs for HTTP Basic Auth. PR #177.

  • Upgrade HTTP Basic Auth handling with automatic headers (automatic browser login prompt). PR #175.

  • Update dependencies for security. PR #174.

  • Add docs for Middleware. PR #173.

0.17.0

0.16.0

0.15.0

0.14.0

  • Improve automatically generated names of path operations in OpenAPI (in API docs). A function read_items instead of having a generated name “Read Items Get” will have “Read Items”. PR #155.

  • Add docs for: Testing FastAPI. PR #151.

  • Update /docs Swagger UI to enable deep linking. This allows sharing the URL pointing directly to the path operation documentation in the docs. PR #148 by @wshayes.

  • Update development dependencies, Pipfile.lock. PR #150.

  • Include Falcon and Hug in: Alternatives, Inspiration and Comparisons.

0.13.0

  • Improve/upgrade OAuth2 scopes support with SecurityScopes:
    • SecurityScopes can be declared as a parameter like Request, to get the scopes of all super-dependencies/dependants.
    • Improve Security handling, merging scopes when declaring SecurityScopes.
    • Allow using SecurityBase (like OAuth2) classes with Depends and still document them. Security now is needed only to declare scopes.
    • Updated docs about: OAuth2 with Password (and hashing), Bearer with JWT tokens.
    • New docs about: OAuth2 scopes.
    • PR #141.

0.12.1

  • Fix bug: handling additional responses in APIRouter.include_router(). PR #140.

  • Fix typo in SQL tutorial. PR #138 by @mostaphaRoudsari.

  • Fix typos in section about nested models and OAuth2 with JWT. PR #127 by @mmcloud.

0.12.0

  • Add additional responses parameter to path operation decorators to extend responses in OpenAPI (and API docs).
    • It also allows extending existing responses generated from response_model, declare other media types (like images), etc.
    • The new documentation is here: Additional Responses.
    • responses can also be added to .include_router(), the updated docs are here: Bigger Applications.
    • PR #97 originally initiated by @barsi.
  • Update scripts/test-cov-html.sh to allow passing extra parameters like -vv, for development.

0.11.0

  • Add auto_error parameter to security utility functions. Allowing them to be optional. Also allowing to have multiple alternative security schemes that are then checked in a single dependency instead of each one verifying and returning the error to the client automatically when not satisfied. PR #134.

  • Update SQL Tutorial to close database sessions even when there are exceptions. PR #89 by @alexiri.

  • Fix duplicate dependency in pyproject.toml. PR #128 by @zxalif.

0.10.3

0.10.2

  • Fix OpenAPI (JSON Schema) for declarations of Python Union (JSON Schema additionalProperties). PR #121.

  • Update Background Tasks with a note on Celery.

  • Document response models using unions and lists, updated at: Extra Models. PR #108.

0.10.1

0.10.0

0.9.1

0.9.0

0.8.0

  • Make development scripts executable. PR #76 by @euri10.

  • Add support for adding tags in app.include_router(). PR #55 by @euri10. Documentation updated in the section: Bigger Applications.

  • Update docs related to Uvicorn to use new --reload option from version 0.5.x. PR #74.

  • Update isort imports and scripts to be compatible with newer versions. PR #75.

0.7.1

0.7.0

0.6.4

0.6.3

  • Add Favicons to docs. PR #53.

0.6.2

0.6.1

0.6.0

0.5.1

0.5.0

0.4.0

0.3.0

0.2.1

  • Fix jsonable_encoder for Pydantic models with Config but without json_encoders: #29.

0.2.0

  • Fix typos in Security section: #24 by @kkinder.

  • Add support for Pydantic custom JSON encoders: #21 by @euri10.

0.1.19

  • Upgrade Starlette version to the current latest 0.10.1: #17 by @euri10.