Fastapi

Latest version: v0.115.8

Safety actively analyzes 706267 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 15 of 34

0.74.0

Not secure
Breaking Changes

* ✨ Update internal `AsyncExitStack` to fix context for dependencies with `yield`. PR [4575](https://github.com/tiangolo/fastapi/pull/4575) by [tiangolo](https://github.com/tiangolo).

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

Python
async def get_database():
with Session() as session:
try:
yield session
except HTTPException:
session.rollback()
raise
finally:
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`:

Python
async def do_something():
try:
yield something
finally:
some_cleanup()


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

Features

* The same PR [4575](https://github.com/tiangolo/fastapi/pull/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:

Python
from contextvars import ContextVar
from typing import Any, Dict, Optional


legacy_request_state_context_var: ContextVar[Optional[Dict[str, Any]]] = ContextVar(
"legacy_request_state_context_var", default=None
)

async def set_up_request_state_dependency():
request_state = {"user": "deadpond"}
contextvar_token = legacy_request_state_context_var.set(request_state)
yield request_state
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](https://github.com/tiangolo/fastapi/pull/4575).

Internal

* 🔧 Add Striveworks sponsor. PR [4596](https://github.com/tiangolo/fastapi/pull/4596) by [tiangolo](https://github.com/tiangolo).
* 💚 Only build docs on push when on master to avoid duplicate runs from PRs. PR [4564](https://github.com/tiangolo/fastapi/pull/4564) by [tiangolo](https://github.com/tiangolo).
* 👥 Update FastAPI People. PR [4502](https://github.com/tiangolo/fastapi/pull/4502) by [github-actions[bot]](https://github.com/apps/github-actions).

0.73.0

Not secure
Features

* ✨ Add support for declaring `UploadFile` parameters without explicit `File()`. PR [4469](https://github.com/tiangolo/fastapi/pull/4469) by [tiangolo](https://github.com/tiangolo). New docs: [Request Files - File Parameters with UploadFile](https://fastapi.tiangolo.com/tutorial/request-files/#file-parameters-with-uploadfile).
* ✨ Add support for tags with Enums. PR [4468](https://github.com/tiangolo/fastapi/pull/4468) by [tiangolo](https://github.com/tiangolo). New docs: [Path Operation Configuration - Tags with Enums](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags-with-enums).
* ✨ Allow hiding from OpenAPI (and Swagger UI) `Query`, `Cookie`, `Header`, and `Path` parameters. PR [3144](https://github.com/tiangolo/fastapi/pull/3144) by [astraldawn](https://github.com/astraldawn). New docs: [Query Parameters and String Validations - Exclude from OpenAPI](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-from-openapi).

Docs

* 📝 Tweak and improve docs for Request Files. PR [4470](https://github.com/tiangolo/fastapi/pull/4470) by [tiangolo](https://github.com/tiangolo).

Fixes

* 🐛 Fix bug preventing to use OpenAPI when using tuples. PR [3874](https://github.com/tiangolo/fastapi/pull/3874) by [victorbenichoux](https://github.com/victorbenichoux).
* 🐛 Prefer custom encoder over defaults if specified in `jsonable_encoder`. PR [2061](https://github.com/tiangolo/fastapi/pull/2061) by [viveksunder](https://github.com/viveksunder).
* 💚 Duplicate PR to trigger CI. PR [4467](https://github.com/tiangolo/fastapi/pull/4467) by [tiangolo](https://github.com/tiangolo).

Internal

* 🐛 Fix docs dependencies cache, to get the latest Material for MkDocs. PR [4466](https://github.com/tiangolo/fastapi/pull/4466) by [tiangolo](https://github.com/tiangolo).
* 🔧 Add sponsor Dropbase. PR [4465](https://github.com/tiangolo/fastapi/pull/4465) by [tiangolo](https://github.com/tiangolo).

0.72.0

Not secure
Features

* ✨ Enable configuring Swagger UI parameters. Original PR [2568](https://github.com/tiangolo/fastapi/pull/2568) by [jmriebold](https://github.com/jmriebold). Here are the new docs: [Configuring Swagger UI](https://fastapi.tiangolo.com/advanced/extending-openapi/#configuring-swagger-ui).

Docs

* 📝 Update Python Types docs, add missing 3.6 / 3.9 example. PR [4434](https://github.com/tiangolo/fastapi/pull/4434) by [tiangolo](https://github.com/tiangolo).

Translations

* 🌐 Update Chinese translation for `docs/help-fastapi.md`. PR [3847](https://github.com/tiangolo/fastapi/pull/3847) by [jaystone776](https://github.com/jaystone776).
* 🌐 Fix Korean translation for `docs/ko/docs/index.md`. PR [4195](https://github.com/tiangolo/fastapi/pull/4195) by [kty4119](https://github.com/kty4119).
* 🌐 Add Polish translation for `docs/pl/docs/index.md`. PR [4245](https://github.com/tiangolo/fastapi/pull/4245) by [MicroPanda123](https://github.com/MicroPanda123).
* 🌐 Add Chinese translation for `docs\tutorial\path-operation-configuration.md`. PR [3312](https://github.com/tiangolo/fastapi/pull/3312) by [jaystone776](https://github.com/jaystone776).

Internal

* 🔧 Enable MkDocs Material Insiders' `content.tabs.link`. PR [4399](https://github.com/tiangolo/fastapi/pull/4399) by [tiangolo](https://github.com/tiangolo).

0.71.0

Not secure
Features

* ✨ Add docs and tests for Python 3.9 and Python 3.10. PR [3712](https://github.com/tiangolo/fastapi/pull/3712) by [tiangolo](https://github.com/tiangolo).
* You can start with [Python Types Intro](https://fastapi.tiangolo.com/python-types/), 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](https://github.com/tiangolo/fastapi/pull/4145) by [simondale00](https://github.com/simondale00).

Internal

* 👥 Update FastAPI People. PR [4354](https://github.com/tiangolo/fastapi/pull/4354) by [github-actions[bot]](https://github.com/apps/github-actions).
* 🔧 Add FastAPI Trove Classifier for PyPI as now there's one 🤷😁. PR [4386](https://github.com/tiangolo/fastapi/pull/4386) by [tiangolo](https://github.com/tiangolo).
* ⬆ Upgrade MkDocs Material and configs. PR [4385](https://github.com/tiangolo/fastapi/pull/4385) by [tiangolo](https://github.com/tiangolo).

0.70.1

Not secure
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](https://github.com/tiangolo/fastapi/pull/4272) by [PrettyWood](https://github.com/PrettyWood).

Translations

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

Internal

* 👥 Update FastAPI People. PR [4274](https://github.com/tiangolo/fastapi/pull/4274) by [github-actions[bot]](https://github.com/apps/github-actions).

0.70.0

Not secure
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

* ⬆️ Upgrade Starlette to 0.16.0. PR [4016](https://github.com/tiangolo/fastapi/pull/4016) by [tiangolo](https://github.com/tiangolo).

Also upgrades the ranges of optional dependencies:

* `"jinja2 >=2.11.2,<4.0.0"`
* `"itsdangerous >=1.1.0,<3.0.0"`

Page 15 of 34

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.