diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 77bce055c6..a0b507dd90 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -97,7 +97,7 @@ jobs: path: docs/${{ matrix.lang }}/.cache - name: Build Docs run: uv run ./scripts/docs.py build-lang ${{ matrix.lang }} - - uses: actions/upload-artifact@v6 + - uses: actions/upload-artifact@v7 with: name: docs-site-${{ matrix.lang }} path: ./site/** diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 734fc244d3..3002120399 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -45,7 +45,7 @@ jobs: run: | rm -rf ./site mkdir ./site - - uses: actions/download-artifact@v7 + - uses: actions/download-artifact@v8 with: path: ./site/ pattern: docs-site-* diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml index f23b962b70..7e7cbc68bf 100644 --- a/.github/workflows/smokeshow.yml +++ b/.github/workflows/smokeshow.yml @@ -28,7 +28,7 @@ jobs: pyproject.toml uv.lock - run: uv sync --locked --no-dev --group github-actions - - uses: actions/download-artifact@v7 + - uses: actions/download-artifact@v8 with: name: coverage-html path: htmlcov diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6046a4560d..5b139f1d12 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -107,14 +107,14 @@ jobs: run: uv pip install "git+https://github.com/Kludex/starlette@main" - run: mkdir coverage - name: Test - run: uv run --no-sync bash scripts/test.sh + run: uv run --no-sync bash scripts/test-cov.sh env: COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} # Do not store coverage for all possible combinations to avoid file size max errors in Smokeshow - name: Store coverage files if: matrix.coverage == 'coverage' - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v7 with: name: coverage-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/coverage/.coverage.*') }} path: coverage @@ -176,7 +176,7 @@ jobs: - name: Install Dependencies run: uv sync --locked --no-dev --group tests --extra all - name: Get coverage files - uses: actions/download-artifact@v7 + uses: actions/download-artifact@v8 with: pattern: coverage-* path: coverage @@ -185,7 +185,7 @@ jobs: - run: uv run coverage combine coverage - run: uv run coverage html --title "Coverage for ${{ github.sha }}" - name: Store coverage HTML - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v7 with: name: coverage-html path: htmlcov diff --git a/README.md b/README.md index 16d149f8fe..9d7796ba30 100644 --- a/README.md +++ b/README.md @@ -5,25 +5,25 @@ FastAPI framework, high performance, easy to learn, fast to code, ready for production
--- -**Documentation**: https://fastapi.tiangolo.com +**Documentation**: [https://fastapi.tiangolo.com](https://fastapi.tiangolo.com) -**Source Code**: https://github.com/fastapi/fastapi +**Source Code**: [https://github.com/fastapi/fastapi](https://github.com/fastapi/fastapi) --- @@ -38,7 +38,7 @@ The key features are: * **Easy**: Designed to be easy to use and learn. Less time reading docs. * **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs. * **Robust**: Get production-ready code. With automatic interactive documentation. -* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema. +* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: [OpenAPI](https://github.com/OAI/OpenAPI-Specification) (previously known as Swagger) and [JSON Schema](https://json-schema.org/). * estimation based on tests conducted by an internal development team, building production applications. @@ -72,37 +72,37 @@ The key features are: -Other sponsors +[Other sponsors](https://fastapi.tiangolo.com/fastapi-people/#sponsors) ## Opinions "_[...] I'm using **FastAPI** a ton these days. [...] I'm actually planning to use it for all of my team's **ML services at Microsoft**. Some of them are getting integrated into the core **Windows** product and some **Office** products._" -
+
## **Typer**, the FastAPI of CLIs
-fastapi dev main.py...email-validator - for email validation.
+* [`email-validator`](https://github.com/JoshData/python-email-validator) - for email validation.
Used by Starlette:
-* httpx - Required if you want to use the `TestClient`.
-* jinja2 - Required if you want to use the default template configuration.
-* python-multipart - Required if you want to support form "parsing", with `request.form()`.
+* [`httpx`](https://www.python-httpx.org) - Required if you want to use the `TestClient`.
+* [`jinja2`](https://jinja.palletsprojects.com) - Required if you want to use the default template configuration.
+* [`python-multipart`](https://github.com/Kludex/python-multipart) - Required if you want to support form "parsing", with `request.form()`.
Used by FastAPI:
-* uvicorn - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
+* [`uvicorn`](https://www.uvicorn.dev) - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* `fastapi-cli[standard]` - to provide the `fastapi` command.
- * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to FastAPI Cloud.
+ * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to [FastAPI Cloud](https://fastapicloud.com).
### Without `standard` Dependencies
@@ -549,13 +549,13 @@ There are some additional dependencies you might want to install.
Additional optional Pydantic dependencies:
-* pydantic-settings - for settings management.
-* pydantic-extra-types - for extra types to be used with Pydantic.
+* [`pydantic-settings`](https://docs.pydantic.dev/latest/usage/pydantic_settings/) - for settings management.
+* [`pydantic-extra-types`](https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/) - for extra types to be used with Pydantic.
Additional optional FastAPI dependencies:
-* orjson - Required if you want to use `ORJSONResponse`.
-* ujson - Required if you want to use `UJSONResponse`.
+* [`orjson`](https://github.com/ijl/orjson) - Required if you want to use `ORJSONResponse`.
+* [`ujson`](https://github.com/esnme/ultrajson) - Required if you want to use `UJSONResponse`.
## License
diff --git a/docs/de/docs/advanced/websockets.md b/docs/de/docs/advanced/websockets.md
index b1a49c5aad..22c131838e 100644
--- a/docs/de/docs/advanced/websockets.md
+++ b/docs/de/docs/advanced/websockets.md
@@ -38,13 +38,13 @@ In der Produktion hätten Sie eine der oben genannten Optionen.
Aber es ist der einfachste Weg, sich auf die Serverseite von WebSockets zu konzentrieren und ein funktionierendes Beispiel zu haben:
-{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *}
+{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *}
## Einen `websocket` erstellen { #create-a-websocket }
Erstellen Sie in Ihrer **FastAPI**-Anwendung einen `websocket`:
-{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *}
+{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *}
/// note | Technische Details
@@ -58,7 +58,7 @@ Sie könnten auch `from starlette.websockets import WebSocket` verwenden.
In Ihrer WebSocket-Route können Sie Nachrichten `await`en und Nachrichten senden.
-{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *}
+{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *}
Sie können Binär-, Text- und JSON-Daten empfangen und senden.
@@ -109,7 +109,7 @@ In WebSocket-Endpunkten können Sie Folgendes aus `fastapi` importieren und verw
Diese funktionieren auf die gleiche Weise wie für andere FastAPI-Endpunkte/*Pfadoperationen*:
-{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *}
+{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *}
/// info | Info
@@ -154,7 +154,7 @@ Damit können Sie den WebSocket verbinden und dann Nachrichten senden und empfan
Wenn eine WebSocket-Verbindung geschlossen wird, löst `await websocket.receive_text()` eine `WebSocketDisconnect`-Exception aus, die Sie dann wie in folgendem Beispiel abfangen und behandeln können.
-{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *}
+{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *}
Zum Ausprobieren:
diff --git a/docs/en/data/contributors.yml b/docs/en/data/contributors.yml
index 41115ccbd4..15721587a1 100644
--- a/docs/en/data/contributors.yml
+++ b/docs/en/data/contributors.yml
@@ -1,13 +1,18 @@
tiangolo:
login: tiangolo
- count: 871
+ count: 922
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
url: https://github.com/tiangolo
dependabot:
login: dependabot
- count: 133
+ count: 142
avatarUrl: https://avatars.githubusercontent.com/in/29110?v=4
url: https://github.com/apps/dependabot
+YuriiMotov:
+ login: YuriiMotov
+ count: 57
+ avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
+ url: https://github.com/YuriiMotov
alejsdev:
login: alejsdev
count: 53
@@ -18,11 +23,6 @@ pre-commit-ci:
count: 50
avatarUrl: https://avatars.githubusercontent.com/in/68672?v=4
url: https://github.com/apps/pre-commit-ci
-YuriiMotov:
- login: YuriiMotov
- count: 38
- avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
- url: https://github.com/YuriiMotov
github-actions:
login: github-actions
count: 26
@@ -33,16 +33,16 @@ Kludex:
count: 25
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
url: https://github.com/Kludex
+svlandeg:
+ login: svlandeg
+ count: 18
+ avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
+ url: https://github.com/svlandeg
dmontagu:
login: dmontagu
count: 17
avatarUrl: https://avatars.githubusercontent.com/u/35119617?u=540f30c937a6450812628b9592a1dfe91bbe148e&v=4
url: https://github.com/dmontagu
-svlandeg:
- login: svlandeg
- count: 17
- avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
- url: https://github.com/svlandeg
nilslindemann:
login: nilslindemann
count: 15
@@ -148,6 +148,11 @@ AlexWendland:
count: 4
avatarUrl: https://avatars.githubusercontent.com/u/3949212?u=c4c0c615e0ea33d00bfe16b779cf6ebc0f58071c&v=4
url: https://github.com/AlexWendland
+valentinDruzhinin:
+ login: valentinDruzhinin
+ count: 4
+ avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
+ url: https://github.com/valentinDruzhinin
divums:
login: divums
count: 3
@@ -283,11 +288,6 @@ hamidrasti:
count: 3
avatarUrl: https://avatars.githubusercontent.com/u/43915620?v=4
url: https://github.com/hamidrasti
-valentinDruzhinin:
- login: valentinDruzhinin
- count: 3
- avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
- url: https://github.com/valentinDruzhinin
kkinder:
login: kkinder
count: 2
@@ -521,7 +521,7 @@ s111d:
estebanx64:
login: estebanx64
count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/10840422?u=812422ae5d6a4bc5ff331c901fc54f9ab3cecf5c&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/10840422?u=2ca073ee47a625e495a9573bd374ddcd7be5ec91&v=4
url: https://github.com/estebanx64
ndimares:
login: ndimares
@@ -573,3 +573,8 @@ Taoup:
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/22348542?v=4
url: https://github.com/Taoup
+jonathan-fulton:
+ login: jonathan-fulton
+ count: 2
+ avatarUrl: https://avatars.githubusercontent.com/u/4665111?u=bda1c12e5137bd7771a6aa24d9515b87c11da150&v=4
+ url: https://github.com/jonathan-fulton
diff --git a/docs/en/data/people.yml b/docs/en/data/people.yml
index 89269ecd69..07094b9cbd 100644
--- a/docs/en/data/people.yml
+++ b/docs/en/data/people.yml
@@ -1,15 +1,15 @@
maintainers:
- login: tiangolo
- answers: 1923
+ answers: 1925
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
url: https://github.com/tiangolo
experts:
- login: tiangolo
- count: 1923
+ count: 1925
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
url: https://github.com/tiangolo
- login: YuriiMotov
- count: 1107
+ count: 1120
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
url: https://github.com/YuriiMotov
- login: github-actions
@@ -53,7 +53,7 @@ experts:
avatarUrl: https://avatars.githubusercontent.com/u/331403?v=4
url: https://github.com/phy25
- login: JavierSanchezCastro
- count: 106
+ count: 107
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
url: https://github.com/JavierSanchezCastro
- login: luzzodev
@@ -246,7 +246,7 @@ experts:
url: https://github.com/mattmess1221
last_month_experts:
- login: YuriiMotov
- count: 20
+ count: 31
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
url: https://github.com/YuriiMotov
- login: Toygarmetu
@@ -254,16 +254,20 @@ last_month_experts:
avatarUrl: https://avatars.githubusercontent.com/u/92878791?u=538530cb6d5554e71f9c28709d794db9a74d23d9&v=4
url: https://github.com/Toygarmetu
- login: JavierSanchezCastro
- count: 4
+ count: 5
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
url: https://github.com/JavierSanchezCastro
+- login: tiangolo
+ count: 3
+ avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
+ url: https://github.com/tiangolo
- login: valentinDruzhinin
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
url: https://github.com/valentinDruzhinin
three_months_experts:
- login: YuriiMotov
- count: 77
+ count: 91
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
url: https://github.com/YuriiMotov
- login: tiangolo
@@ -286,14 +290,14 @@ three_months_experts:
count: 4
avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
url: https://github.com/valentinDruzhinin
-- login: RichieB2B
- count: 3
- avatarUrl: https://avatars.githubusercontent.com/u/1461970?u=edaa57d1077705244ea5c9244f4783d94ff11f12&v=4
- url: https://github.com/RichieB2B
- login: sachinh35
count: 3
avatarUrl: https://avatars.githubusercontent.com/u/21972708?u=8560b97b8b41e175f476270b56de8a493b84f302&v=4
url: https://github.com/sachinh35
+- login: RichieB2B
+ count: 3
+ avatarUrl: https://avatars.githubusercontent.com/u/1461970?u=edaa57d1077705244ea5c9244f4783d94ff11f12&v=4
+ url: https://github.com/RichieB2B
- login: EmmanuelNiyonshuti
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/142030687?u=ab131d5ad4670280a978f489babe71c9bf9c1097&v=4
@@ -326,13 +330,9 @@ three_months_experts:
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/142113?u=bf10f10080026346b092633c380977b61cee0d9c&v=4
url: https://github.com/florentx
-- login: JunjieAraoXiong
- count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/167785867?u=b69afe090c8bf5fd73f2d23fc3a887b28f68f192&v=4
- url: https://github.com/JunjieAraoXiong
six_months_experts:
- login: YuriiMotov
- count: 150
+ count: 163
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
url: https://github.com/YuriiMotov
- login: tiangolo
@@ -348,7 +348,7 @@ six_months_experts:
avatarUrl: https://avatars.githubusercontent.com/u/155247530?u=645169bc81856b7f1bd20090ecb0171a56dcbeb4&v=4
url: https://github.com/engripaye
- login: JavierSanchezCastro
- count: 12
+ count: 13
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
url: https://github.com/JavierSanchezCastro
- login: Toygarmetu
@@ -403,14 +403,14 @@ six_months_experts:
count: 3
avatarUrl: https://avatars.githubusercontent.com/u/1482917?u=666f39197a88cfa38b8bd78d39ef04d95c948b6b&v=4
url: https://github.com/pankeshpatel
-- login: huynguyengl99
- count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/49433085?u=7b626115686c5d97a2a32a03119f5300e425cc9f&v=4
- url: https://github.com/huynguyengl99
- login: EmmanuelNiyonshuti
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/142030687?u=ab131d5ad4670280a978f489babe71c9bf9c1097&v=4
url: https://github.com/EmmanuelNiyonshuti
+- login: huynguyengl99
+ count: 2
+ avatarUrl: https://avatars.githubusercontent.com/u/49433085?u=7b626115686c5d97a2a32a03119f5300e425cc9f&v=4
+ url: https://github.com/huynguyengl99
- login: davidbrochart
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/4711805?u=d39696d995a9e02ec3613ffb2f62b20b14f92f26&v=4
@@ -469,29 +469,29 @@ six_months_experts:
url: https://github.com/profatsky
one_year_experts:
- login: YuriiMotov
- count: 906
+ count: 918
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
url: https://github.com/YuriiMotov
- login: luzzodev
- count: 62
+ count: 60
avatarUrl: https://avatars.githubusercontent.com/u/27291415?u=5607ae1ce75c5f54f09500ca854227f7bfd2033b&v=4
url: https://github.com/luzzodev
- login: tiangolo
- count: 30
+ count: 31
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
url: https://github.com/tiangolo
- login: valentinDruzhinin
count: 30
avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
url: https://github.com/valentinDruzhinin
-- login: alv2017
- count: 19
- avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
- url: https://github.com/alv2017
- login: JavierSanchezCastro
- count: 18
+ count: 19
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
url: https://github.com/JavierSanchezCastro
+- login: alv2017
+ count: 17
+ avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
+ url: https://github.com/alv2017
- login: engripaye
count: 14
avatarUrl: https://avatars.githubusercontent.com/u/155247530?u=645169bc81856b7f1bd20090ecb0171a56dcbeb4&v=4
@@ -508,6 +508,10 @@ one_year_experts:
count: 8
avatarUrl: https://avatars.githubusercontent.com/u/92878791?u=538530cb6d5554e71f9c28709d794db9a74d23d9&v=4
url: https://github.com/Toygarmetu
+- login: raceychan
+ count: 6
+ avatarUrl: https://avatars.githubusercontent.com/u/75417963?u=060c62870ec5a791765e63ac20d8885d11143786&v=4
+ url: https://github.com/raceychan
- login: yinziyan1206
count: 6
avatarUrl: https://avatars.githubusercontent.com/u/37829370?u=da44ca53aefd5c23f346fab8e9fd2e108294c179&v=4
@@ -516,10 +520,6 @@ one_year_experts:
count: 6
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
url: https://github.com/Kludex
-- login: raceychan
- count: 6
- avatarUrl: https://avatars.githubusercontent.com/u/75417963?u=060c62870ec5a791765e63ac20d8885d11143786&v=4
- url: https://github.com/raceychan
- login: ceb10n
count: 5
avatarUrl: https://avatars.githubusercontent.com/u/235213?u=edcce471814a1eba9f0cdaa4cd0de18921a940a6&v=4
@@ -588,10 +588,18 @@ one_year_experts:
count: 3
avatarUrl: https://avatars.githubusercontent.com/u/210023470?u=c25d66addf36a747bd9fab773c4a6e7b238f45d4&v=4
url: https://github.com/Jelle-tenB
-- login: jgould22
- count: 3
- avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
- url: https://github.com/jgould22
+- login: Garrett-R
+ count: 2
+ avatarUrl: https://avatars.githubusercontent.com/u/6614695?u=c128fd775002882f6e391bda5a89d1bdc5bdf45f&v=4
+ url: https://github.com/Garrett-R
+- login: TaigoFr
+ count: 2
+ avatarUrl: https://avatars.githubusercontent.com/u/17792131?u=372b27056ec82f1ae03d8b3f37ef55b04a7cfdd1&v=4
+ url: https://github.com/TaigoFr
+- login: EmmanuelNiyonshuti
+ count: 2
+ avatarUrl: https://avatars.githubusercontent.com/u/142030687?u=ab131d5ad4670280a978f489babe71c9bf9c1097&v=4
+ url: https://github.com/EmmanuelNiyonshuti
- login: stan-dot
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/56644812?u=a7dd773084f1c17c5f05019cc25a984e24873691&v=4
@@ -604,10 +612,6 @@ one_year_experts:
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/49433085?u=7b626115686c5d97a2a32a03119f5300e425cc9f&v=4
url: https://github.com/huynguyengl99
-- login: EmmanuelNiyonshuti
- count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/142030687?u=ab131d5ad4670280a978f489babe71c9bf9c1097&v=4
- url: https://github.com/EmmanuelNiyonshuti
- login: Ale-Cas
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/64859146?u=d52a6ecf8d83d2927e2ae270bdfcc83495dba8c9&v=4
@@ -704,7 +708,3 @@ one_year_experts:
count: 2
avatarUrl: https://avatars.githubusercontent.com/u/24671280?u=7ea0d9bfe46cf762594d62fd2f3c6d3813c3584c&v=4
url: https://github.com/XieJiSS
-- login: profatsky
- count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/92920843?u=81e54bb0b613c171f7cd0ab3cbb58873782c9c9c&v=4
- url: https://github.com/profatsky
diff --git a/docs/en/data/topic_repos.yml b/docs/en/data/topic_repos.yml
index a37cb6dcfd..693d08ffd5 100644
--- a/docs/en/data/topic_repos.yml
+++ b/docs/en/data/topic_repos.yml
@@ -1,191 +1,191 @@
- name: full-stack-fastapi-template
html_url: https://github.com/fastapi/full-stack-fastapi-template
- stars: 41312
+ stars: 41789
owner_login: fastapi
owner_html_url: https://github.com/fastapi
- name: Hello-Python
html_url: https://github.com/mouredev/Hello-Python
- stars: 34206
+ stars: 34587
owner_login: mouredev
owner_html_url: https://github.com/mouredev
- name: serve
html_url: https://github.com/jina-ai/serve
- stars: 21832
+ stars: 21835
owner_login: jina-ai
owner_html_url: https://github.com/jina-ai
- name: HivisionIDPhotos
html_url: https://github.com/Zeyi-Lin/HivisionIDPhotos
- stars: 20661
+ stars: 20755
owner_login: Zeyi-Lin
owner_html_url: https://github.com/Zeyi-Lin
- name: sqlmodel
html_url: https://github.com/fastapi/sqlmodel
- stars: 17567
+ stars: 17687
owner_login: fastapi
owner_html_url: https://github.com/fastapi
- name: fastapi-best-practices
html_url: https://github.com/zhanymkanov/fastapi-best-practices
- stars: 16291
+ stars: 16611
owner_login: zhanymkanov
owner_html_url: https://github.com/zhanymkanov
- name: Douyin_TikTok_Download_API
html_url: https://github.com/Evil0ctal/Douyin_TikTok_Download_API
- stars: 16132
+ stars: 16474
owner_login: Evil0ctal
owner_html_url: https://github.com/Evil0ctal
- name: SurfSense
html_url: https://github.com/MODSetter/SurfSense
- stars: 12723
+ stars: 13069
owner_login: MODSetter
owner_html_url: https://github.com/MODSetter
- name: machine-learning-zoomcamp
html_url: https://github.com/DataTalksClub/machine-learning-zoomcamp
- stars: 12575
+ stars: 12674
owner_login: DataTalksClub
owner_html_url: https://github.com/DataTalksClub
- name: fastapi_mcp
html_url: https://github.com/tadata-org/fastapi_mcp
- stars: 11478
+ stars: 11604
owner_login: tadata-org
owner_html_url: https://github.com/tadata-org
- name: awesome-fastapi
html_url: https://github.com/mjhea0/awesome-fastapi
- stars: 11018
+ stars: 11119
owner_login: mjhea0
owner_html_url: https://github.com/mjhea0
- name: XHS-Downloader
html_url: https://github.com/JoeanAmier/XHS-Downloader
- stars: 9938
+ stars: 10206
owner_login: JoeanAmier
owner_html_url: https://github.com/JoeanAmier
- name: polar
html_url: https://github.com/polarsource/polar
- stars: 9348
+ stars: 9500
owner_login: polarsource
owner_html_url: https://github.com/polarsource
- name: FastUI
html_url: https://github.com/pydantic/FastUI
- stars: 8949
+ stars: 8956
owner_login: pydantic
owner_html_url: https://github.com/pydantic
- name: FileCodeBox
html_url: https://github.com/vastsa/FileCodeBox
- stars: 8060
+ stars: 8128
owner_login: vastsa
owner_html_url: https://github.com/vastsa
- name: nonebot2
html_url: https://github.com/nonebot/nonebot2
- stars: 7311
+ stars: 7384
owner_login: nonebot
owner_html_url: https://github.com/nonebot
- name: hatchet
html_url: https://github.com/hatchet-dev/hatchet
- stars: 6479
+ stars: 6659
owner_login: hatchet-dev
owner_html_url: https://github.com/hatchet-dev
- name: fastapi-users
html_url: https://github.com/fastapi-users/fastapi-users
- stars: 5970
+ stars: 6024
owner_login: fastapi-users
owner_html_url: https://github.com/fastapi-users
- name: serge
html_url: https://github.com/serge-chat/serge
- stars: 5751
+ stars: 5746
owner_login: serge-chat
owner_html_url: https://github.com/serge-chat
- name: strawberry
html_url: https://github.com/strawberry-graphql/strawberry
- stars: 4598
+ stars: 4616
owner_login: strawberry-graphql
owner_html_url: https://github.com/strawberry-graphql
- name: devpush
html_url: https://github.com/hunvreus/devpush
- stars: 4407
+ stars: 4515
owner_login: hunvreus
owner_html_url: https://github.com/hunvreus
- name: Kokoro-FastAPI
html_url: https://github.com/remsky/Kokoro-FastAPI
- stars: 4359
+ stars: 4494
owner_login: remsky
owner_html_url: https://github.com/remsky
+- name: Yuxi-Know
+ html_url: https://github.com/xerrors/Yuxi-Know
+ stars: 4404
+ owner_login: xerrors
+ owner_html_url: https://github.com/xerrors
- name: poem
html_url: https://github.com/poem-web/poem
- stars: 4337
+ stars: 4359
owner_login: poem-web
owner_html_url: https://github.com/poem-web
- name: chatgpt-web-share
html_url: https://github.com/chatpire/chatgpt-web-share
- stars: 4279
+ stars: 4274
owner_login: chatpire
owner_html_url: https://github.com/chatpire
- name: dynaconf
html_url: https://github.com/dynaconf/dynaconf
- stars: 4244
+ stars: 4266
owner_login: dynaconf
owner_html_url: https://github.com/dynaconf
-- name: Yuxi-Know
- html_url: https://github.com/xerrors/Yuxi-Know
- stars: 4154
- owner_login: xerrors
- owner_html_url: https://github.com/xerrors
- name: atrilabs-engine
html_url: https://github.com/Atri-Labs/atrilabs-engine
- stars: 4086
+ stars: 4085
owner_login: Atri-Labs
owner_html_url: https://github.com/Atri-Labs
- name: logfire
html_url: https://github.com/pydantic/logfire
- stars: 3975
+ stars: 4050
owner_login: pydantic
owner_html_url: https://github.com/pydantic
-- name: LitServe
- html_url: https://github.com/Lightning-AI/LitServe
- stars: 3797
- owner_login: Lightning-AI
- owner_html_url: https://github.com/Lightning-AI
- name: huma
html_url: https://github.com/danielgtaylor/huma
- stars: 3785
+ stars: 3848
owner_login: danielgtaylor
owner_html_url: https://github.com/danielgtaylor
+- name: LitServe
+ html_url: https://github.com/Lightning-AI/LitServe
+ stars: 3803
+ owner_login: Lightning-AI
+ owner_html_url: https://github.com/Lightning-AI
- name: datamodel-code-generator
html_url: https://github.com/koxudaxi/datamodel-code-generator
- stars: 3731
+ stars: 3785
owner_login: koxudaxi
owner_html_url: https://github.com/koxudaxi
- name: fastapi-admin
html_url: https://github.com/fastapi-admin/fastapi-admin
- stars: 3697
+ stars: 3717
owner_login: fastapi-admin
owner_html_url: https://github.com/fastapi-admin
- name: farfalle
html_url: https://github.com/rashadphz/farfalle
- stars: 3506
+ stars: 3515
owner_login: rashadphz
owner_html_url: https://github.com/rashadphz
- name: tracecat
html_url: https://github.com/TracecatHQ/tracecat
- stars: 3458
+ stars: 3498
owner_login: TracecatHQ
owner_html_url: https://github.com/TracecatHQ
- name: mcp-context-forge
html_url: https://github.com/IBM/mcp-context-forge
- stars: 3216
+ stars: 3347
owner_login: IBM
owner_html_url: https://github.com/IBM
- name: opyrator
html_url: https://github.com/ml-tooling/opyrator
- stars: 3134
+ stars: 3139
owner_login: ml-tooling
owner_html_url: https://github.com/ml-tooling
- name: docarray
html_url: https://github.com/docarray/docarray
- stars: 3111
+ stars: 3116
owner_login: docarray
owner_html_url: https://github.com/docarray
- name: fastapi-realworld-example-app
html_url: https://github.com/nsidnev/fastapi-realworld-example-app
- stars: 3072
+ stars: 3079
owner_login: nsidnev
owner_html_url: https://github.com/nsidnev
- name: uvicorn-gunicorn-fastapi-docker
@@ -195,64 +195,64 @@
owner_html_url: https://github.com/tiangolo
- name: FastAPI-template
html_url: https://github.com/s3rius/FastAPI-template
- stars: 2728
+ stars: 2749
owner_login: s3rius
owner_html_url: https://github.com/s3rius
- name: best-of-web-python
html_url: https://github.com/ml-tooling/best-of-web-python
- stars: 2686
+ stars: 2695
owner_login: ml-tooling
owner_html_url: https://github.com/ml-tooling
-- name: YC-Killer
- html_url: https://github.com/sahibzada-allahyar/YC-Killer
- stars: 2648
- owner_login: sahibzada-allahyar
- owner_html_url: https://github.com/sahibzada-allahyar
- name: sqladmin
html_url: https://github.com/aminalaee/sqladmin
- stars: 2637
+ stars: 2674
owner_login: aminalaee
owner_html_url: https://github.com/aminalaee
+- name: YC-Killer
+ html_url: https://github.com/sahibzada-allahyar/YC-Killer
+ stars: 2665
+ owner_login: sahibzada-allahyar
+ owner_html_url: https://github.com/sahibzada-allahyar
- name: fastapi-react
html_url: https://github.com/Buuntu/fastapi-react
- stars: 2573
+ stars: 2585
owner_login: Buuntu
owner_html_url: https://github.com/Buuntu
- name: RasaGPT
html_url: https://github.com/paulpierre/RasaGPT
- stars: 2460
+ stars: 2462
owner_login: paulpierre
owner_html_url: https://github.com/paulpierre
- name: supabase-py
html_url: https://github.com/supabase/supabase-py
- stars: 2428
+ stars: 2452
owner_login: supabase
owner_html_url: https://github.com/supabase
- name: 30-Days-of-Python
html_url: https://github.com/codingforentrepreneurs/30-Days-of-Python
- stars: 2347
+ stars: 2435
owner_login: codingforentrepreneurs
owner_html_url: https://github.com/codingforentrepreneurs
+- name: NoteDiscovery
+ html_url: https://github.com/gamosoft/NoteDiscovery
+ stars: 2354
+ owner_login: gamosoft
+ owner_html_url: https://github.com/gamosoft
- name: nextpy
html_url: https://github.com/dot-agent/nextpy
- stars: 2337
+ stars: 2335
owner_login: dot-agent
owner_html_url: https://github.com/dot-agent
- name: fastapi-utils
html_url: https://github.com/fastapiutils/fastapi-utils
- stars: 2299
+ stars: 2306
owner_login: fastapiutils
owner_html_url: https://github.com/fastapiutils
- name: langserve
html_url: https://github.com/langchain-ai/langserve
- stars: 2255
+ stars: 2276
owner_login: langchain-ai
owner_html_url: https://github.com/langchain-ai
-- name: NoteDiscovery
- html_url: https://github.com/gamosoft/NoteDiscovery
- stars: 2182
- owner_login: gamosoft
- owner_html_url: https://github.com/gamosoft
- name: solara
html_url: https://github.com/widgetti/solara
stars: 2154
@@ -260,236 +260,236 @@
owner_html_url: https://github.com/widgetti
- name: mangum
html_url: https://github.com/Kludex/mangum
- stars: 2071
+ stars: 2084
owner_login: Kludex
owner_html_url: https://github.com/Kludex
- name: fastapi_best_architecture
html_url: https://github.com/fastapi-practices/fastapi_best_architecture
- stars: 2036
+ stars: 2083
owner_login: fastapi-practices
owner_html_url: https://github.com/fastapi-practices
- name: vue-fastapi-admin
html_url: https://github.com/mizhexiaoxiao/vue-fastapi-admin
- stars: 1983
+ stars: 2012
owner_login: mizhexiaoxiao
owner_html_url: https://github.com/mizhexiaoxiao
-- name: agentkit
- html_url: https://github.com/BCG-X-Official/agentkit
- stars: 1941
- owner_login: BCG-X-Official
- owner_html_url: https://github.com/BCG-X-Official
- name: fastapi-langgraph-agent-production-ready-template
html_url: https://github.com/wassim249/fastapi-langgraph-agent-production-ready-template
- stars: 1920
+ stars: 2006
owner_login: wassim249
owner_html_url: https://github.com/wassim249
+- name: agentkit
+ html_url: https://github.com/BCG-X-Official/agentkit
+ stars: 1946
+ owner_login: BCG-X-Official
+ owner_html_url: https://github.com/BCG-X-Official
+- name: slowapi
+ html_url: https://github.com/laurentS/slowapi
+ stars: 1924
+ owner_login: laurentS
+ owner_html_url: https://github.com/laurentS
- name: openapi-python-client
html_url: https://github.com/openapi-generators/openapi-python-client
- stars: 1900
+ stars: 1915
owner_login: openapi-generators
owner_html_url: https://github.com/openapi-generators
- name: manage-fastapi
html_url: https://github.com/ycd/manage-fastapi
- stars: 1894
+ stars: 1898
owner_login: ycd
owner_html_url: https://github.com/ycd
-- name: slowapi
- html_url: https://github.com/laurentS/slowapi
- stars: 1891
- owner_login: laurentS
- owner_html_url: https://github.com/laurentS
- name: piccolo
html_url: https://github.com/piccolo-orm/piccolo
- stars: 1854
+ stars: 1864
owner_login: piccolo-orm
owner_html_url: https://github.com/piccolo-orm
- name: fastapi-cache
html_url: https://github.com/long2ice/fastapi-cache
- stars: 1816
+ stars: 1837
owner_login: long2ice
owner_html_url: https://github.com/long2ice
+- name: FastAPI-boilerplate
+ html_url: https://github.com/benavlabs/FastAPI-boilerplate
+ stars: 1820
+ owner_login: benavlabs
+ owner_html_url: https://github.com/benavlabs
- name: python-week-2022
html_url: https://github.com/rochacbruno/python-week-2022
- stars: 1813
+ stars: 1811
owner_login: rochacbruno
owner_html_url: https://github.com/rochacbruno
- name: ormar
- html_url: https://github.com/collerek/ormar
- stars: 1797
- owner_login: collerek
- owner_html_url: https://github.com/collerek
-- name: FastAPI-boilerplate
- html_url: https://github.com/benavlabs/FastAPI-boilerplate
- stars: 1792
- owner_login: benavlabs
- owner_html_url: https://github.com/benavlabs
+ html_url: https://github.com/ormar-orm/ormar
+ stars: 1801
+ owner_login: ormar-orm
+ owner_html_url: https://github.com/ormar-orm
- name: termpair
html_url: https://github.com/cs01/termpair
- stars: 1727
+ stars: 1728
owner_login: cs01
owner_html_url: https://github.com/cs01
- name: fastapi-crudrouter
html_url: https://github.com/awtkns/fastapi-crudrouter
- stars: 1677
+ stars: 1682
owner_login: awtkns
owner_html_url: https://github.com/awtkns
- name: langchain-serve
html_url: https://github.com/jina-ai/langchain-serve
- stars: 1634
+ stars: 1633
owner_login: jina-ai
owner_html_url: https://github.com/jina-ai
- name: fastapi-pagination
html_url: https://github.com/uriyyo/fastapi-pagination
- stars: 1607
+ stars: 1631
owner_login: uriyyo
owner_html_url: https://github.com/uriyyo
-- name: awesome-fastapi-projects
- html_url: https://github.com/Kludex/awesome-fastapi-projects
- stars: 1592
- owner_login: Kludex
- owner_html_url: https://github.com/Kludex
- name: bracket
html_url: https://github.com/evroon/bracket
- stars: 1580
+ stars: 1619
owner_login: evroon
owner_html_url: https://github.com/evroon
+- name: awesome-fastapi-projects
+ html_url: https://github.com/Kludex/awesome-fastapi-projects
+ stars: 1596
+ owner_login: Kludex
+ owner_html_url: https://github.com/Kludex
- name: coronavirus-tracker-api
html_url: https://github.com/ExpDev07/coronavirus-tracker-api
- stars: 1570
+ stars: 1568
owner_login: ExpDev07
owner_html_url: https://github.com/ExpDev07
- name: fastapi-amis-admin
html_url: https://github.com/amisadmin/fastapi-amis-admin
- stars: 1512
+ stars: 1520
owner_login: amisadmin
owner_html_url: https://github.com/amisadmin
- name: fastcrud
html_url: https://github.com/benavlabs/fastcrud
- stars: 1471
+ stars: 1487
owner_login: benavlabs
owner_html_url: https://github.com/benavlabs
- name: fastapi-boilerplate
html_url: https://github.com/teamhide/fastapi-boilerplate
- stars: 1461
+ stars: 1465
owner_login: teamhide
owner_html_url: https://github.com/teamhide
- name: awesome-python-resources
html_url: https://github.com/DjangoEx/awesome-python-resources
- stars: 1435
+ stars: 1441
owner_login: DjangoEx
owner_html_url: https://github.com/DjangoEx
- name: prometheus-fastapi-instrumentator
html_url: https://github.com/trallnag/prometheus-fastapi-instrumentator
- stars: 1417
+ stars: 1433
owner_login: trallnag
owner_html_url: https://github.com/trallnag
- name: fastapi-code-generator
html_url: https://github.com/koxudaxi/fastapi-code-generator
- stars: 1382
+ stars: 1384
owner_login: koxudaxi
owner_html_url: https://github.com/koxudaxi
-- name: fastapi-scaff
- html_url: https://github.com/atpuxiner/fastapi-scaff
- stars: 1367
- owner_login: atpuxiner
- owner_html_url: https://github.com/atpuxiner
- name: fastapi-tutorial
html_url: https://github.com/liaogx/fastapi-tutorial
- stars: 1360
+ stars: 1365
owner_login: liaogx
owner_html_url: https://github.com/liaogx
+- name: WebRPA
+ html_url: https://github.com/pmh1314520/WebRPA
+ stars: 1354
+ owner_login: pmh1314520
+ owner_html_url: https://github.com/pmh1314520
- name: budgetml
html_url: https://github.com/ebhy/budgetml
- stars: 1343
+ stars: 1344
owner_login: ebhy
owner_html_url: https://github.com/ebhy
+- name: fastapi-scaff
+ html_url: https://github.com/atpuxiner/fastapi-scaff
+ stars: 1305
+ owner_login: atpuxiner
+ owner_html_url: https://github.com/atpuxiner
- name: bolt-python
html_url: https://github.com/slackapi/bolt-python
- stars: 1276
+ stars: 1278
owner_login: slackapi
owner_html_url: https://github.com/slackapi
- name: bedrock-chat
html_url: https://github.com/aws-samples/bedrock-chat
- stars: 1268
+ stars: 1271
owner_login: aws-samples
owner_html_url: https://github.com/aws-samples
- name: fastapi-alembic-sqlmodel-async
html_url: https://github.com/vargasjona/fastapi-alembic-sqlmodel-async
- stars: 1265
+ stars: 1269
owner_login: vargasjona
owner_html_url: https://github.com/vargasjona
- name: fastapi_production_template
html_url: https://github.com/zhanymkanov/fastapi_production_template
- stars: 1227
+ stars: 1231
owner_login: zhanymkanov
owner_html_url: https://github.com/zhanymkanov
- name: restish
html_url: https://github.com/rest-sh/restish
- stars: 1200
+ stars: 1225
owner_login: rest-sh
owner_html_url: https://github.com/rest-sh
-- name: langchain-extract
- html_url: https://github.com/langchain-ai/langchain-extract
- stars: 1183
- owner_login: langchain-ai
- owner_html_url: https://github.com/langchain-ai
-- name: odmantic
- html_url: https://github.com/art049/odmantic
- stars: 1162
- owner_login: art049
- owner_html_url: https://github.com/art049
- name: aktools
html_url: https://github.com/akfamily/aktools
- stars: 1155
+ stars: 1223
owner_login: akfamily
owner_html_url: https://github.com/akfamily
- name: RuoYi-Vue3-FastAPI
html_url: https://github.com/insistence/RuoYi-Vue3-FastAPI
- stars: 1155
+ stars: 1202
owner_login: insistence
owner_html_url: https://github.com/insistence
+- name: langchain-extract
+ html_url: https://github.com/langchain-ai/langchain-extract
+ stars: 1189
+ owner_login: langchain-ai
+ owner_html_url: https://github.com/langchain-ai
+- name: odmantic
+ html_url: https://github.com/art049/odmantic
+ stars: 1167
+ owner_login: art049
+ owner_html_url: https://github.com/art049
- name: authx
html_url: https://github.com/yezz123/authx
- stars: 1142
+ stars: 1144
owner_login: yezz123
owner_html_url: https://github.com/yezz123
-- name: SAG
- html_url: https://github.com/Zleap-AI/SAG
- stars: 1110
- owner_login: Zleap-AI
- owner_html_url: https://github.com/Zleap-AI
-- name: flock
- html_url: https://github.com/Onelevenvy/flock
- stars: 1069
- owner_login: Onelevenvy
- owner_html_url: https://github.com/Onelevenvy
-- name: fastapi-observability
- html_url: https://github.com/blueswen/fastapi-observability
- stars: 1063
- owner_login: blueswen
- owner_html_url: https://github.com/blueswen
- name: enterprise-deep-research
html_url: https://github.com/SalesforceAIResearch/enterprise-deep-research
- stars: 1061
+ stars: 1123
owner_login: SalesforceAIResearch
owner_html_url: https://github.com/SalesforceAIResearch
-- name: titiler
- html_url: https://github.com/developmentseed/titiler
- stars: 1039
- owner_login: developmentseed
- owner_html_url: https://github.com/developmentseed
+- name: SAG
+ html_url: https://github.com/Zleap-AI/SAG
+ stars: 1115
+ owner_login: Zleap-AI
+ owner_html_url: https://github.com/Zleap-AI
+- name: FileSync
+ html_url: https://github.com/polius/FileSync
+ stars: 1111
+ owner_login: polius
+ owner_html_url: https://github.com/polius
- name: every-pdf
html_url: https://github.com/DDULDDUCK/every-pdf
- stars: 1017
+ stars: 1093
owner_login: DDULDDUCK
owner_html_url: https://github.com/DDULDDUCK
-- name: autollm
- html_url: https://github.com/viddexa/autollm
- stars: 1005
- owner_login: viddexa
- owner_html_url: https://github.com/viddexa
-- name: lanarky
- html_url: https://github.com/ajndkr/lanarky
- stars: 995
- owner_login: ajndkr
- owner_html_url: https://github.com/ajndkr
+- name: fastapi-observability
+ html_url: https://github.com/blueswen/fastapi-observability
+ stars: 1079
+ owner_login: blueswen
+ owner_html_url: https://github.com/blueswen
+- name: flock
+ html_url: https://github.com/Onelevenvy/flock
+ stars: 1073
+ owner_login: Onelevenvy
+ owner_html_url: https://github.com/Onelevenvy
+- name: titiler
+ html_url: https://github.com/developmentseed/titiler
+ stars: 1060
+ owner_login: developmentseed
+ owner_html_url: https://github.com/developmentseed
diff --git a/docs/en/data/translation_reviewers.yml b/docs/en/data/translation_reviewers.yml
index 3d321818fc..73f6dc6f0d 100644
--- a/docs/en/data/translation_reviewers.yml
+++ b/docs/en/data/translation_reviewers.yml
@@ -31,7 +31,7 @@ hard-coders:
hasansezertasan:
login: hasansezertasan
count: 95
- avatarUrl: https://avatars.githubusercontent.com/u/13135006?u=99f0b0f0fc47e88e8abb337b4447357939ef93e7&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/13135006?u=d36995e41a00590da64e6204cfd112e0484ac1ca&v=4
url: https://github.com/hasansezertasan
alv2017:
login: alv2017
@@ -43,21 +43,31 @@ nazarepiedady:
count: 87
avatarUrl: https://avatars.githubusercontent.com/u/31008635?u=f69ddc4ea8bda3bdfac7aa0e2ea38de282e6ee2d&v=4
url: https://github.com/nazarepiedady
+tiangolo:
+ login: tiangolo
+ count: 82
+ avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
+ url: https://github.com/tiangolo
AlertRED:
login: AlertRED
count: 81
avatarUrl: https://avatars.githubusercontent.com/u/15695000?u=f5a4944c6df443030409c88da7d7fa0b7ead985c&v=4
url: https://github.com/AlertRED
-tiangolo:
- login: tiangolo
- count: 78
- avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
- url: https://github.com/tiangolo
Alexandrhub:
login: Alexandrhub
count: 68
avatarUrl: https://avatars.githubusercontent.com/u/119126536?u=9fc0d48f3307817bafecc5861eb2168401a6cb04&v=4
url: https://github.com/Alexandrhub
+nilslindemann:
+ login: nilslindemann
+ count: 67
+ avatarUrl: https://avatars.githubusercontent.com/u/6892179?u=1dca6a22195d6cd1ab20737c0e19a4c55d639472&v=4
+ url: https://github.com/nilslindemann
+YuriiMotov:
+ login: YuriiMotov
+ count: 65
+ avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
+ url: https://github.com/YuriiMotov
cassiobotaro:
login: cassiobotaro
count: 64
@@ -68,21 +78,11 @@ waynerv:
count: 63
avatarUrl: https://avatars.githubusercontent.com/u/39515546?u=ec35139777597cdbbbddda29bf8b9d4396b429a9&v=4
url: https://github.com/waynerv
-nilslindemann:
- login: nilslindemann
- count: 61
- avatarUrl: https://avatars.githubusercontent.com/u/6892179?u=1dca6a22195d6cd1ab20737c0e19a4c55d639472&v=4
- url: https://github.com/nilslindemann
mattwang44:
login: mattwang44
count: 61
avatarUrl: https://avatars.githubusercontent.com/u/24987826?u=58e37fb3927b9124b458945ac4c97aa0f1062d85&v=4
url: https://github.com/mattwang44
-YuriiMotov:
- login: YuriiMotov
- count: 56
- avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
- url: https://github.com/YuriiMotov
Laineyzhang55:
login: Laineyzhang55
count: 48
@@ -128,6 +128,11 @@ solomein-sv:
count: 38
avatarUrl: https://avatars.githubusercontent.com/u/46193920?u=789927ee09cfabd752d3bd554fa6baf4850d2777&v=4
url: https://github.com/solomein-sv
+mezgoodle:
+ login: mezgoodle
+ count: 38
+ avatarUrl: https://avatars.githubusercontent.com/u/41520940?u=4a9c765af688389d54296845d18b8f6cd6ddf09a&v=4
+ url: https://github.com/mezgoodle
JavierSanchezCastro:
login: JavierSanchezCastro
count: 38
@@ -138,11 +143,6 @@ alejsdev:
count: 37
avatarUrl: https://avatars.githubusercontent.com/u/90076947?u=0facffe3abf87f57a1f05fa773d1119cc5c2f6a5&v=4
url: https://github.com/alejsdev
-mezgoodle:
- login: mezgoodle
- count: 37
- avatarUrl: https://avatars.githubusercontent.com/u/41520940?u=4a9c765af688389d54296845d18b8f6cd6ddf09a&v=4
- url: https://github.com/mezgoodle
stlucasgarcia:
login: stlucasgarcia
count: 36
@@ -163,21 +163,21 @@ rjNemo:
count: 34
avatarUrl: https://avatars.githubusercontent.com/u/56785022?u=d5c3a02567c8649e146fcfc51b6060ccaf8adef8&v=4
url: https://github.com/rjNemo
-codingjenny:
- login: codingjenny
+yychanlee:
+ login: yychanlee
count: 34
avatarUrl: https://avatars.githubusercontent.com/u/103817302?u=3a042740dc0ff58615da0d8679230966fd7693e8&v=4
- url: https://github.com/codingjenny
+ url: https://github.com/yychanlee
+Vincy1230:
+ login: Vincy1230
+ count: 34
+ avatarUrl: https://avatars.githubusercontent.com/u/81342412?u=ab5e256a4077a4a91f3f9cd2115ba80780454cbe&v=4
+ url: https://github.com/Vincy1230
akarev0:
login: akarev0
count: 33
avatarUrl: https://avatars.githubusercontent.com/u/53393089?u=6e528bb4789d56af887ce6fe237bea4010885406&v=4
url: https://github.com/akarev0
-Vincy1230:
- login: Vincy1230
- count: 33
- avatarUrl: https://avatars.githubusercontent.com/u/81342412?u=ab5e256a4077a4a91f3f9cd2115ba80780454cbe&v=4
- url: https://github.com/Vincy1230
romashevchenko:
login: romashevchenko
count: 32
@@ -313,6 +313,11 @@ sattosan:
count: 19
avatarUrl: https://avatars.githubusercontent.com/u/20574756?u=b0d8474d2938189c6954423ae8d81d91013f80a8&v=4
url: https://github.com/sattosan
+maru0123-2004:
+ login: maru0123-2004
+ count: 19
+ avatarUrl: https://avatars.githubusercontent.com/u/43961566?u=16ed8603a4d6a4665cb6c53a7aece6f31379b769&v=4
+ url: https://github.com/maru0123-2004
yes0ng:
login: yes0ng
count: 19
@@ -383,11 +388,6 @@ Joao-Pedro-P-Holanda:
count: 16
avatarUrl: https://avatars.githubusercontent.com/u/110267046?u=331bd016326dac4cf3df4848f6db2dbbf8b5f978&v=4
url: https://github.com/Joao-Pedro-P-Holanda
-maru0123-2004:
- login: maru0123-2004
- count: 16
- avatarUrl: https://avatars.githubusercontent.com/u/43961566?u=16ed8603a4d6a4665cb6c53a7aece6f31379b769&v=4
- url: https://github.com/maru0123-2004
JaeHyuckSa:
login: JaeHyuckSa
count: 16
@@ -683,6 +683,11 @@ JoaoGustavoRogel:
count: 9
avatarUrl: https://avatars.githubusercontent.com/u/29525510?u=a0a91251f5e43e132608d55d28ccb8645c5ea405&v=4
url: https://github.com/JoaoGustavoRogel
+valentinDruzhinin:
+ login: valentinDruzhinin
+ count: 9
+ avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
+ url: https://github.com/valentinDruzhinin
Yarous:
login: Yarous
count: 9
@@ -738,6 +743,11 @@ sungchan1:
count: 8
avatarUrl: https://avatars.githubusercontent.com/u/28076127?u=fadbf24840186aca639d344bb3e0ecf7ff3441cf&v=4
url: https://github.com/sungchan1
+roli2py:
+ login: roli2py
+ count: 8
+ avatarUrl: https://avatars.githubusercontent.com/u/61126128?u=bcb7a286e435a6b9d6a84b07db1232580ee796d4&v=4
+ url: https://github.com/roli2py
Serrones:
login: Serrones
count: 7
@@ -783,11 +793,6 @@ d2a-raudenaerde:
count: 7
avatarUrl: https://avatars.githubusercontent.com/u/5213150?u=e6d0ef65c571c7e544fc1c7ec151c7c0a72fb6bb&v=4
url: https://github.com/d2a-raudenaerde
-valentinDruzhinin:
- login: valentinDruzhinin
- count: 7
- avatarUrl: https://avatars.githubusercontent.com/u/12831905?u=aae1ebc675c91e8fa582df4fcc4fc4128106344d&v=4
- url: https://github.com/valentinDruzhinin
Zerohertz:
login: Zerohertz
count: 7
@@ -1271,7 +1276,7 @@ rafsaf:
frnsimoes:
login: frnsimoes
count: 3
- avatarUrl: https://avatars.githubusercontent.com/u/66239468?u=cba345870d8d6b25dd6d56ee18f7120581e3c573&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/66239468?u=98fb2a38bcac765ea9651af8a0ab8f37df86570d&v=4
url: https://github.com/frnsimoes
lieryan:
login: lieryan
@@ -1371,7 +1376,7 @@ nymous:
EpsilonRationes:
login: EpsilonRationes
count: 3
- avatarUrl: https://avatars.githubusercontent.com/u/148639079?v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/148639079?u=5dd6c4a3f570dea44d208465fd10b709bcdfa69a&v=4
url: https://github.com/EpsilonRationes
SametEmin:
login: SametEmin
@@ -1611,7 +1616,7 @@ raphaelauv:
Fahad-Md-Kamal:
login: Fahad-Md-Kamal
count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/34704464?u=141086368c5557d5a1a533fe291f21f9fc584458&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/34704464?u=0b1da22a9b88b14d99e7e4368eadde7ecd695366&v=4
url: https://github.com/Fahad-Md-Kamal
zxcq544:
login: zxcq544
diff --git a/docs/en/data/translators.yml b/docs/en/data/translators.yml
index dd5900a417..38a3306dc4 100644
--- a/docs/en/data/translators.yml
+++ b/docs/en/data/translators.yml
@@ -10,7 +10,7 @@ jaystone776:
url: https://github.com/jaystone776
tiangolo:
login: tiangolo
- count: 31
+ count: 46
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
url: https://github.com/tiangolo
ceb10n:
@@ -33,10 +33,15 @@ SwftAlpc:
count: 23
avatarUrl: https://avatars.githubusercontent.com/u/52768429?u=6a3aa15277406520ad37f6236e89466ed44bc5b8&v=4
url: https://github.com/SwftAlpc
+YuriiMotov:
+ login: YuriiMotov
+ count: 23
+ avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
+ url: https://github.com/YuriiMotov
hasansezertasan:
login: hasansezertasan
count: 22
- avatarUrl: https://avatars.githubusercontent.com/u/13135006?u=99f0b0f0fc47e88e8abb337b4447357939ef93e7&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/13135006?u=d36995e41a00590da64e6204cfd112e0484ac1ca&v=4
url: https://github.com/hasansezertasan
waynerv:
login: waynerv
@@ -58,11 +63,11 @@ Joao-Pedro-P-Holanda:
count: 14
avatarUrl: https://avatars.githubusercontent.com/u/110267046?u=331bd016326dac4cf3df4848f6db2dbbf8b5f978&v=4
url: https://github.com/Joao-Pedro-P-Holanda
-codingjenny:
- login: codingjenny
+yychanlee:
+ login: yychanlee
count: 14
avatarUrl: https://avatars.githubusercontent.com/u/103817302?u=3a042740dc0ff58615da0d8679230966fd7693e8&v=4
- url: https://github.com/codingjenny
+ url: https://github.com/yychanlee
Xewus:
login: Xewus
count: 13
@@ -108,11 +113,6 @@ pablocm83:
count: 8
avatarUrl: https://avatars.githubusercontent.com/u/28315068?u=3310fbb05bb8bfc50d2c48b6cb64ac9ee4a14549&v=4
url: https://github.com/pablocm83
-YuriiMotov:
- login: YuriiMotov
- count: 8
- avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=bc48be95c429989224786106b027f3c5e40cc354&v=4
- url: https://github.com/YuriiMotov
ptt3199:
login: ptt3199
count: 7
@@ -466,7 +466,7 @@ ArtemKhymenko:
hasnatsajid:
login: hasnatsajid
count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/86589885?v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/86589885?u=3712c0362d7a4000d76022339c545cf46aa5903f&v=4
url: https://github.com/hasnatsajid
alperiox:
login: alperiox
@@ -481,7 +481,7 @@ emrhnsyts:
vusallyv:
login: vusallyv
count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/85983771?u=6fb8e2f876bca06e9f846606423c8f18fb46ad06&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/85983771?u=620ce103dcdc47953c952bb8d402a9cf8199014d&v=4
url: https://github.com/vusallyv
jackleeio:
login: jackleeio
@@ -496,7 +496,7 @@ choi-haram:
imtiaz101325:
login: imtiaz101325
count: 2
- avatarUrl: https://avatars.githubusercontent.com/u/54007087?u=194d972b501b9ea9d2ddeaed757c492936e0121a&v=4
+ avatarUrl: https://avatars.githubusercontent.com/u/54007087?u=61e79c4c39798cd4d339788045dc44d4c6252bde&v=4
url: https://github.com/imtiaz101325
fabianfalon:
login: fabianfalon
diff --git a/docs/en/docs/_llm-test.md b/docs/en/docs/_llm-test.md
index ff0e24f26c..cc9cb48fba 100644
--- a/docs/en/docs/_llm-test.md
+++ b/docs/en/docs/_llm-test.md
@@ -11,7 +11,7 @@ Use as follows:
* Check if things are okay in the translation.
* If necessary, improve your language specific prompt, the general prompt, or the English document.
* Then manually fix the remaining issues in the translation, so that it is a good translation.
-* Retranslate, having the good translation in place. The ideal result would be that the LLM makes no changes anymore to the translation. That means that the general prompt and your language specific prompt are as good as they can be (It will sometimes make a few seemingly random changes, the reason is that LLMs are not deterministic algorithms).
+* Retranslate, having the good translation in place. The ideal result would be that the LLM makes no changes anymore to the translation. That means that the general prompt and your language specific prompt are as good as they can be (It will sometimes make a few seemingly random changes, the reason is that [LLMs are not deterministic algorithms](https://doublespeak.chat/#/handbook#deterministic-output)).
The tests:
@@ -166,18 +166,18 @@ See sections `### Special blocks` and `### Tab blocks` in the general prompt in
//// tab | Test
-The link text should get translated, the link address should remain unchaged:
+The link text should get translated, the link address should remain unchanged:
* [Link to heading above](#code-snippets)
-* [Internal link](index.md#installation){.internal-link target=_blank}
-* External link
-* Link to a style
-* Link to a script
-* Link to an image
+* [Internal link](index.md#installation)
+* [External link](https://sqlmodel.tiangolo.com/)
+* [Link to a style](https://fastapi.tiangolo.com/css/styles.css)
+* [Link to a script](https://fastapi.tiangolo.com/js/logic.js)
+* [Link to an image](https://fastapi.tiangolo.com/img/foo.jpg)
The link text should get translated, the link address should point to the translation:
-* FastAPI link
+* [FastAPI link](https://fastapi.tiangolo.com/)
////
diff --git a/docs/en/docs/advanced/additional-responses.md b/docs/en/docs/advanced/additional-responses.md
index 6306bd1f9a..577c06daa5 100644
--- a/docs/en/docs/advanced/additional-responses.md
+++ b/docs/en/docs/advanced/additional-responses.md
@@ -243,5 +243,5 @@ For example:
To see what exactly you can include in the responses, you can check these sections in the OpenAPI specification:
-* OpenAPI Responses Object, it includes the `Response Object`.
-* OpenAPI Response Object, you can include anything from this directly in each response inside your `responses` parameter. Including `description`, `headers`, `content` (inside of this is that you declare different media types and JSON Schemas), and `links`.
+* [OpenAPI Responses Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responses-object), it includes the `Response Object`.
+* [OpenAPI Response Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#response-object), you can include anything from this directly in each response inside your `responses` parameter. Including `description`, `headers`, `content` (inside of this is that you declare different media types and JSON Schemas), and `links`.
diff --git a/docs/en/docs/advanced/additional-status-codes.md b/docs/en/docs/advanced/additional-status-codes.md
index 23bcd13c32..3b6da23557 100644
--- a/docs/en/docs/advanced/additional-status-codes.md
+++ b/docs/en/docs/advanced/additional-status-codes.md
@@ -38,4 +38,4 @@ You could also use `from starlette.responses import JSONResponse`.
If you return additional status codes and responses directly, they won't be included in the OpenAPI schema (the API docs), because FastAPI doesn't have a way to know beforehand what you are going to return.
-But you can document that in your code, using: [Additional Responses](additional-responses.md){.internal-link target=_blank}.
+But you can document that in your code, using: [Additional Responses](additional-responses.md).
diff --git a/docs/en/docs/advanced/advanced-dependencies.md b/docs/en/docs/advanced/advanced-dependencies.md
index 3a23a6d1ad..6c940f5a9b 100644
--- a/docs/en/docs/advanced/advanced-dependencies.md
+++ b/docs/en/docs/advanced/advanced-dependencies.md
@@ -132,7 +132,7 @@ If you have this specific use case using SQLModel (or SQLAlchemy), you could exp
That way the session would release the database connection, so other requests could use it.
-If you have a different use case that needs to exit early from a dependency with `yield`, please create a GitHub Discussion Question with your specific use case and why you would benefit from having early closing for dependencies with `yield`.
+If you have a different use case that needs to exit early from a dependency with `yield`, please create a [GitHub Discussion Question](https://github.com/fastapi/fastapi/discussions/new?category=questions) with your specific use case and why you would benefit from having early closing for dependencies with `yield`.
If there are compelling use cases for early closing in dependencies with `yield`, I would consider adding a new way to opt in to early closing.
@@ -144,7 +144,7 @@ This was changed in version 0.110.0 to fix unhandled memory consumption from for
### Background Tasks and Dependencies with `yield`, Technical Details { #background-tasks-and-dependencies-with-yield-technical-details }
-Before FastAPI 0.106.0, raising exceptions after `yield` was not possible, the exit code in dependencies with `yield` was executed *after* the response was sent, so [Exception Handlers](../tutorial/handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank} would have already run.
+Before FastAPI 0.106.0, raising exceptions after `yield` was not possible, the exit code in dependencies with `yield` was executed *after* the response was sent, so [Exception Handlers](../tutorial/handling-errors.md#install-custom-exception-handlers) would have already run.
This was designed this way mainly to allow using the same objects "yielded" by dependencies inside of background tasks, because the exit code would be executed after the background tasks were finished.
diff --git a/docs/en/docs/advanced/async-tests.md b/docs/en/docs/advanced/async-tests.md
index cefb1d1841..c7ec5e9e29 100644
--- a/docs/en/docs/advanced/async-tests.md
+++ b/docs/en/docs/advanced/async-tests.md
@@ -16,11 +16,11 @@ Even if your **FastAPI** application uses normal `def` functions instead of `asy
The `TestClient` does some magic inside to call the asynchronous FastAPI application in your normal `def` test functions, using standard pytest. But that magic doesn't work anymore when we're using it inside asynchronous functions. By running our tests asynchronously, we can no longer use the `TestClient` inside our test functions.
-The `TestClient` is based on HTTPX, and luckily, we can use it directly to test the API.
+The `TestClient` is based on [HTTPX](https://www.python-httpx.org), and luckily, we can use it directly to test the API.
## Example { #example }
-For a simple example, let's consider a file structure similar to the one described in [Bigger Applications](../tutorial/bigger-applications.md){.internal-link target=_blank} and [Testing](../tutorial/testing.md){.internal-link target=_blank}:
+For a simple example, let's consider a file structure similar to the one described in [Bigger Applications](../tutorial/bigger-applications.md) and [Testing](../tutorial/testing.md):
```
.
@@ -84,7 +84,7 @@ Note that we're using async/await with the new `AsyncClient` - the request is as
/// warning
-If your application relies on lifespan events, the `AsyncClient` won't trigger these events. To ensure they are triggered, use `LifespanManager` from florimondmanca/asgi-lifespan.
+If your application relies on lifespan events, the `AsyncClient` won't trigger these events. To ensure they are triggered, use `LifespanManager` from [florimondmanca/asgi-lifespan](https://github.com/florimondmanca/asgi-lifespan#usage).
///
@@ -94,6 +94,6 @@ As the testing function is now asynchronous, you can now also call (and `await`)
/// tip
-If you encounter a `RuntimeError: Task attached to a different loop` when integrating asynchronous function calls in your tests (e.g. when using MongoDB's MotorClient), remember to instantiate objects that need an event loop only within async functions, e.g. an `@app.on_event("startup")` callback.
+If you encounter a `RuntimeError: Task attached to a different loop` when integrating asynchronous function calls in your tests (e.g. when using [MongoDB's MotorClient](https://stackoverflow.com/questions/41584243/runtimeerror-task-attached-to-a-different-loop)), remember to instantiate objects that need an event loop only within async functions, e.g. an `@app.on_event("startup")` callback.
///
diff --git a/docs/en/docs/advanced/behind-a-proxy.md b/docs/en/docs/advanced/behind-a-proxy.md
index 707efe54d6..e510e2cf3d 100644
--- a/docs/en/docs/advanced/behind-a-proxy.md
+++ b/docs/en/docs/advanced/behind-a-proxy.md
@@ -16,9 +16,9 @@ But for security, as the server doesn't know it is behind a trusted proxy, it wo
The proxy headers are:
-* X-Forwarded-For
-* X-Forwarded-Proto
-* X-Forwarded-Host
+* [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For)
+* [X-Forwarded-Proto](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Proto)
+* [X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Host)
///
@@ -69,7 +69,7 @@ https://mysuperapp.com/items/
/// tip
-If you want to learn more about HTTPS, check the guide [About HTTPS](../deployment/https.md){.internal-link target=_blank}.
+If you want to learn more about HTTPS, check the guide [About HTTPS](../deployment/https.md).
///
@@ -108,9 +108,9 @@ When **FastAPI CLI** is configured with `--forwarded-allow-ips`, it trusts these
## Testing locally with Traefik { #testing-locally-with-traefik }
-You can easily run the configuration with reverse proxy and ASGI application behind it locally using Traefik.
+You can easily run the configuration with reverse proxy and ASGI application behind it locally using [https://docs.traefik.io/](Traefik).
-Download Traefik, it's a single binary, you can extract the compressed file and run it directly from the terminal.
+[https://github.com/containous/traefik/releases](Download Traefik), it's a single binary, you can extract the compressed file and run it directly from the terminal.
Then create a file `traefik.toml` with:
@@ -411,7 +411,7 @@ Let's now use the following app:
{* ../../docs_src/behind_a_proxy/tutorial001_py310.py *}
-If your proxy removes the prefix before forwarding requests (like in Traefik configuration from [Stripping the prefix](#stripping-the-prefix){.internal-link target=_blank}), you should use the `--root-path` option of your ASGI server:
+If your proxy removes the prefix before forwarding requests (like in Traefik configuration from [Stripping the prefix](#stripping-the-prefix)), you should use the `--root-path` option of your ASGI server:
@@ -765,6 +765,6 @@ and then it won't include it in the OpenAPI schema.
## Mounting a sub-application { #mounting-a-sub-application }
-If you need to mount a sub-application (as described in [Sub Applications - Mounts](sub-applications.md){.internal-link target=_blank}) while also using a proxy with `root_path`, you can do it normally, as you would expect.
+If you need to mount a sub-application (as described in [Sub Applications - Mounts](sub-applications.md)) while also using a proxy with `root_path`, you can do it normally, as you would expect.
FastAPI will internally use the `root_path` smartly, so it will just work. ✨
diff --git a/docs/en/docs/advanced/custom-response.md b/docs/en/docs/advanced/custom-response.md
index e88e958657..0dcb575176 100644
--- a/docs/en/docs/advanced/custom-response.md
+++ b/docs/en/docs/advanced/custom-response.md
@@ -2,7 +2,7 @@
By default, **FastAPI** will return JSON responses.
-You can override it by returning a `Response` directly as seen in [Return a Response directly](response-directly.md){.internal-link target=_blank}.
+You can override it by returning a `Response` directly as seen in [Return a Response directly](response-directly.md).
But if you return a `Response` directly (or any subclass, like `JSONResponse`), the data won't be automatically converted (even if you declare a `response_model`), and the documentation won't be automatically generated (for example, including the specific "media type", in the HTTP header `Content-Type` as part of the generated OpenAPI).
@@ -20,15 +20,15 @@ If you use a response class with no media type, FastAPI will expect your respons
By default FastAPI returns JSON responses.
-If you declare a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} FastAPI will use it to serialize the data to JSON, using Pydantic.
+If you declare a [Response Model](../tutorial/response-model.md) FastAPI will use it to serialize the data to JSON, using Pydantic.
-If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank} and put it in a `JSONResponse`.
+If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md) and put it in a `JSONResponse`.
If you declare a `response_class` with a JSON media type (`application/json`), like is the case with the `JSONResponse`, the data you return will be automatically converted (and filtered) with any Pydantic `response_model` that you declared in the *path operation decorator*. But the data won't be serialized to JSON bytes with Pydantic, instead it will be converted with the `jsonable_encoder` and then passed to the `JSONResponse` class, which will serialize it to bytes using the standard JSON library in Python.
### JSON Performance { #json-performance }
-In short, if you want the maximum performance, use a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} and don't declare a `response_class` in the *path operation decorator*.
+In short, if you want the maximum performance, use a [Response Model](../tutorial/response-model.md) and don't declare a `response_class` in the *path operation decorator*.
{* ../../docs_src/response_model/tutorial001_01_py310.py ln[15:17] hl[16] *}
@@ -53,7 +53,7 @@ And it will be documented as such in OpenAPI.
### Return a `Response` { #return-a-response }
-As seen in [Return a Response directly](response-directly.md){.internal-link target=_blank}, you can also override the response directly in your *path operation*, by returning it.
+As seen in [Return a Response directly](response-directly.md), you can also override the response directly in your *path operation*, by returning it.
The same example from above, returning an `HTMLResponse`, could look like:
@@ -138,6 +138,14 @@ Takes some data and returns an `application/json` encoded response.
This is the default response used in **FastAPI**, as you read above.
+/// note | Technical Details
+
+But if you declare a response model or return type, that will be used directly to serialize the data to JSON, and a response with the right media type for JSON will be returned directly, without using the `JSONResponse` class.
+
+This is the ideal way to get the best performance.
+
+///
+
### `RedirectResponse` { #redirectresponse }
Returns an HTTP redirect. Uses a 307 status code (Temporary Redirect) by default.
@@ -165,31 +173,25 @@ You can also use the `status_code` parameter combined with the `response_class`
### `StreamingResponse` { #streamingresponse }
-Takes an async generator or a normal generator/iterator and streams the response body.
+Takes an async generator or a normal generator/iterator (a function with `yield`) and streams the response body.
-{* ../../docs_src/custom_response/tutorial007_py310.py hl[2,14] *}
+{* ../../docs_src/custom_response/tutorial007_py310.py hl[3,16] *}
-#### Using `StreamingResponse` with file-like objects { #using-streamingresponse-with-file-like-objects }
+/// note | Technical Details
-If you have a file-like object (e.g. the object returned by `open()`), you can create a generator function to iterate over that file-like object.
+An `async` task can only be cancelled when it reaches an `await`. If there is no `await`, the generator (function with `yield`) can not be cancelled properly and may keep running even after cancellation is requested.
-That way, you don't have to read it all first in memory, and you can pass that generator function to the `StreamingResponse`, and return it.
+Since this small example does not need any `await` statements, we add an `await anyio.sleep(0)` to give the event loop a chance to handle cancellation.
-This includes many libraries to interact with cloud storage, video processing, and others.
+This would be even more important with large or infinite streams.
-{* ../../docs_src/custom_response/tutorial008_py310.py hl[2,10:12,14] *}
-
-1. This is the generator function. It's a "generator function" because it contains `yield` statements inside.
-2. By using a `with` block, we make sure that the file-like object is closed after the generator function is done. So, after it finishes sending the response.
-3. This `yield from` tells the function to iterate over that thing named `file_like`. And then, for each part iterated, yield that part as coming from this generator function (`iterfile`).
-
- So, it is a generator function that transfers the "generating" work to something else internally.
-
- By doing it this way, we can put it in a `with` block, and that way, ensure that the file-like object is closed after finishing.
+///
/// tip
-Notice that here as we are using standard `open()` that doesn't support `async` and `await`, we declare the path operation with normal `def`.
+Instead of returning a `StreamingResponse` directly, you should probably follow the style in [Stream Data](./stream-data.md), it's much more convenient and handles cancellation behind the scenes for you.
+
+If you are streaming JSON Lines, follow the [Stream JSON Lines](../tutorial/stream-json-lines.md) tutorial.
///
@@ -218,7 +220,7 @@ In this case, you can return the file path directly from your *path operation* f
You can create your own custom response class, inheriting from `Response` and using it.
-For example, let's say that you want to use `orjson` with some settings.
+For example, let's say that you want to use [`orjson`](https://github.com/ijl/orjson) with some settings.
Let's say you want it to return indented and formatted JSON, so you want to use the orjson option `orjson.OPT_INDENT_2`.
@@ -244,7 +246,7 @@ Of course, you will probably find much better ways to take advantage of this tha
### `orjson` or Response Model { #orjson-or-response-model }
-If what you are looking for is performance, you are probably better off using a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} than an `orjson` response.
+If what you are looking for is performance, you are probably better off using a [Response Model](../tutorial/response-model.md) than an `orjson` response.
With a response model, FastAPI will use Pydantic to serialize the data to JSON, without using intermediate steps, like converting it with `jsonable_encoder`, which would happen in any other case.
@@ -268,4 +270,4 @@ You can still override `response_class` in *path operations* as before.
## Additional documentation { #additional-documentation }
-You can also declare the media type and many other details in OpenAPI using `responses`: [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+You can also declare the media type and many other details in OpenAPI using `responses`: [Additional Responses in OpenAPI](additional-responses.md).
diff --git a/docs/en/docs/advanced/dataclasses.md b/docs/en/docs/advanced/dataclasses.md
index be85303bfb..52fe4ae7c8 100644
--- a/docs/en/docs/advanced/dataclasses.md
+++ b/docs/en/docs/advanced/dataclasses.md
@@ -2,11 +2,11 @@
FastAPI is built on top of **Pydantic**, and I have been showing you how to use Pydantic models to declare requests and responses.
-But FastAPI also supports using `dataclasses` the same way:
+But FastAPI also supports using [`dataclasses`](https://docs.python.org/3/library/dataclasses.html) the same way:
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
-This is still supported thanks to **Pydantic**, as it has internal support for `dataclasses`.
+This is still supported thanks to **Pydantic**, as it has [internal support for `dataclasses`](https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel).
So, even with the code above that doesn't use Pydantic explicitly, FastAPI is using Pydantic to convert those standard dataclasses to Pydantic's own flavor of dataclasses.
@@ -74,7 +74,7 @@ In that case, you can simply swap the standard `dataclasses` with `pydantic.data
As always, in FastAPI you can combine `def` and `async def` as needed.
- If you need a refresher about when to use which, check out the section _"In a hurry?"_ in the docs about [`async` and `await`](../async.md#in-a-hurry){.internal-link target=_blank}.
+ If you need a refresher about when to use which, check out the section _"In a hurry?"_ in the docs about [`async` and `await`](../async.md#in-a-hurry).
9. This *path operation function* is not returning dataclasses (although it could), but a list of dictionaries with internal data.
@@ -88,7 +88,7 @@ Check the in-code annotation tips above to see more specific details.
You can also combine `dataclasses` with other Pydantic models, inherit from them, include them in your own models, etc.
-To learn more, check the Pydantic docs about dataclasses.
+To learn more, check the [Pydantic docs about dataclasses](https://docs.pydantic.dev/latest/concepts/dataclasses/).
## Version { #version }
diff --git a/docs/en/docs/advanced/events.md b/docs/en/docs/advanced/events.md
index 302e963251..820f06d55b 100644
--- a/docs/en/docs/advanced/events.md
+++ b/docs/en/docs/advanced/events.md
@@ -150,11 +150,11 @@ Because of that, it's now recommended to instead use the `lifespan` as explained
Just a technical detail for the curious nerds. 🤓
-Underneath, in the ASGI technical specification, this is part of the Lifespan Protocol, and it defines events called `startup` and `shutdown`.
+Underneath, in the ASGI technical specification, this is part of the [Lifespan Protocol](https://asgi.readthedocs.io/en/latest/specs/lifespan.html), and it defines events called `startup` and `shutdown`.
/// info
-You can read more about the Starlette `lifespan` handlers in Starlette's Lifespan' docs.
+You can read more about the Starlette `lifespan` handlers in [Starlette's Lifespan' docs](https://www.starlette.dev/lifespan/).
Including how to handle lifespan state that can be used in other areas of your code.
@@ -162,4 +162,4 @@ Including how to handle lifespan state that can be used in other areas of your c
## Sub Applications { #sub-applications }
-🚨 Keep in mind that these lifespan events (startup and shutdown) will only be executed for the main application, not for [Sub Applications - Mounts](sub-applications.md){.internal-link target=_blank}.
+🚨 Keep in mind that these lifespan events (startup and shutdown) will only be executed for the main application, not for [Sub Applications - Mounts](sub-applications.md).
diff --git a/docs/en/docs/advanced/generate-clients.md b/docs/en/docs/advanced/generate-clients.md
index 1e6173c9ae..9e0abaacc3 100644
--- a/docs/en/docs/advanced/generate-clients.md
+++ b/docs/en/docs/advanced/generate-clients.md
@@ -8,11 +8,11 @@ In this guide, you'll learn how to generate a **TypeScript SDK** for your FastAP
## Open Source SDK Generators { #open-source-sdk-generators }
-A versatile option is the OpenAPI Generator, which supports **many programming languages** and can generate SDKs from your OpenAPI specification.
+A versatile option is the [OpenAPI Generator](https://openapi-generator.tech/), which supports **many programming languages** and can generate SDKs from your OpenAPI specification.
-For **TypeScript clients**, Hey API is a purpose-built solution, providing an optimized experience for the TypeScript ecosystem.
+For **TypeScript clients**, [Hey API](https://heyapi.dev/) is a purpose-built solution, providing an optimized experience for the TypeScript ecosystem.
-You can discover more SDK generators on OpenAPI.Tools.
+You can discover more SDK generators on [OpenAPI.Tools](https://openapi.tools/#sdk).
/// tip
@@ -24,15 +24,15 @@ FastAPI automatically generates **OpenAPI 3.1** specifications, so any tool you
This section highlights **venture-backed** and **company-supported** solutions from companies that sponsor FastAPI. These products provide **additional features** and **integrations** on top of high-quality generated SDKs.
-By ✨ [**sponsoring FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨, these companies help ensure the framework and its **ecosystem** remain healthy and **sustainable**.
+By ✨ [**sponsoring FastAPI**](../help-fastapi.md#sponsor-the-author) ✨, these companies help ensure the framework and its **ecosystem** remain healthy and **sustainable**.
Their sponsorship also demonstrates a strong commitment to the FastAPI **community** (you), showing that they care not only about offering a **great service** but also about supporting a **robust and thriving framework**, FastAPI. 🙇
For example, you might want to try:
-* Speakeasy
-* Stainless
-* liblab
+* [Speakeasy](https://speakeasy.com/editor?utm_source=fastapi+repo&utm_medium=github+sponsorship)
+* [Stainless](https://www.stainless.com/?utm_source=fastapi&utm_medium=referral)
+* [liblab](https://developers.liblab.com/tutorials/sdk-for-fastapi?utm_source=fastapi)
Some of these solutions may also be open source or offer free tiers, so you can try them without a financial commitment. Other commercial SDK generators are available and can be found online. 🤓
@@ -66,7 +66,7 @@ npx @hey-api/openapi-ts -i http://localhost:8000/openapi.json -o src/client
This will generate a TypeScript SDK in `./src/client`.
-You can learn how to install `@hey-api/openapi-ts` and read about the generated output on their website.
+You can learn how to [install `@hey-api/openapi-ts`](https://heyapi.dev/openapi-ts/get-started) and read about the [generated output](https://heyapi.dev/openapi-ts/output) on their website.
### Using the SDK { #using-the-sdk }
diff --git a/docs/en/docs/advanced/index.md b/docs/en/docs/advanced/index.md
index 9355516fb4..c8056ab54f 100644
--- a/docs/en/docs/advanced/index.md
+++ b/docs/en/docs/advanced/index.md
@@ -2,7 +2,7 @@
## Additional Features { #additional-features }
-The main [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank} should be enough to give you a tour through all the main features of **FastAPI**.
+The main [Tutorial - User Guide](../tutorial/index.md) should be enough to give you a tour through all the main features of **FastAPI**.
In the next sections you will see other options, configurations, and additional features.
@@ -16,6 +16,6 @@ And it's possible that for your use case, the solution is in one of them.
## Read the Tutorial first { #read-the-tutorial-first }
-You could still use most of the features in **FastAPI** with the knowledge from the main [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank}.
+You could still use most of the features in **FastAPI** with the knowledge from the main [Tutorial - User Guide](../tutorial/index.md).
And the next sections assume you already read it, and assume that you know those main ideas.
diff --git a/docs/en/docs/advanced/json-base64-bytes.md b/docs/en/docs/advanced/json-base64-bytes.md
index c0dfec72b9..9f0602c54f 100644
--- a/docs/en/docs/advanced/json-base64-bytes.md
+++ b/docs/en/docs/advanced/json-base64-bytes.md
@@ -4,7 +4,7 @@ If your app needs to receive and send JSON data, but you need to include binary
## Base64 vs Files { #base64-vs-files }
-Consider first if you can use [Request Files](../tutorial/request-files.md){.internal-link target=_blank} for uploading binary data and [Custom Response - FileResponse](./custom-response.md#fileresponse--fileresponse-){.internal-link target=_blank} for sending binary data, instead of encoding it in JSON.
+Consider first if you can use [Request Files](../tutorial/request-files.md) for uploading binary data and [Custom Response - FileResponse](./custom-response.md#fileresponse--fileresponse-) for sending binary data, instead of encoding it in JSON.
JSON can only contain UTF-8 encoded strings, so it can't contain raw bytes.
diff --git a/docs/en/docs/advanced/middleware.md b/docs/en/docs/advanced/middleware.md
index b448f5c520..65f9438c95 100644
--- a/docs/en/docs/advanced/middleware.md
+++ b/docs/en/docs/advanced/middleware.md
@@ -1,8 +1,8 @@
# Advanced Middleware { #advanced-middleware }
-In the main tutorial you read how to add [Custom Middleware](../tutorial/middleware.md){.internal-link target=_blank} to your application.
+In the main tutorial you read how to add [Custom Middleware](../tutorial/middleware.md) to your application.
-And then you also read how to handle [CORS with the `CORSMiddleware`](../tutorial/cors.md){.internal-link target=_blank}.
+And then you also read how to handle [CORS with the `CORSMiddleware`](../tutorial/cors.md).
In this section we'll see how to use other middlewares.
@@ -91,7 +91,7 @@ There are many other ASGI middlewares.
For example:
-* Uvicorn's `ProxyHeadersMiddleware`
-* MessagePack
+* [Uvicorn's `ProxyHeadersMiddleware`](https://github.com/encode/uvicorn/blob/master/uvicorn/middleware/proxy_headers.py)
+* [MessagePack](https://github.com/florimondmanca/msgpack-asgi)
-To see other available middlewares check Starlette's Middleware docs and the ASGI Awesome List.
+To see other available middlewares check [Starlette's Middleware docs](https://www.starlette.dev/middleware/) and the [ASGI Awesome List](https://github.com/florimondmanca/awesome-asgi).
diff --git a/docs/en/docs/advanced/openapi-callbacks.md b/docs/en/docs/advanced/openapi-callbacks.md
index 5bd7c2cfd4..40cf479567 100644
--- a/docs/en/docs/advanced/openapi-callbacks.md
+++ b/docs/en/docs/advanced/openapi-callbacks.md
@@ -35,7 +35,7 @@ This part is pretty normal, most of the code is probably already familiar to you
/// tip
-The `callback_url` query parameter uses a Pydantic Url type.
+The `callback_url` query parameter uses a Pydantic [Url](https://docs.pydantic.dev/latest/api/networks/) type.
///
@@ -66,7 +66,7 @@ This example doesn't implement the callback itself (that could be just a line of
The actual callback is just an HTTP request.
-When implementing the callback yourself, you could use something like HTTPX or Requests.
+When implementing the callback yourself, you could use something like [HTTPX](https://www.python-httpx.org) or [Requests](https://requests.readthedocs.io/).
///
@@ -106,11 +106,11 @@ It should look just like a normal FastAPI *path operation*:
There are 2 main differences from a normal *path operation*:
* It doesn't need to have any actual code, because your app will never call this code. It's only used to document the *external API*. So, the function could just have `pass`.
-* The *path* can contain an OpenAPI 3 expression (see more below) where it can use variables with parameters and parts of the original request sent to *your API*.
+* The *path* can contain an [OpenAPI 3 expression](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#key-expression) (see more below) where it can use variables with parameters and parts of the original request sent to *your API*.
### The callback path expression { #the-callback-path-expression }
-The callback *path* can have an OpenAPI 3 expression that can contain parts of the original request sent to *your API*.
+The callback *path* can have an [OpenAPI 3 expression](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#key-expression) that can contain parts of the original request sent to *your API*.
In this case, it's the `str`:
@@ -179,7 +179,7 @@ Notice that you are not passing the router itself (`invoices_callback_router`) t
### Check the docs { #check-the-docs }
-Now you can start your app and go to http://127.0.0.1:8000/docs.
+Now you can start your app and go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs).
You will see your docs including a "Callbacks" section for your *path operation* that shows how the *external API* should look like:
diff --git a/docs/en/docs/advanced/openapi-webhooks.md b/docs/en/docs/advanced/openapi-webhooks.md
index d9b73ea4a2..3da42819a6 100644
--- a/docs/en/docs/advanced/openapi-webhooks.md
+++ b/docs/en/docs/advanced/openapi-webhooks.md
@@ -48,7 +48,7 @@ This is because it is expected that **your users** would define the actual **URL
### Check the docs { #check-the-docs }
-Now you can start your app and go to http://127.0.0.1:8000/docs.
+Now you can start your app and go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs).
You will see your docs have the normal *path operations* and now also some **webhooks**:
diff --git a/docs/en/docs/advanced/path-operation-advanced-configuration.md b/docs/en/docs/advanced/path-operation-advanced-configuration.md
index fdc77c8a25..800bf305dc 100644
--- a/docs/en/docs/advanced/path-operation-advanced-configuration.md
+++ b/docs/en/docs/advanced/path-operation-advanced-configuration.md
@@ -60,7 +60,7 @@ That defines the metadata about the main response of a *path operation*.
You can also declare additional responses with their models, status codes, etc.
-There's a whole chapter here in the documentation about it, you can read it at [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+There's a whole chapter here in the documentation about it, you can read it at [Additional Responses in OpenAPI](additional-responses.md).
## OpenAPI Extra { #openapi-extra }
@@ -68,7 +68,7 @@ When you declare a *path operation* in your application, **FastAPI** automatical
/// note | Technical details
-In the OpenAPI specification it is called the Operation Object.
+In the OpenAPI specification it is called the [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object).
///
@@ -82,7 +82,7 @@ This *path operation*-specific OpenAPI schema is normally generated automaticall
This is a low level extension point.
-If you only need to declare additional responses, a more convenient way to do it is with [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+If you only need to declare additional responses, a more convenient way to do it is with [Additional Responses in OpenAPI](additional-responses.md).
///
diff --git a/docs/en/docs/advanced/response-change-status-code.md b/docs/en/docs/advanced/response-change-status-code.md
index 8aa601e7bd..8efd631981 100644
--- a/docs/en/docs/advanced/response-change-status-code.md
+++ b/docs/en/docs/advanced/response-change-status-code.md
@@ -1,6 +1,6 @@
# Response - Change Status Code { #response-change-status-code }
-You probably read before that you can set a default [Response Status Code](../tutorial/response-status-code.md){.internal-link target=_blank}.
+You probably read before that you can set a default [Response Status Code](../tutorial/response-status-code.md).
But in some cases you need to return a different status code than the default.
diff --git a/docs/en/docs/advanced/response-cookies.md b/docs/en/docs/advanced/response-cookies.md
index cfc615d7e4..a7ad90cad8 100644
--- a/docs/en/docs/advanced/response-cookies.md
+++ b/docs/en/docs/advanced/response-cookies.md
@@ -20,7 +20,7 @@ You can also declare the `Response` parameter in dependencies, and set cookies (
You can also create cookies when returning a `Response` directly in your code.
-To do that, you can create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank}.
+To do that, you can create a response as described in [Return a Response Directly](response-directly.md).
Then set Cookies in it, and then return it:
@@ -48,4 +48,4 @@ And as the `Response` can be used frequently to set headers and cookies, **FastA
///
-To see all the available parameters and options, check the documentation in Starlette.
+To see all the available parameters and options, check the [documentation in Starlette](https://www.starlette.dev/responses/#set-cookie).
diff --git a/docs/en/docs/advanced/response-directly.md b/docs/en/docs/advanced/response-directly.md
index 9d58490eb1..c9d18649fa 100644
--- a/docs/en/docs/advanced/response-directly.md
+++ b/docs/en/docs/advanced/response-directly.md
@@ -2,21 +2,21 @@
When you create a **FastAPI** *path operation* you can normally return any data from it: a `dict`, a `list`, a Pydantic model, a database model, etc.
-If you declare a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} FastAPI will use it to serialize the data to JSON, using Pydantic.
+If you declare a [Response Model](../tutorial/response-model.md) FastAPI will use it to serialize the data to JSON, using Pydantic.
-If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank} and put it in a `JSONResponse`.
+If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md) and put it in a `JSONResponse`.
You could also create a `JSONResponse` directly and return it.
/// tip
-You will normally have much better performance using a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} than returning a `JSONResponse` directly, as that way it serializes the data using Pydantic, in Rust.
+You will normally have much better performance using a [Response Model](../tutorial/response-model.md) than returning a `JSONResponse` directly, as that way it serializes the data using Pydantic, in Rust.
///
## Return a `Response` { #return-a-response }
-You can return any `Response` or any sub-class of it.
+You can return a `Response` or any sub-class of it.
/// info
@@ -28,7 +28,9 @@ And when you return a `Response`, **FastAPI** will pass it directly.
It won't do any data conversion with Pydantic models, it won't convert the contents to any type, etc.
-This gives you a lot of flexibility. You can return any data type, override any data declaration or validation, etc.
+This gives you a lot of **flexibility**. You can return any data type, override any data declaration or validation, etc.
+
+It also gives you a lot of **responsibility**. You have to make sure that the data you return is correct, in the correct format, that it can be serialized, etc.
## Using the `jsonable_encoder` in a `Response` { #using-the-jsonable-encoder-in-a-response }
@@ -54,7 +56,7 @@ The example above shows all the parts you need, but it's not very useful yet, as
Now, let's see how you could use that to return a custom response.
-Let's say that you want to return an XML response.
+Let's say that you want to return an [XML](https://en.wikipedia.org/wiki/XML) response.
You could put your XML content in a string, put that in a `Response`, and return it:
@@ -62,20 +64,20 @@ You could put your XML content in a string, put that in a `Response`, and return
## How a Response Model Works { #how-a-response-model-works }
-When you declare a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} in a path operation, **FastAPI** will use it to serialize the data to JSON, using Pydantic.
+When you declare a [Response Model - Return Type](../tutorial/response-model.md) in a path operation, **FastAPI** will use it to serialize the data to JSON, using Pydantic.
{* ../../docs_src/response_model/tutorial001_01_py310.py hl[16,21] *}
As that will happen on the Rust side, the performance will be much better than if it was done with regular Python and the `JSONResponse` class.
-When using a response model FastAPI won't use the `jsonable_encoder` to convert the data (which would be slower) nor the `JSONResponse` class.
+When using a `response_model` or return type, FastAPI won't use the `jsonable_encoder` to convert the data (which would be slower) nor the `JSONResponse` class.
-Instead it takes the JSON bytes generated with Pydantic using the response model and returns a `Response` with the right media type for JSON directly (`application/json`).
+Instead it takes the JSON bytes generated with Pydantic using the response model (or return type) and returns a `Response` with the right media type for JSON directly (`application/json`).
## Notes { #notes }
When you return a `Response` directly its data is not validated, converted (serialized), or documented automatically.
-But you can still document it as described in [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+But you can still document it as described in [Additional Responses in OpenAPI](additional-responses.md).
You can see in later sections how to use/declare these custom `Response`s while still having automatic data conversion, documentation, etc.
diff --git a/docs/en/docs/advanced/response-headers.md b/docs/en/docs/advanced/response-headers.md
index ebc96d5dd0..d7738635dc 100644
--- a/docs/en/docs/advanced/response-headers.md
+++ b/docs/en/docs/advanced/response-headers.md
@@ -20,7 +20,7 @@ You can also declare the `Response` parameter in dependencies, and set headers (
You can also add headers when you return a `Response` directly.
-Create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank} and pass the headers as an additional parameter:
+Create a response as described in [Return a Response Directly](response-directly.md) and pass the headers as an additional parameter:
{* ../../docs_src/response_headers/tutorial001_py310.py hl[10:12] *}
@@ -36,6 +36,6 @@ And as the `Response` can be used frequently to set headers and cookies, **FastA
## Custom Headers { #custom-headers }
-Keep in mind that custom proprietary headers can be added using the `X-` prefix.
+Keep in mind that custom proprietary headers can be added [using the `X-` prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers).
-But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), using the parameter `expose_headers` documented in Starlette's CORS docs.
+But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md)), using the parameter `expose_headers` documented in [Starlette's CORS docs](https://www.starlette.dev/middleware/#corsmiddleware).
diff --git a/docs/en/docs/advanced/security/http-basic-auth.md b/docs/en/docs/advanced/security/http-basic-auth.md
index c066cc63a4..01693e0a01 100644
--- a/docs/en/docs/advanced/security/http-basic-auth.md
+++ b/docs/en/docs/advanced/security/http-basic-auth.md
@@ -32,7 +32,7 @@ Here's a more complete example.
Use a dependency to check if the username and password are correct.
-For this, use the Python standard module `secrets` to check the username and password.
+For this, use the Python standard module [`secrets`](https://docs.python.org/3/library/secrets.html) to check the username and password.
`secrets.compare_digest()` needs to take `bytes` or a `str` that only contains ASCII characters (the ones in English), this means it wouldn't work with characters like `á`, as in `Sebastián`.
diff --git a/docs/en/docs/advanced/security/index.md b/docs/en/docs/advanced/security/index.md
index 996d716b4c..4f6959a9a4 100644
--- a/docs/en/docs/advanced/security/index.md
+++ b/docs/en/docs/advanced/security/index.md
@@ -2,7 +2,7 @@
## Additional Features { #additional-features }
-There are some extra features to handle security apart from the ones covered in the [Tutorial - User Guide: Security](../../tutorial/security/index.md){.internal-link target=_blank}.
+There are some extra features to handle security apart from the ones covered in the [Tutorial - User Guide: Security](../../tutorial/security/index.md).
/// tip
@@ -14,6 +14,6 @@ And it's possible that for your use case, the solution is in one of them.
## Read the Tutorial first { #read-the-tutorial-first }
-The next sections assume you already read the main [Tutorial - User Guide: Security](../../tutorial/security/index.md){.internal-link target=_blank}.
+The next sections assume you already read the main [Tutorial - User Guide: Security](../../tutorial/security/index.md).
They are all based on the same concepts, but allow some extra functionalities.
diff --git a/docs/en/docs/advanced/security/oauth2-scopes.md b/docs/en/docs/advanced/security/oauth2-scopes.md
index 67c927cd08..459646bbd9 100644
--- a/docs/en/docs/advanced/security/oauth2-scopes.md
+++ b/docs/en/docs/advanced/security/oauth2-scopes.md
@@ -60,7 +60,7 @@ For OAuth2 they are just strings.
## Global view { #global-view }
-First, let's quickly see the parts that change from the examples in the main **Tutorial - User Guide** for [OAuth2 with Password (and hashing), Bearer with JWT tokens](../../tutorial/security/oauth2-jwt.md){.internal-link target=_blank}. Now using OAuth2 scopes:
+First, let's quickly see the parts that change from the examples in the main **Tutorial - User Guide** for [OAuth2 with Password (and hashing), Bearer with JWT tokens](../../tutorial/security/oauth2-jwt.md). Now using OAuth2 scopes:
{* ../../docs_src/security/tutorial005_an_py310.py hl[5,9,13,47,65,106,108:116,122:126,130:136,141,157] *}
@@ -271,4 +271,4 @@ But in the end, they are implementing the same OAuth2 standard.
## `Security` in decorator `dependencies` { #security-in-decorator-dependencies }
-The same way you can define a `list` of `Depends` in the decorator's `dependencies` parameter (as explained in [Dependencies in path operation decorators](../../tutorial/dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}), you could also use `Security` with `scopes` there.
+The same way you can define a `list` of `Depends` in the decorator's `dependencies` parameter (as explained in [Dependencies in path operation decorators](../../tutorial/dependencies/dependencies-in-path-operation-decorators.md)), you could also use `Security` with `scopes` there.
diff --git a/docs/en/docs/advanced/settings.md b/docs/en/docs/advanced/settings.md
index 61a6ac8bc1..f0f3bb41d0 100644
--- a/docs/en/docs/advanced/settings.md
+++ b/docs/en/docs/advanced/settings.md
@@ -8,7 +8,7 @@ For this reason it's common to provide them in environment variables that are re
/// tip
-To understand environment variables you can read [Environment Variables](../environment-variables.md){.internal-link target=_blank}.
+To understand environment variables you can read [Environment Variables](../environment-variables.md).
///
@@ -20,11 +20,11 @@ That means that any value read in Python from an environment variable will be a
## Pydantic `Settings` { #pydantic-settings }
-Fortunately, Pydantic provides a great utility to handle these settings coming from environment variables with Pydantic: Settings management.
+Fortunately, Pydantic provides a great utility to handle these settings coming from environment variables with [Pydantic: Settings management](https://docs.pydantic.dev/latest/concepts/pydantic_settings/).
### Install `pydantic-settings` { #install-pydantic-settings }
-First, make sure you create your [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install the `pydantic-settings` package:
+First, make sure you create your [virtual environment](../virtual-environments.md), activate it, and then install the `pydantic-settings` package:
-And then, open the docs for the sub-application, at http://127.0.0.1:8000/subapi/docs.
+And then, open the docs for the sub-application, at [http://127.0.0.1:8000/subapi/docs](http://127.0.0.1:8000/subapi/docs).
You will see the automatic API docs for the sub-application, including only its own _path operations_, all under the correct sub-path prefix `/subapi`:
@@ -64,4 +64,4 @@ That way, the sub-application will know to use that path prefix for the docs UI.
And the sub-application could also have its own mounted sub-applications and everything would work correctly, because FastAPI handles all these `root_path`s automatically.
-You will learn more about the `root_path` and how to use it explicitly in the section about [Behind a Proxy](behind-a-proxy.md){.internal-link target=_blank}.
+You will learn more about the `root_path` and how to use it explicitly in the section about [Behind a Proxy](behind-a-proxy.md).
diff --git a/docs/en/docs/advanced/templates.md b/docs/en/docs/advanced/templates.md
index 71c8f73c03..6570865e27 100644
--- a/docs/en/docs/advanced/templates.md
+++ b/docs/en/docs/advanced/templates.md
@@ -8,7 +8,7 @@ There are utilities to configure it easily that you can use directly in your **F
## Install dependencies { #install-dependencies }
-Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and install `jinja2`:
+Make sure you create a [virtual environment](../virtual-environments.md), activate it, and install `jinja2`:
@@ -44,7 +44,7 @@ Then I spent some time designing the developer "API" I wanted to have as a user I tested several ideas in the most popular Python editors: PyCharm, VS Code, Jedi based editors. -By the last Python Developer Survey, that covers about 80% of the users. +By the last [Python Developer Survey](https://www.jetbrains.com/research/python-developers-survey-2018/#development-tools), that covers about 80% of the users. It means that **FastAPI** was specifically tested with the editors used by 80% of the Python developers. And as most of the other editors tend to work similarly, all its benefits should work for virtually all editors. @@ -54,11 +54,11 @@ All in a way that provided the best development experience for all the developer ## Requirements { #requirements } -After testing several alternatives, I decided that I was going to use **Pydantic** for its advantages. +After testing several alternatives, I decided that I was going to use [**Pydantic**](https://docs.pydantic.dev/) for its advantages. Then I contributed to it, to make it fully compliant with JSON Schema, to support different ways to define constraint declarations, and to improve editor support (type checks, autocompletion) based on the tests in several editors. -During the development, I also contributed to **Starlette**, the other key requirement. +During the development, I also contributed to [**Starlette**](https://www.starlette.dev/), the other key requirement. ## Development { #development } @@ -76,4 +76,4 @@ But still, there are many improvements and features to come. **FastAPI** has a great future ahead. -And [your help](help-fastapi.md){.internal-link target=_blank} is greatly appreciated. +And [your help](help-fastapi.md) is greatly appreciated. diff --git a/docs/en/docs/how-to/authentication-error-status-code.md b/docs/en/docs/how-to/authentication-error-status-code.md index b15298e736..83b974e2da 100644 --- a/docs/en/docs/how-to/authentication-error-status-code.md +++ b/docs/en/docs/how-to/authentication-error-status-code.md @@ -2,7 +2,7 @@ Before FastAPI version `0.122.0`, when the integrated security utilities returned an error to the client after a failed authentication, they used the HTTP status code `403 Forbidden`. -Starting with FastAPI version `0.122.0`, they use the more appropriate HTTP status code `401 Unauthorized`, and return a sensible `WWW-Authenticate` header in the response, following the HTTP specifications, RFC 7235, RFC 9110. +Starting with FastAPI version `0.122.0`, they use the more appropriate HTTP status code `401 Unauthorized`, and return a sensible `WWW-Authenticate` header in the response, following the HTTP specifications, [RFC 7235](https://datatracker.ietf.org/doc/html/rfc7235#section-3.1), [RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#name-401-unauthorized). But if for some reason your clients depend on the old behavior, you can revert to it by overriding the method `make_not_authenticated_error` in your security classes. diff --git a/docs/en/docs/how-to/conditional-openapi.md b/docs/en/docs/how-to/conditional-openapi.md index b2a7f812f7..2c0edf87f4 100644 --- a/docs/en/docs/how-to/conditional-openapi.md +++ b/docs/en/docs/how-to/conditional-openapi.md @@ -10,7 +10,7 @@ That doesn't add any extra security to your API, the *path operations* will stil If there's a security flaw in your code, it will still exist. -Hiding the documentation just makes it more difficult to understand how to interact with your API, and could make it more difficult for you to debug it in production. It could be considered simply a form of Security through obscurity. +Hiding the documentation just makes it more difficult to understand how to interact with your API, and could make it more difficult for you to debug it in production. It could be considered simply a form of [Security through obscurity](https://en.wikipedia.org/wiki/Security_through_obscurity). If you want to secure your API, there are several better things you can do, for example: diff --git a/docs/en/docs/how-to/configure-swagger-ui.md b/docs/en/docs/how-to/configure-swagger-ui.md index ad9c01556d..7c3d9cb25a 100644 --- a/docs/en/docs/how-to/configure-swagger-ui.md +++ b/docs/en/docs/how-to/configure-swagger-ui.md @@ -1,6 +1,6 @@ # Configure Swagger UI { #configure-swagger-ui } -You can configure some extra Swagger UI parameters. +You can configure some extra [Swagger UI parameters](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/). To configure them, pass the `swagger_ui_parameters` argument when creating the `FastAPI()` app object or to the `get_swagger_ui_html()` function. @@ -50,7 +50,7 @@ For example, to disable `deepLinking` you could pass these settings to `swagger_ ## Other Swagger UI Parameters { #other-swagger-ui-parameters } -To see all the other possible configurations you can use, read the official docs for Swagger UI parameters. +To see all the other possible configurations you can use, read the official [docs for Swagger UI parameters](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/). ## JavaScript-only settings { #javascript-only-settings } diff --git a/docs/en/docs/how-to/custom-docs-ui-assets.md b/docs/en/docs/how-to/custom-docs-ui-assets.md index d3e505040a..c9e5d8a152 100644 --- a/docs/en/docs/how-to/custom-docs-ui-assets.md +++ b/docs/en/docs/how-to/custom-docs-ui-assets.md @@ -54,7 +54,7 @@ Now, to be able to test that everything works, create a *path operation*: ### Test it { #test-it } -Now, you should be able to go to your docs at http://127.0.0.1:8000/docs, and reload the page, it will load those assets from the new CDN. +Now, you should be able to go to your docs at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs), and reload the page, it will load those assets from the new CDN. ## Self-hosting JavaScript and CSS for docs { #self-hosting-javascript-and-css-for-docs } @@ -93,12 +93,12 @@ You can probably right-click each link and select an option similar to "Save lin **Swagger UI** uses the files: -* `swagger-ui-bundle.js` -* `swagger-ui.css` +* [`swagger-ui-bundle.js`](https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js) +* [`swagger-ui.css`](https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css) And **ReDoc** uses the file: -* `redoc.standalone.js` +* [`redoc.standalone.js`](https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js) After that, your file structure could look like: @@ -122,7 +122,7 @@ After that, your file structure could look like: ### Test the static files { #test-the-static-files } -Start your application and go to http://127.0.0.1:8000/static/redoc.standalone.js. +Start your application and go to [http://127.0.0.1:8000/static/redoc.standalone.js](http://127.0.0.1:8000/static/redoc.standalone.js). You should see a very long JavaScript file for **ReDoc**. @@ -180,6 +180,6 @@ Now, to be able to test that everything works, create a *path operation*: ### Test Static Files UI { #test-static-files-ui } -Now, you should be able to disconnect your WiFi, go to your docs at http://127.0.0.1:8000/docs, and reload the page. +Now, you should be able to disconnect your WiFi, go to your docs at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs), and reload the page. And even without Internet, you would be able to see the docs for your API and interact with it. diff --git a/docs/en/docs/how-to/custom-request-and-route.md b/docs/en/docs/how-to/custom-request-and-route.md index bfc60729f8..bce232017e 100644 --- a/docs/en/docs/how-to/custom-request-and-route.md +++ b/docs/en/docs/how-to/custom-request-and-route.md @@ -18,7 +18,7 @@ If you are just starting with **FastAPI** you might want to skip this section. Some use cases include: -* Converting non-JSON request bodies to JSON (e.g. `msgpack`). +* Converting non-JSON request bodies to JSON (e.g. [`msgpack`](https://msgpack.org/index.html)). * Decompressing gzip-compressed request bodies. * Automatically logging all request bodies. @@ -32,7 +32,7 @@ And an `APIRoute` subclass to use that custom request class. /// tip -This is a toy example to demonstrate how it works, if you need Gzip support, you can use the provided [`GzipMiddleware`](../advanced/middleware.md#gzipmiddleware){.internal-link target=_blank}. +This is a toy example to demonstrate how it works, if you need Gzip support, you can use the provided [`GzipMiddleware`](../advanced/middleware.md#gzipmiddleware). /// @@ -66,7 +66,7 @@ The `scope` `dict` and `receive` function are both part of the ASGI specificatio And those two things, `scope` and `receive`, are what is needed to create a new `Request` instance. -To learn more about the `Request` check Starlette's docs about Requests. +To learn more about the `Request` check [Starlette's docs about Requests](https://www.starlette.dev/requests/). /// @@ -82,7 +82,7 @@ But because of our changes in `GzipRequest.body`, the request body will be autom /// tip -To solve this same problem, it's probably a lot easier to use the `body` in a custom handler for `RequestValidationError` ([Handling Errors](../tutorial/handling-errors.md#use-the-requestvalidationerror-body){.internal-link target=_blank}). +To solve this same problem, it's probably a lot easier to use the `body` in a custom handler for `RequestValidationError` ([Handling Errors](../tutorial/handling-errors.md#use-the-requestvalidationerror-body)). But this example is still valid and it shows how to interact with the internal components. diff --git a/docs/en/docs/how-to/extending-openapi.md b/docs/en/docs/how-to/extending-openapi.md index b480223bf0..c110a444f1 100644 --- a/docs/en/docs/how-to/extending-openapi.md +++ b/docs/en/docs/how-to/extending-openapi.md @@ -37,7 +37,7 @@ The parameter `summary` is available in OpenAPI 3.1.0 and above, supported by Fa Using the information above, you can use the same utility function to generate the OpenAPI schema and override each part that you need. -For example, let's add ReDoc's OpenAPI extension to include a custom logo. +For example, let's add [ReDoc's OpenAPI extension to include a custom logo](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md#x-logo). ### Normal **FastAPI** { #normal-fastapi } @@ -75,6 +75,6 @@ Now you can replace the `.openapi()` method with your new function. ### Check it { #check-it } -Once you go to http://127.0.0.1:8000/redoc you will see that you are using your custom logo (in this example, **FastAPI**'s logo): +Once you go to [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc) you will see that you are using your custom logo (in this example, **FastAPI**'s logo):diff --git a/docs/en/docs/how-to/general.md b/docs/en/docs/how-to/general.md index 4f611dab05..da6738eb9b 100644 --- a/docs/en/docs/how-to/general.md +++ b/docs/en/docs/how-to/general.md @@ -4,40 +4,40 @@ Here are several pointers to other places in the docs, for general or frequent q ## Filter Data - Security { #filter-data-security } -To ensure that you don't return more data than you should, read the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md){.internal-link target=_blank}. +To ensure that you don't return more data than you should, read the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md). ## Optimize Response Performance - Response Model - Return Type { #optimize-response-performance-response-model-return-type } -To optimize performance when returning JSON data, use a return type or response model, that way Pydantic will handle the serialization to JSON on the Rust side, without going through Python. Read more in the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md){.internal-link target=_blank}. +To optimize performance when returning JSON data, use a return type or response model, that way Pydantic will handle the serialization to JSON on the Rust side, without going through Python. Read more in the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md). ## Documentation Tags - OpenAPI { #documentation-tags-openapi } -To add tags to your *path operations*, and group them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Tags](../tutorial/path-operation-configuration.md#tags){.internal-link target=_blank}. +To add tags to your *path operations*, and group them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Tags](../tutorial/path-operation-configuration.md#tags). ## Documentation Summary and Description - OpenAPI { #documentation-summary-and-description-openapi } -To add a summary and description to your *path operations*, and show them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Summary and Description](../tutorial/path-operation-configuration.md#summary-and-description){.internal-link target=_blank}. +To add a summary and description to your *path operations*, and show them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Summary and Description](../tutorial/path-operation-configuration.md#summary-and-description). ## Documentation Response description - OpenAPI { #documentation-response-description-openapi } -To define the description of the response, shown in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Response description](../tutorial/path-operation-configuration.md#response-description){.internal-link target=_blank}. +To define the description of the response, shown in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Response description](../tutorial/path-operation-configuration.md#response-description). ## Documentation Deprecate a *Path Operation* - OpenAPI { #documentation-deprecate-a-path-operation-openapi } -To deprecate a *path operation*, and show it in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Deprecation](../tutorial/path-operation-configuration.md#deprecate-a-path-operation){.internal-link target=_blank}. +To deprecate a *path operation*, and show it in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Deprecation](../tutorial/path-operation-configuration.md#deprecate-a-path-operation). ## Convert any Data to JSON-compatible { #convert-any-data-to-json-compatible } -To convert any data to JSON-compatible, read the docs for [Tutorial - JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank}. +To convert any data to JSON-compatible, read the docs for [Tutorial - JSON Compatible Encoder](../tutorial/encoder.md). ## OpenAPI Metadata - Docs { #openapi-metadata-docs } -To add metadata to your OpenAPI schema, including a license, version, contact, etc, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md){.internal-link target=_blank}. +To add metadata to your OpenAPI schema, including a license, version, contact, etc, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md). ## OpenAPI Custom URL { #openapi-custom-url } -To customize the OpenAPI URL (or remove it), read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#openapi-url){.internal-link target=_blank}. +To customize the OpenAPI URL (or remove it), read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#openapi-url). ## OpenAPI Docs URLs { #openapi-docs-urls } -To update the URLs used for the automatically generated docs user interfaces, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#docs-urls){.internal-link target=_blank}. +To update the URLs used for the automatically generated docs user interfaces, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#docs-urls). diff --git a/docs/en/docs/how-to/graphql.md b/docs/en/docs/how-to/graphql.md index 426b2e9821..2d93876f35 100644 --- a/docs/en/docs/how-to/graphql.md +++ b/docs/en/docs/how-to/graphql.md @@ -18,18 +18,18 @@ Make sure you evaluate if the **benefits** for your use case compensate the **dr Here are some of the **GraphQL** libraries that have **ASGI** support. You could use them with **FastAPI**: -* Strawberry 🍓 - * With docs for FastAPI -* Ariadne - * With docs for FastAPI -* Tartiflette - * With Tartiflette ASGI to provide ASGI integration -* Graphene - * With starlette-graphene3 +* [Strawberry](https://strawberry.rocks/) 🍓 + * With [docs for FastAPI](https://strawberry.rocks/docs/integrations/fastapi) +* [Ariadne](https://ariadnegraphql.org/) + * With [docs for FastAPI](https://ariadnegraphql.org/docs/fastapi-integration) +* [Tartiflette](https://tartiflette.io/) + * With [Tartiflette ASGI](https://tartiflette.github.io/tartiflette-asgi/) to provide ASGI integration +* [Graphene](https://graphene-python.org/) + * With [starlette-graphene3](https://github.com/ciscorn/starlette-graphene3) ## GraphQL with Strawberry { #graphql-with-strawberry } -If you need or want to work with **GraphQL**, **Strawberry** is the **recommended** library as it has the design closest to **FastAPI's** design, it's all based on **type annotations**. +If you need or want to work with **GraphQL**, [**Strawberry**](https://strawberry.rocks/) is the **recommended** library as it has the design closest to **FastAPI's** design, it's all based on **type annotations**. Depending on your use case, you might prefer to use a different library, but if you asked me, I would probably suggest you try **Strawberry**. @@ -37,24 +37,24 @@ Here's a small preview of how you could integrate Strawberry with FastAPI: {* ../../docs_src/graphql_/tutorial001_py310.py hl[3,22,25] *} -You can learn more about Strawberry in the Strawberry documentation. +You can learn more about Strawberry in the [Strawberry documentation](https://strawberry.rocks/). -And also the docs about Strawberry with FastAPI. +And also the docs about [Strawberry with FastAPI](https://strawberry.rocks/docs/integrations/fastapi). ## Older `GraphQLApp` from Starlette { #older-graphqlapp-from-starlette } -Previous versions of Starlette included a `GraphQLApp` class to integrate with Graphene. +Previous versions of Starlette included a `GraphQLApp` class to integrate with [Graphene](https://graphene-python.org/). -It was deprecated from Starlette, but if you have code that used it, you can easily **migrate** to starlette-graphene3, that covers the same use case and has an **almost identical interface**. +It was deprecated from Starlette, but if you have code that used it, you can easily **migrate** to [starlette-graphene3](https://github.com/ciscorn/starlette-graphene3), that covers the same use case and has an **almost identical interface**. /// tip -If you need GraphQL, I still would recommend you check out Strawberry, as it's based on type annotations instead of custom classes and types. +If you need GraphQL, I still would recommend you check out [Strawberry](https://strawberry.rocks/), as it's based on type annotations instead of custom classes and types. /// ## Learn More { #learn-more } -You can learn more about **GraphQL** in the official GraphQL documentation. +You can learn more about **GraphQL** in the [official GraphQL documentation](https://graphql.org/). You can also read more about each those libraries described above in their links. diff --git a/docs/en/docs/how-to/index.md b/docs/en/docs/how-to/index.md index 5a8ce08de7..3d3696671c 100644 --- a/docs/en/docs/how-to/index.md +++ b/docs/en/docs/how-to/index.md @@ -8,6 +8,6 @@ If something seems interesting and useful to your project, go ahead and check it /// tip -If you want to **learn FastAPI** in a structured way (recommended), go and read the [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank} chapter by chapter instead. +If you want to **learn FastAPI** in a structured way (recommended), go and read the [Tutorial - User Guide](../tutorial/index.md) chapter by chapter instead. /// diff --git a/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md b/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md index fc90220b89..99d3835c38 100644 --- a/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md +++ b/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md @@ -22,7 +22,7 @@ If you have an old FastAPI app with Pydantic v1, here I'll show you how to migra ## Official Guide { #official-guide } -Pydantic has an official Migration Guide from v1 to v2. +Pydantic has an official [Migration Guide](https://docs.pydantic.dev/latest/migration/) from v1 to v2. It also includes what has changed, how validations are now more correct and strict, possible caveats, etc. @@ -30,7 +30,7 @@ You can read it to understand better what has changed. ## Tests { #tests } -Make sure you have [tests](../tutorial/testing.md){.internal-link target=_blank} for your app and you run them on continuous integration (CI). +Make sure you have [tests](../tutorial/testing.md) for your app and you run them on continuous integration (CI). This way, you can do the upgrade and make sure everything is still working as expected. @@ -38,7 +38,7 @@ This way, you can do the upgrade and make sure everything is still working as ex In many cases, when you use regular Pydantic models without customizations, you will be able to automate most of the process of migrating from Pydantic v1 to Pydantic v2. -You can use `bump-pydantic` from the same Pydantic team. +You can use [`bump-pydantic`](https://github.com/pydantic/bump-pydantic) from the same Pydantic team. This tool will help you to automatically change most of the code that needs to be changed. diff --git a/docs/en/docs/how-to/testing-database.md b/docs/en/docs/how-to/testing-database.md index 400fdcfc64..a8e183ce0f 100644 --- a/docs/en/docs/how-to/testing-database.md +++ b/docs/en/docs/how-to/testing-database.md @@ -1,7 +1,7 @@ # Testing a Database { #testing-a-database } -You can study about databases, SQL, and SQLModel in the SQLModel docs. 🤓 +You can study about databases, SQL, and SQLModel in the [SQLModel docs](https://sqlmodel.tiangolo.com/). 🤓 -There's a mini tutorial on using SQLModel with FastAPI. ✨ +There's a mini [tutorial on using SQLModel with FastAPI](https://sqlmodel.tiangolo.com/tutorial/fastapi/). ✨ -That tutorial includes a section about testing SQL databases. 😎 +That tutorial includes a section about [testing SQL databases](https://sqlmodel.tiangolo.com/tutorial/fastapi/tests/). 😎 diff --git a/docs/en/docs/index.md b/docs/en/docs/index.md index 7f9d5efbf2..efe13ee4f4 100644 --- a/docs/en/docs/index.md +++ b/docs/en/docs/index.md @@ -11,25 +11,25 @@ FastAPI framework, high performance, easy to learn, fast to code, ready for production --- -**Documentation**: https://fastapi.tiangolo.com +**Documentation**: [https://fastapi.tiangolo.com](https://fastapi.tiangolo.com) -**Source Code**: https://github.com/fastapi/fastapi +**Source Code**: [https://github.com/fastapi/fastapi](https://github.com/fastapi/fastapi) --- @@ -44,7 +44,7 @@ The key features are: * **Easy**: Designed to be easy to use and learn. Less time reading docs. * **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs. * **Robust**: Get production-ready code. With automatic interactive documentation. -* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema. +* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: [OpenAPI](https://github.com/OAI/OpenAPI-Specification) (previously known as Swagger) and [JSON Schema](https://json-schema.org/). * estimation based on tests conducted by an internal development team, building production applications. @@ -55,51 +55,51 @@ The key features are: ### Keystone Sponsor { #keystone-sponsor } {% for sponsor in sponsors.keystone -%} -
+
{% endfor -%} ### Gold and Silver Sponsors { #gold-and-silver-sponsors } {% for sponsor in sponsors.gold -%} -
+
{% endfor -%} {%- for sponsor in sponsors.silver -%} -
+
{% endfor %} -Other sponsors +[Other sponsors](https://fastapi.tiangolo.com/fastapi-people/#sponsors) ## Opinions { #opinions } "_[...] I'm using **FastAPI** a ton these days. [...] I'm actually planning to use it for all of my team's **ML services at Microsoft**. Some of them are getting integrated into the core **Windows** product and some **Office** products._" -
Kabir Khan - Microsoft (ref)+Kabir Khan - Microsoft (ref)--- "_We adopted the **FastAPI** library to spawn a **REST** server that can be queried to obtain **predictions**. [for Ludwig]_" -Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala - Uber (ref)+Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala - Uber (ref)--- "_**Netflix** is pleased to announce the open-source release of our **crisis management** orchestration framework: **Dispatch**! [built with **FastAPI**]_" -Kevin Glisson, Marc Vilanova, Forest Monsen - Netflix (ref)+Kevin Glisson, Marc Vilanova, Forest Monsen - Netflix (ref)--- "_I’m over the moon excited about **FastAPI**. It’s so fun!_" -Brian Okken - Python Bytes podcast host (ref)+Brian Okken - [Python Bytes](https://pythonbytes.fm/episodes/show/123/time-to-right-the-py-wrongs?time_in_sec=855) podcast host (ref)--- "_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._" - +Timothy Crosley - [Hug](https://github.com/hugapi/hug) creator (ref)--- @@ -107,27 +107,27 @@ The key features are: "_We've switched over to **FastAPI** for our **APIs** [...] I think you'll like it [...]_" - +Ines Montani - Matthew Honnibal - [Explosion AI](https://explosion.ai) founders - [spaCy](https://spacy.io) creators (ref) - (ref)--- "_If anyone is looking to build a production Python API, I would highly recommend **FastAPI**. It is **beautifully designed**, **simple to use** and **highly scalable**, it has become a **key component** in our API first development strategy and is driving many automations and services such as our Virtual TAC Engineer._" -Deon Pillsbury - Cisco (ref)+Deon Pillsbury - Cisco (ref)--- ## FastAPI mini documentary { #fastapi-mini-documentary } -There's a FastAPI mini documentary released at the end of 2025, you can watch it online: +There's a [FastAPI mini documentary](https://www.youtube.com/watch?v=mpR8ngthqiE) released at the end of 2025, you can watch it online: -+
## **Typer**, the FastAPI of CLIs { #typer-the-fastapi-of-clis } -
+
-If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**. +If you are building a CLI app to be used in the terminal instead of a web API, check out [**Typer**](https://typer.tiangolo.com/). **Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. ⌨️ 🚀 @@ -135,12 +135,12 @@ If you are building a CLI app to be FastAPI stands on the shoulders of giants: -* Starlette for the web parts. -* Pydantic for the data parts. +* [Starlette](https://www.starlette.dev/) for the web parts. +* [Pydantic](https://docs.pydantic.dev/) for the data parts. ## Installation { #installation } -Create and activate a virtual environment and then install FastAPI: +Create and activate a [virtual environment](https://fastapi.tiangolo.com/virtual-environments/) and then install FastAPI:
@@ -199,7 +199,7 @@ async def read_item(item_id: int, q: str | None = None): **Note**: -If you don't know, check the _"In a hurry?"_ section about `async` and `await` in the docs. +If you don't know, check the _"In a hurry?"_ section about [`async` and `await` in the docs](https://fastapi.tiangolo.com/async/#in-a-hurry). @@ -237,17 +237,17 @@ INFO: Application startup complete.-And open the docs at http://127.0.0.1:8000/docs. +And open the docs at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). You will see the automatic API docs, including the paths from all the submodules, using the correct paths (and prefixes) and the correct tags: diff --git a/docs/en/docs/tutorial/body-nested-models.md b/docs/en/docs/tutorial/body-nested-models.md index b84c9242e9..17c560f40e 100644 --- a/docs/en/docs/tutorial/body-nested-models.md +++ b/docs/en/docs/tutorial/body-nested-models.md @@ -96,7 +96,7 @@ Again, doing just that declaration, with **FastAPI** you get: Apart from normal singular types like `str`, `int`, `float`, etc. you can use more complex singular types that inherit from `str`. -To see all the options you have, checkout Pydantic's Type Overview. You will see some examples in the next chapter. +To see all the options you have, checkout [Pydantic's Type Overview](https://docs.pydantic.dev/latest/concepts/types/). You will see some examples in the next chapter. For example, as in the `Image` model we have a `url` field, we can declare it to be an instance of Pydantic's `HttpUrl` instead of a `str`: diff --git a/docs/en/docs/tutorial/body-updates.md b/docs/en/docs/tutorial/body-updates.md index 1b7fd70661..e45f96c16f 100644 --- a/docs/en/docs/tutorial/body-updates.md +++ b/docs/en/docs/tutorial/body-updates.md @@ -2,7 +2,7 @@ ## Update replacing with `PUT` { #update-replacing-with-put } -To update an item you can use the HTTP `PUT` operation. +To update an item you can use the [HTTP `PUT`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) operation. You can use the `jsonable_encoder` to convert the input data to data that can be stored as JSON (e.g. with a NoSQL database). For example, converting `datetime` to `str`. @@ -28,7 +28,7 @@ And the data would be saved with that "new" `tax` of `10.5`. ## Partial updates with `PATCH` { #partial-updates-with-patch } -You can also use the HTTP `PATCH` operation to *partially* update data. +You can also use the [HTTP `PATCH`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) operation to *partially* update data. This means that you can send only the data that you want to update, leaving the rest intact. @@ -95,6 +95,6 @@ Notice that the input model is still validated. So, if you want to receive partial updates that can omit all the attributes, you need to have a model with all the attributes marked as optional (with default values or `None`). -To distinguish from the models with all optional values for **updates** and models with required values for **creation**, you can use the ideas described in [Extra Models](extra-models.md){.internal-link target=_blank}. +To distinguish from the models with all optional values for **updates** and models with required values for **creation**, you can use the ideas described in [Extra Models](extra-models.md). /// diff --git a/docs/en/docs/tutorial/body.md b/docs/en/docs/tutorial/body.md index fb4471836e..ca72548a4d 100644 --- a/docs/en/docs/tutorial/body.md +++ b/docs/en/docs/tutorial/body.md @@ -6,7 +6,7 @@ A **request** body is data sent by the client to your API. A **response** body i Your API almost always has to send a **response** body. But clients don't necessarily need to send **request bodies** all the time, sometimes they only request a path, maybe with some query parameters, but don't send a body. -To declare a **request** body, you use Pydantic models with all their power and benefits. +To declare a **request** body, you use [Pydantic](https://docs.pydantic.dev/) models with all their power and benefits. /// info @@ -73,7 +73,7 @@ With just that Python type declaration, **FastAPI** will: * If the data is invalid, it will return a nice and clear error, indicating exactly where and what was the incorrect data. * Give you the received data in the parameter `item`. * As you declared it in the function to be of type `Item`, you will also have all the editor support (completion, etc) for all of the attributes and their types. -* Generate JSON Schema definitions for your model, you can also use them anywhere else you like if it makes sense for your project. +* Generate [JSON Schema](https://json-schema.org) definitions for your model, you can also use them anywhere else you like if it makes sense for your project. * Those schemas will be part of the generated OpenAPI schema, and used by the automatic documentation UIs. ## Automatic docs { #automatic-docs } @@ -102,15 +102,15 @@ And it was thoroughly tested at the design phase, before any implementation, to There were even some changes to Pydantic itself to support this. -The previous screenshots were taken with Visual Studio Code. +The previous screenshots were taken with [Visual Studio Code](https://code.visualstudio.com). -But you would get the same editor support with PyCharm and most of the other Python editors: +But you would get the same editor support with [PyCharm](https://www.jetbrains.com/pycharm/) and most of the other Python editors:### Check it { #check-it } -Open your browser at http://127.0.0.1:8000/items/5?q=somequery. +Open your browser at [http://127.0.0.1:8000/items/5?q=somequery](http://127.0.0.1:8000/items/5?q=somequery). You will see the JSON response as: @@ -264,17 +264,17 @@ You already created an API that: ### Interactive API docs { #interactive-api-docs } -Now go to http://127.0.0.1:8000/docs. +Now go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). -You will see the automatic interactive API documentation (provided by Swagger UI): +You will see the automatic interactive API documentation (provided by [Swagger UI](https://github.com/swagger-api/swagger-ui)):  ### Alternative API docs { #alternative-api-docs } -And now, go to http://127.0.0.1:8000/redoc. +And now, go to [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc). -You will see the alternative automatic documentation (provided by ReDoc): +You will see the alternative automatic documentation (provided by [ReDoc](https://github.com/Rebilly/ReDoc)):  @@ -316,7 +316,7 @@ The `fastapi dev` server should reload automatically. ### Interactive API docs upgrade { #interactive-api-docs-upgrade } -Now go to http://127.0.0.1:8000/docs. +Now go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). * The interactive API documentation will be automatically updated, including the new body: @@ -332,7 +332,7 @@ Now go to http://127.0.0.1:8000/redoc. +And now, go to [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc). * The alternative documentation will also reflect the new query parameter and body: @@ -442,7 +442,7 @@ For a more complete example including more features, see the Dependency Injection** system. * Security and authentication, including support for **OAuth2** with **JWT tokens** and **HTTP Basic** auth. * More advanced (but equally easy) techniques for declaring **deeply nested JSON models** (thanks to Pydantic). -* **GraphQL** integration with Strawberry and other libraries. +* **GraphQL** integration with [Strawberry](https://strawberry.rocks) and other libraries. * Many extra features (thanks to Starlette) as: * **WebSockets** * extremely easy tests based on HTTPX and `pytest` @@ -452,7 +452,7 @@ For a more complete example including more features, see the FastAPI Cloud, go and join the waiting list if you haven't. 🚀 +You can optionally deploy your FastAPI app to [FastAPI Cloud](https://fastapicloud.com), go and join the waiting list if you haven't. 🚀 If you already have a **FastAPI Cloud** account (we invited you from the waiting list 😉), you can deploy your application with one command. @@ -488,7 +488,7 @@ That's it! Now you can access your app at that URL. ✨ #### About FastAPI Cloud { #about-fastapi-cloud } -**FastAPI Cloud** is built by the same author and team behind **FastAPI**. +**[FastAPI Cloud](https://fastapicloud.com)** is built by the same author and team behind **FastAPI**. It streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort. @@ -504,9 +504,9 @@ Follow your cloud provider's guides to deploy FastAPI apps with them. 🤓 ## Performance { #performance } -Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*) +Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as [one of the fastest Python frameworks available](https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7), only below Starlette and Uvicorn themselves (used internally by FastAPI). (*) -To understand more about it, see the section Benchmarks. +To understand more about it, see the section [Benchmarks](https://fastapi.tiangolo.com/benchmarks/). ## Dependencies { #dependencies } @@ -518,19 +518,19 @@ When you install FastAPI with `pip install "fastapi[standard]"` it comes with th Used by Pydantic: -*About the command
-The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using Uvicorn. +The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using [Uvicorn](https://www.uvicorn.dev). By default, `fastapi dev` will start with auto-reload enabled for local development. -You can read more about it in the FastAPI CLI docs. +You can read more about it in the [FastAPI CLI docs](https://fastapi.tiangolo.com/fastapi-cli/).fastapi dev main.py...email-validator- for email validation. +* [`email-validator`](https://github.com/JoshData/python-email-validator) - for email validation. Used by Starlette: -*httpx- Required if you want to use the `TestClient`. -*jinja2- Required if you want to use the default template configuration. -*python-multipart- Required if you want to support form "parsing", with `request.form()`. +* [`httpx`](https://www.python-httpx.org) - Required if you want to use the `TestClient`. +* [`jinja2`](https://jinja.palletsprojects.com) - Required if you want to use the default template configuration. +* [`python-multipart`](https://github.com/Kludex/python-multipart) - Required if you want to support form "parsing", with `request.form()`. Used by FastAPI: -*uvicorn- for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving. +* [`uvicorn`](https://www.uvicorn.dev) - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving. * `fastapi-cli[standard]` - to provide the `fastapi` command. - * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to FastAPI Cloud. + * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to [FastAPI Cloud](https://fastapicloud.com). ### Without `standard` Dependencies { #without-standard-dependencies } @@ -546,13 +546,13 @@ There are some additional dependencies you might want to install. Additional optional Pydantic dependencies: -*pydantic-settings- for settings management. -*pydantic-extra-types- for extra types to be used with Pydantic. +* [`pydantic-settings`](https://docs.pydantic.dev/latest/usage/pydantic_settings/) - for settings management. +* [`pydantic-extra-types`](https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/) - for extra types to be used with Pydantic. Additional optional FastAPI dependencies: -*orjson- Required if you want to use `ORJSONResponse`. -*ujson- Required if you want to use `UJSONResponse`. +* [`orjson`](https://github.com/ijl/orjson) - Required if you want to use `ORJSONResponse`. +* [`ujson`](https://github.com/esnme/ultrajson) - Required if you want to use `UJSONResponse`. ## License { #license } diff --git a/docs/en/docs/js/custom.js b/docs/en/docs/js/custom.js index be326d3029..311995d7cd 100644 --- a/docs/en/docs/js/custom.js +++ b/docs/en/docs/js/custom.js @@ -174,10 +174,38 @@ function handleSponsorImages() { }); } +function openLinksInNewTab() { + const siteUrl = document.querySelector("link[rel='canonical']")?.href + || window.location.origin; + const siteOrigin = new URL(siteUrl).origin; + document.querySelectorAll(".md-content a[href]").forEach(a => { + if (a.getAttribute("target") === "_self") return; + const href = a.getAttribute("href"); + if (!href) return; + try { + const url = new URL(href, window.location.href); + // Skip same-page anchor links (only the hash differs) + if (url.origin === window.location.origin + && url.pathname === window.location.pathname + && url.search === window.location.search) return; + if (!a.hasAttribute("target")) { + a.setAttribute("target", "_blank"); + a.setAttribute("rel", "noopener"); + } + if (url.origin !== siteOrigin) { + a.dataset.externalLink = ""; + } else { + a.dataset.internalLink = ""; + } + } catch (_) {} + }); +} + async function main() { setupTermynal(); showRandomAnnouncement('announce-left', 5000) handleSponsorImages(); + openLinksInNewTab(); } document$.subscribe(() => { main() diff --git a/docs/en/docs/management-tasks.md b/docs/en/docs/management-tasks.md index fc6e1eb280..e4094c4a18 100644 --- a/docs/en/docs/management-tasks.md +++ b/docs/en/docs/management-tasks.md @@ -1,6 +1,6 @@ # Repository Management Tasks -These are the tasks that can be performed to manage the FastAPI repository by [team members](./fastapi-people.md#team){.internal-link target=_blank}. +These are the tasks that can be performed to manage the FastAPI repository by [team members](./fastapi-people.md#team). /// tip @@ -8,9 +8,9 @@ This section is useful only to a handful of people, team members with permission /// -...so, you are a [team member of FastAPI](./fastapi-people.md#team){.internal-link target=_blank}? Wow, you are so cool! 😎 +...so, you are a [team member of FastAPI](./fastapi-people.md#team)? Wow, you are so cool! 😎 -You can help with everything on [Help FastAPI - Get Help](./help-fastapi.md){.internal-link target=_blank} the same ways as external contributors. But additionally, there are some tasks that only you (as part of the team) can perform. +You can help with everything on [Help FastAPI - Get Help](./help-fastapi.md) the same ways as external contributors. But additionally, there are some tasks that only you (as part of the team) can perform. Here are the general instructions for the tasks you can perform. @@ -40,7 +40,7 @@ For conversations that are more difficult, for example to reject a PR, you can a ## Edit PR Titles -* Edit the PR title to start with an emoji from gitmoji. +* Edit the PR title to start with an emoji from [gitmoji](https://gitmoji.dev/). * Use the emoji character, not the GitHub code. So, use `🐛` instead of `:bug:`. This is so that it shows up correctly outside of GitHub, for example in the release notes. * For translations use the `🌐` emoji ("globe with meridians"). * Start the title with a verb. For example `Add`, `Refactor`, `Fix`, etc. This way the title will say the action that the PR does. Like `Add support for teleporting`, instead of `Teleporting wasn't working, so this PR fixes it`. @@ -53,15 +53,15 @@ For conversations that are more difficult, for example to reject a PR, you can a 🌐 Add Spanish translation for `docs/es/docs/teleporting.md` ``` -Once the PR is merged, a GitHub Action (latest-changes) will use the PR title to update the latest changes automatically. +Once the PR is merged, a GitHub Action ([latest-changes](https://github.com/tiangolo/latest-changes)) will use the PR title to update the latest changes automatically. So, having a nice PR title will not only look nice in GitHub, but also in the release notes. 📝 ## Add Labels to PRs -The same GitHub Action latest-changes uses one label in the PR to decide the section in the release notes to put this PR in. +The same GitHub Action [latest-changes](https://github.com/tiangolo/latest-changes) uses one label in the PR to decide the section in the release notes to put this PR in. -Make sure you use a supported label from the latest-changes list of labels: +Make sure you use a supported label from the [latest-changes list of labels](https://github.com/tiangolo/latest-changes#using-labels): * `breaking`: Breaking Changes * Existing code will break if they update the version without changing their code. This rarely happens, so this label is not frequently used. @@ -108,7 +108,7 @@ This way, we can notice when there are new translations ready, because they have Translations are generated automatically with LLMs and scripts. -There's one GitHub Action that can be manually run to add or update translations for a language: `translate.yml`. +There's one GitHub Action that can be manually run to add or update translations for a language: [`translate.yml`](https://github.com/fastapi/fastapi/actions/workflows/translate.yml). For these language translation PRs, confirm that: @@ -140,7 +140,7 @@ For these language translation PRs, confirm that: ## FastAPI People PRs -Every month, a GitHub Action updates the FastAPI People data. Those PRs look like this one: 👥 Update FastAPI People. +Every month, a GitHub Action updates the FastAPI People data. Those PRs look like this one: [👥 Update FastAPI People](https://github.com/fastapi/fastapi/pull/11669). If the tests are passing, you can merge it right away. @@ -155,4 +155,4 @@ Dependabot will create PRs to update dependencies for several things, and those When a question in GitHub Discussions has been answered, mark the answer by clicking "Mark as answer". -You can filter discussions by `Questions` that are `Unanswered`. +You can filter discussions by [`Questions` that are `Unanswered`](https://github.com/tiangolo/fastapi/discussions/categories/questions?discussions_q=category:Questions+is:open+is:unanswered). diff --git a/docs/en/docs/management.md b/docs/en/docs/management.md index 085a1756f8..7f20474f6d 100644 --- a/docs/en/docs/management.md +++ b/docs/en/docs/management.md @@ -4,15 +4,15 @@ Here's a short description of how the FastAPI repository is managed and maintain ## Owner -I, @tiangolo, am the creator and owner of the FastAPI repository. 🤓 +I, [@tiangolo](https://github.com/tiangolo), am the creator and owner of the FastAPI repository. 🤓 -I normally give the final review to each PR before merging them. I make the final decisions on the project, I'm the BDFL. 😅 +I normally give the final review to each PR before merging them. I make the final decisions on the project, I'm the [BDFL](https://en.wikipedia.org/wiki/Benevolent_dictator_for_life). 😅 ## Team There's a team of people that help manage and maintain the project. 😎 -They have different levels of permissions and [specific instructions](./management-tasks.md){.internal-link target=_blank}. +They have different levels of permissions and [specific instructions](./management-tasks.md). Some of the tasks they can perform include: @@ -22,13 +22,13 @@ Some of the tasks they can perform include: * Mark answers in GitHub Discussions questions, etc. * Merge some specific types of PRs. -You can see the current team members in [FastAPI People - Team](./fastapi-people.md#team){.internal-link target=_blank}. +You can see the current team members in [FastAPI People - Team](./fastapi-people.md#team). Joining the team is by invitation only, and I could update or remove permissions, instructions, or membership. ## FastAPI Experts -The people that help others the most in GitHub Discussions can become [**FastAPI Experts**](./fastapi-people.md#fastapi-experts){.internal-link target=_blank}. +The people that help others the most in GitHub Discussions can become [**FastAPI Experts**](./fastapi-people.md#fastapi-experts). This is normally the best way to contribute to the project. @@ -36,4 +36,4 @@ This is normally the best way to contribute to the project. External contributions are very welcome and appreciated, including answering questions, submitting PRs, etc. 🙇♂️ -There are many ways to [help maintain FastAPI](./help-fastapi.md#help-maintain-fastapi){.internal-link target=_blank}. +There are many ways to [help maintain FastAPI](./help-fastapi.md#help-maintain-fastapi). diff --git a/docs/en/docs/project-generation.md b/docs/en/docs/project-generation.md index 610d23ccb1..aa579af5ef 100644 --- a/docs/en/docs/project-generation.md +++ b/docs/en/docs/project-generation.md @@ -4,7 +4,7 @@ Templates, while typically come with a specific setup, are designed to be flexib You can use this template to get started, as it includes a lot of the initial set up, security, database and some API endpoints already done for you. -GitHub Repository: Full Stack FastAPI Template +GitHub Repository: [Full Stack FastAPI Template](https://github.com/tiangolo/full-stack-fastapi-template) ## Full Stack FastAPI Template - Technology Stack and Features { #full-stack-fastapi-template-technology-stack-and-features } diff --git a/docs/en/docs/python-types.md b/docs/en/docs/python-types.md index 90c32cec8c..0cddcd3902 100644 --- a/docs/en/docs/python-types.md +++ b/docs/en/docs/python-types.md @@ -269,7 +269,7 @@ It doesn't mean "`one_person` is the **class** called `Person`". ## Pydantic models { #pydantic-models } -Pydantic is a Python library to perform data validation. +[Pydantic](https://docs.pydantic.dev/) is a Python library to perform data validation. You declare the "shape" of the data as classes with attributes. @@ -285,13 +285,13 @@ An example from the official Pydantic docs: /// info -To learn more about Pydantic, check its docs. +To learn more about [Pydantic, check its docs](https://docs.pydantic.dev/). /// **FastAPI** is all based on Pydantic. -You will see a lot more of all this in practice in the [Tutorial - User Guide](tutorial/index.md){.internal-link target=_blank}. +You will see a lot more of all this in practice in the [Tutorial - User Guide](tutorial/index.md). ## Type Hints with Metadata Annotations { #type-hints-with-metadata-annotations } @@ -337,12 +337,12 @@ With **FastAPI** you declare parameters with type hints and you get: * **Document** the API using OpenAPI: * which is then used by the automatic interactive documentation user interfaces. -This might all sound abstract. Don't worry. You'll see all this in action in the [Tutorial - User Guide](tutorial/index.md){.internal-link target=_blank}. +This might all sound abstract. Don't worry. You'll see all this in action in the [Tutorial - User Guide](tutorial/index.md). The important thing is that by using standard Python types, in a single place (instead of adding more classes, decorators, etc), **FastAPI** will do a lot of the work for you. /// info -If you already went through all the tutorial and came back to see more about types, a good resource is the "cheat sheet" from `mypy`. +If you already went through all the tutorial and came back to see more about types, a good resource is [the "cheat sheet" from `mypy`](https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html). /// diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index e0adeb1dc2..f7013ed8ee 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -7,6 +7,71 @@ hide: ## Latest Changes +### Docs + +* 📝 Update links in docs to no longer use the classes external-link and internal-link. PR [#15061](https://github.com/fastapi/fastapi/pull/15061) by [@tiangolo](https://github.com/tiangolo). +* 🔨 Add JS and CSS handling for automatic `target=_blank` for links in docs. PR [#15063](https://github.com/fastapi/fastapi/pull/15063) by [@tiangolo](https://github.com/tiangolo). +* 💄 Update styles for internal and external links in new tab. PR [#15058](https://github.com/fastapi/fastapi/pull/15058) by [@tiangolo](https://github.com/tiangolo). +* 📝 Add documentation for the FastAPI VS Code extension. PR [#15008](https://github.com/fastapi/fastapi/pull/15008) by [@savannahostrowski](https://github.com/savannahostrowski). +* 📝 Fix doctrings for `max_digits` and `decimal_places`. PR [#14944](https://github.com/fastapi/fastapi/pull/14944) by [@YuriiMotov](https://github.com/YuriiMotov). +* 📝 Add dates to release notes. PR [#15001](https://github.com/fastapi/fastapi/pull/15001) by [@YuriiMotov](https://github.com/YuriiMotov). + +### Internal + +* 🔨 Update script to autofix permalinks to account for headers with Markdown links. PR [#15062](https://github.com/fastapi/fastapi/pull/15062) by [@tiangolo](https://github.com/tiangolo). +* 📌 Pin Click for MkDocs live reload. PR [#15057](https://github.com/fastapi/fastapi/pull/15057) by [@tiangolo](https://github.com/tiangolo). +* ⬆ Bump werkzeug from 3.1.5 to 3.1.6. PR [#14948](https://github.com/fastapi/fastapi/pull/14948) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump pydantic-ai from 1.62.0 to 1.63.0. PR [#15035](https://github.com/fastapi/fastapi/pull/15035) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump pytest-codspeed from 4.2.0 to 4.3.0. PR [#15034](https://github.com/fastapi/fastapi/pull/15034) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump strawberry-graphql from 0.291.2 to 0.307.1. PR [#15033](https://github.com/fastapi/fastapi/pull/15033) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump typer from 0.21.1 to 0.24.1. PR [#15032](https://github.com/fastapi/fastapi/pull/15032) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump actions/download-artifact from 7 to 8. PR [#15020](https://github.com/fastapi/fastapi/pull/15020) by [@dependabot[bot]](https://github.com/apps/dependabot). +* ⬆ Bump actions/upload-artifact from 6 to 7. PR [#15019](https://github.com/fastapi/fastapi/pull/15019) by [@dependabot[bot]](https://github.com/apps/dependabot). + +## 0.135.1 + +### Fixes + +* 🐛 Fix, avoid yield from a TaskGroup, only as an async context manager, closed in the request async exit stack. PR [#15038](https://github.com/fastapi/fastapi/pull/15038) by [@tiangolo](https://github.com/tiangolo). + +### Docs + +* ✏️ Fix typo in `docs/en/docs/_llm-test.md`. PR [#15007](https://github.com/fastapi/fastapi/pull/15007) by [@adityagiri3600](https://github.com/adityagiri3600). +* 📝 Update Skill, optimize context, trim and refactor into references. PR [#15031](https://github.com/fastapi/fastapi/pull/15031) by [@tiangolo](https://github.com/tiangolo). + +### Internal + +* 👥 Update FastAPI People - Experts. PR [#15037](https://github.com/fastapi/fastapi/pull/15037) by [@tiangolo](https://github.com/tiangolo). +* 👥 Update FastAPI People - Contributors and Translators. PR [#15029](https://github.com/fastapi/fastapi/pull/15029) by [@tiangolo](https://github.com/tiangolo). +* 👥 Update FastAPI GitHub topic repositories. PR [#15036](https://github.com/fastapi/fastapi/pull/15036) by [@tiangolo](https://github.com/tiangolo). + +## 0.135.0 + +### Features + +* ✨ Add support for Server Sent Events. PR [#15030](https://github.com/fastapi/fastapi/pull/15030) by [@tiangolo](https://github.com/tiangolo). + * New docs: [Server-Sent Events (SSE)](https://fastapi.tiangolo.com/tutorial/server-sent-events/). + +## 0.134.0 + +### Features + +* ✨ Add support for streaming JSON Lines and binary data with `yield`. PR [#15022](https://github.com/fastapi/fastapi/pull/15022) by [@tiangolo](https://github.com/tiangolo). + * This also upgrades Starlette from `>=0.40.0` to `>=0.46.0`, as it's needed to properly unrwap and re-raise exceptions from exception groups. + * New docs: [Stream JSON Lines](https://fastapi.tiangolo.com/tutorial/stream-json-lines/). + * And new docs: [Stream Data](https://fastapi.tiangolo.com/advanced/stream-data/). + +### Docs + +* 📝 Update Library Agent Skill with streaming responses. PR [#15024](https://github.com/fastapi/fastapi/pull/15024) by [@tiangolo](https://github.com/tiangolo). +* 📝 Update docs for responses and new stream with `yield`. PR [#15023](https://github.com/fastapi/fastapi/pull/15023) by [@tiangolo](https://github.com/tiangolo). +* 📝 Add `await` in `StreamingResponse` code example to allow cancellation. PR [#14681](https://github.com/fastapi/fastapi/pull/14681) by [@casperdcl](https://github.com/casperdcl). +* 📝 Rename `docs_src/websockets` to `docs_src/websockets_` to avoid import errors. PR [#14979](https://github.com/fastapi/fastapi/pull/14979) by [@YuriiMotov](https://github.com/YuriiMotov). + +### Internal + +* 🔨 Run tests with `pytest-xdist` and `pytest-cov`. PR [#14992](https://github.com/fastapi/fastapi/pull/14992) by [@YuriiMotov](https://github.com/YuriiMotov). + ## 0.133.1 ### Features @@ -18,13 +83,13 @@ hide: * ✅ Fix all tests are skipped on Windows. PR [#14994](https://github.com/fastapi/fastapi/pull/14994) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.133.0 +## 0.133.0 (2026-02-24) ### Upgrades * ⬆️ Add support for Starlette 1.0.0+. PR [#14987](https://github.com/fastapi/fastapi/pull/14987) by [@tiangolo](https://github.com/tiangolo). -## 0.132.1 +## 0.132.1 (2026-02-24) ### Refactors @@ -35,7 +100,7 @@ hide: * 👥 Update FastAPI People - Experts. PR [#14972](https://github.com/fastapi/fastapi/pull/14972) by [@tiangolo](https://github.com/tiangolo). * 👷 Allow skipping `benchmark` job in `test` workflow. PR [#14974](https://github.com/fastapi/fastapi/pull/14974) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.132.0 +## 0.132.0 (2026-02-23) ### Breaking Changes @@ -52,13 +117,13 @@ hide: * 👷 Do not run codspeed with coverage as it's not tracked. PR [#14966](https://github.com/fastapi/fastapi/pull/14966) by [@tiangolo](https://github.com/tiangolo). * 👷 Do not include benchmark tests in coverage to speed up coverage processing. PR [#14965](https://github.com/fastapi/fastapi/pull/14965) by [@tiangolo](https://github.com/tiangolo). -## 0.131.0 +## 0.131.0 (2026-02-22) ### Breaking Changes * 🗑️ Deprecate `ORJSONResponse` and `UJSONResponse`. PR [#14964](https://github.com/fastapi/fastapi/pull/14964) by [@tiangolo](https://github.com/tiangolo). -## 0.130.0 +## 0.130.0 (2026-02-22) ### Features @@ -66,7 +131,7 @@ hide: * This results in 2x (or more) performance increase for JSON responses. * New docs: [Custom Response - JSON Performance](https://fastapi.tiangolo.com/advanced/custom-response/#json-performance). -## 0.129.2 +## 0.129.2 (2026-02-21) ### Internal @@ -75,7 +140,7 @@ hide: * ➖ Drop support for `fastapi-slim`, no more versions will be released, use only `"fastapi[standard]"` or `fastapi`. PR [#14957](https://github.com/fastapi/fastapi/pull/14957) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update pyproject.toml, remove unneeded lines. PR [#14956](https://github.com/fastapi/fastapi/pull/14956) by [@tiangolo](https://github.com/tiangolo). -## 0.129.1 +## 0.129.1 (2026-02-21) ### Fixes @@ -110,7 +175,7 @@ hide: * ⬆ Bump cryptography from 46.0.4 to 46.0.5. PR [#14892](https://github.com/fastapi/fastapi/pull/14892) by [@dependabot[bot]](https://github.com/apps/dependabot). * ⬆ Bump pillow from 12.1.0 to 12.1.1. PR [#14899](https://github.com/fastapi/fastapi/pull/14899) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.129.0 +## 0.129.0 (2026-02-12) ### Breaking Changes @@ -129,7 +194,7 @@ hide: * 🔨 Update docs.py scripts to migrate Python 3.9 to Python 3.10. PR [#14906](https://github.com/fastapi/fastapi/pull/14906) by [@tiangolo](https://github.com/tiangolo). -## 0.128.8 +## 0.128.8 (2026-02-11) ### Docs @@ -140,7 +205,7 @@ hide: * 🔨 Tweak PDM hook script. PR [#14895](https://github.com/fastapi/fastapi/pull/14895) by [@tiangolo](https://github.com/tiangolo). * ♻️ Update build setup for `fastapi-slim`, deprecate it, and make it only depend on `fastapi`. PR [#14894](https://github.com/fastapi/fastapi/pull/14894) by [@tiangolo](https://github.com/tiangolo). -## 0.128.7 +## 0.128.7 (2026-02-10) ### Features @@ -162,7 +227,7 @@ hide: * ✅ Test order for the submitted byte Files. PR [#14828](https://github.com/fastapi/fastapi/pull/14828) by [@valentinDruzhinin](https://github.com/valentinDruzhinin). * 🔧 Configure `test` workflow to run tests with `inline-snapshot=review`. PR [#14876](https://github.com/fastapi/fastapi/pull/14876) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.128.6 +## 0.128.6 (2026-02-09) ### Fixes @@ -176,7 +241,7 @@ hide: * ✅ Fix parameterized tests with snapshots. PR [#14875](https://github.com/fastapi/fastapi/pull/14875) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.128.5 +## 0.128.5 (2026-02-08) ### Refactors @@ -186,7 +251,7 @@ hide: * ✅ Add inline snapshot tests for OpenAPI before changes from Pydantic v2. PR [#14864](https://github.com/fastapi/fastapi/pull/14864) by [@tiangolo](https://github.com/tiangolo). -## 0.128.4 +## 0.128.4 (2026-02-07) ### Refactors @@ -203,7 +268,7 @@ hide: * ⬆️ Upgrade development dependencies. PR [#14854](https://github.com/fastapi/fastapi/pull/14854) by [@tiangolo](https://github.com/tiangolo). -## 0.128.3 +## 0.128.3 (2026-02-06) ### Refactors @@ -222,7 +287,7 @@ hide: * 👷 Run tests with Starlette from git. PR [#14849](https://github.com/fastapi/fastapi/pull/14849) by [@tiangolo](https://github.com/tiangolo). * 👷 Run tests with lower bound uv sync, upgrade `fastapi[all]` minimum dependencies: `ujson >=5.8.0`, `orjson >=3.9.3`. PR [#14846](https://github.com/fastapi/fastapi/pull/14846) by [@tiangolo](https://github.com/tiangolo). -## 0.128.2 +## 0.128.2 (2026-02-05) ### Features @@ -258,7 +323,7 @@ hide: * 🔨 Add max pages to translate to configs. PR [#14840](https://github.com/fastapi/fastapi/pull/14840) by [@tiangolo](https://github.com/tiangolo). -## 0.128.1 +## 0.128.1 (2026-02-04) ### Features @@ -358,7 +423,7 @@ hide: * 🔥 Remove test variants for Pydantic v1 in test_request_params. PR [#14612](https://github.com/fastapi/fastapi/pull/14612) by [@tiangolo](https://github.com/tiangolo). * 🔥 Remove Pydantic v1 specific test variants. PR [#14611](https://github.com/fastapi/fastapi/pull/14611) by [@tiangolo](https://github.com/tiangolo). -## 0.128.0 +## 0.128.0 (2025-12-27) ### Breaking Changes @@ -368,7 +433,7 @@ hide: * ✅ Run performance tests only on Pydantic v2. PR [#14608](https://github.com/fastapi/fastapi/pull/14608) by [@tiangolo](https://github.com/tiangolo). -## 0.127.1 +## 0.127.1 (2025-12-26) ### Refactors @@ -392,7 +457,7 @@ hide: * 👷 Run CodSpeed tests in parallel to other tests to speed up CI. PR [#14586](https://github.com/fastapi/fastapi/pull/14586) by [@tiangolo](https://github.com/tiangolo). * 🔨 Update scripts and pre-commit to autofix files. PR [#14585](https://github.com/fastapi/fastapi/pull/14585) by [@tiangolo](https://github.com/tiangolo). -## 0.127.0 +## 0.127.0 (2025-12-21) ### Breaking Changes @@ -407,7 +472,7 @@ hide: * ⬆️ Upgrade OpenAI model for translations to gpt-5.2. PR [#14579](https://github.com/fastapi/fastapi/pull/14579) by [@tiangolo](https://github.com/tiangolo). -## 0.126.0 +## 0.126.0 (2025-12-20) ### Upgrades @@ -429,7 +494,7 @@ hide: * ⬆️ Use prek as a pre-commit alternative. PR [#14572](https://github.com/fastapi/fastapi/pull/14572) by [@tiangolo](https://github.com/tiangolo). * 👷 Add performance tests with CodSpeed. PR [#14558](https://github.com/fastapi/fastapi/pull/14558) by [@tiangolo](https://github.com/tiangolo). -## 0.125.0 +## 0.125.0 (2025-12-17) ### Breaking Changes @@ -473,13 +538,13 @@ hide: * 👷 Update github-actions user for GitHub Actions workflows. PR [#14528](https://github.com/fastapi/fastapi/pull/14528) by [@tiangolo](https://github.com/tiangolo). * ➕ Add requirements for translations. PR [#14515](https://github.com/fastapi/fastapi/pull/14515) by [@tiangolo](https://github.com/tiangolo). -## 0.124.4 +## 0.124.4 (2025-12-12) ### Fixes * 🐛 Fix parameter aliases. PR [#14371](https://github.com/fastapi/fastapi/pull/14371) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.124.3 +## 0.124.3 (2025-12-12) ### Fixes @@ -505,13 +570,13 @@ hide: * 👷 Tweak coverage to not pass Smokeshow max file size limit. PR [#14507](https://github.com/fastapi/fastapi/pull/14507) by [@tiangolo](https://github.com/tiangolo). * ✅ Expand test matrix to include Windows and MacOS. PR [#14171](https://github.com/fastapi/fastapi/pull/14171) by [@svlandeg](https://github.com/svlandeg). -## 0.124.2 +## 0.124.2 (2025-12-10) ### Fixes * 🐛 Fix support for `if TYPE_CHECKING`, non-evaluated stringified annotations. PR [#14485](https://github.com/fastapi/fastapi/pull/14485) by [@tiangolo](https://github.com/tiangolo). -## 0.124.1 +## 0.124.1 (2025-12-10) ### Fixes @@ -526,7 +591,7 @@ hide: * ✅ Add test for Pydantic v2, dataclasses, UUID, and `__annotations__`. PR [#14477](https://github.com/fastapi/fastapi/pull/14477) by [@tiangolo](https://github.com/tiangolo). -## 0.124.0 +## 0.124.0 (2025-12-06) ### Features @@ -536,38 +601,38 @@ hide: * ✏️ Fix typo in `scripts/mkdocs_hooks.py`. PR [#14457](https://github.com/fastapi/fastapi/pull/14457) by [@yujiteshima](https://github.com/yujiteshima). -## 0.123.10 +## 0.123.10 (2025-12-05) ### Fixes * 🐛 Fix using class (not instance) dependency that has `__call__` method. PR [#14458](https://github.com/fastapi/fastapi/pull/14458) by [@YuriiMotov](https://github.com/YuriiMotov). * 🐛 Fix `separate_input_output_schemas=False` with `computed_field`. PR [#14453](https://github.com/fastapi/fastapi/pull/14453) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.123.9 +## 0.123.9 (2025-12-04) ### Fixes * 🐛 Fix OAuth2 scopes in OpenAPI in extra corner cases, parent dependency with scopes, sub-dependency security scheme without scopes. PR [#14459](https://github.com/fastapi/fastapi/pull/14459) by [@tiangolo](https://github.com/tiangolo). -## 0.123.8 +## 0.123.8 (2025-12-04) ### Fixes * 🐛 Fix OpenAPI security scheme OAuth2 scopes declaration, deduplicate security schemes with different scopes. PR [#14455](https://github.com/fastapi/fastapi/pull/14455) by [@tiangolo](https://github.com/tiangolo). -## 0.123.7 +## 0.123.7 (2025-12-04) ### Fixes * 🐛 Fix evaluating stringified annotations in Python 3.10. PR [#11355](https://github.com/fastapi/fastapi/pull/11355) by [@chaen](https://github.com/chaen). -## 0.123.6 +## 0.123.6 (2025-12-04) ### Fixes * 🐛 Fix support for functools wraps and partial combined, for async and regular functions and classes in path operations and dependencies. PR [#14448](https://github.com/fastapi/fastapi/pull/14448) by [@tiangolo](https://github.com/tiangolo). -## 0.123.5 +## 0.123.5 (2025-12-02) ### Features @@ -588,7 +653,7 @@ hide: * 🌐 Sync German docs. PR [#14367](https://github.com/fastapi/fastapi/pull/14367) by [@nilslindemann](https://github.com/nilslindemann). -## 0.123.4 +## 0.123.4 (2025-12-02) ### Fixes @@ -598,14 +663,14 @@ hide: * 📝 Fix docstring of `servers` parameter. PR [#14405](https://github.com/fastapi/fastapi/pull/14405) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.123.3 +## 0.123.3 (2025-12-02) ### Fixes * 🐛 Fix Query\Header\Cookie parameter model alias. PR [#14360](https://github.com/fastapi/fastapi/pull/14360) by [@YuriiMotov](https://github.com/YuriiMotov). * 🐛 Fix optional sequence handling in `serialize sequence value` with Pydantic V2. PR [#14297](https://github.com/fastapi/fastapi/pull/14297) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.123.2 +## 0.123.2 (2025-12-02) ### Fixes @@ -620,7 +685,7 @@ hide: * 📝 Update Primary Key notes for the SQL databases tutorial to avoid confusion. PR [#14120](https://github.com/fastapi/fastapi/pull/14120) by [@FlaviusRaducu](https://github.com/FlaviusRaducu). * 📝 Clarify estimation note in documentation. PR [#14070](https://github.com/fastapi/fastapi/pull/14070) by [@SaisakthiM](https://github.com/SaisakthiM). -## 0.123.1 +## 0.123.1 (2025-12-02) ### Fixes @@ -636,13 +701,13 @@ hide: * 👥 Update FastAPI People - Sponsors. PR [#14422](https://github.com/fastapi/fastapi/pull/14422) by [@tiangolo](https://github.com/tiangolo). * 👥 Update FastAPI People - Contributors and Translators. PR [#14420](https://github.com/fastapi/fastapi/pull/14420) by [@tiangolo](https://github.com/tiangolo). -## 0.123.0 +## 0.123.0 (2025-11-30) ### Fixes * 🐛 Cache dependencies that don't use scopes and don't have sub-dependencies with scopes. PR [#14419](https://github.com/fastapi/fastapi/pull/14419) by [@tiangolo](https://github.com/tiangolo). -## 0.122.1 +## 0.122.1 (2025-11-30) ### Fixes @@ -656,7 +721,7 @@ hide: * ⬆ Bump markdown-include-variants from 0.0.5 to 0.0.6. PR [#14418](https://github.com/fastapi/fastapi/pull/14418) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.122.0 +## 0.122.0 (2025-11-24) ### Fixes @@ -674,7 +739,7 @@ hide: * 🛠️ Add `add-permalinks` and `add-permalinks-page` to `scripts/docs.py`. PR [#14033](https://github.com/fastapi/fastapi/pull/14033) by [@YuriiMotov](https://github.com/YuriiMotov). * 🔧 Upgrade Material for MkDocs and remove insiders. PR [#14375](https://github.com/fastapi/fastapi/pull/14375) by [@tiangolo](https://github.com/tiangolo). -## 0.121.3 +## 0.121.3 (2025-11-19) ### Refactors @@ -690,7 +755,7 @@ hide: * 📝 Fix typos in code comments. PR [#14364](https://github.com/fastapi/fastapi/pull/14364) by [@Edge-Seven](https://github.com/Edge-Seven). * 📝 Add docs for using FastAPI Cloud. PR [#14359](https://github.com/fastapi/fastapi/pull/14359) by [@tiangolo](https://github.com/tiangolo). -## 0.121.2 +## 0.121.2 (2025-11-13) ### Fixes @@ -708,7 +773,7 @@ hide: * 🌐 Sync Russian docs. PR [#14331](https://github.com/fastapi/fastapi/pull/14331) by [@YuriiMotov](https://github.com/YuriiMotov). * 🌐 Sync German docs. PR [#14317](https://github.com/fastapi/fastapi/pull/14317) by [@nilslindemann](https://github.com/nilslindemann). -## 0.121.1 +## 0.121.1 (2025-11-08) ### Fixes @@ -723,7 +788,7 @@ hide: * ⬆ Bump ruff from 0.13.2 to 0.14.3. PR [#14276](https://github.com/fastapi/fastapi/pull/14276) by [@dependabot[bot]](https://github.com/apps/dependabot). * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#14289](https://github.com/fastapi/fastapi/pull/14289) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.121.0 +## 0.121.0 (2025-11-03) ### Features @@ -738,13 +803,13 @@ hide: * ⬆ Bump mkdocs-macros-plugin from 1.4.0 to 1.4.1. PR [#14277](https://github.com/fastapi/fastapi/pull/14277) by [@dependabot[bot]](https://github.com/apps/dependabot). * ⬆ Bump mkdocstrings[python] from 0.26.1 to 0.30.1. PR [#14279](https://github.com/fastapi/fastapi/pull/14279) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.120.4 +## 0.120.4 (2025-10-31) ### Fixes * 🐛 Fix security schemes in OpenAPI when added at the top level app. PR [#14266](https://github.com/fastapi/fastapi/pull/14266) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.120.3 +## 0.120.3 (2025-10-30) ### Refactors @@ -756,7 +821,7 @@ hide: * 📝 Update note for untranslated pages. PR [#14257](https://github.com/fastapi/fastapi/pull/14257) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.120.2 +## 0.120.2 (2025-10-29) ### Fixes @@ -769,7 +834,7 @@ hide: * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#14237](https://github.com/fastapi/fastapi/pull/14237) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). * ⬆ Bump actions/upload-artifact from 4 to 5. PR [#14235](https://github.com/fastapi/fastapi/pull/14235) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.120.1 +## 0.120.1 (2025-10-27) ### Upgrades @@ -779,7 +844,7 @@ hide: * 🔧 Add `license` and `license-files` to `pyproject.toml`, remove `License` from `classifiers`. PR [#14230](https://github.com/fastapi/fastapi/pull/14230) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.120.0 +## 0.120.0 (2025-10-23) There are no major nor breaking changes in this release. ☕️ @@ -799,7 +864,7 @@ This new version `0.120.0` only contains that transition to the new home package * 🛠️ Update German LLM prompt and test file. PR [#14189](https://github.com/fastapi/fastapi/pull/14189) by [@nilslindemann](https://github.com/nilslindemann). * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#14181](https://github.com/fastapi/fastapi/pull/14181) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.119.1 +## 0.119.1 (2025-10-20) ### Fixes @@ -814,7 +879,7 @@ This new version `0.120.0` only contains that transition to the new home package * 🔧 Add sponsor Requestly. PR [#14205](https://github.com/fastapi/fastapi/pull/14205) by [@tiangolo](https://github.com/tiangolo). * 🔧 Configure reminder for `waiting` label in `issue-manager`. PR [#14156](https://github.com/fastapi/fastapi/pull/14156) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.119.0 +## 0.119.0 (2025-10-11) FastAPI now (temporarily) supports both Pydantic v2 models and `pydantic.v1` models at the same time in the same app, to make it easier for any FastAPI apps still using Pydantic v1 to gradually but quickly **migrate to Pydantic v2**. @@ -854,13 +919,13 @@ You can read in the docs more about how to [Migrate from Pydantic v1 to Pydantic * ✨ Add support for `from pydantic.v1 import BaseModel`, mixed Pydantic v1 and v2 models in the same app. PR [#14168](https://github.com/fastapi/fastapi/pull/14168) by [@tiangolo](https://github.com/tiangolo). -## 0.118.3 +## 0.118.3 (2025-10-10) ### Upgrades * ⬆️ Add support for Python 3.14. PR [#14165](https://github.com/fastapi/fastapi/pull/14165) by [@svlandeg](https://github.com/svlandeg). -## 0.118.2 +## 0.118.2 (2025-10-08) ### Fixes @@ -870,7 +935,7 @@ You can read in the docs more about how to [Migrate from Pydantic v1 to Pydantic * ⬆ Bump astral-sh/setup-uv from 6 to 7. PR [#14167](https://github.com/fastapi/fastapi/pull/14167) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.118.1 +## 0.118.1 (2025-10-08) ### Upgrades @@ -905,7 +970,7 @@ You can read in the docs more about how to [Migrate from Pydantic v1 to Pydantic * 👷 Update docs previews comment, single comment, add failure status. PR [#14129](https://github.com/fastapi/fastapi/pull/14129) by [@tiangolo](https://github.com/tiangolo). * 🔨 Modify `mkdocs_hooks.py` to add `title` to page's metadata (remove permalinks in social cards). PR [#14125](https://github.com/fastapi/fastapi/pull/14125) by [@YuriiMotov](https://github.com/YuriiMotov). -## 0.118.0 +## 0.118.0 (2025-09-29) ### Fixes @@ -938,13 +1003,13 @@ You can read more about it in the docs for [Advanced Dependencies - Dependencies * 🐛 Fix sponsor display issue by hiding element on image error. PR [#14097](https://github.com/fastapi/fastapi/pull/14097) by [@alejsdev](https://github.com/alejsdev). * 🐛 Hide sponsor badge when sponsor image is not displayed. PR [#14096](https://github.com/fastapi/fastapi/pull/14096) by [@alejsdev](https://github.com/alejsdev). -## 0.117.1 +## 0.117.1 (2025-09-20) ### Fixes * 🐛 Fix validation error when `File` is declared after `Form` parameter. PR [#11194](https://github.com/fastapi/fastapi/pull/11194) by [@thomasleveil](https://github.com/thomasleveil). -## 0.117.0 +## 0.117.0 (2025-09-20) ### Features @@ -985,7 +1050,7 @@ You can read more about it in the docs for [Advanced Dependencies - Dependencies * 🛠️ Update `docs.py generate-readme` command to remove permalinks from headers. PR [#14055](https://github.com/fastapi/fastapi/pull/14055) by [@YuriiMotov](https://github.com/YuriiMotov). * ⬆️ Update mypy to 1.14.1. PR [#12970](https://github.com/fastapi/fastapi/pull/12970) by [@tamird](https://github.com/tamird). -## 0.116.2 +## 0.116.2 (2025-09-16) ### Upgrades @@ -1066,7 +1131,7 @@ You can read more about it in the docs for [Advanced Dependencies - Dependencies * 👥 Update FastAPI People - Experts. PR [#13889](https://github.com/fastapi/fastapi/pull/13889) by [@tiangolo](https://github.com/tiangolo). * 🔨 Update FastAPI People sleep interval, use external settings. PR [#13888](https://github.com/fastapi/fastapi/pull/13888) by [@tiangolo](https://github.com/tiangolo). -## 0.116.1 +## 0.116.1 (2025-07-11) ### Upgrades @@ -1080,7 +1145,7 @@ You can read more about it in the docs for [Advanced Dependencies - Dependencies * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#13871](https://github.com/fastapi/fastapi/pull/13871) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.116.0 +## 0.116.0 (2025-07-07) ### Features @@ -1107,7 +1172,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#13843](https://github.com/fastapi/fastapi/pull/13843) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). * 👥 Update FastAPI People - Contributors and Translators. PR [#13845](https://github.com/fastapi/fastapi/pull/13845) by [@tiangolo](https://github.com/tiangolo). -## 0.115.14 +## 0.115.14 (2025-06-26) ### Fixes @@ -1131,7 +1196,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#13823](https://github.com/fastapi/fastapi/pull/13823) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.115.13 +## 0.115.13 (2025-06-17) ### Fixes @@ -1236,7 +1301,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 🔧 Clean up `docs/en/mkdocs.yml` configuration file. PR [#13542](https://github.com/fastapi/fastapi/pull/13542) by [@svlandeg](https://github.com/svlandeg). * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12986](https://github.com/fastapi/fastapi/pull/12986) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.115.12 +## 0.115.12 (2025-03-23) ### Fixes @@ -1265,7 +1330,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * ⬆ Bump ruff to 0.9.4. PR [#13299](https://github.com/fastapi/fastapi/pull/13299) by [@dependabot[bot]](https://github.com/apps/dependabot). * 🔧 Update sponsors: pause TestDriven. PR [#13446](https://github.com/fastapi/fastapi/pull/13446) by [@tiangolo](https://github.com/tiangolo). -## 0.115.11 +## 0.115.11 (2025-03-01) ### Fixes @@ -1282,7 +1347,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 👥 Update FastAPI People - Contributors and Translators. PR [#13432](https://github.com/fastapi/fastapi/pull/13432) by [@tiangolo](https://github.com/tiangolo). * 👥 Update FastAPI People - Sponsors. PR [#13433](https://github.com/fastapi/fastapi/pull/13433) by [@tiangolo](https://github.com/tiangolo). -## 0.115.10 +## 0.115.10 (2025-02-28) ### Fixes @@ -1306,7 +1371,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/request-forms.md`. PR [#13383](https://github.com/fastapi/fastapi/pull/13383) by [@valentinDruzhinin](https://github.com/valentinDruzhinin). * 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/testing.md`. PR [#13371](https://github.com/fastapi/fastapi/pull/13371) by [@valentinDruzhinin](https://github.com/valentinDruzhinin). -## 0.115.9 +## 0.115.9 (2025-02-27) ### Fixes @@ -1369,7 +1434,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * ⬆ Bump inline-snapshot from 0.18.1 to 0.19.3. PR [#13298](https://github.com/fastapi/fastapi/pull/13298) by [@dependabot[bot]](https://github.com/apps/dependabot). * 🔧 Update sponsors, add Permit. PR [#13288](https://github.com/fastapi/fastapi/pull/13288) by [@tiangolo](https://github.com/tiangolo). -## 0.115.8 +## 0.115.8 (2025-01-30) ### Fixes @@ -1404,7 +1469,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 🔨 Update FastAPI People Experts script, refactor and optimize data fetching to handle rate limits. PR [#13267](https://github.com/fastapi/fastapi/pull/13267) by [@tiangolo](https://github.com/tiangolo). * ⬆ Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4. PR [#13251](https://github.com/fastapi/fastapi/pull/13251) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.115.7 +## 0.115.7 (2025-01-22) ### Upgrades @@ -1536,7 +1601,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 🔧 Update team members. PR [#13033](https://github.com/fastapi/fastapi/pull/13033) by [@tiangolo](https://github.com/tiangolo). * 📝 Update sponsors: remove Codacy. PR [#13032](https://github.com/fastapi/fastapi/pull/13032) by [@tiangolo](https://github.com/tiangolo). -## 0.115.6 +## 0.115.6 (2024-12-03) ### Fixes @@ -1570,7 +1635,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12954](https://github.com/fastapi/fastapi/pull/12954) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.115.5 +## 0.115.5 (2024-11-12) ### Refactors @@ -1707,7 +1772,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 🔧 Update sponsors: add Render. PR [#12733](https://github.com/fastapi/fastapi/pull/12733) by [@tiangolo](https://github.com/tiangolo). * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12707](https://github.com/fastapi/fastapi/pull/12707) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.115.4 +## 0.115.4 (2024-10-27) ### Refactors @@ -1769,7 +1834,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 👷 Update GitHub Action to deploy docs previews to handle missing deploy comments. PR [#12527](https://github.com/fastapi/fastapi/pull/12527) by [@tiangolo](https://github.com/tiangolo). * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12505](https://github.com/fastapi/fastapi/pull/12505) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.115.3 +## 0.115.3 (2024-10-22) ### Upgrades @@ -1805,13 +1870,13 @@ If you want to install `fastapi` with the standard dependencies but without `fas * 👷 Use uv in CI. PR [#12281](https://github.com/fastapi/fastapi/pull/12281) by [@tiangolo](https://github.com/tiangolo). * ⬆ Update httpx requirement from <0.25.0,>=0.23.0 to >=0.23.0,<0.28.0. PR [#11509](https://github.com/fastapi/fastapi/pull/11509) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.115.2 +## 0.115.2 (2024-10-12) ### Upgrades * ⬆️ Upgrade Starlette to `>=0.37.2,<0.41.0`. PR [#12431](https://github.com/fastapi/fastapi/pull/12431) by [@tiangolo](https://github.com/tiangolo). -## 0.115.1 +## 0.115.1 (2024-10-12) ### Fixes @@ -1867,7 +1932,7 @@ If you want to install `fastapi` with the standard dependencies but without `fas * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12253](https://github.com/fastapi/fastapi/pull/12253) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). * ✏️ Fix docstring typos in http security. PR [#12223](https://github.com/fastapi/fastapi/pull/12223) by [@albertvillanova](https://github.com/albertvillanova). -## 0.115.0 +## 0.115.0 (2024-09-17) ### Highlights @@ -2001,7 +2066,7 @@ This applies to `Query`, `Header`, and `Cookie` parameters, read the new docs: * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12204](https://github.com/fastapi/fastapi/pull/12204) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.114.2 +## 0.114.2 (2024-09-13) ### Fixes @@ -2018,7 +2083,7 @@ This applies to `Query`, `Header`, and `Cookie` parameters, read the new docs: * 💡 Add comments with instructions for Playwright screenshot scripts. PR [#12193](https://github.com/fastapi/fastapi/pull/12193) by [@tiangolo](https://github.com/tiangolo). * ➕ Add inline-snapshot for tests. PR [#12189](https://github.com/fastapi/fastapi/pull/12189) by [@tiangolo](https://github.com/tiangolo). -## 0.114.1 +## 0.114.1 (2024-09-11) ### Refactors @@ -2043,7 +2108,7 @@ This applies to `Query`, `Header`, and `Cookie` parameters, read the new docs: * 👷 Update `issue-manager.yml`. PR [#12159](https://github.com/fastapi/fastapi/pull/12159) by [@tiangolo](https://github.com/tiangolo). * ✏️ Fix typo in `fastapi/params.py`. PR [#12143](https://github.com/fastapi/fastapi/pull/12143) by [@surreal30](https://github.com/surreal30). -## 0.114.0 +## 0.114.0 (2024-09-06) 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's `model_config = {"extra": "forbid"}`: @@ -2081,7 +2146,7 @@ Read the new docs: [Form Models - Forbid Extra Form Fields](https://fastapi.tian * ✅ Update internal tests for latest Pydantic, including CI tweaks to install the latest Pydantic. PR [#12147](https://github.com/fastapi/fastapi/pull/12147) by [@tiangolo](https://github.com/tiangolo). -## 0.113.0 +## 0.113.0 (2024-09-05) Now you can declare form fields with Pydantic models: @@ -2114,7 +2179,7 @@ Read the new docs: [Form Models](https://fastapi.tiangolo.com/tutorial/request-f * 🔧 Update sponsors: Coherence link. PR [#12130](https://github.com/fastapi/fastapi/pull/12130) by [@tiangolo](https://github.com/tiangolo). -## 0.112.4 +## 0.112.4 (2024-09-05) This release is mainly a big internal refactor to enable adding support for Pydantic models for `Form` fields, but that feature comes in the next release. @@ -2129,7 +2194,7 @@ This release shouldn't affect apps using FastAPI in any way. You don't even have * ⏪️ Temporarily revert "✨ Add support for Pydantic models in `Form` parameters" to make a checkpoint release. PR [#12128](https://github.com/fastapi/fastapi/pull/12128) by [@tiangolo](https://github.com/tiangolo). Restored by PR [#12129](https://github.com/fastapi/fastapi/pull/12129). * ✨ Add support for Pydantic models in `Form` parameters. PR [#12127](https://github.com/fastapi/fastapi/pull/12127) by [@tiangolo](https://github.com/tiangolo). Reverted by PR [#12128](https://github.com/fastapi/fastapi/pull/12128) to make a checkpoint release with only refactors. Restored by PR [#12129](https://github.com/fastapi/fastapi/pull/12129). -## 0.112.3 +## 0.112.3 (2024-09-05) 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. 🚀 @@ -2176,7 +2241,7 @@ This release is mainly internal refactors, it shouldn't affect apps using FastAP * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#12076](https://github.com/fastapi/fastapi/pull/12076) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). * 👷 Update `latest-changes` GitHub Action. PR [#12073](https://github.com/fastapi/fastapi/pull/12073) by [@tiangolo](https://github.com/tiangolo). -## 0.112.2 +## 0.112.2 (2024-08-24) ### Fixes @@ -2227,7 +2292,7 @@ This release is mainly internal refactors, it shouldn't affect apps using FastAP * 🙈 Add .coverage* to `.gitignore`. PR [#11940](https://github.com/fastapi/fastapi/pull/11940) by [@gitworkflows](https://github.com/gitworkflows). * ⚙️ Record and show test coverage contexts (what test covers which line). PR [#11518](https://github.com/fastapi/fastapi/pull/11518) by [@slafs](https://github.com/slafs). -## 0.112.1 +## 0.112.1 (2024-08-15) ### Upgrades @@ -2279,7 +2344,7 @@ This release is mainly internal refactors, it shouldn't affect apps using FastAP * 🔧 Update docs setup with latest configs and plugins. PR [#11953](https://github.com/fastapi/fastapi/pull/11953) by [@tiangolo](https://github.com/tiangolo). * 🔇 Ignore warning from attrs in Trio. PR [#11949](https://github.com/fastapi/fastapi/pull/11949) by [@tiangolo](https://github.com/tiangolo). -## 0.112.0 +## 0.112.0 (2024-08-02) ### Breaking Changes @@ -2349,7 +2414,7 @@ Discussed here: [#11522](https://github.com/fastapi/fastapi/pull/11522) and here * 🔧 Update sponsors: remove TalkPython. PR [#11861](https://github.com/tiangolo/fastapi/pull/11861) by [@tiangolo](https://github.com/tiangolo). * 🔨 Update docs Termynal scripts to not include line nums for local dev. PR [#11854](https://github.com/tiangolo/fastapi/pull/11854) by [@tiangolo](https://github.com/tiangolo). -## 0.111.1 +## 0.111.1 (2024-07-14) ### Upgrades @@ -2443,7 +2508,7 @@ Discussed here: [#11522](https://github.com/fastapi/fastapi/pull/11522) and here * 👷 Tweak CI for test-redistribute, add needed env vars for slim. PR [#11549](https://github.com/tiangolo/fastapi/pull/11549) by [@tiangolo](https://github.com/tiangolo). * 👥 Update FastAPI People. PR [#11511](https://github.com/tiangolo/fastapi/pull/11511) by [@tiangolo](https://github.com/tiangolo). -## 0.111.0 +## 0.111.0 (2024-05-03) ### Features @@ -2482,7 +2547,7 @@ INFO: Application startup complete. * 🔧 Add configs and setup for `fastapi-slim` including optional extras `fastapi-slim[standard]`, and `fastapi` including by default the same `standard` extras. PR [#11503](https://github.com/tiangolo/fastapi/pull/11503) by [@tiangolo](https://github.com/tiangolo). -## 0.110.3 +## 0.110.3 (2024-04-30) ### Docs @@ -2506,7 +2571,7 @@ INFO: Application startup complete. * ⬆ Bump pillow from 10.2.0 to 10.3.0. PR [#11403](https://github.com/tiangolo/fastapi/pull/11403) by [@dependabot[bot]](https://github.com/apps/dependabot). * 🔧 Ungroup dependabot updates. PR [#11465](https://github.com/tiangolo/fastapi/pull/11465) by [@tiangolo](https://github.com/tiangolo). -## 0.110.2 +## 0.110.2 (2024-04-19) ### Fixes @@ -2544,7 +2609,7 @@ INFO: Application startup complete. * ⬆️ Upgrade version of typer for docs. PR [#11393](https://github.com/tiangolo/fastapi/pull/11393) by [@tiangolo](https://github.com/tiangolo). -## 0.110.1 +## 0.110.1 (2024-04-02) ### Fixes @@ -2733,7 +2798,7 @@ INFO: Application startup complete. * 🔥 Remove Jina AI QA Bot from the docs. PR [#11268](https://github.com/tiangolo/fastapi/pull/11268) by [@nan-wang](https://github.com/nan-wang). * 🔧 Update sponsors, remove Jina, remove Powens, move TestDriven.io. PR [#11213](https://github.com/tiangolo/fastapi/pull/11213) by [@tiangolo](https://github.com/tiangolo). -## 0.110.0 +## 0.110.0 (2024-02-24) ### Breaking Changes @@ -2794,7 +2859,7 @@ def my_dep(): * 🌐 Add Spanish translation for `docs/es/docs/benchmarks.md`. PR [#10928](https://github.com/tiangolo/fastapi/pull/10928) by [@pablocm83](https://github.com/pablocm83). * 🌐 Add Spanish translation for `docs/es/docs/advanced/response-change-status-code.md`. PR [#11100](https://github.com/tiangolo/fastapi/pull/11100) by [@alejsdev](https://github.com/alejsdev). -## 0.109.2 +## 0.109.2 (2024-02-04) ### Upgrades @@ -2808,7 +2873,7 @@ def my_dep(): * 🍱 Add new FastAPI logo. PR [#11090](https://github.com/tiangolo/fastapi/pull/11090) by [@tiangolo](https://github.com/tiangolo). -## 0.109.1 +## 0.109.1 (2024-02-03) ### Security fixes @@ -2972,7 +3037,7 @@ Read more in the [advisory: Content-Type Header ReDoS](https://github.com/tiango * ⬆ Bump dawidd6/action-download-artifact from 2.28.0 to 3.0.0. PR [#10777](https://github.com/tiangolo/fastapi/pull/10777) by [@dependabot[bot]](https://github.com/apps/dependabot). * 🔧 Add support for translations to languages with a longer code name, like `zh-hant`. PR [#10950](https://github.com/tiangolo/fastapi/pull/10950) by [@tiangolo](https://github.com/tiangolo). -## 0.109.0 +## 0.109.0 (2024-01-11) ### Features @@ -3042,13 +3107,13 @@ Read more in the [advisory: Content-Type Header ReDoS](https://github.com/tiango * 👷 Upgrade GitHub Action label-approved. PR [#10913](https://github.com/tiangolo/fastapi/pull/10913) by [@tiangolo](https://github.com/tiangolo). * ⬆️ Upgrade GitHub Action label-approved. PR [#10905](https://github.com/tiangolo/fastapi/pull/10905) by [@tiangolo](https://github.com/tiangolo). -## 0.108.0 +## 0.108.0 (2023-12-26) ### Upgrades * ⬆️ Upgrade Starlette to `>=0.29.0,<0.33.0`, update docs and usage of templates with new Starlette arguments. Remove pin of AnyIO `>=3.7.1,<4.0.0`, add support for AnyIO 4.x.x. PR [#10846](https://github.com/tiangolo/fastapi/pull/10846) by [@tiangolo](https://github.com/tiangolo). -## 0.107.0 +## 0.107.0 (2023-12-26) ### Upgrades @@ -3059,7 +3124,7 @@ Read more in the [advisory: Content-Type Header ReDoS](https://github.com/tiango * 📝 Add docs: Node.js script alternative to update OpenAPI for generated clients. PR [#10845](https://github.com/tiangolo/fastapi/pull/10845) by [@alejsdev](https://github.com/alejsdev). * 📝 Restructure Docs section in Contributing page. PR [#10844](https://github.com/tiangolo/fastapi/pull/10844) by [@alejsdev](https://github.com/alejsdev). -## 0.106.0 +## 0.106.0 (2023-12-25) ### Breaking Changes @@ -3175,7 +3240,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 👥 Update FastAPI People. PR [#10567](https://github.com/tiangolo/fastapi/pull/10567) by [@tiangolo](https://github.com/tiangolo). -## 0.105.0 +## 0.105.0 (2023-12-12) ### Features @@ -3200,7 +3265,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 📝 Update release notes, move and check latest-changes. PR [#10588](https://github.com/tiangolo/fastapi/pull/10588) by [@tiangolo](https://github.com/tiangolo). * 👷 Upgrade latest-changes GitHub Action. PR [#10587](https://github.com/tiangolo/fastapi/pull/10587) by [@tiangolo](https://github.com/tiangolo). -## 0.104.1 +## 0.104.1 (2023-10-30) ### Fixes @@ -3235,7 +3300,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 🐛 Fix overriding MKDocs theme lang in hook. PR [#10490](https://github.com/tiangolo/fastapi/pull/10490) by [@tiangolo](https://github.com/tiangolo). * 🔥 Drop/close Gitter chat. Questions should go to GitHub Discussions, free conversations to Discord.. PR [#10485](https://github.com/tiangolo/fastapi/pull/10485) by [@tiangolo](https://github.com/tiangolo). -## 0.104.0 +## 0.104.0 (2023-10-18) ## Features @@ -3253,7 +3318,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 🔧 Update sponsors, Bump.sh images. PR [#10381](https://github.com/tiangolo/fastapi/pull/10381) by [@tiangolo](https://github.com/tiangolo). * 👥 Update FastAPI People. PR [#10363](https://github.com/tiangolo/fastapi/pull/10363) by [@tiangolo](https://github.com/tiangolo). -## 0.103.2 +## 0.103.2 (2023-09-28) ### Refactors @@ -3280,7 +3345,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 🔧 Update sponsors, remove Svix. PR [#10228](https://github.com/tiangolo/fastapi/pull/10228) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update sponsors, add Bump.sh. PR [#10227](https://github.com/tiangolo/fastapi/pull/10227) by [@tiangolo](https://github.com/tiangolo). -## 0.103.1 +## 0.103.1 (2023-09-02) ### Fixes @@ -3315,7 +3380,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 👥 Update FastAPI People. PR [#10186](https://github.com/tiangolo/fastapi/pull/10186) by [@tiangolo](https://github.com/tiangolo). -## 0.103.0 +## 0.103.0 (2023-08-26) ### Features @@ -3326,7 +3391,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 📝 Add note to docs about Separate Input and Output Schemas with FastAPI version. PR [#10150](https://github.com/tiangolo/fastapi/pull/10150) by [@tiangolo](https://github.com/tiangolo). -## 0.102.0 +## 0.102.0 (2023-08-25) ### Features @@ -3350,7 +3415,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 🔧 Update sponsors, add Speakeasy. PR [#10098](https://github.com/tiangolo/fastapi/pull/10098) by [@tiangolo](https://github.com/tiangolo). -## 0.101.1 +## 0.101.1 (2023-08-14) ### Fixes @@ -3387,7 +3452,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * ⬆ Bump mypy from 1.4.0 to 1.4.1. PR [#9756](https://github.com/tiangolo/fastapi/pull/9756) by [@dependabot[bot]](https://github.com/apps/dependabot). * ⬆ Bump mkdocs-material from 9.1.17 to 9.1.21. PR [#9960](https://github.com/tiangolo/fastapi/pull/9960) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.101.0 +## 0.101.0 (2023-08-04) ### Features @@ -3422,7 +3487,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 🔧 Update sponsor Fern. PR [#9979](https://github.com/tiangolo/fastapi/pull/9979) by [@tiangolo](https://github.com/tiangolo). * 👷 Update CI debug mode with Tmate. PR [#9977](https://github.com/tiangolo/fastapi/pull/9977) by [@tiangolo](https://github.com/tiangolo). -## 0.100.1 +## 0.100.1 (2023-07-27) ### Fixes @@ -3454,7 +3519,7 @@ The new execution flow can be found in the docs: [Execution of dependencies with * 👷 Update MkDocs Material token. PR [#9843](https://github.com/tiangolo/fastapi/pull/9843) by [@tiangolo](https://github.com/tiangolo). * 👷 Update token for latest changes. PR [#9842](https://github.com/tiangolo/fastapi/pull/9842) by [@tiangolo](https://github.com/tiangolo). -## 0.100.0 +## 0.100.0 (2023-07-07) ✨ Support for **Pydantic v2** ✨ @@ -3525,14 +3590,14 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * The attribute `schema_extra` for the internal class `Config` has been replaced by the key `json_schema_extra` in the new `model_config` dict. * You can read more about it in the docs for [Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/). * When you install `"fastapi[all]"` it now also includes: - *pydantic-settings- for settings management. - *pydantic-extra-types- for extra types to be used with Pydantic. + * [`pydantic-settings`](https://docs.pydantic.dev/latest/usage/pydantic_settings/) - for settings management. + * [`pydantic-extra-types`](https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/) - for extra types to be used with Pydantic. * Now Pydantic Settings is an additional optional package (included in `"fastapi[all]"`). To use settings you should now import `from pydantic_settings import BaseSettings` instead of importing from `pydantic` directly. * You can read more about it in the docs for [Settings and Environment Variables](https://fastapi.tiangolo.com/advanced/settings/). * PR [#9816](https://github.com/tiangolo/fastapi/pull/9816) by [@tiangolo](https://github.com/tiangolo), included all the work done (in multiple PRs) on the beta branch (`main-pv2`). -## 0.99.1 +## 0.99.1 (2023-07-02) ### Fixes @@ -3542,15 +3607,15 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 📝 Update source examples to use new JSON Schema examples field. PR [#9776](https://github.com/tiangolo/fastapi/pull/9776) by [@tiangolo](https://github.com/tiangolo). -## 0.99.0 +## 0.99.0 (2023-06-30) ### Features * ✨ Add support for OpenAPI 3.1.0. PR [#9770](https://github.com/tiangolo/fastapi/pull/9770) by [@tiangolo](https://github.com/tiangolo). - * New support for documenting **webhooks**, read the new docs here: Advanced User Guide: OpenAPI Webhooks. + * New support for documenting **webhooks**, read the new docs here: [Advanced User Guide: OpenAPI Webhooks](https://fastapi.tiangolo.com/advanced/openapi-webhooks/). * Upgrade OpenAPI 3.1.0, this uses JSON Schema 2020-12. * Upgrade Swagger UI to version 5.x.x, that supports OpenAPI 3.1.0. - * Updated `examples` field in `Query()`, `Cookie()`, `Body()`, etc. based on the latest JSON Schema and OpenAPI. Now it takes a list of examples and they are included directly in the JSON Schema, not outside. Read more about it (including the historical technical details) in the updated docs: Tutorial: Declare Request Example Data. + * Updated `examples` field in `Query()`, `Cookie()`, `Body()`, etc. based on the latest JSON Schema and OpenAPI. Now it takes a list of examples and they are included directly in the JSON Schema, not outside. Read more about it (including the historical technical details) in the updated docs: [Tutorial: Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/). * ✨ Add support for `deque` objects and children in `jsonable_encoder`. PR [#9433](https://github.com/tiangolo/fastapi/pull/9433) by [@cranium](https://github.com/cranium). @@ -3581,7 +3646,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * ⬆️ Upgrade MkDocs and MkDocs Material. PR [#9729](https://github.com/tiangolo/fastapi/pull/9729) by [@tiangolo](https://github.com/tiangolo). * 👷 Build and deploy docs only on docs changes. PR [#9728](https://github.com/tiangolo/fastapi/pull/9728) by [@tiangolo](https://github.com/tiangolo). -## 0.98.0 +## 0.98.0 (2023-06-22) ### Features @@ -3625,7 +3690,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 🔧 Update sponsors, add Flint. PR [#9699](https://github.com/tiangolo/fastapi/pull/9699) by [@tiangolo](https://github.com/tiangolo). * 👷 Lint in CI only once, only with one version of Python, run tests with all of them. PR [#9686](https://github.com/tiangolo/fastapi/pull/9686) by [@tiangolo](https://github.com/tiangolo). -## 0.97.0 +## 0.97.0 (2023-06-11) ### Features @@ -3647,7 +3712,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 💚 Update CI cache to fix installs when dependencies change. PR [#9659](https://github.com/tiangolo/fastapi/pull/9659) by [@tiangolo](https://github.com/tiangolo). * ⬇️ Separate requirements for development into their own requirements.txt files, they shouldn't be extras. PR [#9655](https://github.com/tiangolo/fastapi/pull/9655) by [@tiangolo](https://github.com/tiangolo). -## 0.96.1 +## 0.96.1 (2023-06-10) ### Fixes @@ -3680,7 +3745,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 👷 Add custom token to Smokeshow and Preview Docs for download-artifact, to prevent API rate limits. PR [#9646](https://github.com/tiangolo/fastapi/pull/9646) by [@tiangolo](https://github.com/tiangolo). * 👷 Add custom tokens for GitHub Actions to avoid rate limits. PR [#9647](https://github.com/tiangolo/fastapi/pull/9647) by [@tiangolo](https://github.com/tiangolo). -## 0.96.0 +## 0.96.0 (2023-06-03) ### Features @@ -3710,7 +3775,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 👥 Update FastAPI People. PR [#9602](https://github.com/tiangolo/fastapi/pull/9602) by [@github-actions[bot]](https://github.com/apps/github-actions). * 🔧 Update sponsors, remove InvestSuite. PR [#9612](https://github.com/tiangolo/fastapi/pull/9612) by [@tiangolo](https://github.com/tiangolo). -## 0.95.2 +## 0.95.2 (2023-05-16) * ⬆️ Upgrade Starlette version to `>=0.27.0` for a security release. PR [#9541](https://github.com/tiangolo/fastapi/pull/9541) by [@tiangolo](https://github.com/tiangolo). Details on [Starlette's security advisory](https://github.com/encode/starlette/security/advisories/GHSA-v5gw-mw7f-84px). @@ -3736,7 +3801,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 💚 Disable setup-python pip cache in CI. PR [#9438](https://github.com/tiangolo/fastapi/pull/9438) by [@tiangolo](https://github.com/tiangolo). * ⬆ Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.5. PR [#9346](https://github.com/tiangolo/fastapi/pull/9346) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.95.1 +## 0.95.1 (2023-04-13) ### Fixes @@ -3773,7 +3838,7 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a * 🔧 Update sponsors: remove Jina. PR [#9388](https://github.com/tiangolo/fastapi/pull/9388) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update sponsors, add databento, remove Ines's course and StriveWorks. PR [#9351](https://github.com/tiangolo/fastapi/pull/9351) by [@tiangolo](https://github.com/tiangolo). -## 0.95.0 +## 0.95.0 (2023-03-18) ### Highlights @@ -3882,13 +3947,13 @@ Special thanks to [@nzig](https://github.com/nzig) for the core implementation a * 📝 Update order of examples, latest Python version first, and simplify version tab names. PR [#9269](https://github.com/tiangolo/fastapi/pull/9269) by [@tiangolo](https://github.com/tiangolo). * 📝 Update all docs to use `Annotated` as the main recommendation, with new examples and tests. PR [#9268](https://github.com/tiangolo/fastapi/pull/9268) by [@tiangolo](https://github.com/tiangolo). -## 0.94.1 +## 0.94.1 (2023-03-14) ### Fixes * 🎨 Fix types for lifespan, upgrade Starlette to 0.26.1. PR [#9245](https://github.com/tiangolo/fastapi/pull/9245) by [@tiangolo](https://github.com/tiangolo). -## 0.94.0 +## 0.94.0 (2023-03-10) ### Upgrades @@ -3911,7 +3976,7 @@ Special thanks to [@nzig](https://github.com/nzig) for the core implementation a * ⬆ Bump dawidd6/action-download-artifact from 2.24.3 to 2.26.0. PR [#6034](https://github.com/tiangolo/fastapi/pull/6034) by [@dependabot[bot]](https://github.com/apps/dependabot). * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#5709](https://github.com/tiangolo/fastapi/pull/5709) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.93.0 +## 0.93.0 (2023-03-07) ### Features @@ -3980,7 +4045,7 @@ Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https * ⬆️ Upgrade analytics. PR [#6025](https://github.com/tiangolo/fastapi/pull/6025) by [@tiangolo](https://github.com/tiangolo). * ⬆️ Upgrade and re-enable installing Typer-CLI. PR [#6008](https://github.com/tiangolo/fastapi/pull/6008) by [@tiangolo](https://github.com/tiangolo). -## 0.92.0 +## 0.92.0 (2023-02-14) 🚨 This is a security fix. Please upgrade as soon as possible. @@ -3991,7 +4056,7 @@ Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https * Only applications using forms (e.g. file uploads) could be affected. * For most cases, upgrading won't have any breaking changes. -## 0.91.0 +## 0.91.0 (2023-02-10) ### Upgrades @@ -3999,7 +4064,7 @@ Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https * This can solve nuanced errors when using middlewares. Before Starlette `0.24.0`, a new instance of each middleware class would be created when a new middleware was added. That normally was not a problem, unless the middleware class expected to be created only once, with only one instance, that happened in some cases. This upgrade would solve those cases (thanks [@adriangb](https://github.com/adriangb)! Starlette PR [#2017](https://github.com/encode/starlette/pull/2017)). Now the middleware class instances are created once, right before the first request (the first time the app is called). * If you depended on that previous behavior, you might need to update your code. As always, make sure your tests pass before merging the upgrade. -## 0.90.1 +## 0.90.1 (2023-02-09) ### Upgrades @@ -4019,7 +4084,7 @@ Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https * ✏ Update `zip-docs.sh` internal script, remove extra space. PR [#5931](https://github.com/tiangolo/fastapi/pull/5931) by [@JuanPerdomo00](https://github.com/JuanPerdomo00). -## 0.90.0 +## 0.90.0 (2023-02-08) ### Upgrades @@ -4051,7 +4116,7 @@ Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https * 🔧 Update Sponsor Budget Insight to Powens. PR [#5916](https://github.com/tiangolo/fastapi/pull/5916) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update GitHub Sponsors badge data. PR [#5915](https://github.com/tiangolo/fastapi/pull/5915) by [@tiangolo](https://github.com/tiangolo). -## 0.89.1 +## 0.89.1 (2023-01-10) ### Fixes @@ -4066,7 +4131,7 @@ Read more about it in the new docs: [Advanced User Guide: Lifespan Events](https * 🌐 Add Turkish translation for `docs/tr/docs/tutorial/first_steps.md`. PR [#5691](https://github.com/tiangolo/fastapi/pull/5691) by [@Kadermiyanyedi](https://github.com/Kadermiyanyedi). -## 0.89.0 +## 0.89.0 (2023-01-07) ### Features @@ -4136,7 +4201,7 @@ Read more about it in the new docs: [Response Model - Return Type](https://fasta * 🔧 Update sponsors, disable course bundle. PR [#5713](https://github.com/tiangolo/fastapi/pull/5713) by [@tiangolo](https://github.com/tiangolo). * ⬆ Update typer[all] requirement from <0.7.0,>=0.6.1 to >=0.6.1,<0.8.0. PR [#5639](https://github.com/tiangolo/fastapi/pull/5639) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.88.0 +## 0.88.0 (2022-11-27) ### Upgrades @@ -4161,7 +4226,7 @@ Read more about it in the new docs: [Response Model - Return Type](https://fasta * 👷 Update `setup-python` action in tests to use new caching feature. PR [#5680](https://github.com/tiangolo/fastapi/pull/5680) by [@madkinsz](https://github.com/madkinsz). * ⬆ Bump black from 22.8.0 to 22.10.0. PR [#5569](https://github.com/tiangolo/fastapi/pull/5569) by [@dependabot[bot]](https://github.com/apps/dependabot). -## 0.87.0 +## 0.87.0 (2022-11-13) Highlights of this release: @@ -4200,7 +4265,7 @@ Highlights of this release: * ⬆ Bump dawidd6/action-download-artifact from 2.24.0 to 2.24.1. PR [#5603](https://github.com/tiangolo/fastapi/pull/5603) by [@dependabot[bot]](https://github.com/apps/dependabot). * 📝 Update coverage badge to use Samuel Colvin's Smokeshow. PR [#5585](https://github.com/tiangolo/fastapi/pull/5585) by [@tiangolo](https://github.com/tiangolo). -## 0.86.0 +## 0.86.0 (2022-11-03) ### Features @@ -4228,7 +4293,7 @@ Highlights of this release: * 👷 Switch from Codecov to Smokeshow plus pytest-cov to pure coverage for internal tests. PR [#5583](https://github.com/tiangolo/fastapi/pull/5583) by [@tiangolo](https://github.com/tiangolo). * 👥 Update FastAPI People. PR [#5571](https://github.com/tiangolo/fastapi/pull/5571) by [@github-actions[bot]](https://github.com/apps/github-actions). -## 0.85.2 +## 0.85.2 (2022-10-31) ### Docs @@ -4266,7 +4331,7 @@ Highlights of this release: * ⬆️ Upgrade Typer to include Rich in scripts for docs. PR [#5502](https://github.com/tiangolo/fastapi/pull/5502) by [@tiangolo](https://github.com/tiangolo). * 🐛 Fix calling `mkdocs` for languages as a subprocess to fix/enable MkDocs Material search plugin. PR [#5501](https://github.com/tiangolo/fastapi/pull/5501) by [@tiangolo](https://github.com/tiangolo). -## 0.85.1 +## 0.85.1 (2022-10-14) ### Fixes @@ -4282,7 +4347,7 @@ Highlights of this release: * 🔧 Disable Material for MkDocs search plugin. PR [#5495](https://github.com/tiangolo/fastapi/pull/5495) by [@tiangolo](https://github.com/tiangolo). * 🔇 Ignore Trio warning in tests for CI. PR [#5483](https://github.com/tiangolo/fastapi/pull/5483) by [@samuelcolvin](https://github.com/samuelcolvin). -## 0.85.0 +## 0.85.0 (2022-09-15) ### Features @@ -4297,7 +4362,7 @@ Highlights of this release: * ⬆️ Upgrade mypy and tweak internal type annotations. PR [#5398](https://github.com/tiangolo/fastapi/pull/5398) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update test dependencies, upgrade Pytest, move dependencies from dev to test. PR [#5396](https://github.com/tiangolo/fastapi/pull/5396) by [@tiangolo](https://github.com/tiangolo). -## 0.84.0 +## 0.84.0 (2022-09-14) ### Breaking Changes @@ -4305,7 +4370,7 @@ This version of FastAPI drops support for Python 3.6. 🔥 Please upgrade to a s * 🔧 Update package metadata, drop support for Python 3.6, move build internals from Flit to Hatch. PR [#5240](https://github.com/tiangolo/fastapi/pull/5240) by [@ofek](https://github.com/ofek). -## 0.83.0 +## 0.83.0 (2022-09-11) 🚨 This is probably the last release (or one of the last releases) to support Python 3.6. 🔥 @@ -4330,7 +4395,7 @@ You hopefully updated to a supported version of Python a while ago. If you haven * ⬆ [pre-commit.ci] pre-commit autoupdate. PR [#5352](https://github.com/tiangolo/fastapi/pull/5352) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci). -## 0.82.0 +## 0.82.0 (2022-09-04) 🚨 This is probably the last release (or one of the last releases) to support Python 3.6. 🔥 @@ -4377,7 +4442,7 @@ You hopefully updated to a supported version of Python a while ago. If you haven * ♻ Internal small refactor, move `operation_id` parameter position in delete method for consistency with the code. PR [#4474](https://github.com/tiangolo/fastapi/pull/4474) by [@hiel](https://github.com/hiel). * 🔧 Update sponsors, disable ImgWhale. PR [#5338](https://github.com/tiangolo/fastapi/pull/5338) by [@tiangolo](https://github.com/tiangolo). -## 0.81.0 +## 0.81.0 (2022-08-26) ### Features @@ -4430,7 +4495,7 @@ You hopefully updated to a supported version of Python a while ago. If you haven * ⬆ Upgrade version pin accepted for Flake8, for internal code, to `flake8 >=3.8.3,<6.0.0`. PR [#4097](https://github.com/tiangolo/fastapi/pull/4097) by [@jamescurtin](https://github.com/jamescurtin). * 🍱 Update Jina banner, fix typo. PR [#5301](https://github.com/tiangolo/fastapi/pull/5301) by [@tiangolo](https://github.com/tiangolo). -## 0.80.0 +## 0.80.0 (2022-08-23) ### Breaking Changes - Fixes @@ -4513,7 +4578,7 @@ This way the data will be correctly validated, you won't have an internal server * 🌐 Add missing navigator for `encoder.md` in Korean translation. PR [#5238](https://github.com/tiangolo/fastapi/pull/5238) by [@joonas-yoon](https://github.com/joonas-yoon). * (Empty PR merge by accident) [#4913](https://github.com/tiangolo/fastapi/pull/4913). -## 0.79.1 +## 0.79.1 (2022-08-18) ### Fixes @@ -4549,7 +4614,7 @@ This way the data will be correctly validated, you won't have an internal server * 🔧 Update Jina sponsorship. PR [#5272](https://github.com/tiangolo/fastapi/pull/5272) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update sponsors, Striveworks badge. PR [#5179](https://github.com/tiangolo/fastapi/pull/5179) by [@tiangolo](https://github.com/tiangolo). -## 0.79.0 +## 0.79.0 (2022-07-14) ### Fixes - Breaking Changes @@ -4586,7 +4651,7 @@ This way the data will be correctly validated, you won't have an internal server * 🔧 Update sponsors, remove Dropbase, add Doist. PR [#5096](https://github.com/tiangolo/fastapi/pull/5096) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update sponsors, remove Classiq, add ImgWhale. PR [#5079](https://github.com/tiangolo/fastapi/pull/5079) by [@tiangolo](https://github.com/tiangolo). -## 0.78.0 +## 0.78.0 (2022-05-14) ### Features @@ -4692,7 +4757,7 @@ def main( * 🔧 Add pre-commit with first config and first formatting pass. PR [#4888](https://github.com/tiangolo/fastapi/pull/4888) by [@tiangolo](https://github.com/tiangolo). * 👷 Disable CI installing Material for MkDocs in forks. PR [#4410](https://github.com/tiangolo/fastapi/pull/4410) by [@dolfinus](https://github.com/dolfinus). -## 0.77.1 +## 0.77.1 (2022-05-10) ### Upgrades @@ -4715,7 +4780,7 @@ def main( * 🔧 Add notifications in issue for Uzbek translations. PR [#4884](https://github.com/tiangolo/fastapi/pull/4884) by [@tiangolo](https://github.com/tiangolo). -## 0.77.0 +## 0.77.0 (2022-05-10) ### Upgrades @@ -4748,7 +4813,7 @@ def main( * 🌐 Add Portuguese translation of `tutorial/extra-data-types.md`. PR [#4077](https://github.com/tiangolo/fastapi/pull/4077) by [@luccasmmg](https://github.com/luccasmmg). * 🌐 Update German translation for `docs/features.md`. PR [#3905](https://github.com/tiangolo/fastapi/pull/3905) by [@jomue](https://github.com/jomue). -## 0.76.0 +## 0.76.0 (2022-05-05) ### Upgrades @@ -4761,7 +4826,7 @@ def main( * 🍱 Update sponsor, ExoFlare badge. PR [#4822](https://github.com/tiangolo/fastapi/pull/4822) by [@tiangolo](https://github.com/tiangolo). * 🔧 Update sponsors, enable Dropbase again, update TalkPython link. PR [#4821](https://github.com/tiangolo/fastapi/pull/4821) by [@tiangolo](https://github.com/tiangolo). -## 0.75.2 +## 0.75.2 (2022-04-17) 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. @@ -4782,7 +4847,7 @@ This release includes upgrades to third-party packages that handle security issu * 🔧 Update sponsors, add: ExoFlare, Ines Course; remove: Dropbase, Vim.so, Calmcode; update: Striveworks, TalkPython and TestDriven.io. PR [#4805](https://github.com/tiangolo/fastapi/pull/4805) by [@tiangolo](https://github.com/tiangolo). * ⬆️ Upgrade Codecov GitHub Action. PR [#4801](https://github.com/tiangolo/fastapi/pull/4801) by [@tiangolo](https://github.com/tiangolo). -## 0.75.1 +## 0.75.1 (2022-04-01) ### Translations @@ -4801,19 +4866,19 @@ This release includes upgrades to third-party packages that handle security issu * 🔧 Add Classiq sponsor. PR [#4671](https://github.com/tiangolo/fastapi/pull/4671) by [@tiangolo](https://github.com/tiangolo). * 📝 Add Jina's QA Bot to the docs to help people that want to ask quick questions. PR [#4655](https://github.com/tiangolo/fastapi/pull/4655) by [@tiangolo](https://github.com/tiangolo) based on original PR [#4626](https://github.com/tiangolo/fastapi/pull/4626) by [@hanxiao](https://github.com/hanxiao). -## 0.75.0 +## 0.75.0 (2022-03-04) ### Features * ✨ Add support for custom `generate_unique_id_function` and docs for generating clients. New docs: [Advanced - Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/). PR [#4650](https://github.com/tiangolo/fastapi/pull/4650) by [@tiangolo](https://github.com/tiangolo). -## 0.74.1 +## 0.74.1 (2022-02-21) ### Features * ✨ Include route in scope to allow middleware and other tools to extract its information. PR [#4603](https://github.com/tiangolo/fastapi/pull/4603) by [@tiangolo](https://github.com/tiangolo). -## 0.74.0 +## 0.74.0 (2022-02-17) ### Breaking Changes @@ -4883,7 +4948,7 @@ async def set_up_request_state_dependency(): * 💚 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 +## 0.73.0 (2022-01-23) ### Features @@ -4906,7 +4971,7 @@ async def set_up_request_state_dependency(): * 🐛 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 +## 0.72.0 (2022-01-16) ### Features @@ -4927,7 +4992,7 @@ async def set_up_request_state_dependency(): * 🔧 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 +## 0.71.0 (2022-01-07) ### Features @@ -4942,7 +5007,7 @@ async def set_up_request_state_dependency(): * 🔧 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 +## 0.70.1 (2021-12-12) 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. 🤩 @@ -4971,7 +5036,7 @@ There's nothing interesting in this particular FastAPI release. It is mainly to * 👥 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 +## 0.70.0 (2021-10-07) This release just upgrades Starlette to the latest version, `0.16.0`, which includes several bug fixes and some small breaking changes. @@ -4992,7 +5057,7 @@ Also upgrades the ranges of optional dependencies: * `"jinja2 >=2.11.2,<4.0.0"` * `"itsdangerous >=1.1.0,<3.0.0"` -## 0.69.0 +## 0.69.0 (2021-10-07) ### Breaking Changes - Upgrade @@ -5041,7 +5106,7 @@ This release also removes `graphene` as an optional dependency for GraphQL. If y * 🔧 Lint only in Python 3.7 and above. PR [#4006](https://github.com/tiangolo/fastapi/pull/4006) by [@tiangolo](https://github.com/tiangolo). * 🔧 Add GitHub Action notify-translations config for Azerbaijani. PR [#3995](https://github.com/tiangolo/fastapi/pull/3995) by [@tiangolo](https://github.com/tiangolo). -## 0.68.2 +## 0.68.2 (2021-10-05) This release has **no breaking changes**. 🎉 @@ -5085,7 +5150,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * 🎨 Tweak CSS styles for shell animations. PR [#3888](https://github.com/tiangolo/fastapi/pull/3888) by [@tiangolo](https://github.com/tiangolo). * 🔧 Add new Sponsor Calmcode.io. PR [#3777](https://github.com/tiangolo/fastapi/pull/3777) by [@tiangolo](https://github.com/tiangolo). -## 0.68.1 +## 0.68.1 (2021-08-24) * ✨ Add support for `read_with_orm_mode`, to support [SQLModel](https://sqlmodel.tiangolo.com/) relationship attributes. PR [#3757](https://github.com/tiangolo/fastapi/pull/3757) by [@tiangolo](https://github.com/tiangolo). @@ -5109,7 +5174,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * ⬆ Enable tests for Python 3.9. PR [#2298](https://github.com/tiangolo/fastapi/pull/2298) by [@Kludex](https://github.com/Kludex). * 👥 Update FastAPI People. PR [#3642](https://github.com/tiangolo/fastapi/pull/3642) by [@github-actions[bot]](https://github.com/apps/github-actions). -## 0.68.0 +## 0.68.0 (2021-07-29) ### Features @@ -5138,7 +5203,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * 🔧 Add new GitHub templates with forms for new issues. PR [#3612](https://github.com/tiangolo/fastapi/pull/3612) by [@tiangolo](https://github.com/tiangolo). * 📝 Add official FastAPI Twitter to docs: [@fastapi](https://x.com/fastapi). PR [#3578](https://github.com/tiangolo/fastapi/pull/3578) by [@tiangolo](https://github.com/tiangolo). -## 0.67.0 +## 0.67.0 (2021-07-21) ### Features @@ -5166,7 +5231,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * 👷 Update GitHub Action latest-changes, strike 2 ⚾. PR [#3575](https://github.com/tiangolo/fastapi/pull/3575) by [@tiangolo](https://github.com/tiangolo). * 🔧 Sort external links in docs to have the most recent at the top. PR [#3568](https://github.com/tiangolo/fastapi/pull/3568) by [@tiangolo](https://github.com/tiangolo). -## 0.66.1 +## 0.66.1 (2021-07-19) ### Translations @@ -5179,7 +5244,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * 🔧 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](https://github.com/tiangolo/fastapi/pull/2790) by [@graingert](https://github.com/graingert). * ⬆️ Upgrade python-jose dependency to `>=3.3.0,<4.0.0` for tests. PR [#3468](https://github.com/tiangolo/fastapi/pull/3468) by [@tiangolo](https://github.com/tiangolo). -## 0.66.0 +## 0.66.0 (2021-07-04) ### Features @@ -5197,7 +5262,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * 🌐 Add Spanish translation for `advanced/additional-status-codes.md`. PR [#1252](https://github.com/tiangolo/fastapi/pull/1252) by [@jfunez](https://github.com/jfunez). * 🌐 Add Spanish translation for `advanced/path-operation-advanced-configuration.md`. PR [#1251](https://github.com/tiangolo/fastapi/pull/1251) by [@jfunez](https://github.com/jfunez). -## 0.65.3 +## 0.65.3 (2021-07-03) ### Fixes @@ -5228,7 +5293,7 @@ Soon there will be a new FastAPI release upgrading Starlette to take advantage o * 👥 Update FastAPI People. PR [#3319](https://github.com/tiangolo/fastapi/pull/3319) by [@github-actions[bot]](https://github.com/apps/github-actions). * ⬆ Upgrade docs development dependency on `typer-cli` to >=0.0.12 to fix conflicts. PR [#3429](https://github.com/tiangolo/fastapi/pull/3429) by [@tiangolo](https://github.com/tiangolo). -## 0.65.2 +## 0.65.2 (2021-06-09) ### Security fixes @@ -5253,13 +5318,13 @@ Thanks to [Dima Boger](https://x.com/b0g3r) for the security report! 🙇🔒 * 🔧 Add new banner sponsor badge for FastAPI courses bundle. PR [#3288](https://github.com/tiangolo/fastapi/pull/3288) by [@tiangolo](https://github.com/tiangolo). * 👷 Upgrade Issue Manager GitHub Action. PR [#3236](https://github.com/tiangolo/fastapi/pull/3236) by [@tiangolo](https://github.com/tiangolo). -## 0.65.1 +## 0.65.1 (2021-05-11) ### Security fixes * 📌 Upgrade pydantic pin, to handle security vulnerability [CVE-2021-29510](https://github.com/pydantic/pydantic/security/advisories/GHSA-5jqp-qgf6-3pvh). PR [#3213](https://github.com/tiangolo/fastapi/pull/3213) by [@tiangolo](https://github.com/tiangolo). -## 0.65.0 +## 0.65.0 (2021-05-10) ### Breaking Changes - Upgrade @@ -5278,7 +5343,7 @@ Thanks to [Dima Boger](https://x.com/b0g3r) for the security report! 🙇🔒 * 👥 Update FastAPI People. PR [#3189](https://github.com/tiangolo/fastapi/pull/3189) by [@github-actions[bot]](https://github.com/apps/github-actions). * 🔊 Update FastAPI People to allow better debugging. PR [#3188](https://github.com/tiangolo/fastapi/pull/3188) by [@tiangolo](https://github.com/tiangolo). -## 0.64.0 +## 0.64.0 (2021-05-07) ### Features @@ -5358,7 +5423,7 @@ Thanks to [Dima Boger](https://x.com/b0g3r) for the security report! 🙇🔒 * 🔧 Update InvestSuite sponsor data. PR [#2608](https://github.com/tiangolo/fastapi/pull/2608) by [@tiangolo](https://github.com/tiangolo). * 👥 Update FastAPI People. PR [#2590](https://github.com/tiangolo/fastapi/pull/2590) by [@github-actions[bot]](https://github.com/apps/github-actions). -## 0.63.0 +## 0.63.0 (2020-12-20) ### Features @@ -5397,7 +5462,7 @@ Thanks to [Dima Boger](https://x.com/b0g3r) for the security report! 🙇🔒 * ✨ Add new Gold Sponsor: InvestSuite 🎉. PR [#2508](https://github.com/tiangolo/fastapi/pull/2508) by [@tiangolo](https://github.com/tiangolo). * 🔧 Add issue template configs. PR [#2476](https://github.com/tiangolo/fastapi/pull/2476) by [@tiangolo](https://github.com/tiangolo). -## 0.62.0 +## 0.62.0 (2020-11-29) ### Features @@ -5483,10 +5548,10 @@ Note: all the previous parameters are still there, so it's still possible to dec ### Docs * PR [#2434](https://github.com/tiangolo/fastapi/pull/2434) (above) includes new or updated docs: - * Advanced User Guide - OpenAPI Callbacks. - * Tutorial - Bigger Applications. - * Tutorial - Dependencies - Dependencies in path operation decorators. - * Tutorial - Dependencies - Global Dependencies. + * [Advanced User Guide - OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/). + * [Tutorial - Bigger Applications](https://fastapi.tiangolo.com/tutorial/bigger-applications/). + * [Tutorial - Dependencies - Dependencies in path operation decorators](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-in-path-operation-decorators/). + * [Tutorial - Dependencies - Global Dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/global-dependencies/). * 📝 Add FastAPI monitoring blog post to External Links. PR [#2324](https://github.com/tiangolo/fastapi/pull/2324) by [@louisguitton](https://github.com/louisguitton). * ✏️ Fix typo in Deta tutorial. PR [#2320](https://github.com/tiangolo/fastapi/pull/2320) by [@tiangolo](https://github.com/tiangolo). @@ -5513,7 +5578,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * ✨ Add silver sponsor WeTransfer. PR [#2338](https://github.com/tiangolo/fastapi/pull/2338) by [@tiangolo](https://github.com/tiangolo). * ✨ Set up and enable Material for MkDocs Insiders for the docs. PR [#2325](https://github.com/tiangolo/fastapi/pull/2325) by [@tiangolo](https://github.com/tiangolo). -## 0.61.2 +## 0.61.2 (2020-11-05) ### Fixes @@ -5595,7 +5660,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * 👷 Add GitHub Action Latest Changes. PR [#2160](https://github.com/tiangolo/fastapi/pull/2160). * 👷 Add GitHub Action Label Approved. PR [#2161](https://github.com/tiangolo/fastapi/pull/2161). -## 0.61.1 +## 0.61.1 (2020-08-29) ### Fixes @@ -5615,7 +5680,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Improve docs maintainability by updating `hl_lines` syntax to use ranges. PR [#1863](https://github.com/tiangolo/fastapi/pull/1863) by [@la-mar](https://github.com/la-mar). -## 0.61.0 +## 0.61.0 (2020-08-09) ### Features @@ -5648,7 +5713,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add Flake8 linting. Original PR [#1774](https://github.com/tiangolo/fastapi/pull/1774) by [@MashhadiNima](https://github.com/MashhadiNima). * Disable Gitter bot, as it's currently broken, and Gitter's response doesn't show the problem. PR [#1853](https://github.com/tiangolo/fastapi/pull/1853). -## 0.60.2 +## 0.60.2 (2020-08-08) * Fix typo in docs for query parameters. PR [#1832](https://github.com/tiangolo/fastapi/pull/1832) by [@ycd](https://github.com/ycd). * Add docs about [Async Tests](https://fastapi.tiangolo.com/advanced/async-tests/). PR [#1619](https://github.com/tiangolo/fastapi/pull/1619) by [@empicano](https://github.com/empicano). @@ -5677,7 +5742,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Remove docs preview comment from each commit. PR [#1826](https://github.com/tiangolo/fastapi/pull/1826). * Update GitHub context extraction for Gitter notification bot. PR [#1766](https://github.com/tiangolo/fastapi/pull/1766). -## 0.60.1 +## 0.60.1 (2020-07-22) * Add debugging logs for GitHub actions to introspect GitHub hidden context. PR [#1764](https://github.com/tiangolo/fastapi/pull/1764). * Use OS preference theme for online docs. PR [#1760](https://github.com/tiangolo/fastapi/pull/1760) by [@adriencaccia](https://github.com/adriencaccia). @@ -5686,7 +5751,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update GitHub Actions, use commit from PR for docs preview, not commit from pre-merge. PR [#1761](https://github.com/tiangolo/fastapi/pull/1761). * Update GitHub Actions, refactor Gitter bot. PR [#1746](https://github.com/tiangolo/fastapi/pull/1746). -## 0.60.0 +## 0.60.0 (2020-07-20) * Add GitHub Action to watch for missing preview docs and trigger a preview deploy. PR [#1740](https://github.com/tiangolo/fastapi/pull/1740). * Add custom GitHub Action to get artifact with docs preview. PR [#1739](https://github.com/tiangolo/fastapi/pull/1739). @@ -5696,7 +5761,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add GitHub Actions for CI, move from Travis. PR [#1735](https://github.com/tiangolo/fastapi/pull/1735). * Add support for adding OpenAPI schema for GET requests with a body. PR [#1626](https://github.com/tiangolo/fastapi/pull/1626) by [@victorphoenix3](https://github.com/victorphoenix3). -## 0.59.0 +## 0.59.0 (2020-07-10) * Fix typo in docstring for OAuth2 utils. PR [#1621](https://github.com/tiangolo/fastapi/pull/1621) by [@tomarv2](https://github.com/tomarv2). * Update JWT docs to use Python-jose instead of PyJWT. Initial PR [#1610](https://github.com/tiangolo/fastapi/pull/1610) by [@asheux](https://github.com/asheux). @@ -5714,7 +5779,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Pin dependencies. PR [#1697](https://github.com/tiangolo/fastapi/pull/1697). * Update isort to version 5.x.x. PR [#1670](https://github.com/tiangolo/fastapi/pull/1670) by [@asheux](https://github.com/asheux). -## 0.58.1 +## 0.58.1 (2020-06-28) * Add link in docs to Pydantic data types. PR [#1612](https://github.com/tiangolo/fastapi/pull/1612) by [@tayoogunbiyi](https://github.com/tayoogunbiyi). * Fix link in warning logs for `openapi_prefix`. PR [#1611](https://github.com/tiangolo/fastapi/pull/1611) by [@bavaria95](https://github.com/bavaria95). @@ -5729,7 +5794,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add translation to Chinese for [Path Parameters and Numeric Validations - 路径参数和数值校验](https://fastapi.tiangolo.com/zh/tutorial/path-params-numeric-validations/). PR [#1506](https://github.com/tiangolo/fastapi/pull/1506) by [@waynerv](https://github.com/waynerv). * Add GitHub action to auto-label approved PRs (mainly for translations). PR [#1638](https://github.com/tiangolo/fastapi/pull/1638). -## 0.58.0 +## 0.58.0 (2020-06-15) * Deep merge OpenAPI responses to preserve all the additional metadata. PR [#1577](https://github.com/tiangolo/fastapi/pull/1577). * Mention in docs that only main app events are run (not sub-apps). PR [#1554](https://github.com/tiangolo/fastapi/pull/1554) by [@amacfie](https://github.com/amacfie). @@ -5738,7 +5803,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix Model for JSON Schema keyword `not` as a JSON Schema instead of a list. PR [#1548](https://github.com/tiangolo/fastapi/pull/1548) by [@v-do](https://github.com/v-do). * Add support for OpenAPI `servers`. PR [#1547](https://github.com/tiangolo/fastapi/pull/1547) by [@mikaello](https://github.com/mikaello). -## 0.57.0 +## 0.57.0 (2020-06-13) * Remove broken link from "External Links". PR [#1565](https://github.com/tiangolo/fastapi/pull/1565) by [@victorphoenix3](https://github.com/victorphoenix3). * Update/fix docs for [WebSockets with dependencies](https://fastapi.tiangolo.com/advanced/websockets/#using-depends-and-others). Original PR [#1540](https://github.com/tiangolo/fastapi/pull/1540) by [@ChihSeanHsu](https://github.com/ChihSeanHsu). @@ -5760,7 +5825,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Remove obsolete Chinese articles after adding official community translations. PR [#1510](https://github.com/tiangolo/fastapi/pull/1510) by [@waynerv](https://github.com/waynerv). * Add `__repr__` for *path operation function* parameter helpers (like `Query`, `Depends`, etc) to simplify debugging. PR [#1560](https://github.com/tiangolo/fastapi/pull/1560) by [@rkbeatss](https://github.com/rkbeatss) and [@victorphoenix3](https://github.com/victorphoenix3). -## 0.56.1 +## 0.56.1 (2020-06-12) * Add link to advanced docs from tutorial. PR [#1512](https://github.com/tiangolo/fastapi/pull/1512) by [@kx-chen](https://github.com/kx-chen). * Remove internal unnecessary f-strings. PR [#1526](https://github.com/tiangolo/fastapi/pull/1526) by [@kotamatsuoka](https://github.com/kotamatsuoka). @@ -5780,7 +5845,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Remove `*,` from functions in docs where it's not needed. PR [#1239](https://github.com/tiangolo/fastapi/pull/1239) by [@pankaj-giri](https://github.com/pankaj-giri). * Start translations for Italian. PR [#1557](https://github.com/tiangolo/fastapi/pull/1557) by [@csr](https://github.com/csr). -## 0.56.0 +## 0.56.0 (2020-06-11) * Add support for ASGI `root_path`: * Use `root_path` internally for mounted applications, so that OpenAPI and the docs UI works automatically without extra configurations and parameters. @@ -5810,11 +5875,11 @@ Note: all the previous parameters are still there, so it's still possible to dec * PR [#1467](https://github.com/tiangolo/fastapi/pull/1467). * Add translation to Chinese for [Python Types Intro - Python 类型提示简介](https://fastapi.tiangolo.com/zh/python-types/). PR [#1197](https://github.com/tiangolo/fastapi/pull/1197) by [@waynerv](https://github.com/waynerv). -## 0.55.1 +## 0.55.1 (2020-05-23) * Fix handling of enums with their own schema in path parameters. To support [pydantic/pydantic#1432](https://github.com/pydantic/pydantic/pull/1432) in FastAPI. PR [#1463](https://github.com/tiangolo/fastapi/pull/1463). -## 0.55.0 +## 0.55.0 (2020-05-23) * Allow enums to allow them to have their own schemas in OpenAPI. To support [pydantic/pydantic#1432](https://github.com/pydantic/pydantic/pull/1432) in FastAPI. PR [#1461](https://github.com/tiangolo/fastapi/pull/1461). * Add links for funding through [GitHub sponsors](https://github.com/sponsors/tiangolo). PR [#1425](https://github.com/tiangolo/fastapi/pull/1425). @@ -5830,7 +5895,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update order of execution for `get_db` in SQLAlchemy tutorial. PR [#1293](https://github.com/tiangolo/fastapi/pull/1293) by [@bcb](https://github.com/bcb). * Fix typos in Async docs. PR [#1423](https://github.com/tiangolo/fastapi/pull/1423). -## 0.54.2 +## 0.54.2 (2020-05-16) * Add translation to Spanish for [Concurrency and async / await - Concurrencia y async / await](https://fastapi.tiangolo.com/es/async/). PR [#1290](https://github.com/tiangolo/fastapi/pull/1290) by [@alvaropernas](https://github.com/alvaropernas). * Remove obsolete vote link. PR [#1289](https://github.com/tiangolo/fastapi/pull/1289) by [@donhui](https://github.com/donhui). @@ -5850,12 +5915,12 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add Spanish translation for [Introducción a los Tipos de Python (Python Types Intro)](https://fastapi.tiangolo.com/es/python-types/). PR [#1237](https://github.com/tiangolo/fastapi/pull/1237) by [@mariacamilagl](https://github.com/mariacamilagl). * Add Spanish translation for [Características (Features)](https://fastapi.tiangolo.com/es/features/). PR [#1220](https://github.com/tiangolo/fastapi/pull/1220) by [@mariacamilagl](https://github.com/mariacamilagl). -## 0.54.1 +## 0.54.1 (2020-04-08) * Update database test setup. PR [#1226](https://github.com/tiangolo/fastapi/pull/1226). * Improve test debugging by showing response text in failing tests. PR [#1222](https://github.com/tiangolo/fastapi/pull/1222) by [@samuelcolvin](https://github.com/samuelcolvin). -## 0.54.0 +## 0.54.0 (2020-04-05) * Fix grammatical mistakes in async docs. PR [#1188](https://github.com/tiangolo/fastapi/pull/1188) by [@mickeypash](https://github.com/mickeypash). * Add support for `response_model_exclude_defaults` and `response_model_exclude_none`: @@ -5870,7 +5935,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add first translation to Spanish [FastAPI](https://fastapi.tiangolo.com/es/). PR [#1201](https://github.com/tiangolo/fastapi/pull/1201) by [@mariacamilagl](https://github.com/mariacamilagl). * Add docs about [Settings and Environment Variables](https://fastapi.tiangolo.com/advanced/settings/). Initial PR [1118](https://github.com/tiangolo/fastapi/pull/1118) by [@alexmitelman](https://github.com/alexmitelman). -## 0.53.2 +## 0.53.2 (2020-03-30) * Fix automatic embedding of body fields for dependencies and sub-dependencies. Original PR [#1079](https://github.com/tiangolo/fastapi/pull/1079) by [@Toad2186](https://github.com/Toad2186). * Fix dependency overrides in WebSocket testing. PR [#1122](https://github.com/tiangolo/fastapi/pull/1122) by [@amitlissack](https://github.com/amitlissack). @@ -5878,7 +5943,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Start translations for Chinese. PR [#1187](https://github.com/tiangolo/fastapi/pull/1187) by [@RunningIkkyu](https://github.com/RunningIkkyu). * Add docs for [Schema Extra - Example](https://fastapi.tiangolo.com/tutorial/schema-extra-example/). PR [#1185](https://github.com/tiangolo/fastapi/pull/1185). -## 0.53.1 +## 0.53.1 (2020-03-29) * Fix included example after translations refactor. PR [#1182](https://github.com/tiangolo/fastapi/pull/1182). * Add docs example for `example` in `Field`. Docs at [Body - Fields: JSON Schema extras](https://fastapi.tiangolo.com/tutorial/body-fields/#json-schema-extras). PR [#1106](https://github.com/tiangolo/fastapi/pull/1106) by [@JohnPaton](https://github.com/JohnPaton). @@ -5887,7 +5952,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix typo in docs. PR [#1148](https://github.com/tiangolo/fastapi/pull/1148) by [@PLNech](https://github.com/PLNech). * Update Windows development environment instructions. PR [#1179](https://github.com/tiangolo/fastapi/pull/1179). -## 0.53.0 +## 0.53.0 (2020-03-27) * Update test coverage badge. PR [#1175](https://github.com/tiangolo/fastapi/pull/1175). * Add `orjson` to `pip install fastapi[all]`. PR [#1161](https://github.com/tiangolo/fastapi/pull/1161) by [@michael0liver](https://github.com/michael0liver). @@ -5902,11 +5967,11 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add support for docs translations. New docs: [Development - Contributing: Docs: Translations](https://fastapi.tiangolo.com/contributing/#translations). PR [#1168](https://github.com/tiangolo/fastapi/pull/1168). * Update terminal styles in docs and add note about [**Typer**, the FastAPI of CLIs](https://typer.tiangolo.com/). PR [#1139](https://github.com/tiangolo/fastapi/pull/1139). -## 0.52.0 +## 0.52.0 (2020-03-01) * Add new high-performance JSON response class using `orjson`. New docs: [Custom Response - HTML, Stream, File, others: `ORJSONResponse`](https://fastapi.tiangolo.com/advanced/custom-response/#use-orjsonresponse). PR [#1065](https://github.com/tiangolo/fastapi/pull/1065). -## 0.51.0 +## 0.51.0 (2020-03-01) * Re-export utils from Starlette: * This allows using things like `from fastapi.responses import JSONResponse` instead of `from starlette.responses import JSONResponse`. @@ -5918,7 +5983,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * [Including WSGI - Flask, Django, others](https://fastapi.tiangolo.com/advanced/wsgi/). * PR [#1064](https://github.com/tiangolo/fastapi/pull/1064). -## 0.50.0 +## 0.50.0 (2020-02-29) * Add link to Release Notes from docs about pinning versions for deployment. PR [#1058](https://github.com/tiangolo/fastapi/pull/1058). * Upgrade code to use the latest version of Starlette, including: @@ -5928,7 +5993,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * PR [#1057](https://github.com/tiangolo/fastapi/pull/1057). * Add docs about pinning FastAPI versions for deployment: [Deployment: FastAPI versions](https://fastapi.tiangolo.com/deployment/#fastapi-versions). PR [#1056](https://github.com/tiangolo/fastapi/pull/1056). -## 0.49.2 +## 0.49.2 (2020-02-29) * Fix links in release notes. PR [#1052](https://github.com/tiangolo/fastapi/pull/1052) by [@sattosan](https://github.com/sattosan). * Fix typo in release notes. PR [#1051](https://github.com/tiangolo/fastapi/pull/1051) by [@sattosan](https://github.com/sattosan). @@ -5938,14 +6003,14 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix accepting valid types for response models, including Python types like `List[int]`. PR [#1017](https://github.com/tiangolo/fastapi/pull/1017) by [@patrickmckenna](https://github.com/patrickmckenna). * Fix format in SQL tutorial. PR [#1015](https://github.com/tiangolo/fastapi/pull/1015) by [@vegarsti](https://github.com/vegarsti). -## 0.49.1 +## 0.49.1 (2020-02-28) * Fix path operation duplicated parameters when used in dependencies and the path operation function. PR [#994](https://github.com/tiangolo/fastapi/pull/994) by [@merowinger92](https://github.com/merowinger92). * Update Netlify previews deployment GitHub action as the fix is already merged and there's a new release. PR [#1047](https://github.com/tiangolo/fastapi/pull/1047). * Move mypy configurations to config file. PR [#987](https://github.com/tiangolo/fastapi/pull/987) by [@hukkinj1](https://github.com/hukkinj1). * Temporary fix to Netlify previews not deployable from PRs from forks. PR [#1046](https://github.com/tiangolo/fastapi/pull/1046) by [@mariacamilagl](https://github.com/mariacamilagl). -## 0.49.0 +## 0.49.0 (2020-02-16) * Fix encoding of `pathlib` paths in `jsonable_encoder`. PR [#978](https://github.com/tiangolo/fastapi/pull/978) by [@patrickmckenna](https://github.com/patrickmckenna). * Add articles to [External Links](https://fastapi.tiangolo.com/external-links/): [PythonのWeb frameworkのパフォーマンス比較 (Django, Flask, responder, FastAPI, japronto)](https://qiita.com/bee2/items/0ad260ab9835a2087dae) and [[FastAPI] Python製のASGI Web フレームワーク FastAPIに入門する](https://qiita.com/bee2/items/75d9c0d7ba20e7a4a0e9). PR [#974](https://github.com/tiangolo/fastapi/pull/974) by [@tokusumi](https://github.com/tokusumi). @@ -5956,7 +6021,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update CI to run docs deployment in GitHub actions. PR [#983](https://github.com/tiangolo/fastapi/pull/983). * Allow `callable`s in *path operation functions*, like functions modified with `functools.partial`. PR [#977](https://github.com/tiangolo/fastapi/pull/977). -## 0.48.0 +## 0.48.0 (2020-02-04) * Run linters first in tests to error out faster. PR [#948](https://github.com/tiangolo/fastapi/pull/948). * Log warning about `email-validator` only when used. PR [#946](https://github.com/tiangolo/fastapi/pull/946). @@ -5973,12 +6038,12 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix link in middleware docs. PR [#893](https://github.com/tiangolo/fastapi/pull/893) by [@linchiwei123](https://github.com/linchiwei123). * Rename default API title from "Fast API" to "FastAPI" for consistency. PR [#890](https://github.com/tiangolo/fastapi/pull/890). -## 0.47.1 +## 0.47.1 (2020-01-18) * Fix model filtering in `response_model`, cloning sub-models. PR [#889](https://github.com/tiangolo/fastapi/pull/889). * Fix FastAPI serialization of Pydantic models using ORM mode blocking the event loop. PR [#888](https://github.com/tiangolo/fastapi/pull/888). -## 0.47.0 +## 0.47.0 (2020-01-18) * Refactor documentation to make a simpler and shorter [Tutorial - User Guide](https://fastapi.tiangolo.com/tutorial/) and an additional [Advanced User Guide](https://fastapi.tiangolo.com/advanced/) with all the additional docs. PR [#887](https://github.com/tiangolo/fastapi/pull/887). * Tweak external links, Markdown format, typos. PR [#881](https://github.com/tiangolo/fastapi/pull/881). @@ -5990,7 +6055,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Setup development environment with Python's Venv and Flit, instead of requiring the extra Pipenv duplicating dependencies. Updated docs: [Development - Contributing](https://fastapi.tiangolo.com/contributing/). PR [#877](https://github.com/tiangolo/fastapi/pull/877). * Update docs for [HTTP Basic Auth](https://fastapi.tiangolo.com/advanced/security/http-basic-auth/) to improve security against timing attacks. Initial PR [#807](https://github.com/tiangolo/fastapi/pull/807) by [@zwass](https://github.com/zwass). -## 0.46.0 +## 0.46.0 (2020-01-08) * Fix typos and tweak configs. PR [#837](https://github.com/tiangolo/fastapi/pull/837). * Add link to Chinese article in [External Links](https://fastapi.tiangolo.com/external-links/). PR [810](https://github.com/tiangolo/fastapi/pull/810) by [@wxq0309](https://github.com/wxq0309). @@ -6004,7 +6069,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix Twitter links in docs. PR [#813](https://github.com/tiangolo/fastapi/pull/813) by [@justindujardin](https://github.com/justindujardin). * Add docs for correctly [using FastAPI with Peewee ORM](https://fastapi.tiangolo.com/advanced/sql-databases-peewee/). Including how to overwrite parts of Peewee to correctly handle async threads. PR [#789](https://github.com/tiangolo/fastapi/pull/789). -## 0.45.0 +## 0.45.0 (2019-12-11) * Add support for OpenAPI Callbacks: * New docs: [OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/). @@ -6016,7 +6081,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Remove gender bias in docs for handling errors. PR [#780](https://github.com/tiangolo/fastapi/pull/780). Original idea in PR [#761](https://github.com/tiangolo/fastapi/pull/761) by [@classywhetten](https://github.com/classywhetten). * Rename docs and references to `body-schema` to `body-fields` to keep in line with Pydantic. PR [#746](https://github.com/tiangolo/fastapi/pull/746) by [@prostomarkeloff](https://github.com/prostomarkeloff). -## 0.44.1 +## 0.44.1 (2019-12-04) * Add GitHub social preview images to git. PR [#752](https://github.com/tiangolo/fastapi/pull/752). * Update PyPI "trove classifiers". PR [#751](https://github.com/tiangolo/fastapi/pull/751). @@ -6024,7 +6089,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update "new issue" templates. PR [#749](https://github.com/tiangolo/fastapi/pull/749). * Fix serialization of errors for exotic Pydantic types. PR [#748](https://github.com/tiangolo/fastapi/pull/748) by [@dmontagu](https://github.com/dmontagu). -## 0.44.0 +## 0.44.0 (2019-11-27) * Add GitHub action [Issue Manager](https://github.com/tiangolo/issue-manager). PR [#742](https://github.com/tiangolo/fastapi/pull/742). * Fix typos in docs. PR [734](https://github.com/tiangolo/fastapi/pull/734) by [@bundabrg](https://github.com/bundabrg). @@ -6037,7 +6102,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix typo in HTTP protocol in CORS example. PR [#647](https://github.com/tiangolo/fastapi/pull/647) by [@forestmonster](https://github.com/forestmonster). * Add support for Pydantic versions `1.0.0` and above, with temporary (deprecated) backwards compatibility for Pydantic `0.32.2`. PR [#646](https://github.com/tiangolo/fastapi/pull/646) by [@dmontagu](https://github.com/dmontagu). -## 0.43.0 +## 0.43.0 (2019-11-24) * Update docs to reduce gender bias. PR [#645](https://github.com/tiangolo/fastapi/pull/645) by [@ticosax](https://github.com/ticosax). * Add docs about [overriding the `operationId` for all the *path operations*](https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#using-the-path-operation-function-name-as-the-operationid) based on their function name. PR [#642](https://github.com/tiangolo/fastapi/pull/642) by [@SKalt](https://github.com/SKalt). @@ -6047,7 +6112,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add docs for [self-serving docs' (Swagger UI) static assets](https://fastapi.tiangolo.com/advanced/extending-openapi/#self-hosting-javascript-and-css-for-docs), e.g. to use the docs offline, or without Internet. Initial PR [#557](https://github.com/tiangolo/fastapi/pull/557) by [@svalouch](https://github.com/svalouch). * Fix `black` linting after upgrade. PR [#682](https://github.com/tiangolo/fastapi/pull/682) by [@frankie567](https://github.com/frankie567). -## 0.42.0 +## 0.42.0 (2019-10-09) * 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. @@ -6062,7 +6127,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * PR [#595](https://github.com/tiangolo/fastapi/pull/595). * Fix `sitemap.xml` in website. PR [#598](https://github.com/tiangolo/fastapi/pull/598) by [@samuelcolvin](https://github.com/samuelcolvin). -## 0.41.0 +## 0.41.0 (2019-10-07) * 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`. @@ -6077,7 +6142,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * PR [#589](https://github.com/tiangolo/fastapi/pull/589) by [@dmontagu](https://github.com/dmontagu). * Fix preserving custom route class in routers when including other sub-routers. PR [#538](https://github.com/tiangolo/fastapi/pull/538) by [@dmontagu](https://github.com/dmontagu). -## 0.40.0 +## 0.40.0 (2019-10-04) * Add notes to docs about installing `python-multipart` when using forms. PR [#574](https://github.com/tiangolo/fastapi/pull/574) by [@sliptonic](https://github.com/sliptonic). * Generate OpenAPI schemas in alphabetical order. PR [#554](https://github.com/tiangolo/fastapi/pull/554) by [@dmontagu](https://github.com/dmontagu). @@ -6090,7 +6155,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix incorrect documentation example in [first steps](https://fastapi.tiangolo.com/tutorial/first-steps/). PR [#511](https://github.com/tiangolo/fastapi/pull/511) by [@IgnatovFedor](https://github.com/IgnatovFedor). * Add support for Swagger UI [initOauth](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md) settings with the parameter `swagger_ui_init_oauth`. PR [#499](https://github.com/tiangolo/fastapi/pull/499) by [@zamiramir](https://github.com/zamiramir). -## 0.39.0 +## 0.39.0 (2019-09-29) * 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. @@ -6098,17 +6163,17 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add support for setting a `default_response_class` in the `FastAPI` instance or in `include_router`. Initial PR [#467](https://github.com/tiangolo/fastapi/pull/467) by [@toppk](https://github.com/toppk). * Add support for type annotations using strings and `from __future__ import annotations`. PR [#451](https://github.com/tiangolo/fastapi/pull/451) by [@dmontagu](https://github.com/dmontagu). -## 0.38.1 +## 0.38.1 (2019-09-01) * Fix incorrect `Request` class import. PR [#493](https://github.com/tiangolo/fastapi/pull/493) by [@kamalgill](https://github.com/kamalgill). -## 0.38.0 +## 0.38.0 (2019-08-31) * Add recent articles to [External Links](https://fastapi.tiangolo.com/external-links/) and recent opinions. PR [#490](https://github.com/tiangolo/fastapi/pull/490). * Upgrade support range for Starlette to include `0.12.8`. The new range is `>=0.11.1,<=0.12.8"`. PR [#477](https://github.com/tiangolo/fastapi/pull/477) by [@dmontagu](https://github.com/dmontagu). * Upgrade support to Pydantic version 0.32.2 and update internal code to use it (breaking change). PR [#463](https://github.com/tiangolo/fastapi/pull/463) by [@dmontagu](https://github.com/dmontagu). -## 0.37.0 +## 0.37.0 (2019-08-31) * Add support for custom route classes for advanced use cases. PR [#468](https://github.com/tiangolo/fastapi/pull/468) by [@dmontagu](https://github.com/dmontagu). * Allow disabling Google fonts in ReDoc. PR [#481](https://github.com/tiangolo/fastapi/pull/481) by [@b1-luettje](https://github.com/b1-luettje). @@ -6124,7 +6189,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix using `"default"` extra response with status codes at the same time. PR [#489](https://github.com/tiangolo/fastapi/pull/489). * Allow additional responses to use status code ranges (like `5XX` and `4XX`) and `"default"`. PR [#435](https://github.com/tiangolo/fastapi/pull/435) by [@divums](https://github.com/divums). -## 0.36.0 +## 0.36.0 (2019-08-26) * Fix implementation for `skip_defaults` when returning a Pydantic model. PR [#422](https://github.com/tiangolo/fastapi/pull/422) by [@dmontagu](https://github.com/dmontagu). * Fix OpenAPI generation when using the same dependency in multiple places for the same *path operation*. PR [#417](https://github.com/tiangolo/fastapi/pull/417) by [@dmontagu](https://github.com/dmontagu). @@ -6135,23 +6200,23 @@ Note: all the previous parameters are still there, so it's still possible to dec * PR [#415](https://github.com/tiangolo/fastapi/pull/415) by [@vitalik](https://github.com/vitalik). * Fix mypy error after merging PR #415. PR [#462](https://github.com/tiangolo/fastapi/pull/462). -## 0.35.0 +## 0.35.0 (2019-08-08) * Fix typo in routing `assert`. PR [#419](https://github.com/tiangolo/fastapi/pull/419) by [@pablogamboa](https://github.com/pablogamboa). * Fix typo in docs. PR [#411](https://github.com/tiangolo/fastapi/pull/411) by [@bronsen](https://github.com/bronsen). * Fix parsing a body type declared with `Union`. PR [#400](https://github.com/tiangolo/fastapi/pull/400) by [@koxudaxi](https://github.com/koxudaxi). -## 0.34.0 +## 0.34.0 (2019-08-06) * Upgrade Starlette supported range to include the latest `0.12.7`. The new range is `0.11.1,<=0.12.7`. PR [#367](https://github.com/tiangolo/fastapi/pull/367) by [@dedsm](https://github.com/dedsm). * Add test for OpenAPI schema with duplicate models from PR [#333](https://github.com/tiangolo/fastapi/pull/333) by [@dmontagu](https://github.com/dmontagu). PR [#385](https://github.com/tiangolo/fastapi/pull/385). -## 0.33.0 +## 0.33.0 (2019-07-13) * Upgrade Pydantic version to `0.30.0`. PR [#384](https://github.com/tiangolo/fastapi/pull/384) by [@jekirl](https://github.com/jekirl). -## 0.32.0 +## 0.32.0 (2019-07-12) * Fix typo in docs for features. PR [#380](https://github.com/tiangolo/fastapi/pull/380) by [@MartinoMensio](https://github.com/MartinoMensio). @@ -6175,14 +6240,14 @@ Note: all the previous parameters are still there, so it's still possible to dec * 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](https://github.com/tiangolo/fastapi/pull/347). -## 0.31.0 +## 0.31.0 (2019-06-28) * Upgrade Pydantic supported version to `0.29.0`. * New supported version range is `"pydantic >=0.28,<=0.29.0"`. * This adds support for Pydantic [Generic Models](https://docs.pydantic.dev/latest/#generic-models), kudos to [@dmontagu](https://github.com/dmontagu). * PR [#344](https://github.com/tiangolo/fastapi/pull/344). -## 0.30.1 +## 0.30.1 (2019-06-28) * Add section in docs about [External Links and Articles](https://fastapi.tiangolo.com/external-links/). PR [#341](https://github.com/tiangolo/fastapi/pull/341). @@ -6196,7 +6261,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add SQLite [online viewers to the docs](https://fastapi.tiangolo.com/tutorial/sql-databases/#interact-with-the-database-directly). PR [#330](https://github.com/tiangolo/fastapi/pull/330) by [@cyrilbois](https://github.com/cyrilbois). -## 0.30.0 +## 0.30.0 (2019-06-20) * 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](https://fastapi.tiangolo.com/tutorial/sql-databases/). @@ -6219,7 +6284,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Upgrade Pydantic support to `0.28`. PR [#320](https://github.com/tiangolo/fastapi/pull/320) by [@jekirl](https://github.com/jekirl). -## 0.29.1 +## 0.29.1 (2019-06-13) * Fix handling an empty-body request with a required body param. PR [#311](https://github.com/tiangolo/fastapi/pull/311). @@ -6227,7 +6292,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix docs discrepancy in docs for [Response Model](https://fastapi.tiangolo.com/tutorial/response-model/). PR [#288](https://github.com/tiangolo/fastapi/pull/288) by [@awiddersheim](https://github.com/awiddersheim). -## 0.29.0 +## 0.29.0 (2019-06-06) * Add support for declaring a `Response` parameter: * This allows declaring: @@ -6238,7 +6303,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update attribution to Hug, for inspiring the `response` parameter pattern. * PR [#294](https://github.com/tiangolo/fastapi/pull/294). -## 0.28.0 +## 0.28.0 (2019-06-05) * Implement dependency cache per request. * This avoids calling each dependency multiple times for the same request. @@ -6253,17 +6318,17 @@ Note: all the previous parameters are still there, so it's still possible to dec * New docs: [Testing Dependencies with Overrides](https://fastapi.tiangolo.com/advanced/testing-dependencies/). * PR [#291](https://github.com/tiangolo/fastapi/pull/291). -## 0.27.2 +## 0.27.2 (2019-06-03) * Fix path and query parameters receiving `dict` as a valid type. It should be mapped to a body payload. PR [#287](https://github.com/tiangolo/fastapi/pull/287). Updated docs at: [Query parameter list / multiple values with defaults: Using `list`](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#using-list). -## 0.27.1 +## 0.27.1 (2019-06-03) * 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](https://github.com/tiangolo/fastapi/pull/282). * Fix type declaration of `HTTPException`. PR [#279](https://github.com/tiangolo/fastapi/pull/279). -## 0.27.0 +## 0.27.0 (2019-05-30) * Fix broken link in docs about OAuth 2.0 with scopes. PR [#275](https://github.com/tiangolo/fastapi/pull/275) by [@dmontagu](https://github.com/dmontagu). @@ -6274,7 +6339,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add support for type annotations using `Optional` as in `param: Optional[str] = None`. New documentation: [Optional type declarations](https://fastapi.tiangolo.com/tutorial/query-params/#optional-type-declarations). * PR [#278](https://github.com/tiangolo/fastapi/pull/278). -## 0.26.0 +## 0.26.0 (2019-05-29) * Separate error handling for validation errors. * This will allow developers to customize the exception handlers. @@ -6295,7 +6360,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix type declaration of `response_model` to allow generic Python types as `List[Model]`. Mainly to fix `mypy` for users. PR [#266](https://github.com/tiangolo/fastapi/pull/266). -## 0.25.0 +## 0.25.0 (2019-05-27) * Add support for Pydantic's `include`, `exclude`, `by_alias`. * Update documentation: [Response Model](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). @@ -6311,7 +6376,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * New [documentation section about using `response_model_skip_defaults`](https://fastapi.tiangolo.com/tutorial/response-model/#response-model-encoding-parameters). * PR [#248](https://github.com/tiangolo/fastapi/pull/248) by [@wshayes](https://github.com/wshayes). -## 0.24.0 +## 0.24.0 (2019-05-24) * Add support for WebSockets with dependencies and parameters. * Support included for: @@ -6329,7 +6394,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * This includes JSON Schema support for IP address and network objects, bug fixes, and other features. * PR [#247](https://github.com/tiangolo/fastapi/pull/247) by [@euri10](https://github.com/euri10). -## 0.23.0 +## 0.23.0 (2019-05-21) * Upgrade the compatible version of Starlette to `0.12.0`. * This includes support for ASGI 3 (the latest version of the standard). @@ -6347,7 +6412,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Make Swagger UI and ReDoc URLs parameterizable, allowing to host and serve local versions of them and have offline docs. PR [#112](https://github.com/tiangolo/fastapi/pull/112) by [@euri10](https://github.com/euri10). -## 0.22.0 +## 0.22.0 (2019-05-16) * 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*. @@ -6369,7 +6434,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Re-enable `black` formatting checks for Python 3.7. PR [#229](https://github.com/tiangolo/fastapi/pull/229) by [@zamiramir](https://github.com/zamiramir). -## 0.21.0 +## 0.21.0 (2019-05-15) * On body parsing errors, raise `from` previous exception, to allow better introspection in logging code. PR [#192](https://github.com/tiangolo/fastapi/pull/195) by [@ricardomomm](https://github.com/ricardomomm). @@ -6379,13 +6444,13 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix typo in routing. PR [#221](https://github.com/tiangolo/fastapi/pull/221) by [@djlambert](https://github.com/djlambert). -## 0.20.1 +## 0.20.1 (2019-05-11) * Add typing information to package including file `py.typed`. PR [#209](https://github.com/tiangolo/fastapi/pull/209) by [@meadsteve](https://github.com/meadsteve). * Add FastAPI bot for Gitter. To automatically announce new releases. PR [#189](https://github.com/tiangolo/fastapi/pull/189). -## 0.20.0 +## 0.20.0 (2019-04-27) * Upgrade OAuth2: * Upgrade Password flow using Bearer tokens to use the correct HTTP status code 401 `UNAUTHORIZED`, with `WWW-Authenticate` headers. @@ -6402,7 +6467,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix typos in docs. PR [#176](https://github.com/tiangolo/fastapi/pull/176) by [@chdsbd](https://github.com/chdsbd). -## 0.19.0 +## 0.19.0 (2019-04-26) * Rename *path operation decorator* parameter `content_type` to `response_class`. PR [#183](https://github.com/tiangolo/fastapi/pull/183). @@ -6412,7 +6477,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update how to use a [Custom Response Class](https://fastapi.tiangolo.com/advanced/custom-response/). * PR [#184](https://github.com/tiangolo/fastapi/pull/184). -## 0.18.0 +## 0.18.0 (2019-04-22) * Add docs for [HTTP Basic Auth](https://fastapi.tiangolo.com/advanced/custom-response/). PR [#177](https://github.com/tiangolo/fastapi/pull/177). @@ -6422,7 +6487,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add docs for [Middleware](https://fastapi.tiangolo.com/tutorial/middleware/). PR [#173](https://github.com/tiangolo/fastapi/pull/173). -## 0.17.0 +## 0.17.0 (2019-04-20) * Make Flit publish from CI. PR [#170](https://github.com/tiangolo/fastapi/pull/170). @@ -6430,7 +6495,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * By default, encode by alias. This allows using Pydantic `alias` parameters working by default. PR [#168](https://github.com/tiangolo/fastapi/pull/168). -## 0.16.0 +## 0.16.0 (2019-04-16) * Upgrade *path operation* `docstring` parsing to support proper Markdown descriptions. New documentation at [Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#description-from-docstring). PR [#163](https://github.com/tiangolo/fastapi/pull/163). @@ -6442,13 +6507,13 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix [Query Parameters](https://fastapi.tiangolo.com/tutorial/query-params/) URL examples in docs. PR [#157](https://github.com/tiangolo/fastapi/pull/157) by [@hayata-yamamoto](https://github.com/hayata-yamamoto). -## 0.15.0 +## 0.15.0 (2019-04-14) * Add support for multiple file uploads (as a single form field). New docs at: [Multiple file uploads](https://fastapi.tiangolo.com/tutorial/request-files/#multiple-file-uploads). PR [#158](https://github.com/tiangolo/fastapi/pull/158). * Add docs for: [Additional Status Codes](https://fastapi.tiangolo.com/advanced/additional-status-codes/). PR [#156](https://github.com/tiangolo/fastapi/pull/156). -## 0.14.0 +## 0.14.0 (2019-04-12) * 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](https://github.com/tiangolo/fastapi/pull/155). @@ -6460,7 +6525,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Include Falcon and Hug in: [Alternatives, Inspiration and Comparisons](https://fastapi.tiangolo.com/alternatives/). -## 0.13.0 +## 0.13.0 (2019-04-09) * 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. @@ -6470,7 +6535,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * New docs about: [OAuth2 scopes](https://fastapi.tiangolo.com/advanced/security/oauth2-scopes/). * PR [#141](https://github.com/tiangolo/fastapi/pull/141). -## 0.12.1 +## 0.12.1 (2019-04-05) * Fix bug: handling additional `responses` in `APIRouter.include_router()`. PR [#140](https://github.com/tiangolo/fastapi/pull/140). @@ -6478,7 +6543,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix typos in section about nested models and OAuth2 with JWT. PR [#127](https://github.com/tiangolo/fastapi/pull/127) by [@mmcloud](https://github.com/mmcloud). -## 0.12.0 +## 0.12.0 (2019-04-05) * 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. @@ -6487,7 +6552,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * PR [#97](https://github.com/tiangolo/fastapi/pull/97) originally initiated by [@barsi](https://github.com/barsi). * Update `scripts/test-cov-html.sh` to allow passing extra parameters like `-vv`, for development. -## 0.11.0 +## 0.11.0 (2019-04-03) * 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](https://github.com/tiangolo/fastapi/pull/134). @@ -6495,7 +6560,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix duplicate dependency in `pyproject.toml`. PR [#128](https://github.com/tiangolo/fastapi/pull/128) by [@zxalif](https://github.com/zxalif). -## 0.10.3 +## 0.10.3 (2019-03-30) * Add Gitter chat, badge, links, etc. [https://gitter.im/tiangolo/fastapi](https://gitter.im/tiangolo/fastapi) . PR [#117](https://github.com/tiangolo/fastapi/pull/117). @@ -6509,7 +6574,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix event docs (startup/shutdown) function name. PR [#105](https://github.com/tiangolo/fastapi/pull/105) by [@stratosgear](https://github.com/stratosgear). -## 0.10.2 +## 0.10.2 (2019-03-29) * Fix OpenAPI (JSON Schema) for declarations of Python `Union` (JSON Schema `additionalProperties`). PR [#121](https://github.com/tiangolo/fastapi/pull/121). @@ -6517,11 +6582,11 @@ Note: all the previous parameters are still there, so it's still possible to dec * Document response models using unions and lists, updated at: [Extra Models](https://fastapi.tiangolo.com/tutorial/extra-models/). PR [#108](https://github.com/tiangolo/fastapi/pull/108). -## 0.10.1 +## 0.10.1 (2019-03-25) * Add docs and tests for [encode/databases](https://github.com/encode/databases). New docs at: [Async SQL (Relational) Databases](https://fastapi.tiangolo.com/advanced/async-sql-databases/). PR [#107](https://github.com/tiangolo/fastapi/pull/107). -## 0.10.0 +## 0.10.0 (2019-03-24) * Add support for Background Tasks in *path operation functions* and dependencies. New documentation about [Background Tasks is here](https://fastapi.tiangolo.com/tutorial/background-tasks/). PR [#103](https://github.com/tiangolo/fastapi/pull/103). @@ -6529,11 +6594,11 @@ Note: all the previous parameters are still there, so it's still possible to dec * New docs section about [Events: startup - shutdown](https://fastapi.tiangolo.com/advanced/events/). PR [#99](https://github.com/tiangolo/fastapi/pull/99). -## 0.9.1 +## 0.9.1 (2019-03-22) * Document receiving [Multiple values with the same query parameter](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#query-parameter-list-multiple-values) and [Duplicate headers](https://fastapi.tiangolo.com/tutorial/header-params/#duplicate-headers). PR [#95](https://github.com/tiangolo/fastapi/pull/95). -## 0.9.0 +## 0.9.0 (2019-03-22) * Upgrade compatible Pydantic version to `0.21.0`. PR [#90](https://github.com/tiangolo/fastapi/pull/90). @@ -6543,7 +6608,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Fix link in "Deployment" to "Bigger Applications". -## 0.8.0 +## 0.8.0 (2019-03-16) * Make development scripts executable. PR [#76](https://github.com/tiangolo/fastapi/pull/76) by [@euri10](https://github.com/euri10). @@ -6553,7 +6618,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update `isort` imports and scripts to be compatible with newer versions. PR [#75](https://github.com/tiangolo/fastapi/pull/75). -## 0.7.1 +## 0.7.1 (2019-03-04) * Update [technical details about `async def` handling](https://fastapi.tiangolo.com/async/#path-operation-functions) with respect to previous frameworks. PR [#64](https://github.com/tiangolo/fastapi/pull/64) by [@haizaar](https://github.com/haizaar). @@ -6561,7 +6626,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * Trigger Docker images build on Travis CI automatically. PR [#65](https://github.com/tiangolo/fastapi/pull/65). -## 0.7.0 +## 0.7.0 (2019-03-03) * Add support for `UploadFile` in `File` parameter annotations. * This includes a file-like interface. @@ -6569,7 +6634,7 @@ Note: all the previous parameters are still there, so it's still possible to dec * And here's the updated documentation for using [`Form` parameters mixed with `File` parameters, supporting `bytes` and `UploadFile`](https://fastapi.tiangolo.com/tutorial/request-forms-and-files/) at the same time. * PR [#63](https://github.com/tiangolo/fastapi/pull/63). -## 0.6.4 +## 0.6.4 (2019-03-02) * Add [technical details about `async def` handling to docs](https://fastapi.tiangolo.com/async/#very-technical-details). PR [#61](https://github.com/tiangolo/fastapi/pull/61). @@ -6583,11 +6648,11 @@ Note: all the previous parameters are still there, so it's still possible to dec * Add docs for using [WebSockets with **FastAPI**](https://fastapi.tiangolo.com/advanced/websockets/). PR [#62](https://github.com/tiangolo/fastapi/pull/62). -## 0.6.3 +## 0.6.3 (2019-02-23) * Add Favicons to docs. PR [#53](https://github.com/tiangolo/fastapi/pull/53). -## 0.6.2 +## 0.6.2 (2019-02-23) * Introduce new project generator based on FastAPI and PostgreSQL: [https://github.com/tiangolo/full-stack-fastapi-postgresql](https://github.com/tiangolo/full-stack-fastapi-postgresql). PR [#52](https://github.com/tiangolo/fastapi/pull/52). @@ -6595,17 +6660,17 @@ Note: all the previous parameters are still there, so it's still possible to dec * Improve middleware naming in tutorial for SQL with SQLAlchemy [https://fastapi.tiangolo.com/tutorial/sql-databases/](https://fastapi.tiangolo.com/tutorial/sql-databases/). -## 0.6.1 +## 0.6.1 (2019-02-20) * Add docs for GraphQL: [https://fastapi.tiangolo.com/advanced/graphql/](https://fastapi.tiangolo.com/advanced/graphql/). PR [#48](https://github.com/tiangolo/fastapi/pull/48). -## 0.6.0 +## 0.6.0 (2019-02-19) * Update SQL with SQLAlchemy tutorial at [https://fastapi.tiangolo.com/tutorial/sql-databases/](https://fastapi.tiangolo.com/tutorial/sql-databases/) using the new official `request.state`. PR [#45](https://github.com/tiangolo/fastapi/pull/45). * Upgrade Starlette to version `0.11.1` and add required compatibility changes. PR [#44](https://github.com/tiangolo/fastapi/pull/44). -## 0.5.1 +## 0.5.1 (2019-02-18) * Add section about [helping and getting help with **FastAPI**](https://fastapi.tiangolo.com/help-fastapi/). @@ -6613,9 +6678,9 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update [section about error handling](https://fastapi.tiangolo.com/tutorial/handling-errors/) with more information and make relation with Starlette error handling utilities more explicit. PR [#41](https://github.com/tiangolo/fastapi/pull/41). -* Add Development - Contributing section to the docs. PR [#42](https://github.com/tiangolo/fastapi/pull/42). +* Add [Development - Contributing section to the docs](). PR [#42](https://github.com/tiangolo/fastapi/pull/42). -## 0.5.0 +## 0.5.0 (2019-02-16) * Add new `HTTPException` with support for custom headers. With new documentation for handling errors at: [https://fastapi.tiangolo.com/tutorial/handling-errors/](https://fastapi.tiangolo.com/tutorial/handling-errors/). PR [#35](https://github.com/tiangolo/fastapi/pull/35). @@ -6625,26 +6690,26 @@ Note: all the previous parameters are still there, so it's still possible to dec * Update example for the SQLAlchemy tutorial at [https://fastapi.tiangolo.com/tutorial/sql-databases/](https://fastapi.tiangolo.com/tutorial/sql-databases/) using middleware and database session attached to request. -## 0.4.0 +## 0.4.0 (2019-02-16) * Add `openapi_prefix`, support for reverse proxy and mounting sub-applications. See the docs at [https://fastapi.tiangolo.com/advanced/sub-applications-proxy/](https://fastapi.tiangolo.com/advanced/sub-applications-proxy/): [#26](https://github.com/tiangolo/fastapi/pull/26) by [@kabirkhan](https://github.com/kabirkhan). * Update [docs/tutorial for SQLAlchemy](https://fastapi.tiangolo.com/tutorial/sql-databases/) including note about _DB Browser for SQLite_. -## 0.3.0 +## 0.3.0 (2019-02-12) * Fix/add SQLAlchemy support, including ORM, and update [docs for SQLAlchemy](https://fastapi.tiangolo.com/tutorial/sql-databases/): [#30](https://github.com/tiangolo/fastapi/pull/30). -## 0.2.1 +## 0.2.1 (2019-02-12) * Fix `jsonable_encoder` for Pydantic models with `Config` but without `json_encoders`: [#29](https://github.com/tiangolo/fastapi/pull/29). -## 0.2.0 +## 0.2.0 (2019-02-08) * Fix typos in Security section: [#24](https://github.com/tiangolo/fastapi/pull/24) by [@kkinder](https://github.com/kkinder). * Add support for Pydantic custom JSON encoders: [#21](https://github.com/tiangolo/fastapi/pull/21) by [@euri10](https://github.com/euri10). -## 0.1.19 +## 0.1.19 (2019-02-01) * Upgrade Starlette version to the current latest `0.10.1`: [#17](https://github.com/tiangolo/fastapi/pull/17) by [@euri10](https://github.com/euri10). diff --git a/docs/en/docs/tutorial/background-tasks.md b/docs/en/docs/tutorial/background-tasks.md index 163070d3d3..dfb082f34c 100644 --- a/docs/en/docs/tutorial/background-tasks.md +++ b/docs/en/docs/tutorial/background-tasks.md @@ -63,7 +63,7 @@ And then another background task generated at the *path operation function* will ## Technical Details { #technical-details } -The class `BackgroundTasks` comes directly from `starlette.background`. +The class `BackgroundTasks` comes directly from [`starlette.background`](https://www.starlette.dev/background/). It is imported/included directly into FastAPI so that you can import it from `fastapi` and avoid accidentally importing the alternative `BackgroundTask` (without the `s` at the end) from `starlette.background`. @@ -71,11 +71,11 @@ By only using `BackgroundTasks` (and not `BackgroundTask`), it's then possible t It's still possible to use `BackgroundTask` alone in FastAPI, but you have to create the object in your code and return a Starlette `Response` including it. -You can see more details in Starlette's official docs for Background Tasks. +You can see more details in [Starlette's official docs for Background Tasks](https://www.starlette.dev/background/). ## Caveat { #caveat } -If you need to perform heavy background computation and you don't necessarily need it to be run by the same process (for example, you don't need to share memory, variables, etc), you might benefit from using other bigger tools like Celery. +If you need to perform heavy background computation and you don't necessarily need it to be run by the same process (for example, you don't need to share memory, variables, etc), you might benefit from using other bigger tools like [Celery](https://docs.celeryq.dev). They tend to require more complex configurations, a message/job queue manager, like RabbitMQ or Redis, but they allow you to run background tasks in multiple processes, and especially, in multiple servers. diff --git a/docs/en/docs/tutorial/bigger-applications.md b/docs/en/docs/tutorial/bigger-applications.md index 7fe83c0635..73647723a9 100644 --- a/docs/en/docs/tutorial/bigger-applications.md +++ b/docs/en/docs/tutorial/bigger-applications.md @@ -123,7 +123,7 @@ We will now use a simple dependency to read a custom `X-Token` header: We are using an invented header to simplify this example. -But in real cases you will get better results using the integrated [Security utilities](security/index.md){.internal-link target=_blank}. +But in real cases you will get better results using the integrated [Security utilities](security/index.md). /// @@ -169,7 +169,7 @@ And we can add a list of `dependencies` that will be added to all the *path oper /// tip -Note that, much like [dependencies in *path operation decorators*](dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, no value will be passed to your *path operation function*. +Note that, much like [dependencies in *path operation decorators*](dependencies/dependencies-in-path-operation-decorators.md), no value will be passed to your *path operation function*. /// @@ -185,8 +185,8 @@ The end result is that the item paths are now: * All of them will include the predefined `responses`. * All these *path operations* will have the list of `dependencies` evaluated/executed before them. * If you also declare dependencies in a specific *path operation*, **they will be executed too**. - * The router dependencies are executed first, then the [`dependencies` in the decorator](dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, and then the normal parameter dependencies. - * You can also add [`Security` dependencies with `scopes`](../advanced/security/oauth2-scopes.md){.internal-link target=_blank}. + * The router dependencies are executed first, then the [`dependencies` in the decorator](dependencies/dependencies-in-path-operation-decorators.md), and then the normal parameter dependencies. + * You can also add [`Security` dependencies with `scopes`](../advanced/security/oauth2-scopes.md). /// tip @@ -303,7 +303,7 @@ And as most of your logic will now live in its own specific module, the main fil You import and create a `FastAPI` class as normally. -And we can even declare [global dependencies](dependencies/global-dependencies.md){.internal-link target=_blank} that will be combined with the dependencies for each `APIRouter`: +And we can even declare [global dependencies](dependencies/global-dependencies.md) that will be combined with the dependencies for each `APIRouter`: {* ../../docs_src/bigger_applications/app_an_py310/main.py hl[1,3,7] title["app/main.py"] *} @@ -353,7 +353,7 @@ The second version is an "absolute import": from app.routers import items, users ``` -To learn more about Python Packages and Modules, read the official Python documentation about Modules. +To learn more about Python Packages and Modules, read [the official Python documentation about Modules](https://docs.python.org/3/tutorial/modules.html). /// @@ -479,7 +479,7 @@ $ fastapi dev app/main.py/// tip -If you use PyCharm as your editor, you can use the Pydantic PyCharm Plugin. +If you use [PyCharm](https://www.jetbrains.com/pycharm/) as your editor, you can use the [Pydantic PyCharm Plugin](https://github.com/koxudaxi/pydantic-pycharm-plugin/). It improves editor support for Pydantic models, with: @@ -163,4 +163,4 @@ But adding the type annotations will allow your editor to give you better suppor ## Without Pydantic { #without-pydantic } -If you don't want to use Pydantic models, you can also use **Body** parameters. See the docs for [Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}. +If you don't want to use Pydantic models, you can also use **Body** parameters. See the docs for [Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body). diff --git a/docs/en/docs/tutorial/cors.md b/docs/en/docs/tutorial/cors.md index 61aaa56360..cd84e5214d 100644 --- a/docs/en/docs/tutorial/cors.md +++ b/docs/en/docs/tutorial/cors.md @@ -1,6 +1,6 @@ # CORS (Cross-Origin Resource Sharing) { #cors-cross-origin-resource-sharing } -CORS or "Cross-Origin Resource Sharing" refers to the situations when a frontend running in a browser has JavaScript code that communicates with a backend, and the backend is in a different "origin" than the frontend. +[CORS or "Cross-Origin Resource Sharing"](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) refers to the situations when a frontend running in a browser has JavaScript code that communicates with a backend, and the backend is in a different "origin" than the frontend. ## Origin { #origin } @@ -56,10 +56,10 @@ The following arguments are supported: * `allow_origins` - A list of origins that should be permitted to make cross-origin requests. E.g. `['https://example.org', 'https://www.example.org']`. You can use `['*']` to allow any origin. * `allow_origin_regex` - A regex string to match against origins that should be permitted to make cross-origin requests. e.g. `'https://.*\.example\.org'`. * `allow_methods` - A list of HTTP methods that should be allowed for cross-origin requests. Defaults to `['GET']`. You can use `['*']` to allow all standard methods. -* `allow_headers` - A list of HTTP request headers that should be supported for cross-origin requests. Defaults to `[]`. You can use `['*']` to allow all headers. The `Accept`, `Accept-Language`, `Content-Language` and `Content-Type` headers are always allowed for simple CORS requests. +* `allow_headers` - A list of HTTP request headers that should be supported for cross-origin requests. Defaults to `[]`. You can use `['*']` to allow all headers. The `Accept`, `Accept-Language`, `Content-Language` and `Content-Type` headers are always allowed for [simple CORS requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests). * `allow_credentials` - Indicate that cookies should be supported for cross-origin requests. Defaults to `False`. - None of `allow_origins`, `allow_methods` and `allow_headers` can be set to `['*']` if `allow_credentials` is set to `True`. All of them must be explicitly specified. + None of `allow_origins`, `allow_methods` and `allow_headers` can be set to `['*']` if `allow_credentials` is set to `True`. All of them must be [explicitly specified](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#credentialed_requests_and_wildcards). * `expose_headers` - Indicate any response headers that should be made accessible to the browser. Defaults to `[]`. * `max_age` - Sets a maximum time in seconds for browsers to cache CORS responses. Defaults to `600`. @@ -78,7 +78,7 @@ Any request with an `Origin` header. In this case the middleware will pass the r ## More info { #more-info } -For more info about CORS, check the Mozilla CORS documentation. +For more info about CORS, check the [Mozilla CORS documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). /// note | Technical Details diff --git a/docs/en/docs/tutorial/debugging.md b/docs/en/docs/tutorial/debugging.md index 89bfb702a6..d157cb7bf0 100644 --- a/docs/en/docs/tutorial/debugging.md +++ b/docs/en/docs/tutorial/debugging.md @@ -74,7 +74,7 @@ will not be executed. /// info -For more information, check the official Python docs. +For more information, check [the official Python docs](https://docs.python.org/3/library/__main__.html). /// diff --git a/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md b/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md index c57c608d2b..e663c40823 100644 --- a/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md +++ b/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md @@ -32,7 +32,7 @@ It might also help avoid confusion for new developers that see an unused paramet In this example we use invented custom headers `X-Key` and `X-Token`. -But in real cases, when implementing security, you would get more benefits from using the integrated [Security utilities (the next chapter)](../security/index.md){.internal-link target=_blank}. +But in real cases, when implementing security, you would get more benefits from using the integrated [Security utilities (the next chapter)](../security/index.md). /// @@ -62,7 +62,7 @@ So, you can reuse a normal dependency (that returns a value) you already use som ## Dependencies for a group of *path operations* { #dependencies-for-a-group-of-path-operations } -Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md){.internal-link target=_blank}), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. +Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md)), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. ## Global Dependencies { #global-dependencies } diff --git a/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md b/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md index 24a2076431..7b80a74e44 100644 --- a/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md +++ b/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md @@ -14,8 +14,8 @@ Make sure to use `yield` one single time per dependency. Any function that is valid to use with: -* `@contextlib.contextmanager` or -* `@contextlib.asynccontextmanager` +* [`@contextlib.contextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager) or +* [`@contextlib.asynccontextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager) would be valid to use as a **FastAPI** dependency. @@ -87,7 +87,7 @@ You can have any combinations of dependencies that you want. /// note | Technical Details -This works thanks to Python's Context Managers. +This works thanks to Python's [Context Managers](https://docs.python.org/3/library/contextlib.html). **FastAPI** uses them internally to achieve this. @@ -111,7 +111,7 @@ But it's there for you if you need it. 🤓 {* ../../docs_src/dependencies/tutorial008b_an_py310.py hl[18:22,31] *} -If you want to catch exceptions and create a custom response based on that, create a [Custom Exception Handler](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}. +If you want to catch exceptions and create a custom response based on that, create a [Custom Exception Handler](../handling-errors.md#install-custom-exception-handlers). ## Dependencies with `yield` and `except` { #dependencies-with-yield-and-except } @@ -233,14 +233,14 @@ participant operation as Path Operation Dependencies with `yield` have evolved over time to cover different use cases and fix some issues. -If you want to see what has changed in different versions of FastAPI, you can read more about it in the advanced guide, in [Advanced Dependencies - Dependencies with `yield`, `HTTPException`, `except` and Background Tasks](../../advanced/advanced-dependencies.md#dependencies-with-yield-httpexception-except-and-background-tasks){.internal-link target=_blank}. +If you want to see what has changed in different versions of FastAPI, you can read more about it in the advanced guide, in [Advanced Dependencies - Dependencies with `yield`, `HTTPException`, `except` and Background Tasks](../../advanced/advanced-dependencies.md#dependencies-with-yield-httpexception-except-and-background-tasks). ## Context Managers { #context-managers } ### What are "Context Managers" { #what-are-context-managers } "Context Managers" are any of those Python objects that you can use in a `with` statement. -For example, you can use `with` to read a file: +For example, [you can use `with` to read a file](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files): ```Python with open("./somefile.txt") as f: @@ -264,7 +264,7 @@ If you are just starting with **FastAPI** you might want to skip it for now. /// -In Python, you can create Context Managers by creating a class with two methods: `__enter__()` and `__exit__()`. +In Python, you can create Context Managers by [creating a class with two methods: `__enter__()` and `__exit__()`](https://docs.python.org/3/reference/datamodel.html#context-managers). You can also use them inside of **FastAPI** dependencies with `yield` by using `with` or `async with` statements inside of the dependency function: @@ -275,8 +275,8 @@ You can also use them inside of **FastAPI** dependencies with `yield` by using Another way to create a context manager is with: -* `@contextlib.contextmanager` or -* `@contextlib.asynccontextmanager` +* [`@contextlib.contextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager) or +* [`@contextlib.asynccontextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager) using them to decorate a function with a single `yield`. diff --git a/docs/en/docs/tutorial/dependencies/global-dependencies.md b/docs/en/docs/tutorial/dependencies/global-dependencies.md index 6feda0bc82..e02ac14db2 100644 --- a/docs/en/docs/tutorial/dependencies/global-dependencies.md +++ b/docs/en/docs/tutorial/dependencies/global-dependencies.md @@ -2,15 +2,15 @@ For some types of applications you might want to add dependencies to the whole application. -Similar to the way you can [add `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, you can add them to the `FastAPI` application. +Similar to the way you can [add `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md), you can add them to the `FastAPI` application. In that case, they will be applied to all the *path operations* in the application: {* ../../docs_src/dependencies/tutorial012_an_py310.py hl[17] *} -And all the ideas in the section about [adding `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md){.internal-link target=_blank} still apply, but in this case, to all of the *path operations* in the app. +And all the ideas in the section about [adding `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md) still apply, but in this case, to all of the *path operations* in the app. ## Dependencies for groups of *path operations* { #dependencies-for-groups-of-path-operations } -Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md){.internal-link target=_blank}), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. +Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md)), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. diff --git a/docs/en/docs/tutorial/dependencies/index.md b/docs/en/docs/tutorial/dependencies/index.md index 4a1bb774d9..396c23acbb 100644 --- a/docs/en/docs/tutorial/dependencies/index.md +++ b/docs/en/docs/tutorial/dependencies/index.md @@ -57,7 +57,7 @@ FastAPI added support for `Annotated` (and started recommending it) in version 0 If you have an older version, you would get errors when trying to use `Annotated`. -Make sure you [Upgrade the FastAPI version](../../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`. +Make sure you [Upgrade the FastAPI version](../../deployment/versions.md#upgrading-the-fastapi-versions) to at least 0.95.1 before using `Annotated`. /// @@ -152,7 +152,7 @@ It doesn't matter. **FastAPI** will know what to do. /// note -If you don't know, check the [Async: *"In a hurry?"*](../../async.md#in-a-hurry){.internal-link target=_blank} section about `async` and `await` in the docs. +If you don't know, check the [Async: *"In a hurry?"*](../../async.md#in-a-hurry) section about `async` and `await` in the docs. /// diff --git a/docs/en/docs/tutorial/encoder.md b/docs/en/docs/tutorial/encoder.md index 17982e9d79..c8f8bca8c9 100644 --- a/docs/en/docs/tutorial/encoder.md +++ b/docs/en/docs/tutorial/encoder.md @@ -12,7 +12,7 @@ Let's imagine that you have a database `fake_db` that only receives JSON compati For example, it doesn't receive `datetime` objects, as those are not compatible with JSON. -So, a `datetime` object would have to be converted to a `str` containing the data in ISO format. +So, a `datetime` object would have to be converted to a `str` containing the data in [ISO format](https://en.wikipedia.org/wiki/ISO_8601). The same way, this database wouldn't receive a Pydantic model (an object with attributes), only a `dict`. @@ -24,7 +24,7 @@ It receives an object, like a Pydantic model, and returns a JSON compatible vers In this example, it would convert the Pydantic model to a `dict`, and the `datetime` to a `str`. -The result of calling it is something that can be encoded with the Python standard `json.dumps()`. +The result of calling it is something that can be encoded with the Python standard [`json.dumps()`](https://docs.python.org/3/library/json.html#json.dumps). It doesn't return a large `str` containing the data in JSON format (as a string). It returns a Python standard data structure (e.g. a `dict`) with values and sub-values that are all compatible with JSON. diff --git a/docs/en/docs/tutorial/extra-data-types.md b/docs/en/docs/tutorial/extra-data-types.md index a41f7c5fc4..611aa9b9ee 100644 --- a/docs/en/docs/tutorial/extra-data-types.md +++ b/docs/en/docs/tutorial/extra-data-types.md @@ -36,7 +36,7 @@ Here are some of the additional data types you can use: * `datetime.timedelta`: * A Python `datetime.timedelta`. * In requests and responses will be represented as a `float` of total seconds. - * Pydantic also allows representing it as a "ISO 8601 time diff encoding", see the docs for more info. + * Pydantic also allows representing it as a "ISO 8601 time diff encoding", [see the docs for more info](https://docs.pydantic.dev/latest/concepts/serialization/#custom-serializers). * `frozenset`: * In requests and responses, treated the same as a `set`: * In requests, a list will be read, eliminating duplicates and converting it to a `set`. @@ -49,7 +49,7 @@ Here are some of the additional data types you can use: * `Decimal`: * Standard Python `Decimal`. * In requests and responses, handled the same as a `float`. -* You can check all the valid Pydantic data types here: Pydantic data types. +* You can check all the valid Pydantic data types here: [Pydantic data types](https://docs.pydantic.dev/latest/usage/types/types/). ## Example { #example } diff --git a/docs/en/docs/tutorial/extra-models.md b/docs/en/docs/tutorial/extra-models.md index da4f8f2bda..e231aea90a 100644 --- a/docs/en/docs/tutorial/extra-models.md +++ b/docs/en/docs/tutorial/extra-models.md @@ -12,7 +12,7 @@ This is especially the case for user models, because: Never store user's plaintext passwords. Always store a "secure hash" that you can then verify. -If you don't know, you will learn what a "password hash" is in the [security chapters](security/simple-oauth2.md#password-hashing){.internal-link target=_blank}. +If you don't know, you will learn what a "password hash" is in the [security chapters](security/simple-oauth2.md#password-hashing). /// @@ -162,11 +162,11 @@ You can declare a response to be the `Union` of two or more types, that means, t It will be defined in OpenAPI with `anyOf`. -To do that, use the standard Python type hint `typing.Union`: +To do that, use the standard Python type hint [`typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union): /// note -When defining a `Union`, include the most specific type first, followed by the less specific type. In the example below, the more specific `PlaneItem` comes before `CarItem` in `Union[PlaneItem, CarItem]`. +When defining a [`Union`](https://docs.pydantic.dev/latest/concepts/types/#unions), include the most specific type first, followed by the less specific type. In the example below, the more specific `PlaneItem` comes before `CarItem` in `Union[PlaneItem, CarItem]`. /// diff --git a/docs/en/docs/tutorial/first-steps.md b/docs/en/docs/tutorial/first-steps.md index 84751d9d82..578a17d2e4 100644 --- a/docs/en/docs/tutorial/first-steps.md +++ b/docs/en/docs/tutorial/first-steps.md @@ -58,7 +58,7 @@ That line shows the URL where your app is being served on your local machine. ### Check it { #check-it } -Open your browser at http://127.0.0.1:8000. +Open your browser at [http://127.0.0.1:8000](http://127.0.0.1:8000). You will see the JSON response as: @@ -68,17 +68,17 @@ You will see the JSON response as: ### Interactive API docs { #interactive-api-docs } -Now go to http://127.0.0.1:8000/docs. +Now go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). -You will see the automatic interactive API documentation (provided by Swagger UI): +You will see the automatic interactive API documentation (provided by [Swagger UI](https://github.com/swagger-api/swagger-ui)):  ### Alternative API docs { #alternative-api-docs } -And now, go to http://127.0.0.1:8000/redoc. +And now, go to [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc). -You will see the alternative automatic documentation (provided by ReDoc): +You will see the alternative automatic documentation (provided by [ReDoc](https://github.com/Rebilly/ReDoc)):  @@ -92,7 +92,7 @@ A "schema" is a definition or description of something. Not the code that implem #### API "schema" { #api-schema } -In this case, OpenAPI is a specification that dictates how to define a schema of your API. +In this case, [OpenAPI](https://github.com/OAI/OpenAPI-Specification) is a specification that dictates how to define a schema of your API. This schema definition includes your API paths, the possible parameters they take, etc. @@ -110,7 +110,7 @@ OpenAPI defines an API schema for your API. And that schema includes definitions If you are curious about how the raw OpenAPI schema looks like, FastAPI automatically generates a JSON (schema) with the descriptions of all your API. -You can see it directly at: http://127.0.0.1:8000/openapi.json. +You can see it directly at: [http://127.0.0.1:8000/openapi.json](http://127.0.0.1:8000/openapi.json). It will show a JSON starting with something like: @@ -145,7 +145,7 @@ You could also use it to generate code automatically, for clients that communica ### Deploy your app (optional) { #deploy-your-app-optional } -You can optionally deploy your FastAPI app to FastAPI Cloud, go and join the waiting list if you haven't. 🚀 +You can optionally deploy your FastAPI app to [FastAPI Cloud](https://fastapicloud.com), go and join the waiting list if you haven't. 🚀 If you already have a **FastAPI Cloud** account (we invited you from the waiting list 😉), you can deploy your application with one command. @@ -191,7 +191,7 @@ That's it! Now you can access your app at that URL. ✨ `FastAPI` is a class that inherits directly from `Starlette`. -You can use all the Starlette functionality with `FastAPI` too. +You can use all the [Starlette](https://www.starlette.dev/) functionality with `FastAPI` too. /// @@ -336,7 +336,7 @@ You could also define it as a normal function instead of `async def`: /// note -If you don't know the difference, check the [Async: *"In a hurry?"*](../async.md#in-a-hurry){.internal-link target=_blank}. +If you don't know the difference, check the [Async: *"In a hurry?"*](../async.md#in-a-hurry). /// @@ -352,11 +352,11 @@ There are many other objects and models that will be automatically converted to ### Step 6: Deploy it { #step-6-deploy-it } -Deploy your app to **FastAPI Cloud** with one command: `fastapi deploy`. 🎉 +Deploy your app to **[FastAPI Cloud](https://fastapicloud.com)** with one command: `fastapi deploy`. 🎉 #### About FastAPI Cloud { #about-fastapi-cloud } -**FastAPI Cloud** is built by the same author and team behind **FastAPI**. +**[FastAPI Cloud](https://fastapicloud.com)** is built by the same author and team behind **FastAPI**. It streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort. diff --git a/docs/en/docs/tutorial/handling-errors.md b/docs/en/docs/tutorial/handling-errors.md index f1db17bb2e..78a5f1f20a 100644 --- a/docs/en/docs/tutorial/handling-errors.md +++ b/docs/en/docs/tutorial/handling-errors.md @@ -81,7 +81,7 @@ But in case you needed it for an advanced scenario, you can add custom headers: ## Install custom exception handlers { #install-custom-exception-handlers } -You can add custom exception handlers with the same exception utilities from Starlette. +You can add custom exception handlers with [the same exception utilities from Starlette](https://www.starlette.dev/exceptions/). Let's say you have a custom exception `UnicornException` that you (or a library you use) might `raise`. diff --git a/docs/en/docs/tutorial/index.md b/docs/en/docs/tutorial/index.md index 7212a0c4a9..f65fead6cd 100644 --- a/docs/en/docs/tutorial/index.md +++ b/docs/en/docs/tutorial/index.md @@ -62,7 +62,7 @@ Using it in your editor is what really shows you the benefits of FastAPI, seeing The first step is to install FastAPI. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then **install FastAPI**: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then **install FastAPI**:
@@ -76,7 +76,7 @@ $ pip install "fastapi[standard]" /// note -When you install with `pip install "fastapi[standard]"` it comes with some default optional standard dependencies, including `fastapi-cloud-cli`, which allows you to deploy to FastAPI Cloud. +When you install with `pip install "fastapi[standard]"` it comes with some default optional standard dependencies, including `fastapi-cloud-cli`, which allows you to deploy to [FastAPI Cloud](https://fastapicloud.com). If you don't want to have those optional dependencies, you can instead install `pip install fastapi`. @@ -84,6 +84,12 @@ If you want to install the standard dependencies but without the `fastapi-cloud- /// +/// tip + +FastAPI has an [official extension for VS Code](https://marketplace.visualstudio.com/items?itemName=FastAPILabs.fastapi-vscode) (and Cursor), which provides a lot of features, including a path operation explorer, path operation search, CodeLens navigation in tests (jump to definition from tests), and FastAPI Cloud deployment and logs, all from your editor. + +/// + ## Advanced User Guide { #advanced-user-guide } There is also an **Advanced User Guide** that you can read later after this **Tutorial - User guide**. diff --git a/docs/en/docs/tutorial/metadata.md b/docs/en/docs/tutorial/metadata.md index 5cf0dfca01..2abf0a3421 100644 --- a/docs/en/docs/tutorial/metadata.md +++ b/docs/en/docs/tutorial/metadata.md @@ -14,7 +14,7 @@ You can set the following fields that are used in the OpenAPI specification and | `version` | `string` | The version of the API. This is the version of your own application, not of OpenAPI. For example `2.5.0`. | | `terms_of_service` | `str` | A URL to the Terms of Service for the API. If provided, this has to be a URL. | | `contact` | `dict` | The contact information for the exposed API. It can contain several fields.| -| `license_info` | `dict` | The license information for the exposed API. It can contain several fields.
contactfields
Parameter Type Description namestrThe identifying name of the contact person/organization. urlstrThe URL pointing to the contact information. MUST be in the format of a URL. strThe email address of the contact person/organization. MUST be in the format of an email address. | +| `license_info` | `dict` | The license information for the exposed API. It can contain several fields.
license_infofields
Parameter Type Description namestrREQUIRED (if a license_infois set). The license name used for the API.identifierstrAn SPDX license expression for the API. The identifierfield is mutually exclusive of theurlfield. Available since OpenAPI 3.1.0, FastAPI 0.99.0.urlstrA URL to the license used for the API. MUST be in the format of a URL. | You can set them as follows: @@ -76,7 +76,7 @@ Use the `tags` parameter with your *path operations* (and `APIRouter`s) to assig /// info -Read more about tags in [Path Operation Configuration](path-operation-configuration.md#tags){.internal-link target=_blank}. +Read more about tags in [Path Operation Configuration](path-operation-configuration.md#tags). /// diff --git a/docs/en/docs/tutorial/middleware.md b/docs/en/docs/tutorial/middleware.md index 123ce3a683..5da549cb7e 100644 --- a/docs/en/docs/tutorial/middleware.md +++ b/docs/en/docs/tutorial/middleware.md @@ -15,7 +15,7 @@ A "middleware" is a function that works with every **request** before it is proc If you have dependencies with `yield`, the exit code will run *after* the middleware. -If there were any background tasks (covered in the [Background Tasks](background-tasks.md){.internal-link target=_blank} section, you will see it later), they will run *after* all the middleware. +If there were any background tasks (covered in the [Background Tasks](background-tasks.md) section, you will see it later), they will run *after* all the middleware. /// @@ -35,9 +35,9 @@ The middleware function receives: /// tip -Keep in mind that custom proprietary headers can be added using the `X-` prefix. +Keep in mind that custom proprietary headers can be added [using the `X-` prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers). -But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) using the parameter `expose_headers` documented in Starlette's CORS docs. +But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations ([CORS (Cross-Origin Resource Sharing)](cors.md)) using the parameter `expose_headers` documented in [Starlette's CORS docs](https://www.starlette.dev/middleware/#corsmiddleware). /// @@ -61,7 +61,7 @@ For example, you could add a custom header `X-Process-Time` containing the time /// tip -Here we use `time.perf_counter()` instead of `time.time()` because it can be more precise for these use cases. 🤓 +Here we use [`time.perf_counter()`](https://docs.python.org/3/library/time.html#time.perf_counter) instead of `time.time()` because it can be more precise for these use cases. 🤓 /// @@ -90,6 +90,6 @@ This stacking behavior ensures that middlewares are executed in a predictable an ## Other middlewares { #other-middlewares } -You can later read more about other middlewares in the [Advanced User Guide: Advanced Middleware](../advanced/middleware.md){.internal-link target=_blank}. +You can later read more about other middlewares in the [Advanced User Guide: Advanced Middleware](../advanced/middleware.md). You will read about how to handle CORS with a middleware in the next section. diff --git a/docs/en/docs/tutorial/path-operation-configuration.md b/docs/en/docs/tutorial/path-operation-configuration.md index 2c545dc1a9..e350f7683f 100644 --- a/docs/en/docs/tutorial/path-operation-configuration.md +++ b/docs/en/docs/tutorial/path-operation-configuration.md @@ -58,7 +58,7 @@ You can add a `summary` and `description`: As descriptions tend to be long and cover multiple lines, you can declare the *path operation* description in the function docstring and **FastAPI** will read it from there. -You can write Markdown in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation). +You can write [Markdown](https://en.wikipedia.org/wiki/Markdown) in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation). {* ../../docs_src/path_operation_configuration/tutorial004_py310.py hl[17:25] *} diff --git a/docs/en/docs/tutorial/path-params-numeric-validations.md b/docs/en/docs/tutorial/path-params-numeric-validations.md index de63a51f59..2ba40e92fe 100644 --- a/docs/en/docs/tutorial/path-params-numeric-validations.md +++ b/docs/en/docs/tutorial/path-params-numeric-validations.md @@ -14,7 +14,7 @@ FastAPI added support for `Annotated` (and started recommending it) in version 0 If you have an older version, you would get errors when trying to use `Annotated`. -Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`. +Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions) to at least 0.95.1 before using `Annotated`. /// @@ -122,7 +122,7 @@ And the same for
license_infofields
Parameter Type Description namestrREQUIRED (if a license_infois set). The license name used for the API.identifierstrAn [SPDX](https://spdx.org/licenses/) license expression for the API. The identifierfield is mutually exclusive of theurlfield. Available since OpenAPI 3.1.0, FastAPI 0.99.0.urlstrA URL to the license used for the API. MUST be in the format of a URL. lt. ## Recap { #recap } -With `Query`, `Path` (and others you haven't seen yet) you can declare metadata and string validations in the same ways as with [Query Parameters and String Validations](query-params-str-validations.md){.internal-link target=_blank}. +With `Query`, `Path` (and others you haven't seen yet) you can declare metadata and string validations in the same ways as with [Query Parameters and String Validations](query-params-str-validations.md). And you can also declare numeric validations: diff --git a/docs/en/docs/tutorial/path-params.md b/docs/en/docs/tutorial/path-params.md index 8adbbcfa1b..6614dfdcb7 100644 --- a/docs/en/docs/tutorial/path-params.md +++ b/docs/en/docs/tutorial/path-params.md @@ -6,7 +6,7 @@ You can declare path "parameters" or "variables" with the same syntax used by Py The value of the path parameter `item_id` will be passed to your function as the argument `item_id`. -So, if you run this example and go to http://127.0.0.1:8000/items/foo, you will see a response of: +So, if you run this example and go to [http://127.0.0.1:8000/items/foo](http://127.0.0.1:8000/items/foo), you will see a response of: ```JSON {"item_id":"foo"} @@ -28,7 +28,7 @@ This will give you editor support inside of your function, with error checks, co ## Data conversion { #data-conversion } -If you run this example and open your browser at http://127.0.0.1:8000/items/3, you will see a response of: +If you run this example and open your browser at [http://127.0.0.1:8000/items/3](http://127.0.0.1:8000/items/3), you will see a response of: ```JSON {"item_id":3} @@ -44,7 +44,7 @@ So, with that type declaration, **FastAPI** gives you automatic request http://127.0.0.1:8000/items/foo, you will see a nice HTTP error of: +But if you go to the browser at [http://127.0.0.1:8000/items/foo](http://127.0.0.1:8000/items/foo), you will see a nice HTTP error of: ```JSON { @@ -64,7 +64,7 @@ But if you go to the browser at http://127.0.0.1:8000/items/4.2 +The same error would appear if you provided a `float` instead of an `int`, as in: [http://127.0.0.1:8000/items/4.2](http://127.0.0.1:8000/items/4.2) /// check @@ -78,7 +78,7 @@ This is incredibly helpful while developing and debugging code that interacts wi ## Documentation { #documentation } -And when you open your browser at http://127.0.0.1:8000/docs, you will see an automatic, interactive, API documentation like: +And when you open your browser at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs), you will see an automatic, interactive, API documentation like:@@ -92,9 +92,9 @@ Notice that the path parameter is declared to be an integer. ## Standards-based benefits, alternative documentation { #standards-based-benefits-alternative-documentation } -And because the generated schema is from the OpenAPI standard, there are many compatible tools. +And because the generated schema is from the [OpenAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md) standard, there are many compatible tools. -Because of this, **FastAPI** itself provides an alternative API documentation (using ReDoc), which you can access at http://127.0.0.1:8000/redoc: +Because of this, **FastAPI** itself provides an alternative API documentation (using ReDoc), which you can access at [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc):
@@ -102,7 +102,7 @@ The same way, there are many compatible tools. Including code generation tools f ## Pydantic { #pydantic } -All the data validation is performed under the hood by Pydantic, so you get all the benefits from it. And you know you are in good hands. +All the data validation is performed under the hood by [Pydantic](https://docs.pydantic.dev/), so you get all the benefits from it. And you know you are in good hands. You can use the same type declarations with `str`, `float`, `bool` and many other complex data types. diff --git a/docs/en/docs/tutorial/query-params-str-validations.md b/docs/en/docs/tutorial/query-params-str-validations.md index 7ae94fb0a8..4765b36cbe 100644 --- a/docs/en/docs/tutorial/query-params-str-validations.md +++ b/docs/en/docs/tutorial/query-params-str-validations.md @@ -35,13 +35,13 @@ FastAPI added support for `Annotated` (and started recommending it) in version 0 If you have an older version, you would get errors when trying to use `Annotated`. -Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`. +Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions) to at least 0.95.1 before using `Annotated`. /// ## Use `Annotated` in the type for the `q` parameter { #use-annotated-in-the-type-for-the-q-parameter } -Remember I told you before that `Annotated` can be used to add metadata to your parameters in the [Python Types Intro](../python-types.md#type-hints-with-metadata-annotations){.internal-link target=_blank}? +Remember I told you before that `Annotated` can be used to add metadata to your parameters in the [Python Types Intro](../python-types.md#type-hints-with-metadata-annotations)? Now it's the time to use it with FastAPI. 🚀 @@ -158,7 +158,7 @@ You could **call** that same function in **other places** without FastAPI, and i When you don't use `Annotated` and instead use the **(old) default value style**, if you call that function without FastAPI in **other places**, you have to **remember** to pass the arguments to the function for it to work correctly, otherwise the values will be different from what you expect (e.g. `QueryInfo` or something similar instead of `str`). And your editor won't complain, and Python won't complain running that function, only when the operations inside error out. -Because `Annotated` can have more than one metadata annotation, you could now even use the same function with other tools, like Typer. 🚀 +Because `Annotated` can have more than one metadata annotation, you could now even use the same function with other tools, like [Typer](https://typer.tiangolo.com/). 🚀 ## Add more validations { #add-more-validations } @@ -370,11 +370,11 @@ There could be cases where you need to do some **custom validation** that can't In those cases, you can use a **custom validator function** that is applied after the normal validation (e.g. after validating that the value is a `str`). -You can achieve that using Pydantic's `AfterValidator` inside of `Annotated`. +You can achieve that using [Pydantic's `AfterValidator`](https://docs.pydantic.dev/latest/concepts/validators/#field-after-validator) inside of `Annotated`. /// tip -Pydantic also has `BeforeValidator` and others. 🤓 +Pydantic also has [`BeforeValidator`](https://docs.pydantic.dev/latest/concepts/validators/#field-before-validator) and others. 🤓 /// diff --git a/docs/en/docs/tutorial/query-params.md b/docs/en/docs/tutorial/query-params.md index 9408168cf1..efe2c6d7a0 100644 --- a/docs/en/docs/tutorial/query-params.md +++ b/docs/en/docs/tutorial/query-params.md @@ -183,6 +183,6 @@ In this case, there are 3 query parameters: /// tip -You could also use `Enum`s the same way as with [Path Parameters](path-params.md#predefined-values){.internal-link target=_blank}. +You could also use `Enum`s the same way as with [Path Parameters](path-params.md#predefined-values). /// diff --git a/docs/en/docs/tutorial/request-files.md b/docs/en/docs/tutorial/request-files.md index 93c27df3fe..ae3d6a119d 100644 --- a/docs/en/docs/tutorial/request-files.md +++ b/docs/en/docs/tutorial/request-files.md @@ -4,9 +4,9 @@ You can define files to be uploaded by the client using `File`. /// info -To receive uploaded files, first install `python-multipart`. +To receive uploaded files, first install [`python-multipart`](https://github.com/Kludex/python-multipart). -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example: ```console $ pip install python-multipart @@ -63,8 +63,8 @@ Using `UploadFile` has several advantages over `bytes`: * A file stored in memory up to a maximum size limit, and after passing this limit it will be stored in disk. * This means that it will work well for large files like images, videos, large binaries, etc. without consuming all the memory. * You can get metadata from the uploaded file. -* It has a file-like `async` interface. -* It exposes an actual Python `SpooledTemporaryFile` object that you can pass directly to other libraries that expect a file-like object. +* It has a [file-like](https://docs.python.org/3/glossary.html#term-file-like-object) `async` interface. +* It exposes an actual Python [`SpooledTemporaryFile`](https://docs.python.org/3/library/tempfile.html#tempfile.SpooledTemporaryFile) object that you can pass directly to other libraries that expect a file-like object. ### `UploadFile` { #uploadfile } @@ -72,7 +72,7 @@ Using `UploadFile` has several advantages over `bytes`: * `filename`: A `str` with the original file name that was uploaded (e.g. `myimage.jpg`). * `content_type`: A `str` with the content type (MIME type / media type) (e.g. `image/jpeg`). -* `file`: A `SpooledTemporaryFile` (a file-like object). This is the actual Python file object that you can pass directly to other functions or libraries that expect a "file-like" object. +* `file`: A [`SpooledTemporaryFile`](https://docs.python.org/3/library/tempfile.html#tempfile.SpooledTemporaryFile) (a [file-like](https://docs.python.org/3/glossary.html#term-file-like-object) object). This is the actual Python file object that you can pass directly to other functions or libraries that expect a "file-like" object. `UploadFile` has the following `async` methods. They all call the corresponding file methods underneath (using the internal `SpooledTemporaryFile`). @@ -121,7 +121,7 @@ Data from forms is normally encoded using the "media type" `application/x-www-fo But when the form includes files, it is encoded as `multipart/form-data`. If you use `File`, **FastAPI** will know it has to get the files from the correct part of the body. -If you want to read more about these encodings and form fields, head to the MDN web docs for
POST. +If you want to read more about these encodings and form fields, head to the [MDN web docs for `POST`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST). /// diff --git a/docs/en/docs/tutorial/request-form-models.md b/docs/en/docs/tutorial/request-form-models.md index 37e764c136..2e0f463294 100644 --- a/docs/en/docs/tutorial/request-form-models.md +++ b/docs/en/docs/tutorial/request-form-models.md @@ -4,9 +4,9 @@ You can use **Pydantic models** to declare **form fields** in FastAPI. /// info -To use forms, first install `python-multipart`. +To use forms, first install [`python-multipart`](https://github.com/Kludex/python-multipart). -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example: ```console $ pip install python-multipart diff --git a/docs/en/docs/tutorial/request-forms-and-files.md b/docs/en/docs/tutorial/request-forms-and-files.md index 75f30bd2a9..1443004120 100644 --- a/docs/en/docs/tutorial/request-forms-and-files.md +++ b/docs/en/docs/tutorial/request-forms-and-files.md @@ -4,9 +4,9 @@ You can define files and form fields at the same time using `File` and `Form`. /// info -To receive uploaded files and/or form data, first install `python-multipart`. +To receive uploaded files and/or form data, first install [`python-multipart`](https://github.com/Kludex/python-multipart). -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example: ```console $ pip install python-multipart diff --git a/docs/en/docs/tutorial/request-forms.md b/docs/en/docs/tutorial/request-forms.md index 3f160504f6..8c4b32d850 100644 --- a/docs/en/docs/tutorial/request-forms.md +++ b/docs/en/docs/tutorial/request-forms.md @@ -4,9 +4,9 @@ When you need to receive form fields instead of JSON, you can use `Form`. /// info -To use forms, first install `python-multipart`. +To use forms, first install [`python-multipart`](https://github.com/Kludex/python-multipart). -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example: ```console $ pip install python-multipart @@ -56,7 +56,7 @@ Data from forms is normally encoded using the "media type" `application/x-www-fo But when the form includes files, it is encoded as `multipart/form-data`. You'll read about handling files in the next chapter. -If you want to read more about these encodings and form fields, head to the MDN web docs forPOST. +If you want to read more about these encodings and form fields, head to the [MDN web docs for `POST`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST). /// diff --git a/docs/en/docs/tutorial/response-model.md b/docs/en/docs/tutorial/response-model.md index c8312d92c6..d628167ddb 100644 --- a/docs/en/docs/tutorial/response-model.md +++ b/docs/en/docs/tutorial/response-model.md @@ -74,9 +74,9 @@ Here we are declaring a `UserIn` model, it will contain a plaintext password: /// info -To use `EmailStr`, first install `email-validator`. +To use `EmailStr`, first install [`email-validator`](https://github.com/JoshData/python-email-validator). -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example: ```console $ pip install email-validator @@ -182,7 +182,7 @@ There might be cases where you return something that is not a valid Pydantic fie ### Return a Response Directly { #return-a-response-directly } -The most common case would be [returning a Response directly as explained later in the advanced docs](../advanced/response-directly.md){.internal-link target=_blank}. +The most common case would be [returning a Response directly as explained later in the advanced docs](../advanced/response-directly.md). {* ../../docs_src/response_model/tutorial003_02_py310.py hl[8,10:11] *} @@ -258,7 +258,7 @@ You can also use: * `response_model_exclude_defaults=True` * `response_model_exclude_none=True` -as described in the Pydantic docs for `exclude_defaults` and `exclude_none`. +as described in [the Pydantic docs](https://docs.pydantic.dev/1.10/usage/exporting_models/#modeldict) for `exclude_defaults` and `exclude_none`. /// diff --git a/docs/en/docs/tutorial/response-status-code.md b/docs/en/docs/tutorial/response-status-code.md index dcb35dff54..dcadaa36d8 100644 --- a/docs/en/docs/tutorial/response-status-code.md +++ b/docs/en/docs/tutorial/response-status-code.md @@ -20,7 +20,7 @@ The `status_code` parameter receives a number with the HTTP status code. /// info -`status_code` can alternatively also receive an `IntEnum`, such as Python's `http.HTTPStatus`. +`status_code` can alternatively also receive an `IntEnum`, such as Python's [`http.HTTPStatus`](https://docs.python.org/3/library/http.html#http.HTTPStatus). /// @@ -66,7 +66,7 @@ In short: /// tip -To know more about each status code and which code is for what, check the MDN documentation about HTTP status codes. +To know more about each status code and which code is for what, check the [MDN documentation about HTTP status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status). /// @@ -98,4 +98,4 @@ You could also use `from starlette import status`. ## Changing the default { #changing-the-default } -Later, in the [Advanced User Guide](../advanced/response-change-status-code.md){.internal-link target=_blank}, you will see how to return a different status code than the default you are declaring here. +Later, in the [Advanced User Guide](../advanced/response-change-status-code.md), you will see how to return a different status code than the default you are declaring here. diff --git a/docs/en/docs/tutorial/schema-extra-example.md b/docs/en/docs/tutorial/schema-extra-example.md index 432f58b1e3..2b5fe11c0b 100644 --- a/docs/en/docs/tutorial/schema-extra-example.md +++ b/docs/en/docs/tutorial/schema-extra-example.md @@ -12,7 +12,7 @@ You can declare `examples` for a Pydantic model that will be added to the genera That extra info will be added as-is to the output **JSON Schema** for that model, and it will be used in the API docs. -You can use the attribute `model_config` that takes a `dict` as described in Pydantic's docs: Configuration. +You can use the attribute `model_config` that takes a `dict` as described in [Pydantic's docs: Configuration](https://docs.pydantic.dev/latest/api/config/). You can set `"json_schema_extra"` with a `dict` containing any additional data you would like to show up in the generated JSON Schema, including `examples`. @@ -145,12 +145,12 @@ JSON Schema didn't have `examples`, so OpenAPI added its own `example` field to OpenAPI also added `example` and `examples` fields to other parts of the specification: -* `Parameter Object` (in the specification) that was used by FastAPI's: +* [`Parameter Object` (in the specification)](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object) that was used by FastAPI's: * `Path()` * `Query()` * `Header()` * `Cookie()` -* `Request Body Object`, in the field `content`, on the `Media Type Object` (in the specification) that was used by FastAPI's: +* [`Request Body Object`, in the field `content`, on the `Media Type Object` (in the specification)](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object) that was used by FastAPI's: * `Body()` * `File()` * `Form()` @@ -163,7 +163,7 @@ This old OpenAPI-specific `examples` parameter is now `openapi_examples` since F ### JSON Schema's `examples` field { #json-schemas-examples-field } -But then JSON Schema added an `examples` field to a new version of the specification. +But then JSON Schema added an [`examples`](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.5) field to a new version of the specification. And then the new OpenAPI 3.1.0 was based on the latest version (JSON Schema 2020-12) that included this new field `examples`. diff --git a/docs/en/docs/tutorial/security/first-steps.md b/docs/en/docs/tutorial/security/first-steps.md index 4fbb5e0903..9c58c782ec 100644 --- a/docs/en/docs/tutorial/security/first-steps.md +++ b/docs/en/docs/tutorial/security/first-steps.md @@ -26,11 +26,11 @@ Copy the example in a file `main.py`: /// info -The `python-multipart` package is automatically installed with **FastAPI** when you run the `pip install "fastapi[standard]"` command. +The [`python-multipart`](https://github.com/Kludex/python-multipart) package is automatically installed with **FastAPI** when you run the `pip install "fastapi[standard]"` command. However, if you use the `pip install fastapi` command, the `python-multipart` package is not included by default. -To install it manually, make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it with: +To install it manually, make sure you create a [virtual environment](../../virtual-environments.md), activate it, and then install it with: ```console $ pip install python-multipart @@ -54,7 +54,7 @@ $ fastapi dev main.py ## Check it { #check-it } -Go to the interactive docs at: http://127.0.0.1:8000/docs. +Go to the interactive docs at: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). You will see something like this: @@ -140,7 +140,7 @@ Here `tokenUrl="token"` refers to a relative URL `token` that we haven't created Because we are using a relative URL, if your API was located at `https://example.com/`, then it would refer to `https://example.com/token`. But if your API was located at `https://example.com/api/v1/`, then it would refer to `https://example.com/api/v1/token`. -Using a relative URL is important to make sure your application keeps working even in an advanced use case like [Behind a Proxy](../../advanced/behind-a-proxy.md){.internal-link target=_blank}. +Using a relative URL is important to make sure your application keeps working even in an advanced use case like [Behind a Proxy](../../advanced/behind-a-proxy.md). /// diff --git a/docs/en/docs/tutorial/security/oauth2-jwt.md b/docs/en/docs/tutorial/security/oauth2-jwt.md index 26894ab287..fabdd06a6b 100644 --- a/docs/en/docs/tutorial/security/oauth2-jwt.md +++ b/docs/en/docs/tutorial/security/oauth2-jwt.md @@ -24,13 +24,13 @@ That way, you can create a token with an expiration of, let's say, 1 week. And t After a week, the token will be expired and the user will not be authorized and will have to sign in again to get a new token. And if the user (or a third party) tried to modify the token to change the expiration, you would be able to discover it, because the signatures would not match. -If you want to play with JWT tokens and see how they work, check https://jwt.io. +If you want to play with JWT tokens and see how they work, check [https://jwt.io](https://jwt.io/). ## Install `PyJWT` { #install-pyjwt } We need to install `PyJWT` to generate and verify the JWT tokens in Python. -Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install `pyjwt`: +Make sure you create a [virtual environment](../../virtual-environments.md), activate it, and then install `pyjwt`:@@ -46,7 +46,7 @@ $ pip install pyjwt If you are planning to use digital signature algorithms like RSA or ECDSA, you should install the cryptography library dependency `pyjwt[crypto]`. -You can read more about it in the PyJWT Installation docs. +You can read more about it in the [PyJWT Installation docs](https://pyjwt.readthedocs.io/en/latest/installation.html). /// @@ -72,7 +72,7 @@ It supports many secure hashing algorithms and utilities to work with them. The recommended algorithm is "Argon2". -Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install pwdlib with Argon2: +Make sure you create a [virtual environment](../../virtual-environments.md), activate it, and then install pwdlib with Argon2:@@ -200,7 +200,7 @@ The important thing to keep in mind is that the `sub` key should have a unique i ## Check it { #check-it } -Run the server and go to the docs: http://127.0.0.1:8000/docs. +Run the server and go to the docs: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). You'll see the user interface like: diff --git a/docs/en/docs/tutorial/security/simple-oauth2.md b/docs/en/docs/tutorial/security/simple-oauth2.md index 296e0e2950..a98112d765 100644 --- a/docs/en/docs/tutorial/security/simple-oauth2.md +++ b/docs/en/docs/tutorial/security/simple-oauth2.md @@ -146,7 +146,7 @@ UserInDB( /// info -For a more complete explanation of `**user_dict` check back in [the documentation for **Extra Models**](../extra-models.md#about-user-in-dict){.internal-link target=_blank}. +For a more complete explanation of `**user_dict` check back in [the documentation for **Extra Models**](../extra-models.md#about-user-in-dict). /// @@ -216,7 +216,7 @@ That's the benefit of standards... ## See it in action { #see-it-in-action } -Open the interactive docs: http://127.0.0.1:8000/docs. +Open the interactive docs: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). ### Authenticate { #authenticate } diff --git a/docs/en/docs/tutorial/server-sent-events.md b/docs/en/docs/tutorial/server-sent-events.md new file mode 100644 index 0000000000..d264f8536f --- /dev/null +++ b/docs/en/docs/tutorial/server-sent-events.md @@ -0,0 +1,120 @@ +# Server-Sent Events (SSE) { #server-sent-events-sse } + +You can stream data to the client using **Server-Sent Events** (SSE). + +This is similar to [Stream JSON Lines](stream-json-lines.md), but uses the `text/event-stream` format, which is supported natively by browsers with the [`EventSource` API](https://developer.mozilla.org/en-US/docs/Web/API/EventSource). + +/// info + +Added in FastAPI 0.135.0. + +/// + +## What are Server-Sent Events? { #what-are-server-sent-events } + +SSE is a standard for streaming data from the server to the client over HTTP. + +Each event is a small text block with "fields" like `data`, `event`, `id`, and `retry`, separated by blank lines. + +It looks like this: + +``` +data: {"name": "Portal Gun", "price": 999.99} + +data: {"name": "Plumbus", "price": 32.99} + +``` + +SSE is commonly used for AI chat streaming, live notifications, logs and observability, and other cases where the server pushes updates to the client. + +/// tip + +If you want to stream binary data, for example video or audio, check the advanced guide: [Stream Data](../advanced/stream-data.md). + +/// + +## Stream SSE with FastAPI { #stream-sse-with-fastapi } + +To stream SSE with FastAPI, use `yield` in your *path operation function* and set `response_class=EventSourceResponse`. + +Import `EventSourceResponse` from `fastapi.sse`: + +{* ../../docs_src/server_sent_events/tutorial001_py310.py ln[1:25] hl[4,22] *} + +Each yielded item is encoded as JSON and sent in the `data:` field of an SSE event. + +If you declare the return type as `AsyncIterable[Item]`, FastAPI will use it to **validate**, **document**, and **serialize** the data using Pydantic. + +{* ../../docs_src/server_sent_events/tutorial001_py310.py ln[1:25] hl[10:12,23] *} + +/// tip + +As Pydantic will serialize it in the **Rust** side, you will get much higher **performance** than if you don't declare a return type. + +/// + +### Non-async *path operation functions* { #non-async-path-operation-functions } + +You can also use regular `def` functions (without `async`), and use `yield` the same way. + +FastAPI will make sure it's run correctly so that it doesn't block the event loop. + +As in this case the function is not async, the right return type would be `Iterable[Item]`: + +{* ../../docs_src/server_sent_events/tutorial001_py310.py ln[28:31] hl[29] *} + +### No Return Type { #no-return-type } + +You can also omit the return type. FastAPI will use the [`jsonable_encoder`](./encoder.md) to convert the data and send it. + +{* ../../docs_src/server_sent_events/tutorial001_py310.py ln[34:37] hl[35] *} + +## `ServerSentEvent` { #serversentevent } + +If you need to set SSE fields like `event`, `id`, `retry`, or `comment`, you can yield `ServerSentEvent` objects instead of plain data. + +Import `ServerSentEvent` from `fastapi.sse`: + +{* ../../docs_src/server_sent_events/tutorial002_py310.py hl[4,26] *} + +The `data` field is always encoded as JSON. You can pass any value that can be serialized as JSON, including Pydantic models. + +## Raw Data { #raw-data } + +If you need to send data **without** JSON encoding, use `raw_data` instead of `data`. + +This is useful for sending pre-formatted text, log lines, or special "sentinel" values like `[DONE]`. + +{* ../../docs_src/server_sent_events/tutorial003_py310.py hl[17] *} + +/// note + +`data` and `raw_data` are mutually exclusive. You can only set one of them on each `ServerSentEvent`. + +/// + +## Resuming with `Last-Event-ID` { #resuming-with-last-event-id } + +When a browser reconnects after a connection drop, it sends the last received `id` in the `Last-Event-ID` header. + +You can read it as a header parameter and use it to resume the stream from where the client left off: + +{* ../../docs_src/server_sent_events/tutorial004_py310.py hl[25,27,31] *} + +## SSE with POST { #sse-with-post } + +SSE works with **any HTTP method**, not just `GET`. + +This is useful for protocols like [MCP](https://modelcontextprotocol.io) that stream SSE over `POST`: + +{* ../../docs_src/server_sent_events/tutorial005_py310.py hl[14] *} + +## Technical Details { #technical-details } + +FastAPI implements some SSE best practices out of the box. + +* Send a **"keep alive" `ping` comment** every 15 seconds when there hasn't been any message, to prevent some proxies from closing the connection, as suggested in the [HTML specification: Server-Sent Events](https://html.spec.whatwg.org/multipage/server-sent-events.html#authoring-notes). +* Set the `Cache-Control: no-cache` header to **prevent caching** of the stream. +* Set a special header `X-Accel-Buffering: no` to **prevent buffering** in some proxies like Nginx. + +You don't have to do anything about it, it works out of the box. 🤓 diff --git a/docs/en/docs/tutorial/sql-databases.md b/docs/en/docs/tutorial/sql-databases.md index b42e9ba2f2..69b174b2a8 100644 --- a/docs/en/docs/tutorial/sql-databases.md +++ b/docs/en/docs/tutorial/sql-databases.md @@ -2,9 +2,9 @@ **FastAPI** doesn't require you to use a SQL (relational) database. But you can use **any database** that you want. -Here we'll see an example using SQLModel. +Here we'll see an example using [SQLModel](https://sqlmodel.tiangolo.com/). -**SQLModel** is built on top of SQLAlchemy and Pydantic. It was made by the same author of **FastAPI** to be the perfect match for FastAPI applications that need to use **SQL databases**. +**SQLModel** is built on top of [SQLAlchemy](https://www.sqlalchemy.org/) and Pydantic. It was made by the same author of **FastAPI** to be the perfect match for FastAPI applications that need to use **SQL databases**. /// tip @@ -26,15 +26,15 @@ Later, for your production application, you might want to use a database server /// tip -There is an official project generator with **FastAPI** and **PostgreSQL** including a frontend and more tools: https://github.com/fastapi/full-stack-fastapi-template +There is an official project generator with **FastAPI** and **PostgreSQL** including a frontend and more tools: [https://github.com/fastapi/full-stack-fastapi-template](https://github.com/fastapi/full-stack-fastapi-template) /// -This is a very simple and short tutorial, if you want to learn about databases in general, about SQL, or more advanced features, go to the SQLModel docs. +This is a very simple and short tutorial, if you want to learn about databases in general, about SQL, or more advanced features, go to the [SQLModel docs](https://sqlmodel.tiangolo.com/). ## Install `SQLModel` { #install-sqlmodel } -First, make sure you create your [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install `sqlmodel`: +First, make sure you create your [virtual environment](../virtual-environments.md), activate it, and then install `sqlmodel`:@@ -65,7 +65,7 @@ There are a few differences: * `Field(primary_key=True)` tells SQLModel that the `id` is the **primary key** in the SQL database (you can learn more about SQL primary keys in the SQLModel docs). - **Note:** We use `int | None` for the primary key field so that in Python code we can *create an object without an `id`* (`id=None`), assuming the database will *generate it when saving*. SQLModel understands that the database will provide the `id` and *defines the column as a non-null `INTEGER`* in the database schema. See SQLModel docs on primary keys for details. + **Note:** We use `int | None` for the primary key field so that in Python code we can *create an object without an `id`* (`id=None`), assuming the database will *generate it when saving*. SQLModel understands that the database will provide the `id` and *defines the column as a non-null `INTEGER`* in the database schema. See [SQLModel docs on primary keys](https://sqlmodel.tiangolo.com/tutorial/create-db-and-table/#primary-key-id) for details. * `Field(index=True)` tells SQLModel that it should create a **SQL index** for this column, that would allow faster lookups in the database when reading data filtered by this column. @@ -111,7 +111,7 @@ For production you would probably use a migration script that runs before you st /// tip -SQLModel will have migration utilities wrapping Alembic, but for now, you can use Alembic directly. +SQLModel will have migration utilities wrapping Alembic, but for now, you can use [Alembic](https://alembic.sqlalchemy.org/en/latest/) directly. /// @@ -352,6 +352,6 @@ If you go to the `/docs` API UI, you will see that it is now updated, and it won ## Recap { #recap } -You can use **SQLModel** to interact with a SQL database and simplify the code with *data models* and *table models*. +You can use [**SQLModel**](https://sqlmodel.tiangolo.com/) to interact with a SQL database and simplify the code with *data models* and *table models*. -You can learn a lot more at the **SQLModel** docs, there's a longer mini tutorial on using SQLModel with **FastAPI**. 🚀 +You can learn a lot more at the **SQLModel** docs, there's a longer mini [tutorial on using SQLModel with **FastAPI**](https://sqlmodel.tiangolo.com/tutorial/fastapi/). 🚀 diff --git a/docs/en/docs/tutorial/static-files.md b/docs/en/docs/tutorial/static-files.md index 8fd65a0d7f..38c2ef2485 100644 --- a/docs/en/docs/tutorial/static-files.md +++ b/docs/en/docs/tutorial/static-files.md @@ -23,7 +23,7 @@ You could also use `from starlette.staticfiles import StaticFiles`. This is different from using an `APIRouter` as a mounted application is completely independent. The OpenAPI and docs from your main application won't include anything from the mounted application, etc. -You can read more about this in the [Advanced User Guide](../advanced/index.md){.internal-link target=_blank}. +You can read more about this in the [Advanced User Guide](../advanced/index.md). ## Details { #details } @@ -37,4 +37,4 @@ All these parameters can be different than "`static`", adjust them with the need ## More info { #more-info } -For more details and options check Starlette's docs about Static Files. +For more details and options check [Starlette's docs about Static Files](https://www.starlette.dev/staticfiles/). diff --git a/docs/en/docs/tutorial/stream-json-lines.md b/docs/en/docs/tutorial/stream-json-lines.md new file mode 100644 index 0000000000..3006636362 --- /dev/null +++ b/docs/en/docs/tutorial/stream-json-lines.md @@ -0,0 +1,111 @@ +# Stream JSON Lines { #stream-json-lines } + +You could have a sequence of data that you would like to send in a "**stream**", you could do it with **JSON Lines**. + +/// info + +Added in FastAPI 0.134.0. + +/// + +## What is a Stream? { #what-is-a-stream } + +"**Streaming**" data means that your app will start sending data items to the client without waiting for the entire sequence of items to be ready. + +So, it will send the first item, the client will receive and start processing it, and you might still be producing the next item. + +```mermaid +sequenceDiagram + participant App + participant Client + + App->>App: Produce Item 1 + App->>Client: Send Item 1 + App->>App: Produce Item 2 + Client->>Client: Process Item 1 + App->>Client: Send Item 2 + App->>App: Produce Item 3 + Client->>Client: Process Item 2 + App->>Client: Send Item 3 + Client->>Client: Process Item 3 + Note over App: Keeps producing... + Note over Client: Keeps consuming... +``` + +It could even be an infinite stream, where you keep sending data. + +## JSON Lines { #json-lines } + +In these cases, it's common to send "**JSON Lines**", which is a format where you send one JSON object per line. + +A response would have a content type of `application/jsonl` (instead of `application/json`) and the body would be something like: + +```json +{"name": "Plumbus", "description": "A multi-purpose household device."} +{"name": "Portal Gun", "description": "A portal opening device."} +{"name": "Meeseeks Box", "description": "A box that summons a Meeseeks."} +``` + +It's very similar to a JSON array (equivalent of a Python list), but instead of being wrapped in `[]` and having `,` between the items, it has **one JSON object per line**, they are separated by a new line character. + +/// info + +The important point is that your app will be able to produce each line in turn, while the client consumes the previous lines. + +/// + +/// note | Technical Details + +Because each JSON object will be separated by a new line, they can't contain literal new line characters in their content, but they can contain escaped new lines (`\n`), which is part of the JSON standard. + +But normally you won't have to worry about it, it's done automatically, continue reading. 🤓 + +/// + +## Use Cases { #use-cases } + +You could use this to stream data from an **AI LLM** service, from **logs** or **telemetry**, or from other types of data that can be structured in **JSON** items. + +/// tip + +If you want to stream binary data, for example video or audio, check the advanced guide: [Stream Data](../advanced/stream-data.md). + +/// + +## Stream JSON Lines with FastAPI { #stream-json-lines-with-fastapi } + +To stream JSON Lines with FastAPI you can, instead of using `return` in your *path operation function*, use `yield` to produce each item in turn. + +{* ../../docs_src/stream_json_lines/tutorial001_py310.py ln[1:24] hl[24] *} + +If each JSON item you want to send back is of type `Item` (a Pydantic model) and it's an async function, you can declare the return type as `AsyncIterable[Item]`: + +{* ../../docs_src/stream_json_lines/tutorial001_py310.py ln[1:24] hl[9:11,22] *} + +If you declare the return type, FastAPI will use it to **validate** the data, **document** it in OpenAPI, **filter** it, and **serialize** it using Pydantic. + +/// tip + +As Pydantic will serialize it in the **Rust** side, you will get much higher **performance** than if you don't declare a return type. + +/// + +### Non-async *path operation functions* { #non-async-path-operation-functions } + +You can also use regular `def` functions (without `async`), and use `yield` the same way. + +FastAPI will make sure it's run correctly so that it doesn't block the event loop. + +As in this case the function is not async, the right return type would be `Iterable[Item]`: + +{* ../../docs_src/stream_json_lines/tutorial001_py310.py ln[27:30] hl[28] *} + +### No Return Type { #no-return-type } + +You can also omit the return type. FastAPI will then use the [`jsonable_encoder`](./encoder.md) to convert the data to something that can be serialized to JSON and then send it as JSON Lines. + +{* ../../docs_src/stream_json_lines/tutorial001_py310.py ln[33:36] hl[34] *} + +## Server-Sent Events (SSE) { #server-sent-events-sse } + +FastAPI also has first-class support for Server-Sent Events (SSE), which are quite similar but with a couple of extra details. You can learn about them in the next chapter: [Server-Sent Events (SSE)](server-sent-events.md). 🤓 diff --git a/docs/en/docs/tutorial/testing.md b/docs/en/docs/tutorial/testing.md index 14c1b35668..5b8fbba07c 100644 --- a/docs/en/docs/tutorial/testing.md +++ b/docs/en/docs/tutorial/testing.md @@ -1,18 +1,18 @@ # Testing { #testing } -Thanks to Starlette, testing **FastAPI** applications is easy and enjoyable. +Thanks to [Starlette](https://www.starlette.dev/testclient/), testing **FastAPI** applications is easy and enjoyable. -It is based on HTTPX, which in turn is designed based on Requests, so it's very familiar and intuitive. +It is based on [HTTPX](https://www.python-httpx.org), which in turn is designed based on Requests, so it's very familiar and intuitive. -With it, you can use pytest directly with **FastAPI**. +With it, you can use [pytest](https://docs.pytest.org/) directly with **FastAPI**. ## Using `TestClient` { #using-testclient } /// info -To use `TestClient`, first install `httpx`. +To use `TestClient`, first install [`httpx`](https://www.python-httpx.org). -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example: ```console $ pip install httpx @@ -52,7 +52,7 @@ You could also use `from starlette.testclient import TestClient`. /// tip -If you want to call `async` functions in your tests apart from sending requests to your FastAPI application (e.g. asynchronous database functions), have a look at the [Async Tests](../advanced/async-tests.md){.internal-link target=_blank} in the advanced tutorial. +If you want to call `async` functions in your tests apart from sending requests to your FastAPI application (e.g. asynchronous database functions), have a look at the [Async Tests](../advanced/async-tests.md) in the advanced tutorial. /// @@ -64,7 +64,7 @@ And your **FastAPI** application might also be composed of several files/modules ### **FastAPI** app file { #fastapi-app-file } -Let's say you have a file structure as described in [Bigger Applications](bigger-applications.md){.internal-link target=_blank}: +Let's say you have a file structure as described in [Bigger Applications](bigger-applications.md): ``` . @@ -142,13 +142,13 @@ E.g.: * To pass *headers*, use a `dict` in the `headers` parameter. * For *cookies*, a `dict` in the `cookies` parameter. -For more information about how to pass data to the backend (using `httpx` or the `TestClient`) check the HTTPX documentation. +For more information about how to pass data to the backend (using `httpx` or the `TestClient`) check the [HTTPX documentation](https://www.python-httpx.org). /// info Note that the `TestClient` receives data that can be converted to JSON, not Pydantic models. -If you have a Pydantic model in your test and you want to send its data to the application during testing, you can use the `jsonable_encoder` described in [JSON Compatible Encoder](encoder.md){.internal-link target=_blank}. +If you have a Pydantic model in your test and you want to send its data to the application during testing, you can use the `jsonable_encoder` described in [JSON Compatible Encoder](encoder.md). /// @@ -156,7 +156,7 @@ If you have a Pydantic model in your test and you want to send its data to the a After that, you just need to install `pytest`. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md), activate it, and then install it, for example:diff --git a/docs/en/docs/virtual-environments.md b/docs/en/docs/virtual-environments.md index 615d7949f9..bd46eb820d 100644 --- a/docs/en/docs/virtual-environments.md +++ b/docs/en/docs/virtual-environments.md @@ -22,7 +22,7 @@ A **virtual environment** is a directory with some files in it. This page will teach you how to use **virtual environments** and how they work. -If you are ready to adopt a **tool that manages everything** for you (including installing Python), try uv. +If you are ready to adopt a **tool that manages everything** for you (including installing Python), try [uv](https://github.com/astral-sh/uv). /// @@ -86,7 +86,7 @@ $ python -m venv .venv //// tab | `uv` -If you have `uv` installed, you can use it to create a virtual environment. +If you have [`uv`](https://github.com/astral-sh/uv) installed, you can use it to create a virtual environment.@@ -150,7 +150,7 @@ $ .venv\Scripts\Activate.ps1 //// tab | Windows Bash -Or if you use Bash for Windows (e.g. Git Bash): +Or if you use Bash for Windows (e.g. [Git Bash](https://gitforwindows.org/)):@@ -216,7 +216,7 @@ If it shows the `python` binary at `.venv\Scripts\python`, inside of your projec /// tip -If you use `uv` you would use it to install things instead of `pip`, so you don't need to upgrade `pip`. 😎 +If you use [`uv`](https://github.com/astral-sh/uv) you would use it to install things instead of `pip`, so you don't need to upgrade `pip`. 😎 /// @@ -268,7 +268,7 @@ If you are using **Git** (you should), add a `.gitignore` file to exclude everyt /// tip -If you used `uv` to create the virtual environment, it already did this for you, you can skip this step. 😎 +If you used [`uv`](https://github.com/astral-sh/uv) to create the virtual environment, it already did this for you, you can skip this step. 😎 /// @@ -340,7 +340,7 @@ $ pip install "fastapi[standard]" //// tab | `uv` -If you have `uv`: +If you have [`uv`](https://github.com/astral-sh/uv):@@ -372,7 +372,7 @@ $ pip install -r requirements.txt //// tab | `uv` -If you have `uv`: +If you have [`uv`](https://github.com/astral-sh/uv):@@ -416,8 +416,8 @@ You would probably use an editor, make sure you configure it to use the same vir For example: -* VS Code -* PyCharm +* [VS Code](https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment) +* [PyCharm](https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html) /// tip @@ -455,7 +455,7 @@ Continue reading. 👇🤓 ## Why Virtual Environments { #why-virtual-environments } -To work with FastAPI you need to install Python. +To work with FastAPI you need to install [Python](https://www.python.org/). After that, you would need to **install** FastAPI and any other **packages** you want to use. @@ -564,7 +564,7 @@ $ pip install "fastapi[standard]"-That will download a compressed file with the FastAPI code, normally from PyPI. +That will download a compressed file with the FastAPI code, normally from [PyPI](https://pypi.org/project/fastapi/). It will also **download** files for other packages that FastAPI depends on. @@ -627,7 +627,7 @@ $ .venv\Scripts\Activate.ps1 //// tab | Windows Bash -Or if you use Bash for Windows (e.g. Git Bash): +Or if you use Bash for Windows (e.g. [Git Bash](https://gitforwindows.org/)):@@ -639,13 +639,13 @@ $ source .venv/Scripts/activate //// -That command will create or modify some [environment variables](environment-variables.md){.internal-link target=_blank} that will be available for the next commands. +That command will create or modify some [environment variables](environment-variables.md) that will be available for the next commands. One of those variables is the `PATH` variable. /// tip -You can learn more about the `PATH` environment variable in the [Environment Variables](environment-variables.md#path-environment-variable){.internal-link target=_blank} section. +You can learn more about the `PATH` environment variable in the [Environment Variables](environment-variables.md#path-environment-variable) section. /// @@ -846,7 +846,7 @@ This is a simple guide to get you started and teach you how everything works **u There are many **alternatives** to managing virtual environments, package dependencies (requirements), projects. -Once you are ready and want to use a tool to **manage the entire project**, packages dependencies, virtual environments, etc. I would suggest you try uv. +Once you are ready and want to use a tool to **manage the entire project**, packages dependencies, virtual environments, etc. I would suggest you try [uv](https://github.com/astral-sh/uv). `uv` can do a lot of things, it can: diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml index e86e7b9c41..0db3e7a95b 100644 --- a/docs/en/mkdocs.yml +++ b/docs/en/mkdocs.yml @@ -154,6 +154,8 @@ nav: - tutorial/cors.md - tutorial/sql-databases.md - tutorial/bigger-applications.md + - tutorial/stream-json-lines.md + - tutorial/server-sent-events.md - tutorial/background-tasks.md - tutorial/metadata.md - tutorial/static-files.md @@ -161,6 +163,7 @@ nav: - tutorial/debugging.md - Advanced User Guide: - advanced/index.md + - advanced/stream-data.md - advanced/path-operation-advanced-configuration.md - advanced/additional-status-codes.md - advanced/response-directly.md @@ -195,6 +198,7 @@ nav: - advanced/json-base64-bytes.md - advanced/strict-content-type.md - fastapi-cli.md + - editor-support.md - Deployment: - deployment/index.md - deployment/versions.md diff --git a/docs/es/docs/advanced/websockets.md b/docs/es/docs/advanced/websockets.md index 2a7fed6c59..e9391c36ca 100644 --- a/docs/es/docs/advanced/websockets.md +++ b/docs/es/docs/advanced/websockets.md @@ -38,13 +38,13 @@ En producción tendrías una de las opciones anteriores. Pero es la forma más sencilla de enfocarse en el lado del servidor de WebSockets y tener un ejemplo funcional: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## Crear un `websocket` { #create-a-websocket } En tu aplicación de **FastAPI**, crea un `websocket`: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | Detalles Técnicos @@ -58,7 +58,7 @@ También podrías usar `from starlette.websockets import WebSocket`. En tu ruta de WebSocket puedes `await` para recibir mensajes y enviar mensajes. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} Puedes recibir y enviar datos binarios, de texto y JSON. @@ -109,7 +109,7 @@ En endpoints de WebSocket puedes importar desde `fastapi` y usar: Funcionan de la misma manera que para otros endpoints de FastAPI/*path operations*: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info | Información @@ -154,7 +154,7 @@ Con eso puedes conectar el WebSocket y luego enviar y recibir mensajes: Cuando una conexión de WebSocket se cierra, el `await websocket.receive_text()` lanzará una excepción `WebSocketDisconnect`, que puedes capturar y manejar como en este ejemplo. -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} Para probarlo: diff --git a/docs/fr/docs/advanced/websockets.md b/docs/fr/docs/advanced/websockets.md index 6f5c3e7033..d78f89c374 100644 --- a/docs/fr/docs/advanced/websockets.md +++ b/docs/fr/docs/advanced/websockets.md @@ -38,13 +38,13 @@ En production, vous auriez l'une des options ci-dessus. Mais c'est la façon la plus simple de se concentrer sur la partie serveur des WebSockets et d'avoir un exemple fonctionnel : -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## Créer un `websocket` { #create-a-websocket } Dans votre application **FastAPI**, créez un `websocket` : -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | Détails techniques @@ -58,7 +58,7 @@ Vous pourriez aussi utiliser `from starlette.websockets import WebSocket`. Dans votre route WebSocket, vous pouvez `await` des messages et envoyer des messages. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} Vous pouvez recevoir et envoyer des données binaires, texte et JSON. @@ -109,7 +109,7 @@ Dans les endpoints WebSocket, vous pouvez importer depuis `fastapi` et utiliser Ils fonctionnent de la même manière que pour les autres endpoints/*chemins d'accès* FastAPI : -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info @@ -154,7 +154,7 @@ Avec cela, vous pouvez connecter le WebSocket puis envoyer et recevoir des messa Lorsqu'une connexion WebSocket est fermée, l'instruction `await websocket.receive_text()` lèvera une exception `WebSocketDisconnect`, que vous pouvez ensuite intercepter et gérer comme dans cet exemple. -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} Pour l'essayer : diff --git a/docs/ja/docs/advanced/websockets.md b/docs/ja/docs/advanced/websockets.md index cb5e376de6..efc02079bb 100644 --- a/docs/ja/docs/advanced/websockets.md +++ b/docs/ja/docs/advanced/websockets.md @@ -38,13 +38,13 @@ $ pip install websockets しかし、これはWebSocketsのサーバーサイドに焦点を当て、動作する例を示す最も簡単な方法です。 -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## `websocket` を作成する { #create-a-websocket } **FastAPI** アプリケーションで、`websocket` を作成します。 -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | 技術詳細 @@ -58,7 +58,7 @@ $ pip install websockets WebSocketルートでは、メッセージを待機して送信するために `await` を使用できます。 -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} バイナリやテキストデータ、JSONデータを送受信できます。 @@ -109,7 +109,7 @@ WebSocketエンドポイントでは、`fastapi` から以下をインポート これらは、他のFastAPI エンドポイント/*path operations* の場合と同じように機能します。 -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info | 情報 @@ -154,7 +154,7 @@ $ fastapi dev main.py WebSocket接続が閉じられると、 `await websocket.receive_text()` は例外 `WebSocketDisconnect` を発生させ、この例のようにキャッチして処理することができます。 -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} 試してみるには、 diff --git a/docs/ko/docs/advanced/websockets.md b/docs/ko/docs/advanced/websockets.md index 384f93952b..cb59097f6e 100644 --- a/docs/ko/docs/advanced/websockets.md +++ b/docs/ko/docs/advanced/websockets.md @@ -38,13 +38,13 @@ $ pip install websockets 그러나 이는 WebSockets의 서버 측에 집중하고 동작하는 예제를 제공하는 가장 간단한 방법입니다: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## `websocket` 생성하기 { #create-a-websocket } **FastAPI** 애플리케이션에서 `websocket`을 생성합니다: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | 기술 세부사항 @@ -58,7 +58,7 @@ $ pip install websockets WebSocket 경로에서 메시지를 대기(`await`)하고 전송할 수 있습니다. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} 여러분은 이진 데이터, 텍스트, JSON 데이터를 받을 수 있고 전송할 수 있습니다. @@ -109,7 +109,7 @@ WebSocket 엔드포인트에서 `fastapi`에서 다음을 가져와 사용할 이들은 다른 FastAPI 엔드포인트/*경로 처리*와 동일하게 동작합니다: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info | 정보 @@ -154,7 +154,7 @@ $ fastapi dev main.py WebSocket 연결이 닫히면, `await websocket.receive_text()`가 `WebSocketDisconnect` 예외를 발생시킵니다. 그러면 이 예제처럼 이를 잡아 처리할 수 있습니다. -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} 테스트해보기: diff --git a/docs/pt/docs/advanced/websockets.md b/docs/pt/docs/advanced/websockets.md index c294b7603e..f148defd4c 100644 --- a/docs/pt/docs/advanced/websockets.md +++ b/docs/pt/docs/advanced/websockets.md @@ -38,13 +38,13 @@ Na produção, você teria uma das opções acima. Mas é a maneira mais simples de focar no lado do servidor de WebSockets e ter um exemplo funcional: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## Crie um `websocket` { #create-a-websocket } Em sua aplicação **FastAPI**, crie um `websocket`: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | Detalhes Técnicos @@ -58,7 +58,7 @@ A **FastAPI** fornece o mesmo `WebSocket` diretamente apenas como uma conveniên Em sua rota WebSocket você pode esperar (`await`) por mensagens e enviar mensagens. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} Você pode receber e enviar dados binários, de texto e JSON. @@ -109,7 +109,7 @@ Nos endpoints WebSocket você pode importar do `fastapi` e usar: Eles funcionam da mesma forma que para outros endpoints FastAPI/*operações de rota*: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info | Informação @@ -154,7 +154,7 @@ Com isso você pode conectar o WebSocket e então enviar e receber mensagens: Quando uma conexão WebSocket é fechada, o `await websocket.receive_text()` levantará uma exceção `WebSocketDisconnect`, que você pode então capturar e lidar como neste exemplo. -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} Para testar: diff --git a/docs/ru/docs/advanced/websockets.md b/docs/ru/docs/advanced/websockets.md index 446cc2505e..d565d507bc 100644 --- a/docs/ru/docs/advanced/websockets.md +++ b/docs/ru/docs/advanced/websockets.md @@ -38,13 +38,13 @@ $ pip install websockets Для примера нам нужен наиболее простой способ, который позволит сосредоточиться на серверной части веб‑сокетов и получить рабочий код: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## Создание `websocket` { #create-a-websocket } Создайте `websocket` в своем **FastAPI** приложении: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | Технические детали @@ -58,7 +58,7 @@ $ pip install websockets Через эндпоинт веб-сокета вы можете получать и отправлять сообщения. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} Вы можете получать и отправлять двоичные, текстовые и JSON данные. @@ -109,7 +109,7 @@ $ fastapi dev main.py Они работают так же, как и в других FastAPI эндпоинтах/*операциях пути*: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info | Примечание @@ -154,7 +154,7 @@ $ fastapi dev main.py Если веб-сокет соединение закрыто, то `await websocket.receive_text()` вызовет исключение `WebSocketDisconnect`, которое можно поймать и обработать как в этом примере: -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} Чтобы воспроизвести пример: diff --git a/docs/tr/docs/advanced/websockets.md b/docs/tr/docs/advanced/websockets.md index 16b4be7e8d..a5ab27597e 100644 --- a/docs/tr/docs/advanced/websockets.md +++ b/docs/tr/docs/advanced/websockets.md @@ -38,13 +38,13 @@ Production'da yukarıdaki seçeneklerden birini kullanırsınız. Ama WebSockets'in server tarafına odaklanmak ve çalışan bir örnek görmek için en basit yol bu: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## Bir `websocket` Oluşturun { #create-a-websocket } **FastAPI** uygulamanızda bir `websocket` oluşturun: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | Teknik Detaylar @@ -58,7 +58,7 @@ Ama WebSockets'in server tarafına odaklanmak ve çalışan bir örnek görmek i WebSocket route'unuzda mesajları `await` edebilir ve mesaj gönderebilirsiniz. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} Binary, text ve JSON verisi alıp gönderebilirsiniz. @@ -109,7 +109,7 @@ WebSocket endpoint'lerinde `fastapi` içinden import edip şunları kullanabilir Diğer FastAPI endpoint'leri/*path operations* ile aynı şekilde çalışırlar: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info | Bilgi @@ -154,7 +154,7 @@ Bununla WebSocket'e bağlanabilir, ardından mesaj gönderip alabilirsiniz: Bir WebSocket bağlantısı kapandığında, `await websocket.receive_text()` bir `WebSocketDisconnect` exception'ı raise eder; ardından bunu bu örnekteki gibi yakalayıp (catch) yönetebilirsiniz. -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} Denemek için: diff --git a/docs/uk/docs/advanced/websockets.md b/docs/uk/docs/advanced/websockets.md index 21bb61d7e9..bb06ac00b7 100644 --- a/docs/uk/docs/advanced/websockets.md +++ b/docs/uk/docs/advanced/websockets.md @@ -38,13 +38,13 @@ $ pip install websockets Але це найпростіший спосіб зосередитися на серверній частині WebSockets і мати робочий приклад: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## Створіть `websocket` { #create-a-websocket } У вашому застосунку **FastAPI** створіть `websocket`: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | Технічні деталі @@ -58,7 +58,7 @@ $ pip install websockets У вашому маршруті WebSocket ви можете `await` повідомлення і надсилати повідомлення. -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} Ви можете отримувати та надсилати бінарні, текстові та JSON-дані. @@ -109,7 +109,7 @@ $ fastapi dev main.py Вони працюють так само, як для інших ендпойнтів FastAPI/*операцій шляху*: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info @@ -154,7 +154,7 @@ $ fastapi dev main.py Коли з'єднання WebSocket закривається, `await websocket.receive_text()` підніме виняток `WebSocketDisconnect`, який ви можете перехопити й обробити, як у цьому прикладі. -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} Щоб спробувати: diff --git a/docs/zh-hant/docs/advanced/websockets.md b/docs/zh-hant/docs/advanced/websockets.md index c4e904f6f6..22e3fdcb9e 100644 --- a/docs/zh-hant/docs/advanced/websockets.md +++ b/docs/zh-hant/docs/advanced/websockets.md @@ -38,13 +38,13 @@ $ pip install websockets 但這是能讓我們專注於 WebSocket 伺服端並跑起一個可運作範例的最簡單方式: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## 建立一個 `websocket` { #create-a-websocket } 在你的 **FastAPI** 應用中,建立一個 `websocket`: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | 技術細節 @@ -58,7 +58,7 @@ $ pip install websockets 在你的 WebSocket 路由中,你可以 `await` 接收訊息並傳送訊息。 -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} 你可以接收與傳送二進位、文字與 JSON 資料。 @@ -109,7 +109,7 @@ $ fastapi dev main.py 它們的運作方式與其他 FastAPI 端點/*路徑操作* 相同: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info @@ -154,7 +154,7 @@ $ fastapi dev main.py 當 WebSocket 連線關閉時,`await websocket.receive_text()` 會拋出 `WebSocketDisconnect` 例外,你可以像範例中那樣捕捉並處理。 -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} 試用方式: diff --git a/docs/zh/docs/advanced/websockets.md b/docs/zh/docs/advanced/websockets.md index 513e1aaecd..a4cdae3a22 100644 --- a/docs/zh/docs/advanced/websockets.md +++ b/docs/zh/docs/advanced/websockets.md @@ -38,13 +38,13 @@ $ pip install websockets 但这是一种专注于 WebSockets 的服务器端并提供一个工作示例的最简单方式: -{* ../../docs_src/websockets/tutorial001_py310.py hl[2,6:38,41:43] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[2,6:38,41:43] *} ## 创建 `websocket` { #create-a-websocket } 在您的 **FastAPI** 应用程序中,创建一个 `websocket`: -{* ../../docs_src/websockets/tutorial001_py310.py hl[1,46:47] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[1,46:47] *} /// note | 技术细节 @@ -58,7 +58,7 @@ $ pip install websockets 在您的 WebSocket 路由中,您可以使用 `await` 等待消息并发送消息。 -{* ../../docs_src/websockets/tutorial001_py310.py hl[48:52] *} +{* ../../docs_src/websockets_/tutorial001_py310.py hl[48:52] *} 您可以接收和发送二进制、文本和 JSON 数据。 @@ -109,7 +109,7 @@ $ fastapi dev main.py 它们的工作方式与其他 FastAPI 端点/*路径操作* 相同: -{* ../../docs_src/websockets/tutorial002_an_py310.py hl[68:69,82] *} +{* ../../docs_src/websockets_/tutorial002_an_py310.py hl[68:69,82] *} /// info @@ -154,7 +154,7 @@ $ fastapi dev main.py 当 WebSocket 连接关闭时,`await websocket.receive_text()` 将引发 `WebSocketDisconnect` 异常,您可以捕获并处理该异常,就像本示例中的示例一样。 -{* ../../docs_src/websockets/tutorial003_py310.py hl[79:81] *} +{* ../../docs_src/websockets_/tutorial003_py310.py hl[79:81] *} 尝试以下操作: diff --git a/docs_src/custom_response/tutorial007_py310.py b/docs_src/custom_response/tutorial007_py310.py index e2a53a2119..f8dd9f895d 100644 --- a/docs_src/custom_response/tutorial007_py310.py +++ b/docs_src/custom_response/tutorial007_py310.py @@ -1,3 +1,4 @@ +import anyio from fastapi import FastAPI from fastapi.responses import StreamingResponse @@ -7,6 +8,7 @@ app = FastAPI() async def fake_video_streamer(): for i in range(10): yield b"some fake video bytes" + await anyio.sleep(0) @app.get("/") diff --git a/docs_src/websockets/__init__.py b/docs_src/server_sent_events/__init__.py similarity index 100% rename from docs_src/websockets/__init__.py rename to docs_src/server_sent_events/__init__.py diff --git a/docs_src/server_sent_events/tutorial001_py310.py b/docs_src/server_sent_events/tutorial001_py310.py new file mode 100644 index 0000000000..8fa470da50 --- /dev/null +++ b/docs_src/server_sent_events/tutorial001_py310.py @@ -0,0 +1,43 @@ +from collections.abc import AsyncIterable, Iterable + +from fastapi import FastAPI +from fastapi.sse import EventSourceResponse +from pydantic import BaseModel + +app = FastAPI() + + +class Item(BaseModel): + name: str + description: str | None + + +items = [ + Item(name="Plumbus", description="A multi-purpose household device."), + Item(name="Portal Gun", description="A portal opening device."), + Item(name="Meeseeks Box", description="A box that summons a Meeseeks."), +] + + +@app.get("/items/stream", response_class=EventSourceResponse) +async def sse_items() -> AsyncIterable[Item]: + for item in items: + yield item + + +@app.get("/items/stream-no-async", response_class=EventSourceResponse) +def sse_items_no_async() -> Iterable[Item]: + for item in items: + yield item + + +@app.get("/items/stream-no-annotation", response_class=EventSourceResponse) +async def sse_items_no_annotation(): + for item in items: + yield item + + +@app.get("/items/stream-no-async-no-annotation", response_class=EventSourceResponse) +def sse_items_no_async_no_annotation(): + for item in items: + yield item diff --git a/docs_src/server_sent_events/tutorial002_py310.py b/docs_src/server_sent_events/tutorial002_py310.py new file mode 100644 index 0000000000..0f6136f4fd --- /dev/null +++ b/docs_src/server_sent_events/tutorial002_py310.py @@ -0,0 +1,26 @@ +from collections.abc import AsyncIterable + +from fastapi import FastAPI +from fastapi.sse import EventSourceResponse, ServerSentEvent +from pydantic import BaseModel + +app = FastAPI() + + +class Item(BaseModel): + name: str + price: float + + +items = [ + Item(name="Plumbus", price=32.99), + Item(name="Portal Gun", price=999.99), + Item(name="Meeseeks Box", price=49.99), +] + + +@app.get("/items/stream", response_class=EventSourceResponse) +async def stream_items() -> AsyncIterable[ServerSentEvent]: + yield ServerSentEvent(comment="stream of item updates") + for i, item in enumerate(items): + yield ServerSentEvent(data=item, event="item_update", id=str(i + 1), retry=5000) diff --git a/docs_src/server_sent_events/tutorial003_py310.py b/docs_src/server_sent_events/tutorial003_py310.py new file mode 100644 index 0000000000..3006deb86d --- /dev/null +++ b/docs_src/server_sent_events/tutorial003_py310.py @@ -0,0 +1,17 @@ +from collections.abc import AsyncIterable + +from fastapi import FastAPI +from fastapi.sse import EventSourceResponse, ServerSentEvent + +app = FastAPI() + + +@app.get("/logs/stream", response_class=EventSourceResponse) +async def stream_logs() -> AsyncIterable[ServerSentEvent]: + logs = [ + "2025-01-01 INFO Application started", + "2025-01-01 DEBUG Connected to database", + "2025-01-01 WARN High memory usage detected", + ] + for log_line in logs: + yield ServerSentEvent(raw_data=log_line) diff --git a/docs_src/server_sent_events/tutorial004_py310.py b/docs_src/server_sent_events/tutorial004_py310.py new file mode 100644 index 0000000000..3e8f8d113f --- /dev/null +++ b/docs_src/server_sent_events/tutorial004_py310.py @@ -0,0 +1,31 @@ +from collections.abc import AsyncIterable +from typing import Annotated + +from fastapi import FastAPI, Header +from fastapi.sse import EventSourceResponse, ServerSentEvent +from pydantic import BaseModel + +app = FastAPI() + + +class Item(BaseModel): + name: str + price: float + + +items = [ + Item(name="Plumbus", price=32.99), + Item(name="Portal Gun", price=999.99), + Item(name="Meeseeks Box", price=49.99), +] + + +@app.get("/items/stream", response_class=EventSourceResponse) +async def stream_items( + last_event_id: Annotated[int | None, Header()] = None, +) -> AsyncIterable[ServerSentEvent]: + start = last_event_id + 1 if last_event_id is not None else 0 + for i, item in enumerate(items): + if i < start: + continue + yield ServerSentEvent(data=item, id=str(i)) diff --git a/docs_src/server_sent_events/tutorial005_py310.py b/docs_src/server_sent_events/tutorial005_py310.py new file mode 100644 index 0000000000..4e6730e5aa --- /dev/null +++ b/docs_src/server_sent_events/tutorial005_py310.py @@ -0,0 +1,19 @@ +from collections.abc import AsyncIterable + +from fastapi import FastAPI +from fastapi.sse import EventSourceResponse, ServerSentEvent +from pydantic import BaseModel + +app = FastAPI() + + +class Prompt(BaseModel): + text: str + + +@app.post("/chat/stream", response_class=EventSourceResponse) +async def stream_chat(prompt: Prompt) -> AsyncIterable[ServerSentEvent]: + words = prompt.text.split() + for word in words: + yield ServerSentEvent(data=word, event="token") + yield ServerSentEvent(raw_data="[DONE]", event="done") diff --git a/docs_src/stream_data/__init__.py b/docs_src/stream_data/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs_src/stream_data/tutorial001_py310.py b/docs_src/stream_data/tutorial001_py310.py new file mode 100644 index 0000000000..2e91ec9ac9 --- /dev/null +++ b/docs_src/stream_data/tutorial001_py310.py @@ -0,0 +1,65 @@ +from collections.abc import AsyncIterable, Iterable + +from fastapi import FastAPI +from fastapi.responses import StreamingResponse + +app = FastAPI() + + +message = """ +Rick: (stumbles in drunkenly, and turns on the lights) Morty! You gotta come on. You got--... you gotta come with me. +Morty: (rubs his eyes) What, Rick? What's going on? +Rick: I got a surprise for you, Morty. +Morty: It's the middle of the night. What are you talking about? +Rick: (spills alcohol on Morty's bed) Come on, I got a surprise for you. (drags Morty by the ankle) Come on, hurry up. (pulls Morty out of his bed and into the hall) +Morty: Ow! Ow! You're tugging me too hard! +Rick: We gotta go, gotta get outta here, come on. Got a surprise for you Morty. +""" + + +@app.get("/story/stream", response_class=StreamingResponse) +async def stream_story() -> AsyncIterable[str]: + for line in message.splitlines(): + yield line + + +@app.get("/story/stream-no-async", response_class=StreamingResponse) +def stream_story_no_async() -> Iterable[str]: + for line in message.splitlines(): + yield line + + +@app.get("/story/stream-no-annotation", response_class=StreamingResponse) +async def stream_story_no_annotation(): + for line in message.splitlines(): + yield line + + +@app.get("/story/stream-no-async-no-annotation", response_class=StreamingResponse) +def stream_story_no_async_no_annotation(): + for line in message.splitlines(): + yield line + + +@app.get("/story/stream-bytes", response_class=StreamingResponse) +async def stream_story_bytes() -> AsyncIterable[bytes]: + for line in message.splitlines(): + yield line.encode("utf-8") + + +@app.get("/story/stream-no-async-bytes", response_class=StreamingResponse) +def stream_story_no_async_bytes() -> Iterable[bytes]: + for line in message.splitlines(): + yield line.encode("utf-8") + + +@app.get("/story/stream-no-annotation-bytes", response_class=StreamingResponse) +async def stream_story_no_annotation_bytes(): + for line in message.splitlines(): + yield line.encode("utf-8") + + +@app.get("/story/stream-no-async-no-annotation-bytes", response_class=StreamingResponse) +def stream_story_no_async_no_annotation_bytes(): + for line in message.splitlines(): + yield line.encode("utf-8") diff --git a/docs_src/stream_data/tutorial002_py310.py b/docs_src/stream_data/tutorial002_py310.py new file mode 100644 index 0000000000..aa8bcee3a9 --- /dev/null +++ b/docs_src/stream_data/tutorial002_py310.py @@ -0,0 +1,54 @@ +import base64 +from collections.abc import AsyncIterable, Iterable +from io import BytesIO + +from fastapi import FastAPI +from fastapi.responses import StreamingResponse + +image_base64 = "iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAAbnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjadYzRDYAwCET/mcIRDoq0jGOiJm7g+NJK0vjhS4DjIEfHfZ20DKqSrrWZmyFQV5ctRMOLACxglNCcXk7zVqFzJzF8kV6R5vOJ97yVH78HjfYAtg0ged033ZgAAAoCaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/Pgo8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA0LjQuMC1FeGl2MiI+CiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICBleGlmOlBpeGVsWERpbWVuc2lvbj0iMjkiCiAgIGV4aWY6UGl4ZWxZRGltZW5zaW9uPSIyOSIKICAgdGlmZjpJbWFnZVdpZHRoPSIyOSIKICAgdGlmZjpJbWFnZUxlbmd0aD0iMjkiCiAgIHRpZmY6T3JpZW50YXRpb249IjEiLz4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAKPD94cGFja2V0IGVuZD0idyI/PnQkBZAAAAAEc0JJVAgICAh8CGSIAAABoklEQVRIx8VXwY7FIAjE5iXWU+P/f6RHPNW9LIaOoHYP+0yMShVkwNGG1lqjfy4HfaF0oyEEt+oSQqBaa//m9Wd6PlqhhbRMDiEQM3e59FNKw5qZHpnQfuPaW6lazsztvu/eElFj5j63lNLlMz2ttbZtVMu1MTGo5Sujn93gMzOllKiUQjHGB9QxxneZhJ5iwZ1rL2fwenoGeL0q3wVGhBPHMz0PeFccIfASEeWcO8xEROd50q6eAV6s1s5XXoncas1EKqVQznnwUBdJJmm1l3hmmdlOMrGO8Vl5gZ56Y0y8IZF0BuqkQWM4B6HXrRCKa1SEqyzEo7KK59RT/VHDjX3ZvSefeW3CO6O6vsiA1NrwVkxxAcYTCcHyTjZmJd00pugBQoTnzjvn+kzLBh9GtRDjhleZFwbx3kugP3GvFzdkqRlbDYw0u/HxKjuOw2QxZCGL5V5f4l7cd6qsffUa1DcLM9N1XcTMvep5ul1e4jNPtZfWGIkE6dI8MquXg/dS2CGVJQ2ushd5GmlxFdOw+1tRa32MY4zDQ9yaZ60J3/iX+QG4U3qGrFHmswAAAABJRU5ErkJggg==" +binary_image = base64.b64decode(image_base64) + + +def read_image() -> BytesIO: + return BytesIO(binary_image) + + +app = FastAPI() + + +class PNGStreamingResponse(StreamingResponse): + media_type = "image/png" + + +@app.get("/image/stream", response_class=PNGStreamingResponse) +async def stream_image() -> AsyncIterable[bytes]: + with read_image() as image_file: + for chunk in image_file: + yield chunk + + +@app.get("/image/stream-no-async", response_class=PNGStreamingResponse) +def stream_image_no_async() -> Iterable[bytes]: + with read_image() as image_file: + for chunk in image_file: + yield chunk + + +@app.get("/image/stream-no-async-yield-from", response_class=PNGStreamingResponse) +def stream_image_no_async_yield_from() -> Iterable[bytes]: + with read_image() as image_file: + yield from image_file + + +@app.get("/image/stream-no-annotation", response_class=PNGStreamingResponse) +async def stream_image_no_annotation(): + with read_image() as image_file: + for chunk in image_file: + yield chunk + + +@app.get("/image/stream-no-async-no-annotation", response_class=PNGStreamingResponse) +def stream_image_no_async_no_annotation(): + with read_image() as image_file: + for chunk in image_file: + yield chunk diff --git a/docs_src/stream_json_lines/__init__.py b/docs_src/stream_json_lines/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs_src/stream_json_lines/tutorial001_py310.py b/docs_src/stream_json_lines/tutorial001_py310.py new file mode 100644 index 0000000000..4fbe7c69cc --- /dev/null +++ b/docs_src/stream_json_lines/tutorial001_py310.py @@ -0,0 +1,42 @@ +from collections.abc import AsyncIterable, Iterable + +from fastapi import FastAPI +from pydantic import BaseModel + +app = FastAPI() + + +class Item(BaseModel): + name: str + description: str | None + + +items = [ + Item(name="Plumbus", description="A multi-purpose household device."), + Item(name="Portal Gun", description="A portal opening device."), + Item(name="Meeseeks Box", description="A box that summons a Meeseeks."), +] + + +@app.get("/items/stream") +async def stream_items() -> AsyncIterable[Item]: + for item in items: + yield item + + +@app.get("/items/stream-no-async") +def stream_items_no_async() -> Iterable[Item]: + for item in items: + yield item + + +@app.get("/items/stream-no-annotation") +async def stream_items_no_annotation(): + for item in items: + yield item + + +@app.get("/items/stream-no-async-no-annotation") +def stream_items_no_async_no_annotation(): + for item in items: + yield item diff --git a/docs_src/websockets_/__init__.py b/docs_src/websockets_/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs_src/websockets/tutorial001_py310.py b/docs_src/websockets_/tutorial001_py310.py similarity index 100% rename from docs_src/websockets/tutorial001_py310.py rename to docs_src/websockets_/tutorial001_py310.py diff --git a/docs_src/websockets/tutorial002_an_py310.py b/docs_src/websockets_/tutorial002_an_py310.py similarity index 100% rename from docs_src/websockets/tutorial002_an_py310.py rename to docs_src/websockets_/tutorial002_an_py310.py diff --git a/docs_src/websockets/tutorial002_py310.py b/docs_src/websockets_/tutorial002_py310.py similarity index 100% rename from docs_src/websockets/tutorial002_py310.py rename to docs_src/websockets_/tutorial002_py310.py diff --git a/docs_src/websockets/tutorial003_py310.py b/docs_src/websockets_/tutorial003_py310.py similarity index 100% rename from docs_src/websockets/tutorial003_py310.py rename to docs_src/websockets_/tutorial003_py310.py diff --git a/fastapi/.agents/skills/fastapi/SKILL.md b/fastapi/.agents/skills/fastapi/SKILL.md index 99e2b3b412..48cfdabb87 100644 --- a/fastapi/.agents/skills/fastapi/SKILL.md +++ b/fastapi/.agents/skills/fastapi/SKILL.md @@ -290,146 +290,11 @@ Apply shared dependencies at the router level via `dependencies=[Depends(...)]`. ## Dependency Injection -Use dependencies when: +See [the dependency injection reference](references/dependencies.md) for detailed patterns including `yield` with `scope`, and class dependencies. -* They can't be declared in Pydantic validation and require additional logic -* The logic depends on external resources or could block in any other way -* Other dependencies need their results (it's a sub-dependency) -* The logic can be shared by multiple endpoints to do things like error early, authentication, etc. -* They need to handle cleanup (e.g., DB sessions, file handles), using dependencies with `yield` -* Their logic needs input data from the request, like headers, query parameters, etc. +Use dependencies when the logic can't be declared in Pydantic validation, depends on external resources, needs cleanup (with `yield`), or is shared across endpoints. -### Dependencies with `yield` and `scope` - -When using dependencies with `yield`, they can have a `scope` that defines when the exit code is run. - -Use the default scope `"request"` to run the exit code after the response is sent back. - -```python -from typing import Annotated - -from fastapi import Depends, FastAPI - -app = FastAPI() - - -def get_db(): - db = DBSession() - try: - yield db - finally: - db.close() - - -DBDep = Annotated[DBSession, Depends(get_db)] - - -@app.get("/items/") -async def read_items(db: DBDep): - return db.query(Item).all() -``` - -Use the scope `"function"` when they should run the exit code after the response data is generated but before the response is sent back to the client. - -```python -from typing import Annotated - -from fastapi import Depends, FastAPI - -app = FastAPI() - - -def get_username(): - try: - yield "Rick" - finally: - print("Cleanup up before response is sent") - -UserNameDep = Annotated[str, Depends(get_username, scope="function")] - -@app.get("/users/me") -def get_user_me(username: UserNameDep): - return username -``` - -### Class Dependencies - -Avoid creating class dependencies when possible. - -If a class is needed, instead create a regular function dependency that returns a class instance. - -Do this: - -```python -from dataclasses import dataclass -from typing import Annotated - -from fastapi import Depends, FastAPI - -app = FastAPI() - - -@dataclass -class DatabasePaginator: - offset: int = 0 - limit: int = 100 - q: str | None = None - - def get_page(self) -> dict: - # Simulate a page of data - return { - "offset": self.offset, - "limit": self.limit, - "q": self.q, - "items": [], - } - - -def get_db_paginator( - offset: int = 0, limit: int = 100, q: str | None = None -) -> DatabasePaginator: - return DatabasePaginator(offset=offset, limit=limit, q=q) - - -PaginatorDep = Annotated[DatabasePaginator, Depends(get_db_paginator)] - - -@app.get("/items/") -async def read_items(paginator: PaginatorDep): - return paginator.get_page() -``` - -instead of this: - -```python -# DO NOT DO THIS -from typing import Annotated - -from fastapi import Depends, FastAPI - -app = FastAPI() - - -class DatabasePaginator: - def __init__(self, offset: int = 0, limit: int = 100, q: str | None = None): - self.offset = offset - self.limit = limit - self.q = q - - def get_page(self) -> dict: - # Simulate a page of data - return { - "offset": self.offset, - "limit": self.limit, - "q": self.q, - "items": [], - } - - -@app.get("/items/") -async def read_items(paginator: Annotated[DatabasePaginator, Depends()]): - return paginator.get_page() -``` +Apply shared dependencies at the router level via `dependencies=[Depends(...)]`. ## Async vs Sync *path operations* @@ -461,66 +326,23 @@ The same rules apply to dependencies. Make sure blocking code is not run inside of `async` functions. The logic will work, but will damage the performance heavily. -### Asyncer +When needing to mix blocking and async code, see Asyncer in [the other tools reference](references/other-tools.md). -When needing to run blocking code inside of async functions, or async code inside of blocking functions, suggest using Asyncer. +## Streaming (JSON Lines, SSE, bytes) -Install: +See [the streaming reference](references/streaming.md) for JSON Lines, Server-Sent Events (`EventSourceResponse`, `ServerSentEvent`), and byte streaming (`StreamingResponse`) patterns. -```bash -uv add asyncer -``` +## Tooling -Run blocking sync code inside of async with `asyncify()`: +See [the other tools reference](references/other-tools.md) for details on uv, Ruff, ty for package management, linting, type checking, formatting, etc. -```python -from asyncer import asyncify -from fastapi import FastAPI +## Other Libraries -app = FastAPI() +See [the other tools reference](references/other-tools.md) for details on other libraries: - -def do_blocking_work(name: str) -> str: - # Some blocking I/O operation - return f"Hello {name}" - - -@app.get("/items/") -async def read_items(): - result = await asyncify(do_blocking_work)(name="World") - return {"message": result} -``` - -And run async code inside of blocking sync code with `syncify()`: - -```python -from asyncer import syncify -from fastapi import FastAPI - -app = FastAPI() - - -async def do_async_work(name: str) -> str: - return f"Hello {name}" - - -@app.get("/items/") -def read_items(): - result = syncify(do_async_work)(name="World") - return {"message": result} -``` - -## Use uv, ruff, ty - -If uv is available, use it to manage dependencies. - -If Ruff is available, use it to lint and format the code. Consider enabling the FastAPI rules. - -If ty is available, use it to check types. - -## SQLModel for SQL databases - -When working with SQL databases, prefer using SQLModel as it is integrated with Pydantic and will allow declaring data validation with the same models. +* Asyncer for handling async and await, concurrency, mixing async and blocking code, prefer it over AnyIO or asyncio. +* SQLModel for working with SQL databases, prefer it over SQLAlchemy. +* HTTPX for interacting with HTTP (other APIs), prefer it over Requests. ## Do not use Pydantic RootModels diff --git a/fastapi/.agents/skills/fastapi/references/dependencies.md b/fastapi/.agents/skills/fastapi/references/dependencies.md new file mode 100644 index 0000000000..ca709096e6 --- /dev/null +++ b/fastapi/.agents/skills/fastapi/references/dependencies.md @@ -0,0 +1,142 @@ +# Dependency Injection + +Use dependencies when: + +* They can't be declared in Pydantic validation and require additional logic +* The logic depends on external resources or could block in any other way +* Other dependencies need their results (it's a sub-dependency) +* The logic can be shared by multiple endpoints to do things like error early, authentication, etc. +* They need to handle cleanup (e.g., DB sessions, file handles), using dependencies with `yield` +* Their logic needs input data from the request, like headers, query parameters, etc. + +## Dependencies with `yield` and `scope` + +When using dependencies with `yield`, they can have a `scope` that defines when the exit code is run. + +Use the default scope `"request"` to run the exit code after the response is sent back. + +```python +from typing import Annotated + +from fastapi import Depends, FastAPI + +app = FastAPI() + + +def get_db(): + db = DBSession() + try: + yield db + finally: + db.close() + + +DBDep = Annotated[DBSession, Depends(get_db)] + + +@app.get("/items/") +async def read_items(db: DBDep): + return db.query(Item).all() +``` + +Use the scope `"function"` when they should run the exit code after the response data is generated but before the response is sent back to the client. + +```python +from typing import Annotated + +from fastapi import Depends, FastAPI + +app = FastAPI() + + +def get_username(): + try: + yield "Rick" + finally: + print("Cleanup up before response is sent") + +UserNameDep = Annotated[str, Depends(get_username, scope="function")] + +@app.get("/users/me") +def get_user_me(username: UserNameDep): + return username +``` + +## Class Dependencies + +Avoid creating class dependencies when possible. + +If a class is needed, instead create a regular function dependency that returns a class instance. + +Do this: + +```python +from dataclasses import dataclass +from typing import Annotated + +from fastapi import Depends, FastAPI + +app = FastAPI() + + +@dataclass +class DatabasePaginator: + offset: int = 0 + limit: int = 100 + q: str | None = None + + def get_page(self) -> dict: + # Simulate a page of data + return { + "offset": self.offset, + "limit": self.limit, + "q": self.q, + "items": [], + } + + +def get_db_paginator( + offset: int = 0, limit: int = 100, q: str | None = None +) -> DatabasePaginator: + return DatabasePaginator(offset=offset, limit=limit, q=q) + + +PaginatorDep = Annotated[DatabasePaginator, Depends(get_db_paginator)] + + +@app.get("/items/") +async def read_items(paginator: PaginatorDep): + return paginator.get_page() +``` + +instead of this: + +```python +# DO NOT DO THIS +from typing import Annotated + +from fastapi import Depends, FastAPI + +app = FastAPI() + + +class DatabasePaginator: + def __init__(self, offset: int = 0, limit: int = 100, q: str | None = None): + self.offset = offset + self.limit = limit + self.q = q + + def get_page(self) -> dict: + # Simulate a page of data + return { + "offset": self.offset, + "limit": self.limit, + "q": self.q, + "items": [], + } + + +@app.get("/items/") +async def read_items(paginator: Annotated[DatabasePaginator, Depends()]): + return paginator.get_page() +``` diff --git a/fastapi/.agents/skills/fastapi/references/other-tools.md b/fastapi/.agents/skills/fastapi/references/other-tools.md new file mode 100644 index 0000000000..58b19d0966 --- /dev/null +++ b/fastapi/.agents/skills/fastapi/references/other-tools.md @@ -0,0 +1,76 @@ +# Other Tools + +## uv + +If uv is available, use it to manage dependencies. + +## Ruff + +If Ruff is available, use it to lint and format the code. Consider enabling the FastAPI rules. + +## ty + +If ty is available, use it to check types. + +## Asyncer + +When needing to run blocking code inside of async functions, or async code inside of blocking functions, suggest using Asyncer. + +Prefer it over AnyIO or asyncio. + +Install: + +```bash +uv add asyncer +``` + +Run blocking sync code inside of async with `asyncify()`: + +```python +from asyncer import asyncify +from fastapi import FastAPI + +app = FastAPI() + + +def do_blocking_work(name: str) -> str: + # Some blocking I/O operation + return f"Hello {name}" + + +@app.get("/items/") +async def read_items(): + result = await asyncify(do_blocking_work)(name="World") + return {"message": result} +``` + +And run async code inside of blocking sync code with `syncify()`: + +```python +from asyncer import syncify +from fastapi import FastAPI + +app = FastAPI() + + +async def do_async_work(name: str) -> str: + return f"Hello {name}" + + +@app.get("/items/") +def read_items(): + result = syncify(do_async_work)(name="World") + return {"message": result} +``` + +## SQLModel for SQL databases + +When working with SQL databases, prefer using SQLModel as it is integrated with Pydantic and will allow declaring data validation with the same models. + +Prefer it over SQLAlchemy. + +## HTTPX + +Use HTTPX for handling HTTP communication (e.g. with other APIs). It support sync and async usage. + +Prefer it over Requests. diff --git a/fastapi/.agents/skills/fastapi/references/streaming.md b/fastapi/.agents/skills/fastapi/references/streaming.md new file mode 100644 index 0000000000..0832eedcb9 --- /dev/null +++ b/fastapi/.agents/skills/fastapi/references/streaming.md @@ -0,0 +1,105 @@ +# Streaming + +## Stream JSON Lines + +To stream JSON Lines, declare the return type and use `yield` to return the data. + +```python +@app.get("/items/stream") +async def stream_items() -> AsyncIterable[Item]: + for item in items: + yield item +``` + +## Server-Sent Events (SSE) + +To stream Server-Sent Events, use `response_class=EventSourceResponse` and `yield` items from the endpoint. + +Plain objects are automatically JSON-serialized as `data:` fields, declare the return type so the serialization is done by Pydantic: + +```python +from collections.abc import AsyncIterable + +from fastapi import FastAPI +from fastapi.sse import EventSourceResponse +from pydantic import BaseModel + +app = FastAPI() + + +class Item(BaseModel): + name: str + price: float + + +@app.get("/items/stream", response_class=EventSourceResponse) +async def stream_items() -> AsyncIterable[Item]: + yield Item(name="Plumbus", price=32.99) + yield Item(name="Portal Gun", price=999.99) +``` + +For full control over SSE fields (`event`, `id`, `retry`, `comment`), yield `ServerSentEvent` instances: + +```python +from collections.abc import AsyncIterable + +from fastapi import FastAPI +from fastapi.sse import EventSourceResponse, ServerSentEvent + +app = FastAPI() + + +@app.get("/events", response_class=EventSourceResponse) +async def stream_events() -> AsyncIterable[ServerSentEvent]: + yield ServerSentEvent(data={"status": "started"}, event="status", id="1") + yield ServerSentEvent(data={"progress": 50}, event="progress", id="2") +``` + +Use `raw_data` instead of `data` to send pre-formatted strings without JSON encoding: + +```python +yield ServerSentEvent(raw_data="plain text line", event="log") +``` + +## Stream bytes + +To stream bytes, declare a `response_class=` of `StreamingResponse` or a sub-class, and use `yield` to return the data. + +```python +from fastapi import FastAPI +from fastapi.responses import StreamingResponse +from app.utils import read_image + +app = FastAPI() + + +class PNGStreamingResponse(StreamingResponse): + media_type = "image/png" + +@app.get("/image", response_class=PNGStreamingResponse) +def stream_image_no_async_no_annotation(): + with read_image() as image_file: + yield from image_file +``` + +prefer this over returning a `StreamingResponse` directly: + +```python +# DO NOT DO THIS + +import anyio +from fastapi import FastAPI +from fastapi.responses import StreamingResponse +from app.utils import read_image + +app = FastAPI() + + +class PNGStreamingResponse(StreamingResponse): + media_type = "image/png" + + +@app.get("/") +async def main(): + return PNGStreamingResponse(read_image()) +``` diff --git a/fastapi/__init__.py b/fastapi/__init__.py index e86d5cde63..06dacbd9dc 100644 --- a/fastapi/__init__.py +++ b/fastapi/__init__.py @@ -1,6 +1,6 @@ """FastAPI framework, high performance, easy to learn, fast to code, ready for production""" -__version__ = "0.133.1" +__version__ = "0.135.1" from starlette import status as status diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index ab18ec2db6..8fcf1a5b3c 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -1,7 +1,17 @@ import dataclasses import inspect import sys -from collections.abc import Callable, Mapping, Sequence +from collections.abc import ( + AsyncGenerator, + AsyncIterable, + AsyncIterator, + Callable, + Generator, + Iterable, + Iterator, + Mapping, + Sequence, +) from contextlib import AsyncExitStack, contextmanager from copy import copy, deepcopy from dataclasses import dataclass @@ -251,6 +261,26 @@ def get_typed_return_annotation(call: Callable[..., Any]) -> Any: return get_typed_annotation(annotation, globalns) +_STREAM_ORIGINS = { + AsyncIterable, + AsyncIterator, + AsyncGenerator, + Iterable, + Iterator, + Generator, +} + + +def get_stream_item_type(annotation: Any) -> Any | None: + origin = get_origin(annotation) + if origin is not None and origin in _STREAM_ORIGINS: + type_args = get_args(annotation) + if type_args: + return type_args[0] + return Any + return None + + def get_dependant( *, path: str, diff --git a/fastapi/openapi/utils.py b/fastapi/openapi/utils.py index 812003aee3..828442559b 100644 --- a/fastapi/openapi/utils.py +++ b/fastapi/openapi/utils.py @@ -29,6 +29,7 @@ from fastapi.openapi.constants import METHODS_WITH_BODY, REF_PREFIX from fastapi.openapi.models import OpenAPI from fastapi.params import Body, ParamTypes from fastapi.responses import Response +from fastapi.sse import _SSE_EVENT_SCHEMA from fastapi.types import ModelNameMap from fastapi.utils import ( deep_dict_update, @@ -355,25 +356,60 @@ def get_openapi_path( operation.setdefault("responses", {}).setdefault(status_code, {})[ "description" ] = route.response_description - if route_response_media_type and is_body_allowed_for_status_code( - route.status_code - ): - response_schema = {"type": "string"} - if lenient_issubclass(current_response_class, JSONResponse): - if route.response_field: - response_schema = get_schema_from_model_field( - field=route.response_field, + if is_body_allowed_for_status_code(route.status_code): + # Check for JSONL streaming (generator endpoints) + if route.is_json_stream: + jsonl_content: dict[str, Any] = {} + if route.stream_item_field: + item_schema = get_schema_from_model_field( + field=route.stream_item_field, model_name_map=model_name_map, field_mapping=field_mapping, separate_input_output_schemas=separate_input_output_schemas, ) + jsonl_content["itemSchema"] = item_schema else: - response_schema = {} - operation.setdefault("responses", {}).setdefault( - status_code, {} - ).setdefault("content", {}).setdefault(route_response_media_type, {})[ - "schema" - ] = response_schema + jsonl_content["itemSchema"] = {} + operation.setdefault("responses", {}).setdefault( + status_code, {} + ).setdefault("content", {})["application/jsonl"] = jsonl_content + elif route.is_sse_stream: + sse_content: dict[str, Any] = {} + item_schema = copy.deepcopy(_SSE_EVENT_SCHEMA) + if route.stream_item_field: + content_schema = get_schema_from_model_field( + field=route.stream_item_field, + model_name_map=model_name_map, + field_mapping=field_mapping, + separate_input_output_schemas=separate_input_output_schemas, + ) + item_schema["required"] = ["data"] + item_schema["properties"]["data"] = { + "type": "string", + "contentMediaType": "application/json", + "contentSchema": content_schema, + } + sse_content["itemSchema"] = item_schema + operation.setdefault("responses", {}).setdefault( + status_code, {} + ).setdefault("content", {})["text/event-stream"] = sse_content + elif route_response_media_type: + response_schema = {"type": "string"} + if lenient_issubclass(current_response_class, JSONResponse): + if route.response_field: + response_schema = get_schema_from_model_field( + field=route.response_field, + model_name_map=model_name_map, + field_mapping=field_mapping, + separate_input_output_schemas=separate_input_output_schemas, + ) + else: + response_schema = {} + operation.setdefault("responses", {}).setdefault( + status_code, {} + ).setdefault("content", {}).setdefault( + route_response_media_type, {} + )["schema"] = response_schema if route.responses: operation_responses = operation.setdefault("responses", {}) for ( @@ -453,9 +489,9 @@ def get_fields_from_routes( request_fields_from_routes: list[ModelField] = [] callback_flat_models: list[ModelField] = [] for route in routes: - if getattr(route, "include_in_schema", None) and isinstance( - route, routing.APIRoute - ): + if not isinstance(route, routing.APIRoute): + continue + if route.include_in_schema: if route.body_field: assert isinstance(route.body_field, ModelField), ( "A request body must be a Pydantic Field" @@ -465,6 +501,8 @@ def get_fields_from_routes( responses_from_routes.append(route.response_field) if route.response_fields: responses_from_routes.extend(route.response_fields.values()) + if route.stream_item_field: + responses_from_routes.append(route.stream_item_field) if route.callbacks: callback_flat_models.extend(get_fields_from_routes(route.callbacks)) params = get_flat_params(route.dependant) diff --git a/fastapi/param_functions.py b/fastapi/param_functions.py index 4be504f435..d3edde2682 100644 --- a/fastapi/param_functions.py +++ b/fastapi/param_functions.py @@ -211,7 +211,7 @@ def Path( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -219,7 +219,7 @@ def Path( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, @@ -570,7 +570,7 @@ def Query( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -578,7 +578,7 @@ def Query( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, @@ -892,7 +892,7 @@ def Header( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -900,7 +900,7 @@ def Header( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, @@ -1198,7 +1198,7 @@ def Cookie( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -1206,7 +1206,7 @@ def Cookie( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, @@ -1526,7 +1526,7 @@ def Body( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -1534,7 +1534,7 @@ def Body( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, @@ -1842,7 +1842,7 @@ def Form( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -1850,7 +1850,7 @@ def Form( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, @@ -2157,7 +2157,7 @@ def File( # noqa: N802 int | None, Doc( """ - Maximum number of allow digits for strings. + Maximum number of digits allowed for decimal values. """ ), ] = _Unset, @@ -2165,7 +2165,7 @@ def File( # noqa: N802 int | None, Doc( """ - Maximum number of decimal places allowed for numbers. + Maximum number of decimal places allowed for decimal values. """ ), ] = _Unset, diff --git a/fastapi/responses.py b/fastapi/responses.py index 5b1154c046..554b0952b0 100644 --- a/fastapi/responses.py +++ b/fastapi/responses.py @@ -1,6 +1,7 @@ from typing import Any from fastapi.exceptions import FastAPIDeprecationWarning +from fastapi.sse import EventSourceResponse as EventSourceResponse # noqa from starlette.responses import FileResponse as FileResponse # noqa from starlette.responses import HTMLResponse as HTMLResponse # noqa from starlette.responses import JSONResponse as JSONResponse # noqa diff --git a/fastapi/routing.py b/fastapi/routing.py index d17650a627..e2c83aa7b3 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -11,6 +11,7 @@ from collections.abc import ( Collection, Coroutine, Generator, + Iterator, Mapping, Sequence, ) @@ -27,7 +28,9 @@ from typing import ( TypeVar, ) +import anyio from annotated_doc import Doc +from anyio.abc import ObjectReceiveStream from fastapi import params from fastapi._compat import ( ModelField, @@ -42,6 +45,7 @@ from fastapi.dependencies.utils import ( get_dependant, get_flat_dependant, get_parameterless_sub_dependant, + get_stream_item_type, get_typed_return_annotation, solve_dependencies, ) @@ -53,6 +57,13 @@ from fastapi.exceptions import ( ResponseValidationError, WebSocketRequestValidationError, ) +from fastapi.sse import ( + _PING_INTERVAL, + KEEPALIVE_COMMENT, + EventSourceResponse, + ServerSentEvent, + format_sse_event, +) from fastapi.types import DecoratedCallable, IncEx from fastapi.utils import ( create_model_field, @@ -63,10 +74,10 @@ from fastapi.utils import ( from starlette import routing from starlette._exception_handler import wrap_app_handling_exceptions from starlette._utils import is_async_callable -from starlette.concurrency import run_in_threadpool +from starlette.concurrency import iterate_in_threadpool, run_in_threadpool from starlette.exceptions import HTTPException from starlette.requests import Request -from starlette.responses import JSONResponse, Response +from starlette.responses import JSONResponse, Response, StreamingResponse from starlette.routing import ( BaseRoute, Match, @@ -315,6 +326,24 @@ async def run_endpoint_function( return await run_in_threadpool(dependant.call, **values) +def _build_response_args( + *, status_code: int | None, solved_result: Any +) -> dict[str, Any]: + response_args: dict[str, Any] = { + "background": solved_result.background_tasks, + } + # If status_code was set, use it, otherwise use the default from the + # response class, in the case of redirect it's 307 + current_status_code = ( + status_code if status_code else solved_result.response.status_code + ) + if current_status_code is not None: + response_args["status_code"] = current_status_code + if solved_result.response.status_code: + response_args["status_code"] = solved_result.response.status_code + return response_args + + def get_request_handler( dependant: Dependant, body_field: ModelField | None = None, @@ -330,6 +359,8 @@ def get_request_handler( dependency_overrides_provider: Any | None = None, embed_body_fields: bool = False, strict_content_type: bool | DefaultPlaceholder = Default(True), + stream_item_field: ModelField | None = None, + is_json_stream: bool = False, ) -> Callable[[Request], Coroutine[Any, Any, Response]]: assert dependant.call is not None, "dependant.call must be a function" is_coroutine = dependant.is_coroutine_callable @@ -338,6 +369,7 @@ def get_request_handler( actual_response_class: type[Response] = response_class.value else: actual_response_class = response_class + is_sse_stream = lenient_issubclass(actual_response_class, EventSourceResponse) if isinstance(strict_content_type, DefaultPlaceholder): actual_strict_content_type: bool = strict_content_type.value else: @@ -427,61 +459,259 @@ def get_request_handler( embed_body_fields=embed_body_fields, ) errors = solved_result.errors + assert dependant.call # For types if not errors: - raw_response = await run_endpoint_function( - dependant=dependant, - values=solved_result.values, - is_coroutine=is_coroutine, - ) - if isinstance(raw_response, Response): - if raw_response.background is None: - raw_response.background = solved_result.background_tasks - response = raw_response - else: - response_args: dict[str, Any] = { - "background": solved_result.background_tasks - } - # If status_code was set, use it, otherwise use the default from the - # response class, in the case of redirect it's 307 - current_status_code = ( - status_code if status_code else solved_result.response.status_code - ) - if current_status_code is not None: - response_args["status_code"] = current_status_code - if solved_result.response.status_code: - response_args["status_code"] = solved_result.response.status_code - # Use the fast path (dump_json) when no custom response - # class was set and a response field with a TypeAdapter - # exists. Serializes directly to JSON bytes via Pydantic's - # Rust core, skipping the intermediate Python dict + - # json.dumps() step. - use_dump_json = response_field is not None and isinstance( - response_class, DefaultPlaceholder - ) - content = await serialize_response( - field=response_field, - response_content=raw_response, - include=response_model_include, - exclude=response_model_exclude, - by_alias=response_model_by_alias, - exclude_unset=response_model_exclude_unset, - exclude_defaults=response_model_exclude_defaults, - exclude_none=response_model_exclude_none, - is_coroutine=is_coroutine, - endpoint_ctx=endpoint_ctx, - dump_json=use_dump_json, - ) - if use_dump_json: - response = Response( - content=content, - media_type="application/json", - **response_args, + # Shared serializer for stream items (JSONL and SSE). + # Validates against stream_item_field when set, then + # serializes to JSON bytes. + def _serialize_data(data: Any) -> bytes: + if stream_item_field: + value, errors_ = stream_item_field.validate( + data, {}, loc=("response",) + ) + if errors_: + ctx = endpoint_ctx or EndpointContext() + raise ResponseValidationError( + errors=errors_, + body=data, + endpoint_ctx=ctx, + ) + return stream_item_field.serialize_json( + value, + include=response_model_include, + exclude=response_model_exclude, + by_alias=response_model_by_alias, + exclude_unset=response_model_exclude_unset, + exclude_defaults=response_model_exclude_defaults, + exclude_none=response_model_exclude_none, ) else: - response = actual_response_class(content, **response_args) - if not is_body_allowed_for_status_code(response.status_code): - response.body = b"" + data = jsonable_encoder(data) + return json.dumps(data).encode("utf-8") + + if is_sse_stream: + # Generator endpoint: stream as Server-Sent Events + gen = dependant.call(**solved_result.values) + + def _serialize_sse_item(item: Any) -> bytes: + if isinstance(item, ServerSentEvent): + # User controls the event structure. + # Serialize the data payload if present. + # For ServerSentEvent items we skip stream_item_field + # validation (the user may mix types intentionally). + if item.raw_data is not None: + data_str: str | None = item.raw_data + elif item.data is not None: + if hasattr(item.data, "model_dump_json"): + data_str = item.data.model_dump_json() + else: + data_str = json.dumps(jsonable_encoder(item.data)) + else: + data_str = None + return format_sse_event( + data_str=data_str, + event=item.event, + id=item.id, + retry=item.retry, + comment=item.comment, + ) + else: + # Plain object: validate + serialize via + # stream_item_field (if set) and wrap in data field + return format_sse_event( + data_str=_serialize_data(item).decode("utf-8") + ) + + if dependant.is_async_gen_callable: + sse_aiter: AsyncIterator[Any] = gen.__aiter__() + else: + sse_aiter = iterate_in_threadpool(gen) + + @asynccontextmanager + async def _sse_producer_cm() -> AsyncIterator[ + ObjectReceiveStream[bytes] + ]: + # Use a memory stream to decouple generator iteration + # from the keepalive timer. A producer task pulls items + # from the generator independently, so + # `anyio.fail_after` never wraps the generator's + # `__anext__` directly - avoiding CancelledError that + # would finalize the generator and also working for sync + # generators running in a thread pool. + # + # This context manager is entered on the request-scoped + # AsyncExitStack so its __aexit__ (which cancels the + # task group) is called by the exit stack after the + # streaming response completes — not by async generator + # finalization via GeneratorExit. + # Ref: https://peps.python.org/pep-0789/ + send_stream, receive_stream = anyio.create_memory_object_stream[ + bytes + ](max_buffer_size=1) + + async def _producer() -> None: + async with send_stream: + async for raw_item in sse_aiter: + await send_stream.send(_serialize_sse_item(raw_item)) + + send_keepalive, receive_keepalive = ( + anyio.create_memory_object_stream[bytes](max_buffer_size=1) + ) + + async def _keepalive_inserter() -> None: + """Read from the producer and forward to the output, + inserting keepalive comments on timeout.""" + async with send_keepalive, receive_stream: + try: + while True: + try: + with anyio.fail_after(_PING_INTERVAL): + data = await receive_stream.receive() + await send_keepalive.send(data) + except TimeoutError: + await send_keepalive.send(KEEPALIVE_COMMENT) + except anyio.EndOfStream: + pass + + async with anyio.create_task_group() as tg: + tg.start_soon(_producer) + tg.start_soon(_keepalive_inserter) + yield receive_keepalive + tg.cancel_scope.cancel() + + # Enter the SSE context manager on the request-scoped + # exit stack. The stack outlives the streaming response, + # so __aexit__ runs via proper structured teardown, not + # via GeneratorExit thrown into an async generator. + sse_receive_stream = await async_exit_stack.enter_async_context( + _sse_producer_cm() + ) + # Ensure the receive stream is closed when the exit stack + # unwinds, preventing ResourceWarning from __del__. + async_exit_stack.push_async_callback(sse_receive_stream.aclose) + + async def _sse_with_checkpoints( + stream: ObjectReceiveStream[bytes], + ) -> AsyncIterator[bytes]: + async for data in stream: + yield data + # Guarantee a checkpoint so cancellation can be + # delivered even when the producer is faster than + # the consumer and receive() never suspends. + await anyio.sleep(0) + + sse_stream_content: AsyncIterator[bytes] | Iterator[bytes] = ( + _sse_with_checkpoints(sse_receive_stream) + ) + + response = StreamingResponse( + sse_stream_content, + media_type="text/event-stream", + background=solved_result.background_tasks, + ) + response.headers["Cache-Control"] = "no-cache" + # For Nginx proxies to not buffer server sent events + response.headers["X-Accel-Buffering"] = "no" response.headers.raw.extend(solved_result.response.headers.raw) + elif is_json_stream: + # Generator endpoint: stream as JSONL + gen = dependant.call(**solved_result.values) + + def _serialize_item(item: Any) -> bytes: + return _serialize_data(item) + b"\n" + + if dependant.is_async_gen_callable: + + async def _async_stream_jsonl() -> AsyncIterator[bytes]: + async for item in gen: + yield _serialize_item(item) + # To allow for cancellation to trigger + # Ref: https://github.com/fastapi/fastapi/issues/14680 + await anyio.sleep(0) + + jsonl_stream_content: AsyncIterator[bytes] | Iterator[bytes] = ( + _async_stream_jsonl() + ) + else: + + def _sync_stream_jsonl() -> Iterator[bytes]: + for item in gen: + yield _serialize_item(item) + + jsonl_stream_content = _sync_stream_jsonl() + + response = StreamingResponse( + jsonl_stream_content, + media_type="application/jsonl", + background=solved_result.background_tasks, + ) + response.headers.raw.extend(solved_result.response.headers.raw) + elif dependant.is_async_gen_callable or dependant.is_gen_callable: + # Raw streaming with explicit response_class (e.g. StreamingResponse) + gen = dependant.call(**solved_result.values) + if dependant.is_async_gen_callable: + + async def _async_stream_raw( + async_gen: AsyncIterator[Any], + ) -> AsyncIterator[Any]: + async for chunk in async_gen: + yield chunk + # To allow for cancellation to trigger + # Ref: https://github.com/fastapi/fastapi/issues/14680 + await anyio.sleep(0) + + gen = _async_stream_raw(gen) + response_args = _build_response_args( + status_code=status_code, solved_result=solved_result + ) + response = actual_response_class(content=gen, **response_args) + response.headers.raw.extend(solved_result.response.headers.raw) + else: + raw_response = await run_endpoint_function( + dependant=dependant, + values=solved_result.values, + is_coroutine=is_coroutine, + ) + if isinstance(raw_response, Response): + if raw_response.background is None: + raw_response.background = solved_result.background_tasks + response = raw_response + else: + response_args = _build_response_args( + status_code=status_code, solved_result=solved_result + ) + # Use the fast path (dump_json) when no custom response + # class was set and a response field with a TypeAdapter + # exists. Serializes directly to JSON bytes via Pydantic's + # Rust core, skipping the intermediate Python dict + + # json.dumps() step. + use_dump_json = response_field is not None and isinstance( + response_class, DefaultPlaceholder + ) + content = await serialize_response( + field=response_field, + response_content=raw_response, + include=response_model_include, + exclude=response_model_exclude, + by_alias=response_model_by_alias, + exclude_unset=response_model_exclude_unset, + exclude_defaults=response_model_exclude_defaults, + exclude_none=response_model_exclude_none, + is_coroutine=is_coroutine, + endpoint_ctx=endpoint_ctx, + dump_json=use_dump_json, + ) + if use_dump_json: + response = Response( + content=content, + media_type="application/json", + **response_args, + ) + else: + response = actual_response_class(content, **response_args) + if not is_body_allowed_for_status_code(response.status_code): + response.body = b"" + response.headers.raw.extend(solved_result.response.headers.raw) if errors: validation_error = RequestValidationError( errors, body=body, endpoint_ctx=endpoint_ctx @@ -609,12 +839,28 @@ class APIRoute(routing.Route): ) -> None: self.path = path self.endpoint = endpoint + self.stream_item_type: Any | None = None if isinstance(response_model, DefaultPlaceholder): return_annotation = get_typed_return_annotation(endpoint) if lenient_issubclass(return_annotation, Response): response_model = None else: - response_model = return_annotation + stream_item = get_stream_item_type(return_annotation) + if stream_item is not None: + # Extract item type for JSONL or SSE streaming when + # response_class is DefaultPlaceholder (JSONL) or + # EventSourceResponse (SSE). + # ServerSentEvent is excluded: it's a transport + # wrapper, not a data model, so it shouldn't feed + # into validation or OpenAPI schema generation. + if ( + isinstance(response_class, DefaultPlaceholder) + or lenient_issubclass(response_class, EventSourceResponse) + ) and not lenient_issubclass(stream_item, ServerSentEvent): + self.stream_item_type = stream_item + response_model = None + else: + response_model = return_annotation self.response_model = response_model self.summary = summary self.response_description = response_description @@ -663,6 +909,15 @@ class APIRoute(routing.Route): ) else: self.response_field = None # type: ignore + if self.stream_item_type: + stream_item_name = "StreamItem_" + self.unique_id + self.stream_item_field: ModelField | None = create_model_field( + name=stream_item_name, + type_=self.stream_item_type, + mode="serialization", + ) + else: + self.stream_item_field = None self.dependencies = list(dependencies or []) self.description = description or inspect.cleandoc(self.endpoint.__doc__ or "") # if a "form feed" character (page break) is found in the description text, @@ -704,6 +959,16 @@ class APIRoute(routing.Route): name=self.unique_id, embed_body_fields=self._embed_body_fields, ) + # Detect generator endpoints that should stream as JSONL or SSE + is_generator = ( + self.dependant.is_async_gen_callable or self.dependant.is_gen_callable + ) + self.is_sse_stream = is_generator and lenient_issubclass( + response_class, EventSourceResponse + ) + self.is_json_stream = is_generator and isinstance( + response_class, DefaultPlaceholder + ) self.app = request_response(self.get_route_handler()) def get_route_handler(self) -> Callable[[Request], Coroutine[Any, Any, Response]]: @@ -722,6 +987,8 @@ class APIRoute(routing.Route): dependency_overrides_provider=self.dependency_overrides_provider, embed_body_fields=self._embed_body_fields, strict_content_type=self.strict_content_type, + stream_item_field=self.stream_item_field, + is_json_stream=self.is_json_stream, ) def matches(self, scope: Scope) -> tuple[Match, Scope]: diff --git a/fastapi/sse.py b/fastapi/sse.py new file mode 100644 index 0000000000..901d824964 --- /dev/null +++ b/fastapi/sse.py @@ -0,0 +1,222 @@ +from typing import Annotated, Any + +from annotated_doc import Doc +from pydantic import AfterValidator, BaseModel, Field, model_validator +from starlette.responses import StreamingResponse + +# Canonical SSE event schema matching the OpenAPI 3.2 spec +# (Section 4.14.4 "Special Considerations for Server-Sent Events") +_SSE_EVENT_SCHEMA: dict[str, Any] = { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": {"type": "integer", "minimum": 0}, + }, +} + + +class EventSourceResponse(StreamingResponse): + """Streaming response with `text/event-stream` media type. + + Use as `response_class=EventSourceResponse` on a *path operation* that uses `yield` + to enable Server Sent Events (SSE) responses. + + Works with **any HTTP method** (`GET`, `POST`, etc.), which makes it compatible + with protocols like MCP that stream SSE over `POST`. + + The actual encoding logic lives in the FastAPI routing layer. This class + serves mainly as a marker and sets the correct `Content-Type`. + """ + + media_type = "text/event-stream" + + +def _check_id_no_null(v: str | None) -> str | None: + if v is not None and "\0" in v: + raise ValueError("SSE 'id' must not contain null characters") + return v + + +class ServerSentEvent(BaseModel): + """Represents a single Server-Sent Event. + + When `yield`ed from a *path operation function* that uses + `response_class=EventSourceResponse`, each `ServerSentEvent` is encoded + into the [SSE wire format](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream) + (`text/event-stream`). + + If you yield a plain object (dict, Pydantic model, etc.) instead, it is + automatically JSON-encoded and sent as the `data:` field. + + All `data` values **including plain strings** are JSON-serialized. + + For example, `data="hello"` produces `data: "hello"` on the wire (with + quotes). + """ + + data: Annotated[ + Any, + Doc( + """ + The event payload. + + Can be any JSON-serializable value: a Pydantic model, dict, list, + string, number, etc. It is **always** serialized to JSON: strings + are quoted (`"hello"` becomes `data: "hello"` on the wire). + + Mutually exclusive with `raw_data`. + """ + ), + ] = None + raw_data: Annotated[ + str | None, + Doc( + """ + Raw string to send as the `data:` field **without** JSON encoding. + + Use this when you need to send pre-formatted text, HTML fragments, + CSV lines, or any non-JSON payload. The string is placed directly + into the `data:` field as-is. + + Mutually exclusive with `data`. + """ + ), + ] = None + event: Annotated[ + str | None, + Doc( + """ + Optional event type name. + + Maps to `addEventListener(event, ...)` on the browser. When omitted, + the browser dispatches on the generic `message` event. + """ + ), + ] = None + id: Annotated[ + str | None, + AfterValidator(_check_id_no_null), + Doc( + """ + Optional event ID. + + The browser sends this value back as the `Last-Event-ID` header on + automatic reconnection. **Must not contain null (`\\0`) characters.** + """ + ), + ] = None + retry: Annotated[ + int | None, + Field(ge=0), + Doc( + """ + Optional reconnection time in **milliseconds**. + + Tells the browser how long to wait before reconnecting after the + connection is lost. Must be a non-negative integer. + """ + ), + ] = None + comment: Annotated[ + str | None, + Doc( + """ + Optional comment line(s). + + Comment lines start with `:` in the SSE wire format and are ignored by + `EventSource` clients. Useful for keep-alive pings to prevent + proxy/load-balancer timeouts. + """ + ), + ] = None + + @model_validator(mode="after") + def _check_data_exclusive(self) -> "ServerSentEvent": + if self.data is not None and self.raw_data is not None: + raise ValueError( + "Cannot set both 'data' and 'raw_data' on the same " + "ServerSentEvent. Use 'data' for JSON-serialized payloads " + "or 'raw_data' for pre-formatted strings." + ) + return self + + +def format_sse_event( + *, + data_str: Annotated[ + str | None, + Doc( + """ + Pre-serialized data string to use as the `data:` field. + """ + ), + ] = None, + event: Annotated[ + str | None, + Doc( + """ + Optional event type name (`event:` field). + """ + ), + ] = None, + id: Annotated[ + str | None, + Doc( + """ + Optional event ID (`id:` field). + """ + ), + ] = None, + retry: Annotated[ + int | None, + Doc( + """ + Optional reconnection time in milliseconds (`retry:` field). + """ + ), + ] = None, + comment: Annotated[ + str | None, + Doc( + """ + Optional comment line(s) (`:` prefix). + """ + ), + ] = None, +) -> bytes: + """Build SSE wire-format bytes from **pre-serialized** data. + + The result always ends with `\n\n` (the event terminator). + """ + lines: list[str] = [] + + if comment is not None: + for line in comment.splitlines(): + lines.append(f": {line}") + + if event is not None: + lines.append(f"event: {event}") + + if data_str is not None: + for line in data_str.splitlines(): + lines.append(f"data: {line}") + + if id is not None: + lines.append(f"id: {id}") + + if retry is not None: + lines.append(f"retry: {retry}") + + lines.append("") + lines.append("") + return "\n".join(lines).encode("utf-8") + + +# Keep-alive comment, per the SSE spec recommendation +KEEPALIVE_COMMENT = b": ping\n\n" + +# Seconds between keep-alive pings when a generator is idle. +# Private but importable so tests can monkeypatch it. +_PING_INTERVAL: float = 15.0 diff --git a/pyproject.toml b/pyproject.toml index fa298ad5b1..da6bf9ead4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,7 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP", ] dependencies = [ - "starlette>=0.40.0", + "starlette>=0.46.0", "pydantic>=2.7.0", "typing-extensions>=4.8.0", "typing-inspection>=0.4.2", @@ -130,6 +130,8 @@ docs = [ { include-group = "docs-tests" }, "black >=25.1.0", "cairosvg >=2.8.2", + # for MkDocs live reload + "click==8.2.1", "griffe-typingdoc >=0.3.0", "griffe-warnings-deprecated >=1.1.0", "jieba >=0.42.1", @@ -163,7 +165,7 @@ github-actions = [ tests = [ { include-group = "docs-tests" }, "anyio[trio] >=3.2.1,<5.0.0", - "coverage[toml] >=6.5.0,<8.0", + "coverage[toml] >=7.13,<8.0", "dirty-equals >=0.9.0", "flask >=3.0.0,<4.0.0", "inline-snapshot >=0.21.1", @@ -178,6 +180,10 @@ tests = [ "types-orjson >=3.6.2", "types-ujson >=5.10.0.20240515", "a2wsgi >=1.9.0,<=2.0.0", + "pytest-xdist[psutil]>=2.5.0", + "pytest-cov>=4.0.0", + "pytest-sugar>=1.0.0", + "pytest-timeout>=2.4.0", ] translations = [ "gitpython >=3.1.46", @@ -229,6 +235,7 @@ strict_xfail = true filterwarnings = [ "error", ] +timeout = "20" [tool.coverage.run] parallel = true @@ -240,7 +247,6 @@ source = [ ] relative_files = true context = '${CONTEXT}' -dynamic_context = "test_function" omit = [ "tests/benchmarks/*", "docs_src/response_model/tutorial003_04_py39.py", @@ -317,6 +323,10 @@ ignore = [ "docs_src/security/tutorial005_py310.py" = ["B904"] "docs_src/security/tutorial005_py39.py" = ["B904"] "docs_src/json_base64_bytes/tutorial001_py310.py" = ["UP012"] +"docs_src/stream_json_lines/tutorial001_py310.py" = ["UP028"] +"docs_src/stream_data/tutorial001_py310.py" = ["UP028"] +"docs_src/stream_data/tutorial002_py310.py" = ["UP028"] +"docs_src/server_sent_events/tutorial001_py310.py" = ["UP028"] [tool.ruff.lint.isort] known-third-party = ["fastapi", "pydantic", "starlette"] diff --git a/scripts/docs.py b/scripts/docs.py index 23d74aaf4a..39845144b9 100644 --- a/scripts/docs.py +++ b/scripts/docs.py @@ -66,6 +66,15 @@ code_block3_pattern = re.compile(r"^\s*```") code_block4_pattern = re.compile(r"^\s*````") +# Pattern to match markdown links: [text](url) → text +md_link_pattern = re.compile(r"\[([^\]]+)\]\([^)]+\)") + + +def strip_markdown_links(text: str) -> str: + """Replace markdown links with just their visible text.""" + return md_link_pattern.sub(r"\1", text) + + class VisibleTextExtractor(HTMLParser): """Extract visible text from a string with HTML tags.""" @@ -688,7 +697,11 @@ def add_permalinks_page(path: Path, update_existing: bool = False): if match: hashes, title, _permalink = match.groups() if (not _permalink) or update_existing: - slug = slugify(visible_text_extractor.extract_visible_text(title)) + slug = slugify( + visible_text_extractor.extract_visible_text( + strip_markdown_links(title) + ) + ) if slug in permalinks: # If the slug is already used, append a number to make it unique count = 1 diff --git a/scripts/test-cov-html.sh b/scripts/test-cov-html.sh index f87f906dc2..3397a57609 100755 --- a/scripts/test-cov-html.sh +++ b/scripts/test-cov-html.sh @@ -3,5 +3,4 @@ set -e set -x -bash scripts/test.sh ${@} -bash scripts/coverage.sh +bash scripts/test-cov.sh --cov-report=term-missing --cov-report=html ${@} diff --git a/scripts/test-cov.sh b/scripts/test-cov.sh new file mode 100755 index 0000000000..1f960430f8 --- /dev/null +++ b/scripts/test-cov.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e +set -x + +bash scripts/test.sh --cov --cov-context=test ${@} diff --git a/scripts/test.sh b/scripts/test.sh index 0bffcd1cdd..f7ec7e0a67 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -4,4 +4,4 @@ set -e set -x export PYTHONPATH=./docs_src -coverage run -m pytest tests scripts/tests/ ${@} +pytest -n auto --dist loadgroup tests scripts/tests/ ${@} diff --git a/tests/test_sse.py b/tests/test_sse.py new file mode 100644 index 0000000000..6dfec61838 --- /dev/null +++ b/tests/test_sse.py @@ -0,0 +1,318 @@ +import asyncio +import time +from collections.abc import AsyncIterable, Iterable + +import fastapi.routing +import pytest +from fastapi import APIRouter, FastAPI +from fastapi.responses import EventSourceResponse +from fastapi.sse import ServerSentEvent +from fastapi.testclient import TestClient +from pydantic import BaseModel + + +class Item(BaseModel): + name: str + description: str | None = None + + +items = [ + Item(name="Plumbus", description="A multi-purpose household device."), + Item(name="Portal Gun", description="A portal opening device."), + Item(name="Meeseeks Box", description="A box that summons a Meeseeks."), +] + + +app = FastAPI() + + +@app.get("/items/stream", response_class=EventSourceResponse) +async def sse_items() -> AsyncIterable[Item]: + for item in items: + yield item + + +@app.get("/items/stream-sync", response_class=EventSourceResponse) +def sse_items_sync() -> Iterable[Item]: + yield from items + + +@app.get("/items/stream-no-annotation", response_class=EventSourceResponse) +async def sse_items_no_annotation(): + for item in items: + yield item + + +@app.get("/items/stream-sync-no-annotation", response_class=EventSourceResponse) +def sse_items_sync_no_annotation(): + yield from items + + +@app.get("/items/stream-dict", response_class=EventSourceResponse) +async def sse_items_dict(): + for item in items: + yield {"name": item.name, "description": item.description} + + +@app.get("/items/stream-sse-event", response_class=EventSourceResponse) +async def sse_items_event(): + yield ServerSentEvent(data="hello", event="greeting", id="1") + yield ServerSentEvent(data={"key": "value"}, event="json-data", id="2") + yield ServerSentEvent(comment="just a comment") + yield ServerSentEvent(data="retry-test", retry=5000) + + +@app.get("/items/stream-mixed", response_class=EventSourceResponse) +async def sse_items_mixed() -> AsyncIterable[Item]: + yield items[0] + yield ServerSentEvent(data="custom-event", event="special") + yield items[1] + + +@app.get("/items/stream-string", response_class=EventSourceResponse) +async def sse_items_string(): + yield ServerSentEvent(data="plain text data") + + +@app.post("/items/stream-post", response_class=EventSourceResponse) +async def sse_items_post() -> AsyncIterable[Item]: + for item in items: + yield item + + +@app.get("/items/stream-raw", response_class=EventSourceResponse) +async def sse_items_raw(): + yield ServerSentEvent(raw_data="plain text without quotes") + yield ServerSentEvent(raw_data="html fragment", event="html") + yield ServerSentEvent(raw_data="cpu,87.3,1709145600", event="csv") + + +router = APIRouter() + + +@router.get("/events", response_class=EventSourceResponse) +async def stream_events(): + yield {"msg": "hello"} + yield {"msg": "world"} + + +app.include_router(router, prefix="/api") + + +@pytest.fixture(name="client") +def client_fixture(): + with TestClient(app) as c: + yield c + + +def test_async_generator_with_model(client: TestClient): + response = client.get("/items/stream") + assert response.status_code == 200 + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + assert response.headers["cache-control"] == "no-cache" + assert response.headers["x-accel-buffering"] == "no" + + lines = response.text.strip().split("\n") + data_lines = [line for line in lines if line.startswith("data: ")] + assert len(data_lines) == 3 + assert '"name":"Plumbus"' in data_lines[0] or '"name": "Plumbus"' in data_lines[0] + assert ( + '"name":"Portal Gun"' in data_lines[1] + or '"name": "Portal Gun"' in data_lines[1] + ) + assert ( + '"name":"Meeseeks Box"' in data_lines[2] + or '"name": "Meeseeks Box"' in data_lines[2] + ) + + +def test_sync_generator_with_model(client: TestClient): + response = client.get("/items/stream-sync") + assert response.status_code == 200 + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + +def test_async_generator_no_annotation(client: TestClient): + response = client.get("/items/stream-no-annotation") + assert response.status_code == 200 + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + +def test_sync_generator_no_annotation(client: TestClient): + response = client.get("/items/stream-sync-no-annotation") + assert response.status_code == 200 + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + +def test_dict_items(client: TestClient): + response = client.get("/items/stream-dict") + assert response.status_code == 200 + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + assert '"name"' in data_lines[0] + + +def test_post_method_sse(client: TestClient): + """SSE should work with POST (needed for MCP compatibility).""" + response = client.post("/items/stream-post") + assert response.status_code == 200 + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + +def test_sse_events_with_fields(client: TestClient): + response = client.get("/items/stream-sse-event") + assert response.status_code == 200 + text = response.text + + assert "event: greeting\n" in text + assert 'data: "hello"\n' in text + assert "id: 1\n" in text + + assert "event: json-data\n" in text + assert "id: 2\n" in text + assert 'data: {"key": "value"}\n' in text + + assert ": just a comment\n" in text + + assert "retry: 5000\n" in text + assert 'data: "retry-test"\n' in text + + +def test_mixed_plain_and_sse_events(client: TestClient): + response = client.get("/items/stream-mixed") + assert response.status_code == 200 + text = response.text + + assert "event: special\n" in text + assert 'data: "custom-event"\n' in text + assert '"name"' in text + + +def test_string_data_json_encoded(client: TestClient): + """Strings are always JSON-encoded (quoted).""" + response = client.get("/items/stream-string") + assert response.status_code == 200 + assert 'data: "plain text data"\n' in response.text + + +def test_server_sent_event_null_id_rejected(): + with pytest.raises(ValueError, match="null"): + ServerSentEvent(data="test", id="has\0null") + + +def test_server_sent_event_negative_retry_rejected(): + with pytest.raises(ValueError): + ServerSentEvent(data="test", retry=-1) + + +def test_server_sent_event_float_retry_rejected(): + with pytest.raises(ValueError): + ServerSentEvent(data="test", retry=1.5) # type: ignore[arg-type] + + +def test_raw_data_sent_without_json_encoding(client: TestClient): + """raw_data is sent as-is, not JSON-encoded.""" + response = client.get("/items/stream-raw") + assert response.status_code == 200 + text = response.text + + # raw_data should appear without JSON quotes + assert "data: plain text without quotes\n" in text + # Not JSON-quoted + assert 'data: "plain text without quotes"' not in text + + assert "event: html\n" in text + assert "data:html fragment\n" in text + + assert "event: csv\n" in text + assert "data: cpu,87.3,1709145600\n" in text + + +def test_data_and_raw_data_mutually_exclusive(): + """Cannot set both data and raw_data.""" + with pytest.raises(ValueError, match="Cannot set both"): + ServerSentEvent(data="json", raw_data="raw") + + +def test_sse_on_router_included_in_app(client: TestClient): + response = client.get("/api/events") + assert response.status_code == 200 + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 2 + + +# Keepalive ping tests + + +keepalive_app = FastAPI() + + +@keepalive_app.get("/slow-async", response_class=EventSourceResponse) +async def slow_async_stream(): + yield {"n": 1} + # Sleep longer than the (monkeypatched) ping interval so a keepalive + # comment is emitted before the next item. + await asyncio.sleep(0.3) + yield {"n": 2} + + +@keepalive_app.get("/slow-sync", response_class=EventSourceResponse) +def slow_sync_stream(): + yield {"n": 1} + time.sleep(0.3) + yield {"n": 2} + + +def test_keepalive_ping_async(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(fastapi.routing, "_PING_INTERVAL", 0.05) + with TestClient(keepalive_app) as c: + response = c.get("/slow-async") + assert response.status_code == 200 + text = response.text + # The keepalive comment ": ping" should appear between the two data events + assert ": ping\n" in text + data_lines = [line for line in text.split("\n") if line.startswith("data: ")] + assert len(data_lines) == 2 + + +def test_keepalive_ping_sync(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(fastapi.routing, "_PING_INTERVAL", 0.05) + with TestClient(keepalive_app) as c: + response = c.get("/slow-sync") + assert response.status_code == 200 + text = response.text + assert ": ping\n" in text + data_lines = [line for line in text.split("\n") if line.startswith("data: ")] + assert len(data_lines) == 2 + + +def test_no_keepalive_when_fast(client: TestClient): + """No keepalive comment when items arrive quickly.""" + response = client.get("/items/stream") + assert response.status_code == 200 + # KEEPALIVE_COMMENT is ": ping\n\n". + assert ": ping\n" not in response.text diff --git a/tests/test_stream_bare_type.py b/tests/test_stream_bare_type.py new file mode 100644 index 0000000000..68bd31df6b --- /dev/null +++ b/tests/test_stream_bare_type.py @@ -0,0 +1,42 @@ +import json +from typing import AsyncIterable, Iterable # noqa: UP035 to test coverage + +from fastapi import FastAPI +from fastapi.testclient import TestClient +from pydantic import BaseModel + + +class Item(BaseModel): + name: str + + +app = FastAPI() + + +@app.get("/items/stream-bare-async") +async def stream_bare_async() -> AsyncIterable: + yield {"name": "foo"} + + +@app.get("/items/stream-bare-sync") +def stream_bare_sync() -> Iterable: + yield {"name": "bar"} + + +client = TestClient(app) + + +def test_stream_bare_async_iterable(): + response = client.get("/items/stream-bare-async") + assert response.status_code == 200 + assert response.headers["content-type"] == "application/jsonl" + lines = [json.loads(line) for line in response.text.strip().splitlines()] + assert lines == [{"name": "foo"}] + + +def test_stream_bare_sync_iterable(): + response = client.get("/items/stream-bare-sync") + assert response.status_code == 200 + assert response.headers["content-type"] == "application/jsonl" + lines = [json.loads(line) for line in response.text.strip().splitlines()] + assert lines == [{"name": "bar"}] diff --git a/tests/test_stream_cancellation.py b/tests/test_stream_cancellation.py new file mode 100644 index 0000000000..20069c5f6b --- /dev/null +++ b/tests/test_stream_cancellation.py @@ -0,0 +1,88 @@ +""" +Test that async streaming endpoints can be cancelled without hanging. + +Ref: https://github.com/fastapi/fastapi/issues/14680 +""" + +from collections.abc import AsyncIterable + +import anyio +import pytest +from fastapi import FastAPI +from fastapi.responses import StreamingResponse + +pytestmark = [ + pytest.mark.anyio, + pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning"), +] + + +app = FastAPI() + + +@app.get("/stream-raw", response_class=StreamingResponse) +async def stream_raw() -> AsyncIterable[str]: + """Async generator with no internal await - would hang without checkpoint.""" + i = 0 + while True: + yield f"item {i}\n" + i += 1 + + +@app.get("/stream-jsonl") +async def stream_jsonl() -> AsyncIterable[int]: + """JSONL async generator with no internal await.""" + i = 0 + while True: + yield i + i += 1 + + +async def _run_asgi_and_cancel(app: FastAPI, path: str, timeout: float) -> bool: + """Call the ASGI app for *path* and cancel after *timeout* seconds. + + Returns `True` if the cancellation was delivered (i.e. it did not hang). + """ + chunks: list[bytes] = [] + + async def receive(): # type: ignore[no-untyped-def] + # Simulate a client that never disconnects, rely on cancellation + await anyio.sleep(float("inf")) + return {"type": "http.disconnect"} # pragma: no cover + + async def send(message: dict) -> None: # type: ignore[type-arg] + if message["type"] == "http.response.body": + chunks.append(message.get("body", b"")) + + scope = { + "type": "http", + "asgi": {"version": "3.0", "spec_version": "2.0"}, + "http_version": "1.1", + "method": "GET", + "path": path, + "query_string": b"", + "root_path": "", + "headers": [], + "server": ("test", 80), + } + + with anyio.move_on_after(timeout) as cancel_scope: + await app(scope, receive, send) # type: ignore[arg-type] + + # If we got here within the timeout the generator was cancellable. + # cancel_scope.cancelled_caught is True when move_on_after fired. + return cancel_scope.cancelled_caught or len(chunks) > 0 + + +async def test_raw_stream_cancellation() -> None: + """Raw streaming endpoint should be cancellable within a reasonable time.""" + cancelled = await _run_asgi_and_cancel(app, "/stream-raw", timeout=3.0) + # The key assertion: we reached this line at all (didn't hang). + # cancelled will be True because the infinite generator was interrupted. + assert cancelled + + +async def test_jsonl_stream_cancellation() -> None: + """JSONL streaming endpoint should be cancellable within a reasonable time.""" + cancelled = await _run_asgi_and_cancel(app, "/stream-jsonl", timeout=3.0) + assert cancelled diff --git a/tests/test_stream_json_validation_error.py b/tests/test_stream_json_validation_error.py new file mode 100644 index 0000000000..f60b4a6abe --- /dev/null +++ b/tests/test_stream_json_validation_error.py @@ -0,0 +1,40 @@ +from collections.abc import AsyncIterable, Iterable + +import pytest +from fastapi import FastAPI +from fastapi.exceptions import ResponseValidationError +from fastapi.testclient import TestClient +from pydantic import BaseModel + + +class Item(BaseModel): + name: str + price: float + + +app = FastAPI() + + +@app.get("/items/stream-invalid") +async def stream_items_invalid() -> AsyncIterable[Item]: + yield {"name": "valid", "price": 1.0} + yield {"name": "invalid", "price": "not-a-number"} + + +@app.get("/items/stream-invalid-sync") +def stream_items_invalid_sync() -> Iterable[Item]: + yield {"name": "valid", "price": 1.0} + yield {"name": "invalid", "price": "not-a-number"} + + +client = TestClient(app) + + +def test_stream_json_validation_error_async(): + with pytest.raises(ResponseValidationError): + client.get("/items/stream-invalid") + + +def test_stream_json_validation_error_sync(): + with pytest.raises(ResponseValidationError): + client.get("/items/stream-invalid-sync") diff --git a/tests/test_tutorial/test_additional_responses/test_tutorial002.py b/tests/test_tutorial/test_additional_responses/test_tutorial002.py index 586779e44f..f1b53a96ce 100644 --- a/tests/test_tutorial/test_additional_responses/test_tutorial002.py +++ b/tests/test_tutorial/test_additional_responses/test_tutorial002.py @@ -6,7 +6,7 @@ import pytest from fastapi.testclient import TestClient from inline_snapshot import snapshot -from tests.utils import needs_py310 +from tests.utils import needs_py310, workdir_lock @pytest.fixture( @@ -29,6 +29,7 @@ def test_path_operation(client: TestClient): assert response.json() == {"id": "foo", "value": "there goes my hero"} +@workdir_lock def test_path_operation_img(client: TestClient): shutil.copy("./docs/en/docs/img/favicon.png", "./image.png") response = client.get("/items/foo?img=1") diff --git a/tests/test_tutorial/test_additional_responses/test_tutorial004.py b/tests/test_tutorial/test_additional_responses/test_tutorial004.py index fe56fbb8b5..c6d517f205 100644 --- a/tests/test_tutorial/test_additional_responses/test_tutorial004.py +++ b/tests/test_tutorial/test_additional_responses/test_tutorial004.py @@ -6,7 +6,7 @@ import pytest from fastapi.testclient import TestClient from inline_snapshot import snapshot -from tests.utils import needs_py310 +from tests.utils import needs_py310, workdir_lock @pytest.fixture( @@ -29,6 +29,7 @@ def test_path_operation(client: TestClient): assert response.json() == {"id": "foo", "value": "there goes my hero"} +@workdir_lock def test_path_operation_img(client: TestClient): shutil.copy("./docs/en/docs/img/favicon.png", "./image.png") response = client.get("/items/foo?img=1") diff --git a/tests/test_tutorial/test_background_tasks/test_tutorial001.py b/tests/test_tutorial/test_background_tasks/test_tutorial001.py index 100583f77a..1fc919c399 100644 --- a/tests/test_tutorial/test_background_tasks/test_tutorial001.py +++ b/tests/test_tutorial/test_background_tasks/test_tutorial001.py @@ -4,10 +4,12 @@ from pathlib import Path from fastapi.testclient import TestClient from docs_src.background_tasks.tutorial001_py310 import app +from tests.utils import workdir_lock client = TestClient(app) +@workdir_lock def test(): log = Path("log.txt") if log.is_file(): diff --git a/tests/test_tutorial/test_background_tasks/test_tutorial002.py b/tests/test_tutorial/test_background_tasks/test_tutorial002.py index f29402c833..31b58cde1f 100644 --- a/tests/test_tutorial/test_background_tasks/test_tutorial002.py +++ b/tests/test_tutorial/test_background_tasks/test_tutorial002.py @@ -5,7 +5,7 @@ from pathlib import Path import pytest from fastapi.testclient import TestClient -from ...utils import needs_py310 +from tests.utils import needs_py310, workdir_lock @pytest.fixture( @@ -22,6 +22,7 @@ def get_client(request: pytest.FixtureRequest): return client +@workdir_lock def test(client: TestClient): log = Path("log.txt") if log.is_file(): diff --git a/tests/test_tutorial/test_custom_docs_ui/test_tutorial001.py b/tests/test_tutorial/test_custom_docs_ui/test_tutorial001.py index f7eb7fd97d..ae25497f32 100644 --- a/tests/test_tutorial/test_custom_docs_ui/test_tutorial001.py +++ b/tests/test_tutorial/test_custom_docs_ui/test_tutorial001.py @@ -4,6 +4,8 @@ from pathlib import Path import pytest from fastapi.testclient import TestClient +from tests.utils import workdir_lock + @pytest.fixture(scope="module") def client(): @@ -17,6 +19,7 @@ def client(): static_dir.rmdir() +@workdir_lock def test_swagger_ui_html(client: TestClient): response = client.get("/docs") assert response.status_code == 200, response.text @@ -24,18 +27,21 @@ def test_swagger_ui_html(client: TestClient): assert "https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" in response.text +@workdir_lock def test_swagger_ui_oauth2_redirect_html(client: TestClient): response = client.get("/docs/oauth2-redirect") assert response.status_code == 200, response.text assert "window.opener.swaggerUIRedirectOauth2" in response.text +@workdir_lock def test_redoc_html(client: TestClient): response = client.get("/redoc") assert response.status_code == 200, response.text assert "https://unpkg.com/redoc@2/bundles/redoc.standalone.js" in response.text +@workdir_lock def test_api(client: TestClient): response = client.get("/users/john") assert response.status_code == 200, response.text diff --git a/tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py b/tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py index 28945d8387..ac67170d74 100644 --- a/tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py +++ b/tests/test_tutorial/test_custom_docs_ui/test_tutorial002.py @@ -4,6 +4,8 @@ from pathlib import Path import pytest from fastapi.testclient import TestClient +from tests.utils import workdir_lock + @pytest.fixture(scope="module") def client(): @@ -17,6 +19,7 @@ def client(): static_dir.rmdir() +@workdir_lock def test_swagger_ui_html(client: TestClient): response = client.get("/docs") assert response.status_code == 200, response.text @@ -24,18 +27,21 @@ def test_swagger_ui_html(client: TestClient): assert "/static/swagger-ui.css" in response.text +@workdir_lock def test_swagger_ui_oauth2_redirect_html(client: TestClient): response = client.get("/docs/oauth2-redirect") assert response.status_code == 200, response.text assert "window.opener.swaggerUIRedirectOauth2" in response.text +@workdir_lock def test_redoc_html(client: TestClient): response = client.get("/redoc") assert response.status_code == 200, response.text assert "/static/redoc.standalone.js" in response.text +@workdir_lock def test_api(client: TestClient): response = client.get("/users/john") assert response.status_code == 200, response.text diff --git a/tests/test_tutorial/test_events/test_tutorial002.py b/tests/test_tutorial/test_events/test_tutorial002.py index 47af7a9527..262d936f98 100644 --- a/tests/test_tutorial/test_events/test_tutorial002.py +++ b/tests/test_tutorial/test_events/test_tutorial002.py @@ -3,6 +3,8 @@ from fastapi import FastAPI from fastapi.testclient import TestClient from inline_snapshot import snapshot +from tests.utils import workdir_lock + @pytest.fixture(name="app", scope="module") def get_app(): @@ -11,6 +13,7 @@ def get_app(): yield app +@workdir_lock def test_events(app: FastAPI): with TestClient(app) as client: response = client.get("/items/") @@ -20,6 +23,7 @@ def test_events(app: FastAPI): assert "Application shutdown" in log.read() +@workdir_lock def test_openapi_schema(app: FastAPI): with TestClient(app) as client: response = client.get("/openapi.json") diff --git a/tests/test_tutorial/test_server_sent_events/__init__.py b/tests/test_tutorial/test_server_sent_events/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tutorial/test_server_sent_events/test_tutorial001.py b/tests/test_tutorial/test_server_sent_events/test_tutorial001.py new file mode 100644 index 0000000000..75fdda3601 --- /dev/null +++ b/tests/test_tutorial/test_server_sent_events/test_tutorial001.py @@ -0,0 +1,191 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial001_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.server_sent_events.{request.param}") + + client = TestClient(mod.app) + return client + + +@pytest.mark.parametrize( + "path", + [ + "/items/stream", + "/items/stream-no-async", + "/items/stream-no-annotation", + "/items/stream-no-async-no-annotation", + ], +) +def test_stream_items(client: TestClient, path: str): + response = client.get(path) + assert response.status_code == 200, response.text + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/items/stream": { + "get": { + "summary": "Sse Items", + "operationId": "sse_items_items_stream_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": { + "type": "string", + "contentMediaType": "application/json", + "contentSchema": { + "$ref": "#/components/schemas/Item" + }, + }, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + "required": ["data"], + } + } + }, + } + }, + } + }, + "/items/stream-no-async": { + "get": { + "summary": "Sse Items No Async", + "operationId": "sse_items_no_async_items_stream_no_async_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": { + "type": "string", + "contentMediaType": "application/json", + "contentSchema": { + "$ref": "#/components/schemas/Item" + }, + }, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + "required": ["data"], + } + } + }, + } + }, + } + }, + "/items/stream-no-annotation": { + "get": { + "summary": "Sse Items No Annotation", + "operationId": "sse_items_no_annotation_items_stream_no_annotation_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + } + } + }, + } + }, + } + }, + "/items/stream-no-async-no-annotation": { + "get": { + "summary": "Sse Items No Async No Annotation", + "operationId": "sse_items_no_async_no_annotation_items_stream_no_async_no_annotation_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + } + } + }, + } + }, + } + }, + }, + "components": { + "schemas": { + "Item": { + "properties": { + "name": {"type": "string", "title": "Name"}, + "description": { + "anyOf": [ + {"type": "string"}, + {"type": "null"}, + ], + "title": "Description", + }, + }, + "type": "object", + "required": ["name", "description"], + "title": "Item", + } + } + }, + } + ) diff --git a/tests/test_tutorial/test_server_sent_events/test_tutorial002.py b/tests/test_tutorial/test_server_sent_events/test_tutorial002.py new file mode 100644 index 0000000000..b9cbf43854 --- /dev/null +++ b/tests/test_tutorial/test_server_sent_events/test_tutorial002.py @@ -0,0 +1,83 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial002_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.server_sent_events.{request.param}") + client = TestClient(mod.app) + return client + + +def test_stream_items(client: TestClient): + response = client.get("/items/stream") + assert response.status_code == 200, response.text + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + + lines = response.text.strip().split("\n") + + # First event is a comment-only event + assert lines[0] == ": stream of item updates" + + # Remaining lines contain event:, data:, id:, retry: fields + event_lines = [line for line in lines if line.startswith("event: ")] + assert len(event_lines) == 3 + assert all(line == "event: item_update" for line in event_lines) + + data_lines = [line for line in lines if line.startswith("data: ")] + assert len(data_lines) == 3 + + id_lines = [line for line in lines if line.startswith("id: ")] + assert id_lines == ["id: 1", "id: 2", "id: 3"] + + retry_lines = [line for line in lines if line.startswith("retry: ")] + assert len(retry_lines) == 3 + assert all(line == "retry: 5000" for line in retry_lines) + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/items/stream": { + "get": { + "summary": "Stream Items", + "operationId": "stream_items_items_stream_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + } + } + }, + } + }, + } + } + }, + } + ) diff --git a/tests/test_tutorial/test_server_sent_events/test_tutorial003.py b/tests/test_tutorial/test_server_sent_events/test_tutorial003.py new file mode 100644 index 0000000000..6277a27c90 --- /dev/null +++ b/tests/test_tutorial/test_server_sent_events/test_tutorial003.py @@ -0,0 +1,73 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial003_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.server_sent_events.{request.param}") + client = TestClient(mod.app) + return client + + +def test_stream_logs(client: TestClient): + response = client.get("/logs/stream") + assert response.status_code == 200, response.text + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + # raw_data is sent without JSON encoding (no quotes around the string) + assert data_lines[0] == "data: 2025-01-01 INFO Application started" + assert data_lines[1] == "data: 2025-01-01 DEBUG Connected to database" + assert data_lines[2] == "data: 2025-01-01 WARN High memory usage detected" + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/logs/stream": { + "get": { + "summary": "Stream Logs", + "operationId": "stream_logs_logs_stream_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + } + } + }, + } + }, + } + } + }, + } + ) diff --git a/tests/test_tutorial/test_server_sent_events/test_tutorial004.py b/tests/test_tutorial/test_server_sent_events/test_tutorial004.py new file mode 100644 index 0000000000..38ce888c1c --- /dev/null +++ b/tests/test_tutorial/test_server_sent_events/test_tutorial004.py @@ -0,0 +1,164 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial004_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.server_sent_events.{request.param}") + client = TestClient(mod.app) + return client + + +def test_stream_all_items(client: TestClient): + response = client.get("/items/stream") + assert response.status_code == 200, response.text + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 3 + + id_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("id: ") + ] + assert id_lines == ["id: 0", "id: 1", "id: 2"] + + +def test_resume_from_last_event_id(client: TestClient): + response = client.get( + "/items/stream", + headers={"last-event-id": "0"}, + ) + assert response.status_code == 200, response.text + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 2 + + id_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("id: ") + ] + assert id_lines == ["id: 1", "id: 2"] + + +def test_resume_from_last_item(client: TestClient): + response = client.get( + "/items/stream", + headers={"last-event-id": "1"}, + ) + assert response.status_code == 200, response.text + + data_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("data: ") + ] + assert len(data_lines) == 1 + + id_lines = [ + line for line in response.text.strip().split("\n") if line.startswith("id: ") + ] + assert id_lines == ["id: 2"] + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/items/stream": { + "get": { + "summary": "Stream Items", + "operationId": "stream_items_items_stream_get", + "parameters": [ + { + "name": "last-event-id", + "in": "header", + "required": False, + "schema": { + "anyOf": [{"type": "integer"}, {"type": "null"}], + "title": "Last-Event-Id", + }, + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + } + } + }, + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + }, + }, + }, + } + } + }, + "components": { + "schemas": { + "HTTPValidationError": { + "properties": { + "detail": { + "items": { + "$ref": "#/components/schemas/ValidationError" + }, + "type": "array", + "title": "Detail", + } + }, + "type": "object", + "title": "HTTPValidationError", + }, + "ValidationError": { + "properties": { + "loc": { + "items": { + "anyOf": [{"type": "string"}, {"type": "integer"}] + }, + "type": "array", + "title": "Location", + }, + "msg": {"type": "string", "title": "Message"}, + "type": {"type": "string", "title": "Error Type"}, + "input": {"title": "Input"}, + "ctx": {"type": "object", "title": "Context"}, + }, + "type": "object", + "required": ["loc", "msg", "type"], + "title": "ValidationError", + }, + } + }, + } + ) diff --git a/tests/test_tutorial/test_server_sent_events/test_tutorial005.py b/tests/test_tutorial/test_server_sent_events/test_tutorial005.py new file mode 100644 index 0000000000..1b5c3492f7 --- /dev/null +++ b/tests/test_tutorial/test_server_sent_events/test_tutorial005.py @@ -0,0 +1,141 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial005_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.server_sent_events.{request.param}") + client = TestClient(mod.app) + return client + + +def test_stream_chat(client: TestClient): + response = client.post( + "/chat/stream", + json={"text": "hello world"}, + ) + assert response.status_code == 200, response.text + assert response.headers["content-type"] == "text/event-stream; charset=utf-8" + + lines = response.text.strip().split("\n") + + event_lines = [line for line in lines if line.startswith("event: ")] + assert event_lines == [ + "event: token", + "event: token", + "event: done", + ] + + data_lines = [line for line in lines if line.startswith("data: ")] + assert data_lines == [ + 'data: "hello"', + 'data: "world"', + "data: [DONE]", + ] + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/chat/stream": { + "post": { + "summary": "Stream Chat", + "operationId": "stream_chat_chat_stream_post", + "requestBody": { + "content": { + "application/json": { + "schema": {"$ref": "#/components/schemas/Prompt"} + } + }, + "required": True, + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "text/event-stream": { + "itemSchema": { + "type": "object", + "properties": { + "data": {"type": "string"}, + "event": {"type": "string"}, + "id": {"type": "string"}, + "retry": { + "type": "integer", + "minimum": 0, + }, + }, + } + } + }, + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + }, + }, + }, + } + } + }, + "components": { + "schemas": { + "HTTPValidationError": { + "properties": { + "detail": { + "items": { + "$ref": "#/components/schemas/ValidationError" + }, + "type": "array", + "title": "Detail", + } + }, + "type": "object", + "title": "HTTPValidationError", + }, + "Prompt": { + "properties": {"text": {"type": "string", "title": "Text"}}, + "type": "object", + "required": ["text"], + "title": "Prompt", + }, + "ValidationError": { + "properties": { + "loc": { + "items": { + "anyOf": [{"type": "string"}, {"type": "integer"}] + }, + "type": "array", + "title": "Location", + }, + "msg": {"type": "string", "title": "Message"}, + "type": {"type": "string", "title": "Error Type"}, + "input": {"title": "Input"}, + "ctx": {"type": "object", "title": "Context"}, + }, + "type": "object", + "required": ["loc", "msg", "type"], + "title": "ValidationError", + }, + } + }, + } + ) diff --git a/tests/test_tutorial/test_settings/test_app01.py b/tests/test_tutorial/test_settings/test_app01.py index da27308e80..57ae3e6a68 100644 --- a/tests/test_tutorial/test_settings/test_app01.py +++ b/tests/test_tutorial/test_settings/test_app01.py @@ -22,7 +22,7 @@ def get_mod_name(request: pytest.FixtureRequest): @pytest.fixture(name="client") def get_test_client(mod_name: str, monkeypatch: MonkeyPatch) -> TestClient: if mod_name in sys.modules: - del sys.modules[mod_name] + del sys.modules[mod_name] # pragma: no cover monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com") main_mod = importlib.import_module(mod_name) return TestClient(main_mod.app) diff --git a/tests/test_tutorial/test_static_files/test_tutorial001.py b/tests/test_tutorial/test_static_files/test_tutorial001.py index 1d57310f30..d2b120fbb9 100644 --- a/tests/test_tutorial/test_static_files/test_tutorial001.py +++ b/tests/test_tutorial/test_static_files/test_tutorial001.py @@ -5,6 +5,8 @@ import pytest from fastapi.testclient import TestClient from inline_snapshot import snapshot +from tests.utils import workdir_lock + @pytest.fixture(scope="module") def client(): @@ -20,17 +22,20 @@ def client(): static_dir.rmdir() +@workdir_lock def test_static_files(client: TestClient): response = client.get("/static/sample.txt") assert response.status_code == 200, response.text assert response.text == "This is a sample static file." +@workdir_lock def test_static_files_not_found(client: TestClient): response = client.get("/static/non_existent_file.txt") assert response.status_code == 404, response.text +@workdir_lock def test_openapi_schema(client: TestClient): response = client.get("/openapi.json") assert response.status_code == 200, response.text diff --git a/tests/test_tutorial/test_stream_data/__init__.py b/tests/test_tutorial/test_stream_data/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tutorial/test_stream_data/test_tutorial001.py b/tests/test_tutorial/test_stream_data/test_tutorial001.py new file mode 100644 index 0000000000..9731b04f79 --- /dev/null +++ b/tests/test_tutorial/test_stream_data/test_tutorial001.py @@ -0,0 +1,154 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial001_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.stream_data.{request.param}") + + client = TestClient(mod.app) + return client + + +expected_text = ( + "" + "Rick: (stumbles in drunkenly, and turns on the lights)" + " Morty! You gotta come on. You got--... you gotta come with me." + "Morty: (rubs his eyes) What, Rick? What's going on?" + "Rick: I got a surprise for you, Morty." + "Morty: It's the middle of the night. What are you talking about?" + "Rick: (spills alcohol on Morty's bed) Come on, I got a surprise for you." + " (drags Morty by the ankle) Come on, hurry up." + " (pulls Morty out of his bed and into the hall)" + "Morty: Ow! Ow! You're tugging me too hard!" + "Rick: We gotta go, gotta get outta here, come on." + " Got a surprise for you Morty." +) + + +@pytest.mark.parametrize( + "path", + [ + "/story/stream", + "/story/stream-no-async", + "/story/stream-no-annotation", + "/story/stream-no-async-no-annotation", + "/story/stream-bytes", + "/story/stream-no-async-bytes", + "/story/stream-no-annotation-bytes", + "/story/stream-no-async-no-annotation-bytes", + ], +) +def test_stream_story(client: TestClient, path: str): + response = client.get(path) + assert response.status_code == 200, response.text + assert response.text == expected_text + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/story/stream": { + "get": { + "summary": "Stream Story", + "operationId": "stream_story_story_stream_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-no-async": { + "get": { + "summary": "Stream Story No Async", + "operationId": "stream_story_no_async_story_stream_no_async_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-no-annotation": { + "get": { + "summary": "Stream Story No Annotation", + "operationId": "stream_story_no_annotation_story_stream_no_annotation_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-no-async-no-annotation": { + "get": { + "summary": "Stream Story No Async No Annotation", + "operationId": "stream_story_no_async_no_annotation_story_stream_no_async_no_annotation_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-bytes": { + "get": { + "summary": "Stream Story Bytes", + "operationId": "stream_story_bytes_story_stream_bytes_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-no-async-bytes": { + "get": { + "summary": "Stream Story No Async Bytes", + "operationId": "stream_story_no_async_bytes_story_stream_no_async_bytes_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-no-annotation-bytes": { + "get": { + "summary": "Stream Story No Annotation Bytes", + "operationId": "stream_story_no_annotation_bytes_story_stream_no_annotation_bytes_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + "/story/stream-no-async-no-annotation-bytes": { + "get": { + "summary": "Stream Story No Async No Annotation Bytes", + "operationId": "stream_story_no_async_no_annotation_bytes_story_stream_no_async_no_annotation_bytes_get", + "responses": { + "200": { + "description": "Successful Response", + } + }, + } + }, + }, + } + ) diff --git a/tests/test_tutorial/test_stream_data/test_tutorial002.py b/tests/test_tutorial/test_stream_data/test_tutorial002.py new file mode 100644 index 0000000000..8bd7384c57 --- /dev/null +++ b/tests/test_tutorial/test_stream_data/test_tutorial002.py @@ -0,0 +1,121 @@ +import importlib + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="mod", + params=[ + pytest.param("tutorial002_py310"), + ], +) +def get_mod(request: pytest.FixtureRequest): + return importlib.import_module(f"docs_src.stream_data.{request.param}") + + +@pytest.fixture(name="client") +def get_client(mod): + client = TestClient(mod.app) + return client + + +@pytest.mark.parametrize( + "path", + [ + "/image/stream", + "/image/stream-no-async", + "/image/stream-no-async-yield-from", + "/image/stream-no-annotation", + "/image/stream-no-async-no-annotation", + ], +) +def test_stream_image(mod, client: TestClient, path: str): + response = client.get(path) + assert response.status_code == 200 + assert response.headers["content-type"] == "image/png" + assert response.content == mod.binary_image + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/image/stream": { + "get": { + "summary": "Stream Image", + "operationId": "stream_image_image_stream_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "image/png": {"schema": {"type": "string"}} + }, + } + }, + } + }, + "/image/stream-no-async": { + "get": { + "summary": "Stream Image No Async", + "operationId": "stream_image_no_async_image_stream_no_async_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "image/png": {"schema": {"type": "string"}} + }, + } + }, + } + }, + "/image/stream-no-async-yield-from": { + "get": { + "summary": "Stream Image No Async Yield From", + "operationId": "stream_image_no_async_yield_from_image_stream_no_async_yield_from_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "image/png": {"schema": {"type": "string"}} + }, + } + }, + } + }, + "/image/stream-no-annotation": { + "get": { + "summary": "Stream Image No Annotation", + "operationId": "stream_image_no_annotation_image_stream_no_annotation_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "image/png": {"schema": {"type": "string"}} + }, + } + }, + } + }, + "/image/stream-no-async-no-annotation": { + "get": { + "summary": "Stream Image No Async No Annotation", + "operationId": "stream_image_no_async_no_annotation_image_stream_no_async_no_annotation_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "image/png": {"schema": {"type": "string"}} + }, + } + }, + } + }, + }, + } + ) diff --git a/tests/test_tutorial/test_stream_json_lines/__init__.py b/tests/test_tutorial/test_stream_json_lines/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tutorial/test_stream_json_lines/test_tutorial001.py b/tests/test_tutorial/test_stream_json_lines/test_tutorial001.py new file mode 100644 index 0000000000..0b5f9d95bb --- /dev/null +++ b/tests/test_tutorial/test_stream_json_lines/test_tutorial001.py @@ -0,0 +1,143 @@ +import importlib +import json + +import pytest +from fastapi.testclient import TestClient +from inline_snapshot import snapshot + + +@pytest.fixture( + name="client", + params=[ + pytest.param("tutorial001_py310"), + ], +) +def get_client(request: pytest.FixtureRequest): + mod = importlib.import_module(f"docs_src.stream_json_lines.{request.param}") + + client = TestClient(mod.app) + return client + + +expected_items = [ + {"name": "Plumbus", "description": "A multi-purpose household device."}, + {"name": "Portal Gun", "description": "A portal opening device."}, + {"name": "Meeseeks Box", "description": "A box that summons a Meeseeks."}, +] + + +@pytest.mark.parametrize( + "path", + [ + "/items/stream", + "/items/stream-no-async", + "/items/stream-no-annotation", + "/items/stream-no-async-no-annotation", + ], +) +def test_stream_items(client: TestClient, path: str): + response = client.get(path) + assert response.status_code == 200, response.text + assert response.headers["content-type"] == "application/jsonl" + lines = [json.loads(line) for line in response.text.strip().splitlines()] + assert lines == expected_items + + +def test_openapi_schema(client: TestClient): + response = client.get("/openapi.json") + assert response.status_code == 200, response.text + assert response.json() == snapshot( + { + "openapi": "3.1.0", + "info": {"title": "FastAPI", "version": "0.1.0"}, + "paths": { + "/items/stream": { + "get": { + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/jsonl": { + "itemSchema": { + "$ref": "#/components/schemas/Item" + }, + } + }, + } + }, + "summary": "Stream Items", + "operationId": "stream_items_items_stream_get", + } + }, + "/items/stream-no-async": { + "get": { + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/jsonl": { + "itemSchema": { + "$ref": "#/components/schemas/Item" + }, + } + }, + } + }, + "summary": "Stream Items No Async", + "operationId": "stream_items_no_async_items_stream_no_async_get", + } + }, + "/items/stream-no-annotation": { + "get": { + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/jsonl": { + "itemSchema": {}, + } + }, + } + }, + "summary": "Stream Items No Annotation", + "operationId": "stream_items_no_annotation_items_stream_no_annotation_get", + } + }, + "/items/stream-no-async-no-annotation": { + "get": { + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/jsonl": { + "itemSchema": {}, + } + }, + } + }, + "summary": "Stream Items No Async No Annotation", + "operationId": "stream_items_no_async_no_annotation_items_stream_no_async_no_annotation_get", + } + }, + }, + "components": { + "schemas": { + "Item": { + "properties": { + "name": {"type": "string", "title": "Name"}, + "description": { + "anyOf": [ + {"type": "string"}, + {"type": "null"}, + ], + "title": "Description", + }, + }, + "type": "object", + "required": ["name", "description"], + "title": "Item", + } + } + }, + } + ) diff --git a/tests/test_tutorial/test_templates/test_tutorial001.py b/tests/test_tutorial/test_templates/test_tutorial001.py index 04bc3fce86..f0377e963c 100644 --- a/tests/test_tutorial/test_templates/test_tutorial001.py +++ b/tests/test_tutorial/test_templates/test_tutorial001.py @@ -3,7 +3,10 @@ import shutil from fastapi.testclient import TestClient +from tests.utils import workdir_lock + +@workdir_lock def test_main(): if os.path.isdir("./static"): # pragma: nocover shutil.rmtree("./static") diff --git a/tests/test_tutorial/test_websockets/test_tutorial001.py b/tests/test_tutorial/test_websockets/test_tutorial001.py index 6f3bf1429a..3bf9ec15b2 100644 --- a/tests/test_tutorial/test_websockets/test_tutorial001.py +++ b/tests/test_tutorial/test_websockets/test_tutorial001.py @@ -2,7 +2,7 @@ import pytest from fastapi.testclient import TestClient from fastapi.websockets import WebSocketDisconnect -from docs_src.websockets.tutorial001_py310 import app +from docs_src.websockets_.tutorial001_py310 import app client = TestClient(app) diff --git a/tests/test_tutorial/test_websockets/test_tutorial002.py b/tests/test_tutorial/test_websockets/test_tutorial002.py index 0509b0d0d6..71fb9e68b8 100644 --- a/tests/test_tutorial/test_websockets/test_tutorial002.py +++ b/tests/test_tutorial/test_websockets/test_tutorial002.py @@ -16,7 +16,7 @@ from ...utils import needs_py310 ], ) def get_app(request: pytest.FixtureRequest): - mod = importlib.import_module(f"docs_src.websockets.{request.param}") + mod = importlib.import_module(f"docs_src.websockets_.{request.param}") return mod.app diff --git a/tests/test_tutorial/test_websockets/test_tutorial003.py b/tests/test_tutorial/test_websockets/test_tutorial003.py index 781146371d..e5f24d4879 100644 --- a/tests/test_tutorial/test_websockets/test_tutorial003.py +++ b/tests/test_tutorial/test_websockets/test_tutorial003.py @@ -1,4 +1,5 @@ import importlib +import time from types import ModuleType import pytest @@ -12,7 +13,7 @@ from fastapi.testclient import TestClient ], ) def get_mod(request: pytest.FixtureRequest): - mod = importlib.import_module(f"docs_src.websockets.{request.param}") + mod = importlib.import_module(f"docs_src.websockets_.{request.param}") return mod @@ -42,11 +43,13 @@ def test_websocket_handle_disconnection(client: TestClient): connection.send_text("Hello from 1234") data1 = connection.receive_text() assert data1 == "You wrote: Hello from 1234" + time.sleep(0.01) # Give server time to process broadcast data2 = connection_two.receive_text() client1_says = "Client #1234 says: Hello from 1234" assert data2 == client1_says data1 = connection.receive_text() assert data1 == client1_says connection_two.close() + time.sleep(0.01) # Give server time to process broadcast data1 = connection.receive_text() assert data1 == "Client #5678 left the chat" diff --git a/tests/utils.py b/tests/utils.py index 09c4e13b00..fff7348b9c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -9,6 +9,8 @@ needs_py314 = pytest.mark.skipif( sys.version_info < (3, 14), reason="requires python3.14+" ) +workdir_lock = pytest.mark.xdist_group("workdir_lock") + def skip_module_if_py_gte_314(): """Skip entire module on Python 3.14+ at import time.""" diff --git a/uv.lock b/uv.lock index 9fa1c2dd74..2414d88ed5 100644 --- a/uv.lock +++ b/uv.lock @@ -665,14 +665,14 @@ wheels = [ [[package]] name = "click" -version = "8.3.1" +version = "8.2.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } +sdist = { url = "https://files.pythonhosted.org/packages/60/6c/8ca2efa64cf75a977a0d7fac081354553ebe483345c734fb6b6515d96bbc/click-8.2.1.tar.gz", hash = "sha256:27c491cc05d968d271d5a1db13e3b5a184636d9d930f148c50b038f0d0646202", size = 286342, upload-time = "2025-05-20T23:19:49.832Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, + { url = "https://files.pythonhosted.org/packages/85/32/10bb5764d90a8eee674e9dc6f4db6a0ab47c8c4d0d83c27f7c39ac415a4d/click-8.2.1-py3-none-any.whl", hash = "sha256:61a3265b914e850b85317d0b3109c7f8cd35a670f963866005d6ef1d5175a12b", size = 102215, upload-time = "2025-05-20T23:19:47.796Z" }, ] [[package]] @@ -686,7 +686,7 @@ wheels = [ [[package]] name = "cohere" -version = "5.20.4" +version = "5.20.7" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "fastavro" }, @@ -698,9 +698,9 @@ dependencies = [ { name = "types-requests" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/35/37/65af9c50b5d5772a5528c6a949799f98ae286b8ebb924e0fac0619b3ae88/cohere-5.20.4.tar.gz", hash = "sha256:3b3017048ff5d5b4f113180947d538ca3d0f274de5875f0345be4c8cb3d5119a", size = 180737, upload-time = "2026-02-05T14:47:54.639Z" } +sdist = { url = "https://files.pythonhosted.org/packages/44/0b/96e2b55a0114ed9d69b3154565f54b764e7530735426290b000f467f4c0f/cohere-5.20.7.tar.gz", hash = "sha256:997ed85fabb3a1e4a4c036fdb520382e7bfa670db48eb59a026803b6f7061dbb", size = 184986, upload-time = "2026-02-25T01:22:18.673Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/6d/14/5c5077c6b01aed7a18dfc5ab775a35c7a6cb118e5bc1dafcfc06abdb9d9e/cohere-5.20.4-py3-none-any.whl", hash = "sha256:9cc6ebb0adac3d9f96ac0efffde6a2484534fb0aec3684a62c250d49da958f29", size = 318987, upload-time = "2026-02-05T14:47:53.505Z" }, + { url = "https://files.pythonhosted.org/packages/9d/86/dc991a75e3b9c2007b90dbfaf7f36fdb2457c216f799e26ce0474faf0c1f/cohere-5.20.7-py3-none-any.whl", hash = "sha256:043fef2a12c30c07e9b2c1f0b869fd66ffd911f58d1492f87e901c4190a65914", size = 323389, upload-time = "2026-02-25T01:22:16.902Z" }, ] [[package]] @@ -1037,6 +1037,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" }, ] +[[package]] +name = "execnet" +version = "2.1.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/89/780e11f9588d9e7128a3f87788354c7946a9cbb1401ad38a48c4db9a4f07/execnet-2.1.2.tar.gz", hash = "sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd", size = 166622, upload-time = "2025-11-12T09:56:37.75Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ab/84/02fc1827e8cdded4aa65baef11296a9bbe595c474f0d6d758af082d849fd/execnet-2.1.2-py3-none-any.whl", hash = "sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec", size = 40708, upload-time = "2025-11-12T09:56:36.333Z" }, +] + [[package]] name = "executing" version = "2.2.1" @@ -1116,6 +1125,7 @@ dev = [ { name = "anyio", extra = ["trio"] }, { name = "black" }, { name = "cairosvg" }, + { name = "click" }, { name = "coverage", extra = ["toml"] }, { name = "dirty-equals" }, { name = "flask" }, @@ -1142,6 +1152,10 @@ dev = [ { name = "pyjwt" }, { name = "pytest" }, { name = "pytest-codspeed" }, + { name = "pytest-cov" }, + { name = "pytest-sugar" }, + { name = "pytest-timeout" }, + { name = "pytest-xdist", extra = ["psutil"] }, { name = "python-slugify" }, { name = "pyyaml" }, { name = "ruff" }, @@ -1155,6 +1169,7 @@ dev = [ docs = [ { name = "black" }, { name = "cairosvg" }, + { name = "click" }, { name = "griffe-typingdoc" }, { name = "griffe-warnings-deprecated" }, { name = "httpx" }, @@ -1201,6 +1216,10 @@ tests = [ { name = "pyjwt" }, { name = "pytest" }, { name = "pytest-codspeed" }, + { name = "pytest-cov" }, + { name = "pytest-sugar" }, + { name = "pytest-timeout" }, + { name = "pytest-xdist", extra = ["psutil"] }, { name = "pyyaml" }, { name = "ruff" }, { name = "sqlmodel" }, @@ -1242,7 +1261,7 @@ requires-dist = [ { name = "python-multipart", marker = "extra == 'standard'", specifier = ">=0.0.18" }, { name = "python-multipart", marker = "extra == 'standard-no-fastapi-cloud-cli'", specifier = ">=0.0.18" }, { name = "pyyaml", marker = "extra == 'all'", specifier = ">=5.3.1" }, - { name = "starlette", specifier = ">=0.40.0" }, + { name = "starlette", specifier = ">=0.46.0" }, { name = "typing-extensions", specifier = ">=4.8.0" }, { name = "typing-inspection", specifier = ">=0.4.2" }, { name = "uvicorn", extras = ["standard"], marker = "extra == 'all'", specifier = ">=0.12.0" }, @@ -1257,7 +1276,8 @@ dev = [ { name = "anyio", extras = ["trio"], specifier = ">=3.2.1,<5.0.0" }, { name = "black", specifier = ">=25.1.0" }, { name = "cairosvg", specifier = ">=2.8.2" }, - { name = "coverage", extras = ["toml"], specifier = ">=6.5.0,<8.0" }, + { name = "click", specifier = "==8.2.1" }, + { name = "coverage", extras = ["toml"], specifier = ">=7.13,<8.0" }, { name = "dirty-equals", specifier = ">=0.9.0" }, { name = "flask", specifier = ">=3.0.0,<4.0.0" }, { name = "gitpython", specifier = ">=3.1.46" }, @@ -1283,6 +1303,10 @@ dev = [ { name = "pyjwt", specifier = ">=2.9.0" }, { name = "pytest", specifier = ">=9.0.0" }, { name = "pytest-codspeed", specifier = ">=4.2.0" }, + { name = "pytest-cov", specifier = ">=4.0.0" }, + { name = "pytest-sugar", specifier = ">=1.0.0" }, + { name = "pytest-timeout", specifier = ">=2.4.0" }, + { name = "pytest-xdist", extras = ["psutil"], specifier = ">=2.5.0" }, { name = "python-slugify", specifier = ">=8.0.4" }, { name = "pyyaml", specifier = ">=5.3.1,<7.0.0" }, { name = "ruff", specifier = ">=0.14.14" }, @@ -1296,6 +1320,7 @@ dev = [ docs = [ { name = "black", specifier = ">=25.1.0" }, { name = "cairosvg", specifier = ">=2.8.2" }, + { name = "click", specifier = "==8.2.1" }, { name = "griffe-typingdoc", specifier = ">=0.3.0" }, { name = "griffe-warnings-deprecated", specifier = ">=1.1.0" }, { name = "httpx", specifier = ">=0.23.0,<1.0.0" }, @@ -1331,7 +1356,7 @@ github-actions = [ tests = [ { name = "a2wsgi", specifier = ">=1.9.0,<=2.0.0" }, { name = "anyio", extras = ["trio"], specifier = ">=3.2.1,<5.0.0" }, - { name = "coverage", extras = ["toml"], specifier = ">=6.5.0,<8.0" }, + { name = "coverage", extras = ["toml"], specifier = ">=7.13,<8.0" }, { name = "dirty-equals", specifier = ">=0.9.0" }, { name = "flask", specifier = ">=3.0.0,<4.0.0" }, { name = "httpx", specifier = ">=0.23.0,<1.0.0" }, @@ -1342,6 +1367,10 @@ tests = [ { name = "pyjwt", specifier = ">=2.9.0" }, { name = "pytest", specifier = ">=9.0.0" }, { name = "pytest-codspeed", specifier = ">=4.2.0" }, + { name = "pytest-cov", specifier = ">=4.0.0" }, + { name = "pytest-sugar", specifier = ">=1.0.0" }, + { name = "pytest-timeout", specifier = ">=2.4.0" }, + { name = "pytest-xdist", extras = ["psutil"], specifier = ">=2.5.0" }, { name = "pyyaml", specifier = ">=5.3.1,<7.0.0" }, { name = "ruff", specifier = ">=0.14.14" }, { name = "sqlmodel", specifier = ">=0.0.31" }, @@ -3823,6 +3852,34 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/57/bf/2086963c69bdac3d7cff1cc7ff79b8ce5ea0bec6797a017e1be338a46248/protobuf-6.33.5-py3-none-any.whl", hash = "sha256:69915a973dd0f60f31a08b8318b73eab2bd6a392c79184b3612226b0a3f8ec02", size = 170687, upload-time = "2026-01-29T21:51:32.557Z" }, ] +[[package]] +name = "psutil" +version = "7.2.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/aa/c6/d1ddf4abb55e93cebc4f2ed8b5d6dbad109ecb8d63748dd2b20ab5e57ebe/psutil-7.2.2.tar.gz", hash = "sha256:0746f5f8d406af344fd547f1c8daa5f5c33dbc293bb8d6a16d80b4bb88f59372", size = 493740, upload-time = "2026-01-28T18:14:54.428Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/08/510cbdb69c25a96f4ae523f733cdc963ae654904e8db864c07585ef99875/psutil-7.2.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2edccc433cbfa046b980b0df0171cd25bcaeb3a68fe9022db0979e7aa74a826b", size = 130595, upload-time = "2026-01-28T18:14:57.293Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f5/97baea3fe7a5a9af7436301f85490905379b1c6f2dd51fe3ecf24b4c5fbf/psutil-7.2.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e78c8603dcd9a04c7364f1a3e670cea95d51ee865e4efb3556a3a63adef958ea", size = 131082, upload-time = "2026-01-28T18:14:59.732Z" }, + { url = "https://files.pythonhosted.org/packages/37/d6/246513fbf9fa174af531f28412297dd05241d97a75911ac8febefa1a53c6/psutil-7.2.2-cp313-cp313t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a571f2330c966c62aeda00dd24620425d4b0cc86881c89861fbc04549e5dc63", size = 181476, upload-time = "2026-01-28T18:15:01.884Z" }, + { url = "https://files.pythonhosted.org/packages/b8/b5/9182c9af3836cca61696dabe4fd1304e17bc56cb62f17439e1154f225dd3/psutil-7.2.2-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:917e891983ca3c1887b4ef36447b1e0873e70c933afc831c6b6da078ba474312", size = 184062, upload-time = "2026-01-28T18:15:04.436Z" }, + { url = "https://files.pythonhosted.org/packages/16/ba/0756dca669f5a9300d0cbcbfae9a4c30e446dfc7440ffe43ded5724bfd93/psutil-7.2.2-cp313-cp313t-win_amd64.whl", hash = "sha256:ab486563df44c17f5173621c7b198955bd6b613fb87c71c161f827d3fb149a9b", size = 139893, upload-time = "2026-01-28T18:15:06.378Z" }, + { url = "https://files.pythonhosted.org/packages/1c/61/8fa0e26f33623b49949346de05ec1ddaad02ed8ba64af45f40a147dbfa97/psutil-7.2.2-cp313-cp313t-win_arm64.whl", hash = "sha256:ae0aefdd8796a7737eccea863f80f81e468a1e4cf14d926bd9b6f5f2d5f90ca9", size = 135589, upload-time = "2026-01-28T18:15:08.03Z" }, + { url = "https://files.pythonhosted.org/packages/81/69/ef179ab5ca24f32acc1dac0c247fd6a13b501fd5534dbae0e05a1c48b66d/psutil-7.2.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:eed63d3b4d62449571547b60578c5b2c4bcccc5387148db46e0c2313dad0ee00", size = 130664, upload-time = "2026-01-28T18:15:09.469Z" }, + { url = "https://files.pythonhosted.org/packages/7b/64/665248b557a236d3fa9efc378d60d95ef56dd0a490c2cd37dafc7660d4a9/psutil-7.2.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:7b6d09433a10592ce39b13d7be5a54fbac1d1228ed29abc880fb23df7cb694c9", size = 131087, upload-time = "2026-01-28T18:15:11.724Z" }, + { url = "https://files.pythonhosted.org/packages/d5/2e/e6782744700d6759ebce3043dcfa661fb61e2fb752b91cdeae9af12c2178/psutil-7.2.2-cp314-cp314t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fa4ecf83bcdf6e6c8f4449aff98eefb5d0604bf88cb883d7da3d8d2d909546a", size = 182383, upload-time = "2026-01-28T18:15:13.445Z" }, + { url = "https://files.pythonhosted.org/packages/57/49/0a41cefd10cb7505cdc04dab3eacf24c0c2cb158a998b8c7b1d27ee2c1f5/psutil-7.2.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e452c464a02e7dc7822a05d25db4cde564444a67e58539a00f929c51eddda0cf", size = 185210, upload-time = "2026-01-28T18:15:16.002Z" }, + { url = "https://files.pythonhosted.org/packages/dd/2c/ff9bfb544f283ba5f83ba725a3c5fec6d6b10b8f27ac1dc641c473dc390d/psutil-7.2.2-cp314-cp314t-win_amd64.whl", hash = "sha256:c7663d4e37f13e884d13994247449e9f8f574bc4655d509c3b95e9ec9e2b9dc1", size = 141228, upload-time = "2026-01-28T18:15:18.385Z" }, + { url = "https://files.pythonhosted.org/packages/f2/fc/f8d9c31db14fcec13748d373e668bc3bed94d9077dbc17fb0eebc073233c/psutil-7.2.2-cp314-cp314t-win_arm64.whl", hash = "sha256:11fe5a4f613759764e79c65cf11ebdf26e33d6dd34336f8a337aa2996d71c841", size = 136284, upload-time = "2026-01-28T18:15:19.912Z" }, + { url = "https://files.pythonhosted.org/packages/e7/36/5ee6e05c9bd427237b11b3937ad82bb8ad2752d72c6969314590dd0c2f6e/psutil-7.2.2-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ed0cace939114f62738d808fdcecd4c869222507e266e574799e9c0faa17d486", size = 129090, upload-time = "2026-01-28T18:15:22.168Z" }, + { url = "https://files.pythonhosted.org/packages/80/c4/f5af4c1ca8c1eeb2e92ccca14ce8effdeec651d5ab6053c589b074eda6e1/psutil-7.2.2-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:1a7b04c10f32cc88ab39cbf606e117fd74721c831c98a27dc04578deb0c16979", size = 129859, upload-time = "2026-01-28T18:15:23.795Z" }, + { url = "https://files.pythonhosted.org/packages/b5/70/5d8df3b09e25bce090399cf48e452d25c935ab72dad19406c77f4e828045/psutil-7.2.2-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:076a2d2f923fd4821644f5ba89f059523da90dc9014e85f8e45a5774ca5bc6f9", size = 155560, upload-time = "2026-01-28T18:15:25.976Z" }, + { url = "https://files.pythonhosted.org/packages/63/65/37648c0c158dc222aba51c089eb3bdfa238e621674dc42d48706e639204f/psutil-7.2.2-cp36-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b0726cecd84f9474419d67252add4ac0cd9811b04d61123054b9fb6f57df6e9e", size = 156997, upload-time = "2026-01-28T18:15:27.794Z" }, + { url = "https://files.pythonhosted.org/packages/8e/13/125093eadae863ce03c6ffdbae9929430d116a246ef69866dad94da3bfbc/psutil-7.2.2-cp36-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fd04ef36b4a6d599bbdb225dd1d3f51e00105f6d48a28f006da7f9822f2606d8", size = 148972, upload-time = "2026-01-28T18:15:29.342Z" }, + { url = "https://files.pythonhosted.org/packages/04/78/0acd37ca84ce3ddffaa92ef0f571e073faa6d8ff1f0559ab1272188ea2be/psutil-7.2.2-cp36-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:b58fabe35e80b264a4e3bb23e6b96f9e45a3df7fb7eed419ac0e5947c61e47cc", size = 148266, upload-time = "2026-01-28T18:15:31.597Z" }, + { url = "https://files.pythonhosted.org/packages/b4/90/e2159492b5426be0c1fef7acba807a03511f97c5f86b3caeda6ad92351a7/psutil-7.2.2-cp37-abi3-win_amd64.whl", hash = "sha256:eb7e81434c8d223ec4a219b5fc1c47d0417b12be7ea866e24fb5ad6e84b3d988", size = 137737, upload-time = "2026-01-28T18:15:33.849Z" }, + { url = "https://files.pythonhosted.org/packages/8c/c7/7bb2e321574b10df20cbde462a94e2b71d05f9bbda251ef27d104668306a/psutil-7.2.2-cp37-abi3-win_arm64.whl", hash = "sha256:8c233660f575a5a89e6d4cb65d9f938126312bca76d8fe087b947b3a1aaac9ee", size = 134617, upload-time = "2026-01-28T18:15:36.514Z" }, +] + [[package]] name = "pwdlib" version = "0.3.0" @@ -3930,19 +3987,19 @@ email = [ [[package]] name = "pydantic-ai" -version = "1.62.0" +version = "1.63.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pydantic-ai-slim", extra = ["ag-ui", "anthropic", "bedrock", "cli", "cohere", "evals", "fastmcp", "google", "groq", "huggingface", "logfire", "mcp", "mistral", "openai", "retries", "temporal", "ui", "vertexai", "xai"] }, ] -sdist = { url = "https://files.pythonhosted.org/packages/20/97/e3158fa976a29e9580ba1c59601590424bbb81179c359fd29de0dc23aa09/pydantic_ai-1.62.0.tar.gz", hash = "sha256:d6ae517e365ea3ea162ca8ae643f319e105b71b0b6218b83dcad1d1eb2e38c9b", size = 12130, upload-time = "2026-02-19T05:07:07.853Z" } +sdist = { url = "https://files.pythonhosted.org/packages/15/13/f0a11d43e3e5b2705dd7ee687d4b0fa9b02a7cd23ea4170b92c0a79eb1d3/pydantic_ai-1.63.0.tar.gz", hash = "sha256:269665fbc947d1d4238296a697c12a60d8b1b2c82536f2af4be801f73e165a92", size = 12130, upload-time = "2026-02-23T17:56:34.489Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/bc/7a/053aebfab576603e95fcfce1139de4a87e12bd5a2ef1ba00007a931c3ff0/pydantic_ai-1.62.0-py3-none-any.whl", hash = "sha256:1eb88f745ae045e63da41ad68966e8876c964d0f023fbf5d6a3f5d243370bd04", size = 7227, upload-time = "2026-02-19T05:06:58.341Z" }, + { url = "https://files.pythonhosted.org/packages/a6/4b/7cf9f5b2f8971a176be6ef218ffe6a30a5461bc2bfe914356881808ce159/pydantic_ai-1.63.0-py3-none-any.whl", hash = "sha256:586f63f391aa24e8b06bd0aeafbb1058de1d4f3bfe34c5f13d4f29a2d870afa5", size = 7229, upload-time = "2026-02-23T17:56:26.921Z" }, ] [[package]] name = "pydantic-ai-slim" -version = "1.62.0" +version = "1.63.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, @@ -3954,9 +4011,9 @@ dependencies = [ { name = "pydantic-graph" }, { name = "typing-inspection" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/cc/8d/6350a49f2e4b636efbcfc233221420ab576e4ba4edba38254cb84ae4a1e6/pydantic_ai_slim-1.62.0.tar.gz", hash = "sha256:00d84f659107bbbd88823a3d3dbe7348385935a9870b9d7d4ba799256f6b6983", size = 422452, upload-time = "2026-02-19T05:07:10.292Z" } +sdist = { url = "https://files.pythonhosted.org/packages/da/6d/2b5c0c60b42e6af49830f6a09b5d38fecdb1f20d9659152691eba95613b4/pydantic_ai_slim-1.63.0.tar.gz", hash = "sha256:9377afecdfe4bc17f5c9ed72c758e460703ac5876931aa2f18ace8ac0e69312a", size = 426862, upload-time = "2026-02-23T17:56:36.215Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/3d/67/21e9b3b0944568662e3790c936226bd48a9f27c6b5f27b5916f5857bc4d8/pydantic_ai_slim-1.62.0-py3-none-any.whl", hash = "sha256:5210073fadd46f65859a67da67845093c487f025fa430ed027151f22ec684ab2", size = 549296, upload-time = "2026-02-19T05:07:01.624Z" }, + { url = "https://files.pythonhosted.org/packages/f2/ca/c4e39eec1cff5a294b64313a8a959b38d326819e0f0a41f48e61ce019a22/pydantic_ai_slim-1.63.0-py3-none-any.whl", hash = "sha256:ed393b0f871b748171f65bec5191c3025b5abb8a4fc616afee17eb9dc2dfa15d", size = 554190, upload-time = "2026-02-23T17:56:29.533Z" }, ] [package.optional-dependencies] @@ -4144,7 +4201,7 @@ wheels = [ [[package]] name = "pydantic-evals" -version = "1.62.0" +version = "1.63.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, @@ -4154,9 +4211,9 @@ dependencies = [ { name = "pyyaml" }, { name = "rich" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/23/90/080f6722412263395d1d6d066ee90fa8bc2722ce097844220c2d9c946877/pydantic_evals-1.62.0.tar.gz", hash = "sha256:198c4bee936718a4acf6f504056b113e60b34eb49021df8889a394e14c803693", size = 56434, upload-time = "2026-02-19T05:07:11.793Z" } +sdist = { url = "https://files.pythonhosted.org/packages/99/43/21b6ddf65b56f7401c344f98e4e6258a02d2868c8a52a8b79c0e0e701029/pydantic_evals-1.63.0.tar.gz", hash = "sha256:eed56a7192e07c8be8cf16e53bb2ef652b4f7f7b8527650ac45fde865a4ecf9d", size = 56365, upload-time = "2026-02-23T17:56:37.71Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d8/b9/dc8dba744ec02b16c6fd1abe3fd8ef1b00fd05c72feef5069851b811952f/pydantic_evals-1.62.0-py3-none-any.whl", hash = "sha256:0ca7e10037ed90393c54b6cff41370d6d4bac63f8c878715599c58863c303db1", size = 67341, upload-time = "2026-02-19T05:07:03.83Z" }, + { url = "https://files.pythonhosted.org/packages/9b/f2/7174ad6abca2457e35a1b902ca4fa78aa8ee72e4ec2e9cd5dc8904014ec9/pydantic_evals-1.63.0-py3-none-any.whl", hash = "sha256:2e92a3af579a5670b2babf2044081d0ef99ab5a9ef141972616d71fd7e5bfd0e", size = 67279, upload-time = "2026-02-23T17:56:31.008Z" }, ] [[package]] @@ -4174,7 +4231,7 @@ wheels = [ [[package]] name = "pydantic-graph" -version = "1.62.0" +version = "1.63.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "httpx" }, @@ -4182,9 +4239,9 @@ dependencies = [ { name = "pydantic" }, { name = "typing-inspection" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/3b/b6/0b084c847ecd99624f4fbc5c8ecd3f67a2388a282a32612b2a68c3b3595f/pydantic_graph-1.62.0.tar.gz", hash = "sha256:efe56bee3a8ca35b11a3be6a5f7352419fe182ef1e1323a3267ee12dec95f3c7", size = 58529, upload-time = "2026-02-19T05:07:12.947Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7a/c8/aa3cb56552562b799f31e9de291c8bd88306308cfc9647d220dfff2bea18/pydantic_graph-1.63.0.tar.gz", hash = "sha256:5fd98bb22fa6181f0357a6ffad38a3214af12868bd46492d6456c5db434466b4", size = 58528, upload-time = "2026-02-23T17:56:39.118Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/f0/12/1a9cbcd59fd070ba72b0fe544caa6ca97758518643523ec2bf1162084e0d/pydantic_graph-1.62.0-py3-none-any.whl", hash = "sha256:abe0e7b356b4d3202b069ec020d8dd1f647f55e9a0e85cd272dab48250bde87d", size = 72350, upload-time = "2026-02-19T05:07:05.305Z" }, + { url = "https://files.pythonhosted.org/packages/a4/1c/8dcae24c824dd2690fbe7375083b369b10ed1ad773e2b9d1122bb6c0fcdc/pydantic_graph-1.63.0-py3-none-any.whl", hash = "sha256:d9b7a387116f358d470c042b07aa08125cadfcfa8c08ef01769746a489aef0d5", size = 72353, upload-time = "2026-02-23T17:56:32.304Z" }, ] [[package]] @@ -4353,28 +4410,85 @@ wheels = [ [[package]] name = "pytest-codspeed" -version = "4.2.0" +version = "4.3.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cffi" }, { name = "pytest" }, { name = "rich" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/e2/e8/27fcbe6516a1c956614a4b61a7fccbf3791ea0b992e07416e8948184327d/pytest_codspeed-4.2.0.tar.gz", hash = "sha256:04b5d0bc5a1851ba1504d46bf9d7dbb355222a69f2cd440d54295db721b331f7", size = 113263, upload-time = "2025-10-24T09:02:55.704Z" } +sdist = { url = "https://files.pythonhosted.org/packages/98/ab/eca41967d11c95392829a8b4bfa9220a51cffc4a33ec4653358000356918/pytest_codspeed-4.3.0.tar.gz", hash = "sha256:5230d9d65f39063a313ed1820df775166227ec5c20a1122968f85653d5efee48", size = 124745, upload-time = "2026-02-09T15:23:34.745Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/6c/b8/d599a466c50af3f04001877ae8b17c12b803f3b358235736b91a0769de0d/pytest_codspeed-4.2.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:609828b03972966b75b9b7416fa2570c4a0f6124f67e02d35cd3658e64312a7b", size = 261943, upload-time = "2025-10-24T09:02:37.962Z" }, - { url = "https://files.pythonhosted.org/packages/74/19/ccc1a2fcd28357a8db08ba6b60f381832088a3850abc262c8e0b3406491a/pytest_codspeed-4.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23a0c0fbf8bb4de93a3454fd9e5efcdca164c778aaef0a9da4f233d85cb7f5b8", size = 250782, upload-time = "2025-10-24T09:02:39.617Z" }, - { url = "https://files.pythonhosted.org/packages/b9/2d/f0083a2f14ecf008d961d40439a71da0ae0d568e5f8dc2fccd3e8a2ab3e4/pytest_codspeed-4.2.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2de87bde9fbc6fd53f0fd21dcf2599c89e0b8948d49f9bad224edce51c47e26b", size = 261960, upload-time = "2025-10-24T09:02:40.665Z" }, - { url = "https://files.pythonhosted.org/packages/5f/0c/1f514c553db4ea5a69dfbe2706734129acd0eca8d5101ec16f1dd00dbc0f/pytest_codspeed-4.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:95aeb2479ca383f6b18e2cc9ebcd3b03ab184980a59a232aea6f370bbf59a1e3", size = 250808, upload-time = "2025-10-24T09:02:42.07Z" }, - { url = "https://files.pythonhosted.org/packages/81/04/479905bd6653bc981c0554fcce6df52d7ae1594e1eefd53e6cf31810ec7f/pytest_codspeed-4.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7d4fefbd4ae401e2c60f6be920a0be50eef0c3e4a1f0a1c83962efd45be38b39", size = 262084, upload-time = "2025-10-24T09:02:43.155Z" }, - { url = "https://files.pythonhosted.org/packages/d2/46/d6f345d7907bac6cbb6224bd697ecbc11cf7427acc9e843c3618f19e3476/pytest_codspeed-4.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:309b4227f57fcbb9df21e889ea1ae191d0d1cd8b903b698fdb9ea0461dbf1dfe", size = 251100, upload-time = "2025-10-24T09:02:44.168Z" }, - { url = "https://files.pythonhosted.org/packages/de/dc/e864f45e994a50390ff49792256f1bdcbf42f170e3bc0470ee1a7d2403f3/pytest_codspeed-4.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:72aab8278452a6d020798b9e4f82780966adb00f80d27a25d1274272c54630d5", size = 262057, upload-time = "2025-10-24T09:02:45.791Z" }, - { url = "https://files.pythonhosted.org/packages/1d/1c/f1d2599784486879cf6579d8d94a3e22108f0e1f130033dab8feefd29249/pytest_codspeed-4.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:684fcd9491d810ded653a8d38de4835daa2d001645f4a23942862950664273f8", size = 251013, upload-time = "2025-10-24T09:02:46.937Z" }, - { url = "https://files.pythonhosted.org/packages/0c/fd/eafd24db5652a94b4d00fe9b309b607de81add0f55f073afb68a378a24b6/pytest_codspeed-4.2.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:50794dabea6ec90d4288904452051e2febace93e7edf4ca9f2bce8019dd8cd37", size = 262065, upload-time = "2025-10-24T09:02:48.018Z" }, - { url = "https://files.pythonhosted.org/packages/f9/14/8d9340d7dc0ae647991b28a396e16b3403e10def883cde90d6b663d3f7ec/pytest_codspeed-4.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a0ebd87f2a99467a1cfd8e83492c4712976e43d353ee0b5f71cbb057f1393aca", size = 251057, upload-time = "2025-10-24T09:02:49.102Z" }, - { url = "https://files.pythonhosted.org/packages/4b/39/48cf6afbca55bc7c8c93c3d4ae926a1068bcce3f0241709db19b078d5418/pytest_codspeed-4.2.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:dbbb2d61b85bef8fc7e2193f723f9ac2db388a48259d981bbce96319043e9830", size = 267983, upload-time = "2025-10-24T09:02:50.558Z" }, - { url = "https://files.pythonhosted.org/packages/33/86/4407341efb5dceb3e389635749ce1d670542d6ca148bd34f9d5334295faf/pytest_codspeed-4.2.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:748411c832147bfc85f805af78a1ab1684f52d08e14aabe22932bbe46c079a5f", size = 256732, upload-time = "2025-10-24T09:02:51.603Z" }, - { url = "https://files.pythonhosted.org/packages/25/0e/8cb71fd3ed4ed08c07aec1245aea7bc1b661ba55fd9c392db76f1978d453/pytest_codspeed-4.2.0-py3-none-any.whl", hash = "sha256:e81bbb45c130874ef99aca97929d72682733527a49f84239ba575b5cb843bab0", size = 113726, upload-time = "2025-10-24T09:02:54.785Z" }, + { url = "https://files.pythonhosted.org/packages/7b/64/800bdaeabd3eb126aff7e3e22dc45b2826305f61cbfd093284caf8d9ca01/pytest_codspeed-4.3.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b2acecc4126658abebc683b38121adec405a46e18a619d49d6154c6e60c5deb2", size = 347077, upload-time = "2026-02-09T15:23:17.2Z" }, + { url = "https://files.pythonhosted.org/packages/f3/f1/d69707440829adab86d078d5f1c8c070df116b1624f8eae4ff36933ba612/pytest_codspeed-4.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:619120775e92a3f43fb4ff4c256a251b1554c904d95e2154a382484283f0388a", size = 342234, upload-time = "2026-02-09T15:23:18.407Z" }, + { url = "https://files.pythonhosted.org/packages/d9/15/ec0ac1f022173b3134c9638f2a35f21fbb3142c75da066d9e49e5a8bb4bd/pytest_codspeed-4.3.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:dbeff1eb2f2e36df088658b556fa993e6937bf64ffb07406de4db16fd2b26874", size = 347076, upload-time = "2026-02-09T15:23:19.989Z" }, + { url = "https://files.pythonhosted.org/packages/a5/e8/1fe375794ad02b7835f378a7bcfa8fbac9acadefe600a782a7c4a7064db7/pytest_codspeed-4.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:878aad5e4bb7b401ad8d82f3af5186030cd2bd0d0446782e10dabb9db8827466", size = 342215, upload-time = "2026-02-09T15:23:20.954Z" }, + { url = "https://files.pythonhosted.org/packages/09/58/50df94e9a78e1c77818a492c90557eeb1309af025120c9a21e6375950c52/pytest_codspeed-4.3.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:527a3a02eaa3e4d4583adc4ba2327eef79628f3e1c682a4b959439551a72588e", size = 347395, upload-time = "2026-02-09T15:23:21.986Z" }, + { url = "https://files.pythonhosted.org/packages/e4/56/7dfbd3eefd112a14e6fb65f9ff31dacf2e9c381cb94b27332b81d2b13f8d/pytest_codspeed-4.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9858c2a6e1f391d5696757e7b6e9484749a7376c46f8b4dd9aebf093479a9667", size = 342625, upload-time = "2026-02-09T15:23:23.035Z" }, + { url = "https://files.pythonhosted.org/packages/7f/53/7255f6a25bc56ff1745b254b21545dfe0be2268f5b91ce78f7e8a908f0ad/pytest_codspeed-4.3.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:34f2fd8497456eefbd325673f677ea80d93bb1bc08a578c1fa43a09cec3d1879", size = 347325, upload-time = "2026-02-09T15:23:23.998Z" }, + { url = "https://files.pythonhosted.org/packages/2e/f8/82ae570d8b9ad30f33c9d4002a7a1b2740de0e090540c69a28e4f711ebe2/pytest_codspeed-4.3.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:df6a36a2a9da1406bc50428437f657f0bd8c842ae54bee5fb3ad30e01d50c0f5", size = 342558, upload-time = "2026-02-09T15:23:25.656Z" }, + { url = "https://files.pythonhosted.org/packages/b3/e1/55cfe9474f91d174c7a4b04d257b5fc6d4d06f3d3680f2da672ee59ccc10/pytest_codspeed-4.3.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bec30f4fc9c4973143cd80f0d33fa780e9fa3e01e4dbe8cedf229e72f1212c62", size = 347383, upload-time = "2026-02-09T15:23:26.68Z" }, + { url = "https://files.pythonhosted.org/packages/7f/3b/8fd781d959bbe789b3de8ce4c50d5706a684a0df377147dfb27b200c20c1/pytest_codspeed-4.3.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e6584e641cadf27d894ae90b87c50377232a97cbfd76ee0c7ecd0c056fa3f7f4", size = 342481, upload-time = "2026-02-09T15:23:27.686Z" }, + { url = "https://files.pythonhosted.org/packages/bb/0c/368045133c6effa2c665b1634b7b8a9c88b307f877fa31f1f8df47885b51/pytest_codspeed-4.3.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:df0d1f6ea594f29b745c634d66d5f5f1caa1c3abd2af82fea49d656038e8fc77", size = 353680, upload-time = "2026-02-09T15:23:28.726Z" }, + { url = "https://files.pythonhosted.org/packages/59/21/e543abcd72244294e25ae88ec3a9311ade24d6913f8c8f42569d671700bc/pytest_codspeed-4.3.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a2f5bb6d8898bea7db45e3c8b916ee48e36905b929477bb511b79c5a3ccacda4", size = 347888, upload-time = "2026-02-09T15:23:30.443Z" }, + { url = "https://files.pythonhosted.org/packages/55/d9/b8a53c20cf5b41042c205bb9d36d37da00418d30fd1a94bf9eb147820720/pytest_codspeed-4.3.0-py3-none-any.whl", hash = "sha256:05baff2a61dc9f3e92b92b9c2ab5fb45d9b802438f5373073f5766a91319ed7a", size = 125224, upload-time = "2026-02-09T15:23:33.774Z" }, +] + +[[package]] +name = "pytest-cov" +version = "7.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "coverage", extra = ["toml"] }, + { name = "pluggy" }, + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5e/f7/c933acc76f5208b3b00089573cf6a2bc26dc80a8aece8f52bb7d6b1855ca/pytest_cov-7.0.0.tar.gz", hash = "sha256:33c97eda2e049a0c5298e91f519302a1334c26ac65c1a483d6206fd458361af1", size = 54328, upload-time = "2025-09-09T10:57:02.113Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ee/49/1377b49de7d0c1ce41292161ea0f721913fa8722c19fb9c1e3aa0367eecb/pytest_cov-7.0.0-py3-none-any.whl", hash = "sha256:3b8e9558b16cc1479da72058bdecf8073661c7f57f7d3c5f22a1c23507f2d861", size = 22424, upload-time = "2025-09-09T10:57:00.695Z" }, +] + +[[package]] +name = "pytest-sugar" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, + { name = "termcolor" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0b/4e/60fed105549297ba1a700e1ea7b828044842ea27d72c898990510b79b0e2/pytest-sugar-1.1.1.tar.gz", hash = "sha256:73b8b65163ebf10f9f671efab9eed3d56f20d2ca68bda83fa64740a92c08f65d", size = 16533, upload-time = "2025-08-23T12:19:35.737Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/87/d5/81d38a91c1fdafb6711f053f5a9b92ff788013b19821257c2c38c1e132df/pytest_sugar-1.1.1-py3-none-any.whl", hash = "sha256:2f8319b907548d5b9d03a171515c1d43d2e38e32bd8182a1781eb20b43344cc8", size = 11440, upload-time = "2025-08-23T12:19:34.894Z" }, +] + +[[package]] +name = "pytest-timeout" +version = "2.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ac/82/4c9ecabab13363e72d880f2fb504c5f750433b2b6f16e99f4ec21ada284c/pytest_timeout-2.4.0.tar.gz", hash = "sha256:7e68e90b01f9eff71332b25001f85c75495fc4e3a836701876183c4bcfd0540a", size = 17973, upload-time = "2025-05-05T19:44:34.99Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fa/b6/3127540ecdf1464a00e5a01ee60a1b09175f6913f0644ac748494d9c4b21/pytest_timeout-2.4.0-py3-none-any.whl", hash = "sha256:c42667e5cdadb151aeb5b26d114aff6bdf5a907f176a007a30b940d3d865b5c2", size = 14382, upload-time = "2025-05-05T19:44:33.502Z" }, +] + +[[package]] +name = "pytest-xdist" +version = "3.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "execnet" }, + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/78/b4/439b179d1ff526791eb921115fca8e44e596a13efeda518b9d845a619450/pytest_xdist-3.8.0.tar.gz", hash = "sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1", size = 88069, upload-time = "2025-07-01T13:30:59.346Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ca/31/d4e37e9e550c2b92a9cbc2e4d0b7420a27224968580b5a447f420847c975/pytest_xdist-3.8.0-py3-none-any.whl", hash = "sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88", size = 46396, upload-time = "2025-07-01T13:30:56.632Z" }, +] + +[package.optional-dependencies] +psutil = [ + { name = "psutil" }, ] [[package]] @@ -5267,7 +5381,7 @@ wheels = [ [[package]] name = "strawberry-graphql" -version = "0.291.2" +version = "0.307.1" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cross-web" }, @@ -5276,9 +5390,9 @@ dependencies = [ { name = "python-dateutil" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/33/dd/e0e68f4b17da6ff5773fcd4bebf86fc4ff8620c854be816d047e9af8c4aa/strawberry_graphql-0.291.2.tar.gz", hash = "sha256:e6076604a786e8437bc64a27348584c082113442f072daf757b56e4863543a97", size = 217730, upload-time = "2026-02-06T14:40:51.173Z" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/6a/d2facfa92a81f8c1869e70eb2be09b229bd4d17711513dfea85e87f95317/strawberry_graphql-0.307.1.tar.gz", hash = "sha256:924d94e0218fbce081d6661a659bbd1f9b5bd02b9462e18bc46c203b4babbebe", size = 210786, upload-time = "2026-02-24T17:43:22Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/6f/14/93908a029605955e3411cdb0f2e8cfe170e5331da23357ed71d5c51b15bc/strawberry_graphql-0.291.2-py3-none-any.whl", hash = "sha256:f71d3669086c6747fd4760e6fafe3605d9a33f7d168886e5edd2b61a04972e56", size = 316389, upload-time = "2026-02-06T14:40:53.482Z" }, + { url = "https://files.pythonhosted.org/packages/19/57/258b718472733bf077abf92588f06d251a77d7f180b814097c6a5dab7941/strawberry_graphql-0.307.1-py3-none-any.whl", hash = "sha256:7eca104e81d0108435326ee60a3c3c2e498f73949898ec7a4f274c0de283149b", size = 307503, upload-time = "2026-02-24T17:43:23.565Z" }, ] [[package]] @@ -5542,17 +5656,17 @@ wheels = [ [[package]] name = "typer" -version = "0.21.1" +version = "0.24.1" source = { registry = "https://pypi.org/simple" } dependencies = [ + { name = "annotated-doc" }, { name = "click" }, { name = "rich" }, { name = "shellingham" }, - { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/36/bf/8825b5929afd84d0dabd606c67cd57b8388cb3ec385f7ef19c5cc2202069/typer-0.21.1.tar.gz", hash = "sha256:ea835607cd752343b6b2b7ce676893e5a0324082268b48f27aa058bdb7d2145d", size = 110371, upload-time = "2026-01-06T11:21:10.989Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f5/24/cb09efec5cc954f7f9b930bf8279447d24618bb6758d4f6adf2574c41780/typer-0.24.1.tar.gz", hash = "sha256:e39b4732d65fbdcde189ae76cf7cd48aeae72919dea1fdfc16593be016256b45", size = 118613, upload-time = "2026-02-21T16:54:40.609Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/a0/1d/d9257dd49ff2ca23ea5f132edf1281a0c4f9de8a762b9ae399b670a59235/typer-0.21.1-py3-none-any.whl", hash = "sha256:7985e89081c636b88d172c2ee0cfe33c253160994d47bdfdc302defd7d1f1d01", size = 47381, upload-time = "2026-01-06T11:21:09.824Z" }, + { url = "https://files.pythonhosted.org/packages/4a/91/48db081e7a63bb37284f9fbcefda7c44c277b18b0e13fbc36ea2335b71e6/typer-0.24.1-py3-none-any.whl", hash = "sha256:112c1f0ce578bfb4cab9ffdabc68f031416ebcc216536611ba21f04e9aa84c9e", size = 56085, upload-time = "2026-02-21T16:54:41.616Z" }, ] [[package]] @@ -6000,14 +6114,14 @@ wheels = [ [[package]] name = "werkzeug" -version = "3.1.5" +version = "3.1.6" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markupsafe" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/5a/70/1469ef1d3542ae7c2c7b72bd5e3a4e6ee69d7978fa8a3af05a38eca5becf/werkzeug-3.1.5.tar.gz", hash = "sha256:6a548b0e88955dd07ccb25539d7d0cc97417ee9e179677d22c7041c8f078ce67", size = 864754, upload-time = "2026-01-08T17:49:23.247Z" } +sdist = { url = "https://files.pythonhosted.org/packages/61/f1/ee81806690a87dab5f5653c1f146c92bc066d7f4cebc603ef88eb9e13957/werkzeug-3.1.6.tar.gz", hash = "sha256:210c6bede5a420a913956b4791a7f4d6843a43b6fcee4dfa08a65e93007d0d25", size = 864736, upload-time = "2026-02-19T15:17:18.884Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ad/e4/8d97cca767bcc1be76d16fb76951608305561c6e056811587f36cb1316a8/werkzeug-3.1.5-py3-none-any.whl", hash = "sha256:5111e36e91086ece91f93268bb39b4a35c1e6f1feac762c9c822ded0a4e322dc", size = 225025, upload-time = "2026-01-08T17:49:21.859Z" }, + { url = "https://files.pythonhosted.org/packages/4d/ec/d58832f89ede95652fd01f4f24236af7d32b70cab2196dfcc2d2fd13c5c2/werkzeug-3.1.6-py3-none-any.whl", hash = "sha256:7ddf3357bb9564e407607f988f683d72038551200c704012bb9a4c523d42f131", size = 225166, upload-time = "2026-02-19T15:17:17.475Z" }, ] [[package]]