Browse Source

Merge branch 'master' into feat/exception-on-duplicate-path

pull/5595/head
Irfanuddin Shafi Ahmed 2 years ago
committed by GitHub
parent
commit
51f8280bea
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      .github/workflows/build-docs.yml
  2. 4
      .github/workflows/deploy-docs.yml
  3. 2
      .github/workflows/latest-changes.yml
  4. 2
      .github/workflows/notify-translations.yml
  5. 2
      .github/workflows/people.yml
  6. 6
      .github/workflows/publish.yml
  7. 2
      .github/workflows/smokeshow.yml
  8. 12
      .github/workflows/test.yml
  9. 24
      CITATION.cff
  10. 8
      README.md
  11. 2
      docs/de/docs/features.md
  12. 14
      docs/em/docs/deployment/concepts.md
  13. 26
      docs/em/docs/deployment/docker.md
  14. 8
      docs/em/docs/deployment/server-workers.md
  15. 68
      docs/em/docs/external-links.md
  16. 2
      docs/em/docs/help-fastapi.md
  17. 2
      docs/em/docs/project-generation.md
  18. 22
      docs/en/data/external_links.yml
  19. 2
      docs/en/data/sponsors.yml
  20. 3
      docs/en/docs/about/index.md
  21. 4
      docs/en/docs/advanced/additional-status-codes.md
  22. 16
      docs/en/docs/advanced/advanced-dependencies.md
  23. 6
      docs/en/docs/advanced/generate-clients.md
  24. 12
      docs/en/docs/advanced/security/http-basic-auth.md
  25. 32
      docs/en/docs/advanced/security/oauth2-scopes.md
  26. 12
      docs/en/docs/advanced/settings.md
  27. 4
      docs/en/docs/advanced/testing-dependencies.md
  28. 6
      docs/en/docs/advanced/websockets.md
  29. 70
      docs/en/docs/external-links.md
  30. 5
      docs/en/docs/fastapi-people.md
  31. 5
      docs/en/docs/features.md
  32. 2
      docs/en/docs/help-fastapi.md
  33. 3
      docs/en/docs/help/index.md
  34. 8
      docs/en/docs/how-to/separate-openapi-schemas.md
  35. 2
      docs/en/docs/how-to/sql-databases-peewee.md
  36. 48
      docs/en/docs/img/sponsors/bump-sh-banner.svg
  37. 56
      docs/en/docs/img/sponsors/bump-sh.svg
  38. 15
      docs/en/docs/index.md
  39. 3
      docs/en/docs/js/chat.js
  40. 5
      docs/en/docs/learn/index.md
  41. 24
      docs/en/docs/python-types.md
  42. 25
      docs/en/docs/reference/apirouter.md
  43. 13
      docs/en/docs/reference/background.md
  44. 32
      docs/en/docs/reference/dependencies.md
  45. 3
      docs/en/docs/reference/encoders.md
  46. 22
      docs/en/docs/reference/exceptions.md
  47. 32
      docs/en/docs/reference/fastapi.md
  48. 13
      docs/en/docs/reference/httpconnection.md
  49. 7
      docs/en/docs/reference/index.md
  50. 46
      docs/en/docs/reference/middleware.md
  51. 11
      docs/en/docs/reference/openapi/docs.md
  52. 5
      docs/en/docs/reference/openapi/index.md
  53. 5
      docs/en/docs/reference/openapi/models.md
  54. 36
      docs/en/docs/reference/parameters.md
  55. 18
      docs/en/docs/reference/request.md
  56. 15
      docs/en/docs/reference/response.md
  57. 166
      docs/en/docs/reference/responses.md
  58. 76
      docs/en/docs/reference/security/index.md
  59. 14
      docs/en/docs/reference/staticfiles.md
  60. 39
      docs/en/docs/reference/status.md
  61. 14
      docs/en/docs/reference/templating.md
  62. 14
      docs/en/docs/reference/testclient.md
  63. 23
      docs/en/docs/reference/uploadfile.md
  64. 70
      docs/en/docs/reference/websockets.md
  65. 34
      docs/en/docs/release-notes.md
  66. 3
      docs/en/docs/resources/index.md
  67. 4
      docs/en/docs/tutorial/background-tasks.md
  68. 4
      docs/en/docs/tutorial/bigger-applications.md
  69. 8
      docs/en/docs/tutorial/body-fields.md
  70. 18
      docs/en/docs/tutorial/body-multiple-params.md
  71. 36
      docs/en/docs/tutorial/body-nested-models.md
  72. 8
      docs/en/docs/tutorial/body-updates.md
  73. 12
      docs/en/docs/tutorial/body.md
  74. 8
      docs/en/docs/tutorial/cookie-params.md
  75. 52
      docs/en/docs/tutorial/dependencies/classes-as-dependencies.md
  76. 16
      docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md
  77. 8
      docs/en/docs/tutorial/dependencies/dependencies-with-yield.md
  78. 4
      docs/en/docs/tutorial/dependencies/global-dependencies.md
  79. 14
      docs/en/docs/tutorial/dependencies/index.md
  80. 16
      docs/en/docs/tutorial/dependencies/sub-dependencies.md
  81. 2
      docs/en/docs/tutorial/encoder.md
  82. 8
      docs/en/docs/tutorial/extra-data-types.md
  83. 10
      docs/en/docs/tutorial/extra-models.md
  84. 16
      docs/en/docs/tutorial/header-params.md
  85. 2
      docs/en/docs/tutorial/metadata.md
  86. 10
      docs/en/docs/tutorial/path-operation-configuration.md
  87. 26
      docs/en/docs/tutorial/path-params-numeric-validations.md
  88. 22
      docs/en/docs/tutorial/path-params.md
  89. 95
      docs/en/docs/tutorial/query-params-str-validations.md
  90. 30
      docs/en/docs/tutorial/query-params.md
  91. 28
      docs/en/docs/tutorial/request-files.md
  92. 8
      docs/en/docs/tutorial/request-forms-and-files.md
  93. 8
      docs/en/docs/tutorial/request-forms.md
  94. 28
      docs/en/docs/tutorial/response-model.md
  95. 18
      docs/en/docs/tutorial/schema-extra-example.md
  96. 12
      docs/en/docs/tutorial/security/first-steps.md
  97. 24
      docs/en/docs/tutorial/security/get-current-user.md
  98. 16
      docs/en/docs/tutorial/security/oauth2-jwt.md
  99. 20
      docs/en/docs/tutorial/security/simple-oauth2.md
  100. 20
      docs/en/docs/tutorial/sql-databases.md

20
.github/workflows/build-docs.yml

@ -17,7 +17,7 @@ jobs:
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# For pull requests it's not necessary to checkout the code but for master it is
- uses: dorny/paths-filter@v2
id: filter
@ -35,7 +35,7 @@ jobs:
outputs:
langs: ${{ steps.show-langs.outputs.langs }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
@ -44,14 +44,17 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v06
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-tests.txt') }}-v06
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-docs.txt
# Install MkDocs Material Insiders here just to put it in the cache for the rest of the steps
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
run: |
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
- name: Export Language Codes
id: show-langs
run: |
@ -71,7 +74,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
@ -80,13 +83,16 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v06
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt', 'requirements-docs-tests.txt') }}-v06
- name: Install docs extras
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-docs.txt
- name: Install Material for MkDocs Insiders
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
run: pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
run: |
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/griffe-typing-deprecated.git
pip install git+https://${{ secrets.FASTAPI_MKDOCS_MATERIAL_INSIDERS }}@github.com/pawamoy-insiders/mkdocstrings-python.git
- name: Update Languages
run: python ./scripts/docs.py update-languages
- uses: actions/cache@v3

4
.github/workflows/deploy-docs.yml

@ -14,14 +14,14 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Clean site
run: |
rm -rf ./site
mkdir ./site
- name: Download Artifact Docs
id: download
uses: dawidd6/[email protected]7.0
uses: dawidd6/[email protected]8.0
with:
if_no_artifact_found: ignore
github_token: ${{ secrets.FASTAPI_PREVIEW_DOCS_DOWNLOAD_ARTIFACTS }}

2
.github/workflows/latest-changes.yml

@ -24,7 +24,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# To allow latest-changes to commit to the main branch
token: ${{ secrets.FASTAPI_LATEST_CHANGES }}

2
.github/workflows/notify-translations.yml

@ -23,7 +23,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

2
.github/workflows/people.yml

@ -19,7 +19,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Ref: https://github.com/actions/runner/issues/2033
- name: Fix git safe.directory in container
run: mkdir -p /home/runner/work/_temp/_github_home && printf "[safe]\n\tdirectory = /github/workspace" > /home/runner/work/_temp/_github_home/.gitconfig

6
.github/workflows/publish.yml

@ -13,11 +13,11 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.10"
# Issue ref: https://github.com/actions/setup-python/issues/436
# cache: "pip"
cache-dependency-path: pyproject.toml
@ -32,7 +32,7 @@ jobs:
- name: Build distribution
run: python -m build
- name: Publish
uses: pypa/[email protected].6
uses: pypa/[email protected].10
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Dump GitHub context

2
.github/workflows/smokeshow.yml

@ -24,7 +24,7 @@ jobs:
- run: pip install smokeshow
- uses: dawidd6/[email protected]7.0
- uses: dawidd6/[email protected]8.0
with:
github_token: ${{ secrets.FASTAPI_SMOKESHOW_DOWNLOAD_ARTIFACTS }}
workflow: test.yml

12
.github/workflows/test.yml

@ -17,7 +17,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
@ -29,7 +29,7 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v06
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v06
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
pydantic-version: ["pydantic-v1", "pydantic-v2"]
fail-fast: false
steps:
@ -50,7 +50,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
@ -62,7 +62,7 @@ jobs:
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v06
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt', 'requirements-docs-tests.txt') }}-test-v06
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
@ -92,7 +92,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.8'

24
CITATION.cff

@ -0,0 +1,24 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: FastAPI
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Sebastián
family-names: Ramírez
email: [email protected]
identifiers:
repository-code: 'https://github.com/tiangolo/fastapi'
url: 'https://fastapi.tiangolo.com'
abstract: >-
FastAPI framework, high performance, easy to learn, fast to code,
ready for production
keywords:
- fastapi
- pydantic
- starlette
license: MIT

8
README.md

@ -27,7 +27,7 @@
---
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints.
The key features are:
@ -50,7 +50,7 @@ The key features are:
<a href="https://platform.sh/try-it-now/?utm_source=fastapi-signup&utm_medium=banner&utm_campaign=FastAPI-signup-June-2023" target="_blank" title="Build, run and scale your apps on a modern, reliable, and secure PaaS."><img src="https://fastapi.tiangolo.com/img/sponsors/platform-sh.png"></a>
<a href="https://www.buildwithfern.com/?utm_source=tiangolo&utm_medium=website&utm_campaign=main-badge" target="_blank" title="Fern | SDKs and API docs"><img src="https://fastapi.tiangolo.com/img/sponsors/fern.svg"></a>
<a href="https://www.porter.run" target="_blank" title="Deploy FastAPI on AWS with a few clicks"><img src="https://fastapi.tiangolo.com/img/sponsors/porter.png"></a>
<a href="https://bump.sh/fastapi?utm_source=fastapi&utm_medium=referral&utm_campaign=sponsor" target="_blank" title="Automate FastAPI documentation generation with Bump.sh"><img src="https://fastapi.tiangolo.com/img/sponsors/bump-sh.png"></a>
<a href="https://bump.sh/fastapi?utm_source=fastapi&utm_medium=referral&utm_campaign=sponsor" target="_blank" title="Automate FastAPI documentation generation with Bump.sh"><img src="https://fastapi.tiangolo.com/img/sponsors/bump-sh.svg"></a>
<a href="https://www.deta.sh/?ref=fastapi" target="_blank" title="The launchpad for all your (team's) ideas"><img src="https://fastapi.tiangolo.com/img/sponsors/deta.svg"></a>
<a href="https://training.talkpython.fm/fastapi-courses" target="_blank" title="FastAPI video courses on demand from people you trust"><img src="https://fastapi.tiangolo.com/img/sponsors/talkpython.png"></a>
<a href="https://testdriven.io/courses/tdd-fastapi/" target="_blank" title="Learn to build high-quality web apps with best practices"><img src="https://fastapi.tiangolo.com/img/sponsors/testdriven.svg"></a>
@ -120,7 +120,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
## Requirements
Python 3.7+
Python 3.8+
FastAPI stands on the shoulders of giants:
@ -336,7 +336,7 @@ You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard **Python 3.7+**.
Just standard **Python 3.8+**.
For example, for an `int`:

2
docs/de/docs/features.md

@ -25,7 +25,7 @@ Mit einer interaktiven API-Dokumentation und explorativen webbasierten Benutzers
### Nur modernes Python
Alles basiert auf **Python 3.6 Typ**-Deklarationen (dank Pydantic). Es muss keine neue Syntax gelernt werden, nur standardisiertes modernes Python.
Alles basiert auf **Python 3.8 Typ**-Deklarationen (dank Pydantic). Es muss keine neue Syntax gelernt werden, nur standardisiertes modernes Python.

14
docs/em/docs/deployment/concepts.md

@ -43,7 +43,7 @@
* ⏮️ 🔢 🦲 💖 Certbot 📄 🔕
* ✳
* ⏮️ 🔢 🦲 💖 Certbot 📄 🔕
* Kubernete ⏮️ 🚧 🕹 💖 👌
* Kubernetes ⏮️ 🚧 🕹 💖 👌
* ⏮️ 🔢 🦲 💖 🛂-👨‍💼 📄 🔕
* 🍵 🔘 ☁ 🐕‍🦺 🍕 👫 🐕‍🦺 (✍ 🔛 👶)
@ -115,7 +115,7 @@
🖼 🧰 👈 💪 👉 👨‍🏭:
* ☁
* Kubernete
* Kubernetes
* ☁ ✍
* ☁ 🐝 📳
* ✳
@ -165,7 +165,7 @@
🖼, 👉 💪 🍵:
* ☁
* Kubernete
* Kubernetes
* ☁ ✍
* ☁ 🐝 📳
* ✳
@ -233,15 +233,15 @@
* 🐁 🔜 **🛠️ 👨‍💼** 👂 🔛 **📢** &amp; **⛴**, 🧬 🔜 ✔️ **💗 Uvicorn 👨‍🏭 🛠️**
* **Uvicorn** 🛠️ **Uvicorn 👨‍🏭**
* 1️⃣ Uvicorn **🛠️ 👨‍💼** 🔜 👂 🔛 **📢** &amp; **⛴**, &amp; ⚫️ 🔜 ▶️ **💗 Uvicorn 👨‍🏭 🛠️**
* **Kubernete** &amp; 🎏 📎 **📦 ⚙️**
* **Kubernetes** &amp; 🎏 📎 **📦 ⚙️**
* 🕳 **☁** 🧽 🔜 👂 🔛 **📢** &amp; **⛴**. 🧬 🔜 ✔️ **💗 📦**, 🔠 ⏮️ **1️⃣ Uvicorn 🛠️** 🏃‍♂
* **☁ 🐕‍🦺** 👈 🍵 👉 👆
* ☁ 🐕‍🦺 🔜 🎲 **🍵 🧬 👆**. ⚫️ 🔜 🎲 ➡️ 👆 🔬 **🛠️ 🏃**, ⚖️ **📦 🖼** ⚙️, 🙆 💼, ⚫️ 🔜 🌅 🎲 **👁 Uvicorn 🛠️**, &amp; ☁ 🐕‍🦺 🔜 🈚 🔁 ⚫️.
!!! tip
🚫 😟 🚥 👫 🏬 🔃 **📦**, ☁, ⚖️ Kubernete 🚫 ⚒ 📚 🔑.
🚫 😟 🚥 👫 🏬 🔃 **📦**, ☁, ⚖️ Kubernetes 🚫 ⚒ 📚 🔑.
👤 🔜 💬 👆 🌅 🔃 📦 🖼, ☁, Kubernete, ♒️. 🔮 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
👤 🔜 💬 👆 🌅 🔃 📦 🖼, ☁, Kubernetes, ♒️. 🔮 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
## ⏮️ 🔁 ⏭ ▶️
@ -268,7 +268,7 @@
📥 💪 💭:
* "🕑 📦" Kubernete 👈 🏃 ⏭ 👆 📱 📦
* "🕑 📦" Kubernetes 👈 🏃 ⏭ 👆 📱 📦
* 🎉 ✍ 👈 🏃 ⏮️ 🔁 &amp; ⤴️ ▶️ 👆 🈸
* 👆 🔜 💪 🌌 ▶️/⏏ *👈* 🎉 ✍, 🔍 ❌, ♒️.

26
docs/em/docs/deployment/docker.md

@ -74,7 +74,7 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
, 👆 🔜 🏃 **💗 📦** ⏮️ 🎏 👜, 💖 💽, 🐍 🈸, 🕸 💽 ⏮️ 😥 🕸 🈸, &amp; 🔗 👫 👯‍♂️ 📨 👫 🔗 🕸.
🌐 📦 🧾 ⚙️ (💖 ☁ ⚖️ Kubernete) ✔️ 👫 🕸 ⚒ 🛠️ 🔘 👫.
🌐 📦 🧾 ⚙️ (💖 ☁ ⚖️ Kubernetes) ✔️ 👫 🕸 ⚒ 🛠️ 🔘 👫.
## 📦 &amp; 🛠️
@ -96,7 +96,7 @@ CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
👉 ⚫️❔ 👆 🔜 💚 **🏆 💼**, 🖼:
* ⚙️ **Kubernete** ⚖️ 🎏 🧰
* ⚙️ **Kubernetes** ⚖️ 🎏 🧰
* 🕐❔ 🏃‍♂ 🔛 **🍓 👲**
* ⚙️ ☁ 🐕‍🦺 👈 🔜 🏃 📦 🖼 👆, ♒️.
@ -395,7 +395,7 @@ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
⚫️ 💪 ➕1️⃣ 📦, 🖼 ⏮️ <a href="https://traefik.io/" class="external-link" target="_blank">Traefik</a>, 🚚 **🇺🇸🔍** &amp; **🏧** 🛠️ **📄**.
!!! tip
Traefik ✔️ 🛠️ ⏮️ ☁, Kubernete, &amp; 🎏, ⚫️ 📶 ⏩ ⚒ 🆙 &amp; 🔗 🇺🇸🔍 👆 📦 ⏮️ ⚫️.
Traefik ✔️ 🛠️ ⏮️ ☁, Kubernetes, &amp; 🎏, ⚫️ 📶 ⏩ ⚒ 🆙 &amp; 🔗 🇺🇸🔍 👆 📦 ⏮️ ⚫️.
👐, 🇺🇸🔍 💪 🍵 ☁ 🐕‍🦺 1️⃣ 👫 🐕‍🦺 (⏪ 🏃 🈸 📦).
@ -403,7 +403,7 @@ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
📤 🛎 ➕1️⃣ 🧰 🈚 **▶️ &amp; 🏃‍♂** 👆 📦.
⚫️ 💪 **☁** 🔗, **☁ ✍**, **Kubernete**, **☁ 🐕‍🦺**, ♒️.
⚫️ 💪 **☁** 🔗, **☁ ✍**, **Kubernetes**, **☁ 🐕‍🦺**, ♒️.
🌅 (⚖️ 🌐) 💼, 📤 🙅 🎛 🛠️ 🏃 📦 🔛 🕴 &amp; 🛠️ ⏏ 🔛 ❌. 🖼, ☁, ⚫️ 📋 ⏸ 🎛 `--restart`.
@ -413,7 +413,7 @@ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
🚥 👆 ✔️ <abbr title="A group of machines that are configured to be connected and work together in some way.">🌑</abbr> 🎰 ⏮️ **☁**, ☁ 🐝 📳, 🖖, ⚖️ ➕1️⃣ 🎏 🏗 ⚙️ 🛠️ 📎 📦 🔛 💗 🎰, ⤴️ 👆 🔜 🎲 💚 **🍵 🧬** **🌑 🎚** ↩️ ⚙️ **🛠️ 👨‍💼** (💖 🐁 ⏮️ 👨‍🏭) 🔠 📦.
1️⃣ 📚 📎 📦 🧾 ⚙️ 💖 Kubernete 🛎 ✔️ 🛠️ 🌌 🚚 **🧬 📦** ⏪ 🔗 **📐 ⚖** 📨 📨. 🌐 **🌑 🎚**.
1️⃣ 📚 📎 📦 🧾 ⚙️ 💖 Kubernetes 🛎 ✔️ 🛠️ 🌌 🚚 **🧬 📦** ⏪ 🔗 **📐 ⚖** 📨 📨. 🌐 **🌑 🎚**.
📚 💼, 👆 🔜 🎲 💚 🏗 **☁ 🖼 ⚪️➡️ 🖌** [🔬 🔛](#dockerfile), ❎ 👆 🔗, &amp; 🏃‍♂ **👁 Uvicorn 🛠️** ↩️ 🏃‍♂ 🕳 💖 🐁 ⏮️ Uvicorn 👨‍🏭.
@ -430,7 +430,7 @@ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
### 1️⃣ 📐 ⚙ - 💗 👨‍🏭 📦
🕐❔ 👷 ⏮️ **Kubernete** ⚖️ 🎏 📎 📦 🧾 ⚙️, ⚙️ 👫 🔗 🕸 🛠️ 🔜 ✔ 👁 **📐 ⚙** 👈 👂 🔛 👑 **⛴** 📶 📻 (📨) 🎲 **💗 📦** 🏃 👆 📱.
🕐❔ 👷 ⏮️ **Kubernetes** ⚖️ 🎏 📎 📦 🧾 ⚙️, ⚙️ 👫 🔗 🕸 🛠️ 🔜 ✔ 👁 **📐 ⚙** 👈 👂 🔛 👑 **⛴** 📶 📻 (📨) 🎲 **💗 📦** 🏃 👆 📱.
🔠 👫 📦 🏃‍♂ 👆 📱 🔜 🛎 ✔️ **1️⃣ 🛠️** (✅ Uvicorn 🛠️ 🏃 👆 FastAPI 🈸). 👫 🔜 🌐 **🌓 📦**, 🏃‍♂ 🎏 👜, ✋️ 🔠 ⏮️ 🚮 👍 🛠️, 💾, ♒️. 👈 🌌 👆 🔜 ✊ 📈 **🛠️** **🎏 🐚** 💽, ⚖️ **🎏 🎰**.
@ -489,7 +489,7 @@ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
🚥 👆 🏃 **👁 🛠️ 📍 📦** 👆 🔜 ✔️ 🌅 ⚖️ 🌘 👍-🔬, ⚖, &amp; 📉 💸 💾 🍴 🔠 👈 📦 (🌅 🌘 1️⃣ 🚥 👫 🔁).
&amp; ⤴️ 👆 💪 ⚒ 👈 🎏 💾 📉 &amp; 📄 👆 📳 👆 📦 🧾 ⚙️ (🖼 **Kubernete**). 👈 🌌 ⚫️ 🔜 💪 **🔁 📦** **💪 🎰** ✊ 🔘 🏧 💸 💾 💪 👫, &amp; 💸 💪 🎰 🌑.
&amp; ⤴️ 👆 💪 ⚒ 👈 🎏 💾 📉 &amp; 📄 👆 📳 👆 📦 🧾 ⚙️ (🖼 **Kubernetes**). 👈 🌌 ⚫️ 🔜 💪 **🔁 📦** **💪 🎰** ✊ 🔘 🏧 💸 💾 💪 👫, &amp; 💸 💪 🎰 🌑.
🚥 👆 🈸 **🙅**, 👉 🔜 🎲 **🚫 ⚠**, &amp; 👆 💪 🚫 💪 ✔ 🏋️ 💾 📉. ✋️ 🚥 👆 **⚙️ 📚 💾** (🖼 ⏮️ **🎰 🏫** 🏷), 👆 🔜 ✅ ❔ 🌅 💾 👆 😩 &amp; 🔆 **🔢 📦** 👈 🏃 **🔠 🎰** (&amp; 🎲 🚮 🌖 🎰 👆 🌑).
@ -497,14 +497,14 @@ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
## ⏮️ 🔁 ⏭ ▶️ &amp; 📦
🚥 👆 ⚙️ 📦 (✅ ☁, Kubernete), ⤴️ 📤 2️⃣ 👑 🎯 👆 💪 ⚙️.
🚥 👆 ⚙️ 📦 (✅ ☁, Kubernetes), ⤴️ 📤 2️⃣ 👑 🎯 👆 💪 ⚙️.
### 💗 📦
🚥 👆 ✔️ **💗 📦**, 🎲 🔠 1️⃣ 🏃 **👁 🛠️** (🖼, **Kubernete** 🌑), ⤴️ 👆 🔜 🎲 💚 ✔️ **🎏 📦** 🔨 👷 **⏮️ 📶** 👁 📦, 🏃 👁 🛠️, **⏭** 🏃 🔁 👨‍🏭 📦.
🚥 👆 ✔️ **💗 📦**, 🎲 🔠 1️⃣ 🏃 **👁 🛠️** (🖼, **Kubernetes** 🌑), ⤴️ 👆 🔜 🎲 💚 ✔️ **🎏 📦** 🔨 👷 **⏮️ 📶** 👁 📦, 🏃 👁 🛠️, **⏭** 🏃 🔁 👨‍🏭 📦.
!!! info
🚥 👆 ⚙️ Kubernete, 👉 🔜 🎲 <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" class="external-link" target="_blank">🕑 📦</a>.
🚥 👆 ⚙️ Kubernetes, 👉 🔜 🎲 <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" class="external-link" target="_blank">🕑 📦</a>.
🚥 👆 ⚙️ 💼 📤 🙅‍♂ ⚠ 🏃‍♂ 👈 ⏮️ 📶 **💗 🕰 🔗** (🖼 🚥 👆 🚫 🏃 💽 🛠️, ✋️ ✅ 🚥 💽 🔜), ⤴️ 👆 💪 🚮 👫 🔠 📦 ▶️️ ⏭ ▶️ 👑 🛠️.
@ -574,7 +574,7 @@ COPY ./app /app/app
### 🕐❔ ⚙️
👆 🔜 🎲 **🚫** ⚙️ 👉 🛂 🧢 🖼 (⚖️ 🙆 🎏 🎏 1️⃣) 🚥 👆 ⚙️ **Kubernete** (⚖️ 🎏) &amp; 👆 ⏪ ⚒ **🧬** 🌑 🎚, ⏮️ 💗 **📦**. 📚 💼, 👆 👍 📆 **🏗 🖼 ⚪️➡️ 🖌** 🔬 🔛: [🏗 ☁ 🖼 FastAPI](#build-a-docker-image-for-fastapi).
👆 🔜 🎲 **🚫** ⚙️ 👉 🛂 🧢 🖼 (⚖️ 🙆 🎏 🎏 1️⃣) 🚥 👆 ⚙️ **Kubernetes** (⚖️ 🎏) &amp; 👆 ⏪ ⚒ **🧬** 🌑 🎚, ⏮️ 💗 **📦**. 📚 💼, 👆 👍 📆 **🏗 🖼 ⚪️➡️ 🖌** 🔬 🔛: [🏗 ☁ 🖼 FastAPI](#build-a-docker-image-for-fastapi).
👉 🖼 🔜 ⚠ ✴️ 🎁 💼 🔬 🔛 [📦 ⏮️ 💗 🛠️ &amp; 🎁 💼](#containers-with-multiple-processes-and-special-cases). 🖼, 🚥 👆 🈸 **🙅 🥃** 👈 ⚒ 🔢 🔢 🛠️ ⚓️ 🔛 💽 👷 👍, 👆 🚫 💚 😥 ⏮️ ❎ 🛠️ 🧬 🌑 🎚, &amp; 👆 🚫 🏃 🌅 🌘 1️⃣ 📦 ⏮️ 👆 📱. ⚖️ 🚥 👆 🛠️ ⏮️ **☁ ✍**, 🏃 🔛 👁 💽, ♒️.
@ -585,7 +585,7 @@ COPY ./app /app/app
🖼:
* ⏮️ **☁ ✍** 👁 💽
* ⏮️ **Kubernete** 🌑
* ⏮️ **Kubernetes** 🌑
* ⏮️ ☁ 🐝 📳 🌑
* ⏮️ ➕1️⃣ 🧰 💖 🖖
* ⏮️ ☁ 🐕‍🦺 👈 ✊ 👆 📦 🖼 &amp; 🛠️ ⚫️
@ -682,7 +682,7 @@ CMD ["uvicorn", "app.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port"
## 🌃
⚙️ 📦 ⚙️ (✅ ⏮️ **☁** &amp; **Kubernete**) ⚫️ ▶️️ 📶 🎯 🍵 🌐 **🛠️ 🔧**:
⚙️ 📦 ⚙️ (✅ ⏮️ **☁** &amp; **Kubernetes**) ⚫️ ▶️️ 📶 🎯 🍵 🌐 **🛠️ 🔧**:
* 🇺🇸🔍
* 🏃‍♂ 🔛 🕴

8
docs/em/docs/deployment/server-workers.md

@ -18,9 +18,9 @@
📥 👤 🔜 🎦 👆 ❔ ⚙️ <a href="https://gunicorn.org/" class="external-link" target="_blank">**🐁**</a> ⏮️ **Uvicorn 👨‍🏭 🛠️**.
!!! info
🚥 👆 ⚙️ 📦, 🖼 ⏮️ ☁ ⚖️ Kubernete, 👤 🔜 💬 👆 🌅 🔃 👈 ⏭ 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
🚥 👆 ⚙️ 📦, 🖼 ⏮️ ☁ ⚖️ Kubernetes, 👤 🔜 💬 👆 🌅 🔃 👈 ⏭ 📃: [FastAPI 📦 - ☁](./docker.md){.internal-link target=_blank}.
🎯, 🕐❔ 🏃 🔛 **Kubernete** 👆 🔜 🎲 **🚫** 💚 ⚙️ 🐁 &amp; ↩️ 🏃 **👁 Uvicorn 🛠️ 📍 📦**, ✋️ 👤 🔜 💬 👆 🔃 ⚫️ ⏪ 👈 📃.
🎯, 🕐❔ 🏃 🔛 **Kubernetes** 👆 🔜 🎲 **🚫** 💚 ⚙️ 🐁 &amp; ↩️ 🏃 **👁 Uvicorn 🛠️ 📍 📦**, ✋️ 👤 🔜 💬 👆 🔃 ⚫️ ⏪ 👈 📃.
## 🐁 ⏮️ Uvicorn 👨‍🏭
@ -167,7 +167,7 @@ $ uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4
👤 🔜 🎦 👆 **🛂 ☁ 🖼** 👈 🔌 **🐁 ⏮️ Uvicorn 👨‍🏭** &amp; 🔢 📳 👈 💪 ⚠ 🙅 💼.
📤 👤 🔜 🎦 👆 ❔ **🏗 👆 👍 🖼 ⚪️➡️ 🖌** 🏃 👁 Uvicorn 🛠️ (🍵 🐁). ⚫️ 🙅 🛠️ &amp; 🎲 ⚫️❔ 👆 🔜 💚 🕐❔ ⚙️ 📎 📦 🧾 ⚙️ 💖 **Kubernete**.
📤 👤 🔜 🎦 👆 ❔ **🏗 👆 👍 🖼 ⚪️➡️ 🖌** 🏃 👁 Uvicorn 🛠️ (🍵 🐁). ⚫️ 🙅 🛠️ &amp; 🎲 ⚫️❔ 👆 🔜 💚 🕐❔ ⚙️ 📎 📦 🧾 ⚙️ 💖 **Kubernetes**.
## 🌃
@ -175,4 +175,4 @@ $ uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4
👆 💪 ⚙️ 👉 🧰 &amp; 💭 🚥 👆 ⚒ 🆙 **👆 👍 🛠️ ⚙️** ⏪ ✊ 💅 🎏 🛠️ 🔧 👆.
✅ 👅 ⏭ 📃 💡 🔃 **FastAPI** ⏮️ 📦 (✅ ☁ &amp; Kubernete). 👆 🔜 👀 👈 👈 🧰 ✔️ 🙅 🌌 ❎ 🎏 **🛠️ 🔧** 👍. 👶
✅ 👅 ⏭ 📃 💡 🔃 **FastAPI** ⏮️ 📦 (✅ ☁ &amp; Kubernetes). 👆 🔜 👀 👈 👈 🧰 ✔️ 🙅 🌌 ❎ 🎏 **🛠️ 🔧** 👍. 👶

68
docs/em/docs/external-links.md

@ -11,77 +11,21 @@
## 📄
### 🇪🇸
{% for section_name, section_content in external_links.items() %}
{% if external_links %}
{% for article in external_links.articles.english %}
## {{ section_name }}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇯🇵
{% if external_links %}
{% for article in external_links.articles.japanese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇻🇳
{% if external_links %}
{% for article in external_links.articles.vietnamese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇷🇺
{% if external_links %}
{% for article in external_links.articles.russian %}
{% for lang_name, lang_content in section_content.items() %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### {{ lang_name }}
### 🇩🇪
{% for item in lang_content %}
{% if external_links %}
{% for article in external_links.articles.german %}
* <a href="{{ item.link }}" class="external-link" target="_blank">{{ item.title }}</a> by <a href="{{ item.author_link }}" class="external-link" target="_blank">{{ item.author }}</a>.
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### 🇹🇼
{% if external_links %}
{% for article in external_links.articles.taiwanese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## 📻
{% if external_links %}
{% for article in external_links.podcasts.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## 💬
{% if external_links %}
{% for article in external_links.talks.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## 🏗

2
docs/em/docs/help-fastapi.md

@ -231,8 +231,6 @@
⚙️ 💬 🕴 🎏 🏢 💬.
📤 ⏮️ <a href="https://gitter.im/tiangolo/fastapi" class="external-link" target="_blank">🥊 💬</a>, ✋️ ⚫️ 🚫 ✔️ 📻 &amp; 🏧 ⚒, 💬 🌖 ⚠, 😧 🔜 👍 ⚙️.
### 🚫 ⚙️ 💬 ❔
✔️ 🤯 👈 💬 ✔ 🌅 "🆓 💬", ⚫️ ⏩ 💭 ❔ 👈 💁‍♂️ 🏢 &amp; 🌅 ⚠ ❔,, 👆 💪 🚫 📨 ❔.

2
docs/em/docs/project-generation.md

@ -79,6 +79,6 @@
* **🌈** 🕜 🏷 🛠️.
* **☁ 🧠 🔎** 📨 📁 🏗.
* **🏭 🔜** 🐍 🕸 💽 ⚙️ Uvicorn &amp; 🐁.
* **☁ 👩‍💻** Kubernete (🦲) 🆑/💿 🛠️ 🏗.
* **☁ 👩‍💻** Kubernetes (🦲) 🆑/💿 🛠️ 🏗.
* **🤸‍♂** 💪 ⚒ 1️⃣ 🌈 🏗 🇪🇸 ⏮️ 🏗 🖥.
* **💪 🏧** 🎏 🏷 🛠️ (Pytorch, 🇸🇲), 🚫 🌈.

22
docs/en/data/external_links.yml

@ -1,5 +1,5 @@
articles:
english:
Articles:
English:
- author: Adejumo Ridwan Suleiman
author_link: https://www.linkedin.com/in/adejumoridwan/
link: https://medium.com/python-in-plain-english/build-an-sms-spam-classifier-serverless-database-with-faunadb-and-fastapi-23dbb275bc5b
@ -236,7 +236,7 @@ articles:
author_link: https://medium.com/@krishnardt365
link: https://medium.com/@krishnardt365/fastapi-docker-and-postgres-91943e71be92
title: Fastapi, Docker(Docker compose) and Postgres
german:
German:
- author: Marcel Sander (actidoo)
author_link: https://www.actidoo.com
link: https://www.actidoo.com/de/blog/python-fastapi-domain-driven-design
@ -249,7 +249,7 @@ articles:
author_link: https://hellocoding.de/autor/felix-schuermeyer/
link: https://hellocoding.de/blog/coding-language/python/fastapi
title: REST-API Programmieren mittels Python und dem FastAPI Modul
japanese:
Japanese:
- author: '@bee2'
author_link: https://qiita.com/bee2
link: https://qiita.com/bee2/items/75d9c0d7ba20e7a4a0e9
@ -298,7 +298,7 @@ articles:
author_link: https://qiita.com/mtitg
link: https://qiita.com/mtitg/items/47770e9a562dd150631d
title: FastAPI|DB接続してCRUDするPython製APIサーバーを構築
russian:
Russian:
- author: Troy Köhler
author_link: https://www.linkedin.com/in/trkohler/
link: https://trkohler.com/fast-api-introduction-to-framework
@ -311,18 +311,18 @@ articles:
author_link: https://habr.com/ru/users/57uff3r/
link: https://habr.com/ru/post/454440/
title: 'Мелкая питонячая радость #2: Starlette - Солидная примочка – FastAPI'
vietnamese:
Vietnamese:
- author: Nguyễn Nhân
author_link: https://fullstackstation.com/author/figonking/
link: https://fullstackstation.com/fastapi-trien-khai-bang-docker/
title: 'FASTAPI: TRIỂN KHAI BẰNG DOCKER'
taiwanese:
Taiwanese:
- author: Leon
author_link: http://editor.leonh.space/
link: https://editor.leonh.space/2022/tortoise/
title: 'Tortoise ORM / FastAPI 整合快速筆記'
podcasts:
english:
Podcasts:
English:
- author: Podcast.`__init__`
author_link: https://www.pythonpodcast.com/
link: https://www.pythonpodcast.com/fastapi-web-application-framework-episode-259/
@ -331,8 +331,8 @@ podcasts:
author_link: https://pythonbytes.fm/
link: https://pythonbytes.fm/episodes/show/123/time-to-right-the-py-wrongs?time_in_sec=855
title: FastAPI on PythonBytes
talks:
english:
Talks:
English:
- author: Sebastián Ramírez (tiangolo)
author_link: https://twitter.com/tiangolo
link: https://www.youtube.com/watch?v=PnpTY1f4k2U

2
docs/en/data/sponsors.yml

@ -13,7 +13,7 @@ gold:
img: https://fastapi.tiangolo.com/img/sponsors/porter.png
- url: https://bump.sh/fastapi?utm_source=fastapi&utm_medium=referral&utm_campaign=sponsor
title: Automate FastAPI documentation generation with Bump.sh
img: https://fastapi.tiangolo.com/img/sponsors/bump-sh.png
img: https://fastapi.tiangolo.com/img/sponsors/bump-sh.svg
silver:
- url: https://www.deta.sh/?ref=fastapi
title: The launchpad for all your (team's) ideas

3
docs/en/docs/about/index.md

@ -0,0 +1,3 @@
# About
About FastAPI, its design, inspiration and more. 🤓

4
docs/en/docs/advanced/additional-status-codes.md

@ -26,7 +26,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
{!> ../../../docs_src/additional_status_codes/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 26"
{!> ../../../docs_src/additional_status_codes/tutorial001_an.py!}
@ -41,7 +41,7 @@ To achieve that, import `JSONResponse`, and return your content there directly,
{!> ../../../docs_src/additional_status_codes/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

16
docs/en/docs/advanced/advanced-dependencies.md

@ -24,13 +24,13 @@ To do that, we declare a method `__call__`:
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -51,13 +51,13 @@ And now, we can use `__init__` to declare the parameters of the instance that we
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -78,13 +78,13 @@ We could create an instance of this class with:
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -113,13 +113,13 @@ checker(q="somequery")
{!> ../../../docs_src/dependencies/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/dependencies/tutorial011_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

6
docs/en/docs/advanced/generate-clients.md

@ -35,7 +35,7 @@ Let's start with a simple FastAPI application:
{!> ../../../docs_src/generate_clients/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11 14-15 18 19 23"
{!> ../../../docs_src/generate_clients/tutorial001.py!}
@ -147,7 +147,7 @@ For example, you could have a section for **items** and another section for **us
{!> ../../../docs_src/generate_clients/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23 28 36"
{!> ../../../docs_src/generate_clients/tutorial002.py!}
@ -204,7 +204,7 @@ You can then pass that custom function to **FastAPI** as the `generate_unique_id
{!> ../../../docs_src/generate_clients/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8-9 12"
{!> ../../../docs_src/generate_clients/tutorial003.py!}

12
docs/en/docs/advanced/security/http-basic-auth.md

@ -26,13 +26,13 @@ Then, when you type that username and password, the browser sends them in the he
{!> ../../../docs_src/security/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="2 7 11"
{!> ../../../docs_src/security/tutorial006_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -65,13 +65,13 @@ Then we can use `secrets.compare_digest()` to ensure that `credentials.username`
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 12-24"
{!> ../../../docs_src/security/tutorial007_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -148,13 +148,13 @@ After detecting that the credentials are incorrect, return an `HTTPException` wi
{!> ../../../docs_src/security/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="26-30"
{!> ../../../docs_src/security/tutorial007_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

32
docs/en/docs/advanced/security/oauth2-scopes.md

@ -68,7 +68,7 @@ First, let's quickly see the parts that change from the examples in the main **T
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="2 4 8 12 47 65 106 108-116 122-125 129-135 140 156"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -92,7 +92,7 @@ First, let's quickly see the parts that change from the examples in the main **T
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -121,7 +121,7 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="63-66"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -146,7 +146,7 @@ The `scopes` parameter receives a `dict` with each scope as a key and the descri
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -188,7 +188,7 @@ And we return the scopes as part of the JWT token.
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="156"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -212,7 +212,7 @@ And we return the scopes as part of the JWT token.
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -254,7 +254,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 140 171"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -278,7 +278,7 @@ In this case, it requires the scope `me` (it could require more than one scope).
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -320,7 +320,7 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 106"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -344,7 +344,7 @@ This `SecurityScopes` class is similar to `Request` (`Request` was used to get t
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -377,7 +377,7 @@ In this exception, we include the scopes required (if any) as a string separated
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="106 108-116"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -401,7 +401,7 @@ In this exception, we include the scopes required (if any) as a string separated
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -436,7 +436,7 @@ We also verify that we have a user with that username, and if not, we raise that
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="47 117-128"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -460,7 +460,7 @@ We also verify that we have a user with that username, and if not, we raise that
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -487,7 +487,7 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
{!> ../../../docs_src/security/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="129-135"
{!> ../../../docs_src/security/tutorial005_an.py!}
@ -511,7 +511,7 @@ For this, we use `security_scopes.scopes`, that contains a `list` with all these
{!> ../../../docs_src/security/tutorial005_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

12
docs/en/docs/advanced/settings.md

@ -260,13 +260,13 @@ Now we create a dependency that returns a new `config.Settings()`.
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="6 12-13"
{!> ../../../docs_src/settings/app02_an/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -288,13 +288,13 @@ And then we can require it from the *path operation function* as a dependency an
{!> ../../../docs_src/settings/app02_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 19-21"
{!> ../../../docs_src/settings/app02_an/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -396,13 +396,13 @@ But as we are using the `@lru_cache()` decorator on top, the `Settings` object w
{!> ../../../docs_src/settings/app03_an_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 11"
{!> ../../../docs_src/settings/app03_an/main.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

4
docs/en/docs/advanced/testing-dependencies.md

@ -40,7 +40,7 @@ And then **FastAPI** will call that override instead of the original dependency.
{!> ../../../docs_src/dependency_testing/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="29-30 33"
{!> ../../../docs_src/dependency_testing/tutorial001_an.py!}
@ -55,7 +55,7 @@ And then **FastAPI** will call that override instead of the original dependency.
{!> ../../../docs_src/dependency_testing/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

6
docs/en/docs/advanced/websockets.md

@ -124,7 +124,7 @@ They work the same way as for other FastAPI endpoints/*path operations*:
{!> ../../../docs_src/websockets/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="69-70 83"
{!> ../../../docs_src/websockets/tutorial002_an.py!}
@ -139,7 +139,7 @@ They work the same way as for other FastAPI endpoints/*path operations*:
{!> ../../../docs_src/websockets/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -191,7 +191,7 @@ When a WebSocket connection is closed, the `await websocket.receive_text()` will
{!> ../../../docs_src/websockets/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="81-83"
{!> ../../../docs_src/websockets/tutorial003.py!}

70
docs/en/docs/external-links.md

@ -9,79 +9,21 @@ Here's an incomplete list of some of them.
!!! tip
If you have an article, project, tool, or anything related to **FastAPI** that is not yet listed here, create a <a href="https://github.com/tiangolo/fastapi/edit/master/docs/en/data/external_links.yml" class="external-link" target="_blank">Pull Request adding it</a>.
## Articles
{% for section_name, section_content in external_links.items() %}
### English
## {{ section_name }}
{% if external_links %}
{% for article in external_links.articles.english %}
{% for lang_name, lang_content in section_content.items() %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### Japanese
{% if external_links %}
{% for article in external_links.articles.japanese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### Vietnamese
### {{ lang_name }}
{% if external_links %}
{% for article in external_links.articles.vietnamese %}
{% for item in lang_content %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### Russian
{% if external_links %}
{% for article in external_links.articles.russian %}
* <a href="{{ item.link }}" class="external-link" target="_blank">{{ item.title }}</a> by <a href="{{ item.author_link }}" class="external-link" target="_blank">{{ item.author }}</a>.
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### German
{% if external_links %}
{% for article in external_links.articles.german %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
### Taiwanese
{% if external_links %}
{% for article in external_links.articles.taiwanese %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## Podcasts
{% if external_links %}
{% for article in external_links.podcasts.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## Talks
{% if external_links %}
{% for article in external_links.talks.english %}
* <a href="{{ article.link }}" class="external-link" target="_blank">{{ article.title }}</a> by <a href="{{ article.author_link }}" class="external-link" target="_blank">{{ article.author }}</a>.
{% endfor %}
{% endif %}
## Projects

5
docs/en/docs/fastapi-people.md

@ -1,3 +1,8 @@
---
hide:
- navigation
---
# FastAPI People
FastAPI has an amazing community that welcomes people from all backgrounds.

5
docs/en/docs/features.md

@ -1,3 +1,8 @@
---
hide:
- navigation
---
# Features
## FastAPI features

2
docs/en/docs/help-fastapi.md

@ -231,8 +231,6 @@ Join the 👥 <a href="https://discord.gg/VQjSZaeJmf" class="external-link" targ
Use the chat only for other general conversations.
There is also the previous <a href="https://gitter.im/tiangolo/fastapi" class="external-link" target="_blank">Gitter chat</a>, but as it doesn't have channels and advanced features, conversations are more difficult, so Discord is now the recommended system.
### Don't use the chat for questions
Have in mind that as chats allow more "free conversation", it's easy to ask questions that are too general and more difficult to answer, so, you might not receive answers.

3
docs/en/docs/help/index.md

@ -0,0 +1,3 @@
# Help
Help and get help, contribute, get involved. 🤝

8
docs/en/docs/how-to/separate-openapi-schemas.md

@ -44,7 +44,7 @@ Let's say you have a Pydantic model with default values, like this one:
</details>
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-9]!}
@ -99,7 +99,7 @@ If you use this model as an input like here:
</details>
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="16"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py[ln:1-17]!}
@ -142,7 +142,7 @@ But if you use the same model as an output, like here:
{!> ../../../docs_src/separate_openapi_schemas/tutorial001_py39.py!}
```
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/separate_openapi_schemas/tutorial001.py!}
@ -214,7 +214,7 @@ In that case, you can disable this feature in **FastAPI**, with the parameter `s
{!> ../../../docs_src/separate_openapi_schemas/tutorial002_py39.py!}
```
=== "Python 3.7+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/separate_openapi_schemas/tutorial002.py!}

2
docs/en/docs/how-to/sql-databases-peewee.md

@ -363,7 +363,7 @@ It will have the database connection open at the beginning and will just wait so
This will easily let you test that your app with Peewee and FastAPI is behaving correctly with all the stuff about threads.
If you want to check how Peewee would break your app if used without modification, go the the `sql_app/database.py` file and comment the line:
If you want to check how Peewee would break your app if used without modification, go the `sql_app/database.py` file and comment the line:
```Python
# db._state = PeeweeConnectionState()

48
docs/en/docs/img/sponsors/bump-sh-banner.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 38 KiB

56
docs/en/docs/img/sponsors/bump-sh.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 45 KiB

15
docs/en/docs/index.md

@ -1,3 +1,12 @@
---
hide:
- navigation
---
<style>
.md-content .md-typeset h1 { display: none; }
</style>
<p align="center">
<a href="https://fastapi.tiangolo.com"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" alt="FastAPI"></a>
</p>
@ -27,7 +36,7 @@
---
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints.
The key features are:
@ -115,7 +124,7 @@ If you are building a <abbr title="Command Line Interface">CLI</abbr> app to be
## Requirements
Python 3.7+
Python 3.8+
FastAPI stands on the shoulders of giants:
@ -331,7 +340,7 @@ You do that with standard modern Python types.
You don't have to learn a new syntax, the methods or classes of a specific library, etc.
Just standard **Python 3.7+**.
Just standard **Python 3.8+**.
For example, for an `int`:

3
docs/en/docs/js/chat.js

@ -1,3 +0,0 @@
((window.gitter = {}).chat = {}).options = {
room: 'tiangolo/fastapi'
};

5
docs/en/docs/learn/index.md

@ -0,0 +1,5 @@
# Learn
Here are the introductory sections and the tutorials to learn **FastAPI**.
You could consider this a **book**, a **course**, the **official** and recommended way to learn FastAPI. 😎

24
docs/en/docs/python-types.md

@ -182,7 +182,7 @@ For example, let's define a variable to be a `list` of `str`.
{!> ../../../docs_src/python_types/tutorial006_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
From `typing`, import `List` (with a capital `L`):
@ -230,7 +230,7 @@ You would do the same to declare `tuple`s and `set`s:
{!> ../../../docs_src/python_types/tutorial007_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial007.py!}
@ -255,7 +255,7 @@ The second type parameter is for the values of the `dict`:
{!> ../../../docs_src/python_types/tutorial008_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008.py!}
@ -281,7 +281,7 @@ In Python 3.10 there's also a **new syntax** where you can put the possible type
{!> ../../../docs_src/python_types/tutorial008b_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial008b.py!}
@ -311,13 +311,13 @@ This also means that in Python 3.10, you can use `Something | None`:
{!> ../../../docs_src/python_types/tutorial009_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009.py!}
```
=== "Python 3.6+ alternative"
=== "Python 3.8+ alternative"
```Python hl_lines="1 4"
{!> ../../../docs_src/python_types/tutorial009b.py!}
@ -375,10 +375,10 @@ These types that take type parameters in square brackets are called **Generic ty
* `set`
* `dict`
And the same as with Python 3.6, from the `typing` module:
And the same as with Python 3.8, from the `typing` module:
* `Union`
* `Optional` (the same as with Python 3.6)
* `Optional` (the same as with Python 3.8)
* ...and others.
In Python 3.10, as an alternative to using the generics `Union` and `Optional`, you can use the <abbr title='also called "bitwise or operator", but that meaning is not relevant here'>vertical bar (`|`)</abbr> to declare unions of types, that's a lot better and simpler.
@ -392,13 +392,13 @@ These types that take type parameters in square brackets are called **Generic ty
* `set`
* `dict`
And the same as with Python 3.6, from the `typing` module:
And the same as with Python 3.8, from the `typing` module:
* `Union`
* `Optional`
* ...and others.
=== "Python 3.6+"
=== "Python 3.8+"
* `List`
* `Tuple`
@ -458,7 +458,7 @@ An example from the official Pydantic docs:
{!> ../../../docs_src/python_types/tutorial011_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/python_types/tutorial011.py!}
@ -486,7 +486,7 @@ Python also has a feature that allows putting **additional metadata** in these t
{!> ../../../docs_src/python_types/tutorial013_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
In versions below Python 3.9, you import `Annotated` from `typing_extensions`.

25
docs/en/docs/reference/apirouter.md

@ -0,0 +1,25 @@
# `APIRouter` class
Here's the reference information for the `APIRouter` class, with all its parameters,
attributes and methods.
You can import the `APIRouter` class directly from `fastapi`:
```python
from fastapi import APIRouter
```
::: fastapi.APIRouter
options:
members:
- websocket
- include_router
- get
- put
- post
- delete
- options
- head
- patch
- trace
- on_event

13
docs/en/docs/reference/background.md

@ -0,0 +1,13 @@
# Background Tasks - `BackgroundTasks`
You can declare a parameter in a *path operation function* or dependency function
with the type `BackgroundTasks`, and then you can use it to schedule the execution
of background tasks after the response is sent.
You can import it directly from `fastapi`:
```python
from fastapi import BackgroundTasks
```
::: fastapi.BackgroundTasks

32
docs/en/docs/reference/dependencies.md

@ -0,0 +1,32 @@
# Dependencies - `Depends()` and `Security()`
## `Depends()`
Dependencies are handled mainly with the special function `Depends()` that takes a
callable.
Here is the reference for it and its parameters.
You can import it directly from `fastapi`:
```python
from fastapi import Depends
```
::: fastapi.Depends
## `Security()`
For many scenarios, you can handle security (authorization, authentication, etc.) with
dependencies, using `Depends()`.
But when you want to also declare OAuth2 scopes, you can use `Security()` instead of
`Depends()`.
You can import `Security()` directly from `fastapi`:
```python
from fastapi import Security
```
::: fastapi.Security

3
docs/en/docs/reference/encoders.md

@ -0,0 +1,3 @@
# Encoders - `jsonable_encoder`
::: fastapi.encoders.jsonable_encoder

22
docs/en/docs/reference/exceptions.md

@ -0,0 +1,22 @@
# Exceptions - `HTTPException` and `WebSocketException`
These are the exceptions that you can raise to show errors to the client.
When you raise an exception, as would happen with normal Python, the rest of the
excecution is aborted. This way you can raise these exceptions from anywhere in the
code to abort a request and show the error to the client.
You can use:
* `HTTPException`
* `WebSocketException`
These exceptions can be imported directly from `fastapi`:
```python
from fastapi import HTTPException, WebSocketException
```
::: fastapi.HTTPException
::: fastapi.WebSocketException

32
docs/en/docs/reference/fastapi.md

@ -0,0 +1,32 @@
# `FastAPI` class
Here's the reference information for the `FastAPI` class, with all its parameters,
attributes and methods.
You can import the `FastAPI` class directly from `fastapi`:
```python
from fastapi import FastAPI
```
::: fastapi.FastAPI
options:
members:
- openapi_version
- webhooks
- state
- dependency_overrides
- openapi
- websocket
- include_router
- get
- put
- post
- delete
- options
- head
- patch
- trace
- on_event
- middleware
- exception_handler

13
docs/en/docs/reference/httpconnection.md

@ -0,0 +1,13 @@
# `HTTPConnection` class
When you want to define dependencies that should be compatible with both HTTP and
WebSockets, you can define a parameter that takes an `HTTPConnection` instead of a
`Request` or a `WebSocket`.
You can import it from `fastapi.requests`:
```python
from fastapi.requests import HTTPConnection
```
::: fastapi.requests.HTTPConnection

7
docs/en/docs/reference/index.md

@ -0,0 +1,7 @@
# Reference - Code API
Here's the reference or code API, the classes, functions, parameters, attributes, and
all the FastAPI parts you can use in your applications.
If you want to **learn FastAPI** you are much better off reading the
[FastAPI Tutorial](https://fastapi.tiangolo.com/tutorial/).

46
docs/en/docs/reference/middleware.md

@ -0,0 +1,46 @@
# Middleware
There are several middlewares available provided by Starlette directly.
Read more about them in the
[FastAPI docs for Middleware](https://fastapi.tiangolo.com/advanced/middleware/).
::: fastapi.middleware.cors.CORSMiddleware
It can be imported from `fastapi`:
```python
from fastapi.middleware.cors import CORSMiddleware
```
::: fastapi.middleware.gzip.GZipMiddleware
It can be imported from `fastapi`:
```python
from fastapi.middleware.gzip import GZipMiddleware
```
::: fastapi.middleware.httpsredirect.HTTPSRedirectMiddleware
It can be imported from `fastapi`:
```python
from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware
```
::: fastapi.middleware.trustedhost.TrustedHostMiddleware
It can be imported from `fastapi`:
```python
from fastapi.middleware.trustedhost import TrustedHostMiddleware
```
::: fastapi.middleware.wsgi.WSGIMiddleware
It can be imported from `fastapi`:
```python
from fastapi.middleware.wsgi import WSGIMiddleware
```

11
docs/en/docs/reference/openapi/docs.md

@ -0,0 +1,11 @@
# OpenAPI `docs`
Utilities to handle OpenAPI automatic UI documentation, including Swagger UI (by default at `/docs`) and ReDoc (by default at `/redoc`).
::: fastapi.openapi.docs.get_swagger_ui_html
::: fastapi.openapi.docs.get_redoc_html
::: fastapi.openapi.docs.get_swagger_ui_oauth2_redirect_html
::: fastapi.openapi.docs.swagger_ui_default_parameters

5
docs/en/docs/reference/openapi/index.md

@ -0,0 +1,5 @@
# OpenAPI
There are several utilities to handle OpenAPI.
You normally don't need to use them unless you have a specific advanced use case that requires it.

5
docs/en/docs/reference/openapi/models.md

@ -0,0 +1,5 @@
# OpenAPI `models`
OpenAPI Pydantic models used to generate and validate the generated OpenAPI.
::: fastapi.openapi.models

36
docs/en/docs/reference/parameters.md

@ -0,0 +1,36 @@
# Request Parameters
Here's the reference information for the request parameters.
These are the special functions that you can put in *path operation function*
parameters or dependency functions with `Annotated` to get data from the request.
It includes:
* `Query()`
* `Path()`
* `Body()`
* `Cookie()`
* `Header()`
* `Form()`
* `File()`
You can import them all directly from `fastapi`:
```python
from fastapi import Body, Cookie, File, Form, Header, Path, Query
```
::: fastapi.Query
::: fastapi.Path
::: fastapi.Body
::: fastapi.Cookie
::: fastapi.Header
::: fastapi.Form
::: fastapi.File

18
docs/en/docs/reference/request.md

@ -0,0 +1,18 @@
# `Request` class
You can declare a parameter in a *path operation function* or dependency to be of type
`Request` and then you can access the raw request object directly, without any
validation, etc.
You can import it directly from `fastapi`:
```python
from fastapi import Request
```
!!! tip
When you want to define dependencies that should be compatible with both HTTP and
WebSockets, you can define a parameter that takes an `HTTPConnection` instead of a
`Request` or a `WebSocket`.
::: fastapi.Request

15
docs/en/docs/reference/response.md

@ -0,0 +1,15 @@
# `Response` class
You can declare a parameter in a *path operation function* or dependency to be of type
`Response` and then you can set data for the response like headers or cookies.
You can also use it directly to create an instance of it and return it from your *path
operations*.
You can import it directly from `fastapi`:
```python
from fastapi import Response
```
::: fastapi.Response

166
docs/en/docs/reference/responses.md

@ -0,0 +1,166 @@
# Custom Response Classes - File, HTML, Redirect, Streaming, etc.
There are several custom response classes you can use to create an instance and return
them directly from your *path operations*.
Read more about it in the
[FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/).
You can import them directly from `fastapi.responses`:
```python
from fastapi.responses import (
FileResponse,
HTMLResponse,
JSONResponse,
ORJSONResponse,
PlainTextResponse,
RedirectResponse,
Response,
StreamingResponse,
UJSONResponse,
)
```
## FastAPI Responses
There are a couple of custom FastAPI response classes, you can use them to optimize JSON performance.
::: fastapi.responses.UJSONResponse
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.ORJSONResponse
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
## Starlette Responses
::: fastapi.responses.FileResponse
options:
members:
- chunk_size
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.HTMLResponse
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.JSONResponse
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.PlainTextResponse
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.RedirectResponse
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.Response
options:
members:
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie
::: fastapi.responses.StreamingResponse
options:
members:
- body_iterator
- charset
- status_code
- media_type
- body
- background
- raw_headers
- render
- init_headers
- headers
- set_cookie
- delete_cookie

76
docs/en/docs/reference/security/index.md

@ -0,0 +1,76 @@
# Security Tools
When you need to declare dependencies with OAuth2 scopes you use `Security()`.
But you still need to define what is the dependable, the callable that you pass as
a parameter to `Depends()` or `Security()`.
There are multiple tools that you can use to create those dependables, and they get
integrated into OpenAPI so they are shown in the automatic docs UI, they can be used
by automatically generated clients and SDKs, etc.
You can import them from `fastapi.security`:
```python
from fastapi.security import (
APIKeyCookie,
APIKeyHeader,
APIKeyQuery,
HTTPAuthorizationCredentials,
HTTPBasic,
HTTPBasicCredentials,
HTTPBearer,
HTTPDigest,
OAuth2,
OAuth2AuthorizationCodeBearer,
OAuth2PasswordBearer,
OAuth2PasswordRequestForm,
OAuth2PasswordRequestFormStrict,
OpenIdConnect,
SecurityScopes,
)
```
## API Key Security Schemes
::: fastapi.security.APIKeyCookie
::: fastapi.security.APIKeyHeader
::: fastapi.security.APIKeyQuery
## HTTP Authentication Schemes
::: fastapi.security.HTTPBasic
::: fastapi.security.HTTPBearer
::: fastapi.security.HTTPDigest
## HTTP Credentials
::: fastapi.security.HTTPAuthorizationCredentials
::: fastapi.security.HTTPBasicCredentials
## OAuth2 Authentication
::: fastapi.security.OAuth2
::: fastapi.security.OAuth2AuthorizationCodeBearer
::: fastapi.security.OAuth2PasswordBearer
## OAuth2 Password Form
::: fastapi.security.OAuth2PasswordRequestForm
::: fastapi.security.OAuth2PasswordRequestFormStrict
## OAuth2 Security Scopes in Dependencies
::: fastapi.security.SecurityScopes
## OpenID Connect
::: fastapi.security.OpenIdConnect

14
docs/en/docs/reference/staticfiles.md

@ -0,0 +1,14 @@
# Static Files - `StaticFiles`
You can use the `StaticFiles` class to serve static files, like JavaScript, CSS, images, etc.
Read more about it in the
[FastAPI docs for Static Files](https://fastapi.tiangolo.com/tutorial/static-files/).
You can import it directly from `fastapi.staticfiles`:
```python
from fastapi.staticfiles import StaticFiles
```
::: fastapi.staticfiles.StaticFiles

39
docs/en/docs/reference/status.md

@ -0,0 +1,39 @@
# Status Codes
You can import the `status` module from `fastapi`:
```python
from fastapi import status
```
`status` is provided directly by Starlette.
It containes a group of named constants (variables) with integer status codes.
For example:
* 200: `status.HTTP_200_OK`
* 403: `status.HTTP_403_FORBIDDEN`
* etc.
It can be convenient to quickly access HTTP (and WebSocket) status codes in your app,
using autocompletion for the name without having to remember the integer status codes
by memory.
Read more about it in the
[FastAPI docs about Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/).
## Example
```python
from fastapi import FastAPI, status
app = FastAPI()
@app.get("/items/", status_code=status.HTTP_418_IM_A_TEAPOT)
def read_items():
return [{"name": "Plumbus"}, {"name": "Portal Gun"}]
```
::: fastapi.status

14
docs/en/docs/reference/templating.md

@ -0,0 +1,14 @@
# Templating - `Jinja2Templates`
You can use the `Jinja2Templates` class to render Jinja templates.
Read more about it in the
[FastAPI docs for Templates](https://fastapi.tiangolo.com/advanced/templates/).
You can import it directly from `fastapi.templating`:
```python
from fastapi.templating import Jinja2Templates
```
::: fastapi.templating.Jinja2Templates

14
docs/en/docs/reference/testclient.md

@ -0,0 +1,14 @@
# Test Client - `TestClient`
You can use the `TestClient` class to test FastAPI applications without creating an actual HTTP and socket connection, just communicating directly with the FastAPI code.
Read more about it in the
[FastAPI docs for Testing](https://fastapi.tiangolo.com/tutorial/testing/).
You can import it directly from `fastapi.testclient`:
```python
from fastapi.testclient import TestClient
```
::: fastapi.testclient.TestClient

23
docs/en/docs/reference/uploadfile.md

@ -0,0 +1,23 @@
# `UploadFile` class
You can define *path operation function* parameters to be of the type `UploadFile`
to receive files from the request.
You can import it directly from `fastapi`:
```python
from fastapi import UploadFile
```
::: fastapi.UploadFile
options:
members:
- file
- filename
- size
- headers
- content_type
- read
- write
- seek
- close

70
docs/en/docs/reference/websockets.md

@ -0,0 +1,70 @@
# WebSockets
When defining WebSockets, you normally declare a parameter of type `WebSocket` and
with it you can read data from the client and send data to it.
It is provided directly by Starlette, but you can import it from `fastapi`:
```python
from fastapi import WebSocket
```
!!! tip
When you want to define dependencies that should be compatible with both HTTP and
WebSockets, you can define a parameter that takes an `HTTPConnection` instead of a
`Request` or a `WebSocket`.
::: fastapi.WebSocket
options:
members:
- scope
- app
- url
- base_url
- headers
- query_params
- path_params
- cookies
- client
- state
- url_for
- client_state
- application_state
- receive
- send
- accept
- receive_text
- receive_bytes
- receive_json
- iter_text
- iter_bytes
- iter_json
- send_text
- send_bytes
- send_json
- close
When a client disconnects, a `WebSocketDisconnect` exception is raised, you can catch
it.
You can import it directly form `fastapi`:
```python
from fastapi import WebSocketDisconnect
```
::: fastapi.WebSocketDisconnect
## WebSockets - additional classes
Additional classes for handling WebSockets.
Provided directly by Starlette, but you can import it from `fastapi`:
```python
from fastapi.websockets import WebSocketDisconnect, WebSocketState
```
::: fastapi.websockets.WebSocketDisconnect
::: fastapi.websockets.WebSocketState

34
docs/en/docs/release-notes.md

@ -1,8 +1,42 @@
---
hide:
- navigation
---
# Release Notes
## Latest Changes
* 🔧 Add `CITATION.cff` file for academic citations. PR [#10496](https://github.com/tiangolo/fastapi/pull/10496) by [@tiangolo](https://github.com/tiangolo).
* 📝 Update data structure and render for external-links. PR [#10495](https://github.com/tiangolo/fastapi/pull/10495) by [@tiangolo](https://github.com/tiangolo).
* 🐛 Fix overriding MKDocs theme lang in hook. PR [#10490](https://github.com/tiangolo/fastapi/pull/10490) by [@tiangolo](https://github.com/tiangolo).
* ✏️ Fix link to SPDX license identifier in `docs/en/docs/tutorial/metadata.md`. PR [#10433](https://github.com/tiangolo/fastapi/pull/10433) by [@worldworm](https://github.com/worldworm).
* 📝 Update example validation error from Pydantic v1 to match Pydantic v2 in `docs/en/docs/tutorial/path-params.md`. PR [#10043](https://github.com/tiangolo/fastapi/pull/10043) by [@giuliowaitforitdavide](https://github.com/giuliowaitforitdavide).
* ✏️ Fix typos in emoji docs and in some source examples. PR [#10438](https://github.com/tiangolo/fastapi/pull/10438) by [@afuetterer](https://github.com/afuetterer).
* ✏️ Fix typo in `docs/en/docs/reference/dependencies.md`. PR [#10465](https://github.com/tiangolo/fastapi/pull/10465) by [@suravshresth](https://github.com/suravshresth).
* ✏️ Fix typos and rewordings in `docs/en/docs/tutorial/body-nested-models.md`. PR [#10468](https://github.com/tiangolo/fastapi/pull/10468) by [@yogabonito](https://github.com/yogabonito).
* 📝 Update docs, remove references to removed `pydantic.Required` in `docs/en/docs/tutorial/query-params-str-validations.md`. PR [#10469](https://github.com/tiangolo/fastapi/pull/10469) by [@yogabonito](https://github.com/yogabonito).
* ✏️ Fix typo in `docs/en/docs/reference/index.md`. PR [#10467](https://github.com/tiangolo/fastapi/pull/10467) by [@tarsil](https://github.com/tarsil).
* 🔥 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).
* 🔥 Remove unnecessary duplicated docstrings. PR [#10484](https://github.com/tiangolo/fastapi/pull/10484) by [@tiangolo](https://github.com/tiangolo).
## 0.104.0
## Features
* ✨ Add reference (code API) docs with PEP 727, add subclass with custom docstrings for `BackgroundTasks`, refactor docs structure. PR [#10392](https://github.com/tiangolo/fastapi/pull/10392) by [@tiangolo](https://github.com/tiangolo). New docs at [FastAPI Reference - Code API](https://fastapi.tiangolo.com/reference/).
## Upgrades
* ⬆️ Drop support for Python 3.7, require Python 3.8 or above. PR [#10442](https://github.com/tiangolo/fastapi/pull/10442) by [@tiangolo](https://github.com/tiangolo).
### Internal
* ⬆ Bump dawidd6/action-download-artifact from 2.27.0 to 2.28.0. PR [#10268](https://github.com/tiangolo/fastapi/pull/10268) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump actions/checkout from 3 to 4. PR [#10208](https://github.com/tiangolo/fastapi/pull/10208) by [@dependabot[bot]](https://github.com/apps/dependabot).
* ⬆ Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.10. PR [#10061](https://github.com/tiangolo/fastapi/pull/10061) by [@dependabot[bot]](https://github.com/apps/dependabot).
* 🔧 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
### Refactors

3
docs/en/docs/resources/index.md

@ -0,0 +1,3 @@
# Resources
Additional resources, external links, articles and more. ✈️

4
docs/en/docs/tutorial/background-tasks.md

@ -69,7 +69,7 @@ Using `BackgroundTasks` also works with the dependency injection system, you can
{!> ../../../docs_src/background_tasks/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14 16 23 26"
{!> ../../../docs_src/background_tasks/tutorial002_an.py!}
@ -84,7 +84,7 @@ Using `BackgroundTasks` also works with the dependency injection system, you can
{!> ../../../docs_src/background_tasks/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

4
docs/en/docs/tutorial/bigger-applications.md

@ -118,13 +118,13 @@ We will now use a simple dependency to read a custom `X-Token` header:
{!> ../../../docs_src/bigger_applications/app_an_py39/dependencies.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 5-7"
{!> ../../../docs_src/bigger_applications/app_an/dependencies.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/body-fields.md

@ -18,7 +18,7 @@ First, you have to import it:
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4"
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
@ -33,7 +33,7 @@ First, you have to import it:
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -61,7 +61,7 @@ You can then use `Field` with model attributes:
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12-15"
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
@ -76,7 +76,7 @@ You can then use `Field` with model attributes:
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

18
docs/en/docs/tutorial/body-multiple-params.md

@ -20,7 +20,7 @@ And you can also declare body parameters as optional, by setting the default to
{!> ../../../docs_src/body_multiple_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-21"
{!> ../../../docs_src/body_multiple_params/tutorial001_an.py!}
@ -35,7 +35,7 @@ And you can also declare body parameters as optional, by setting the default to
{!> ../../../docs_src/body_multiple_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -68,7 +68,7 @@ But you can also declare multiple body parameters, e.g. `item` and `user`:
{!> ../../../docs_src/body_multiple_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/body_multiple_params/tutorial002.py!}
@ -123,7 +123,7 @@ But you can instruct **FastAPI** to treat it as another body key using `Body`:
{!> ../../../docs_src/body_multiple_params/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/body_multiple_params/tutorial003_an.py!}
@ -138,7 +138,7 @@ But you can instruct **FastAPI** to treat it as another body key using `Body`:
{!> ../../../docs_src/body_multiple_params/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -197,7 +197,7 @@ For example:
{!> ../../../docs_src/body_multiple_params/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="28"
{!> ../../../docs_src/body_multiple_params/tutorial004_an.py!}
@ -212,7 +212,7 @@ For example:
{!> ../../../docs_src/body_multiple_params/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -250,7 +250,7 @@ as in:
{!> ../../../docs_src/body_multiple_params/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body_multiple_params/tutorial005_an.py!}
@ -265,7 +265,7 @@ as in:
{!> ../../../docs_src/body_multiple_params/tutorial005_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

36
docs/en/docs/tutorial/body-nested-models.md

@ -12,7 +12,7 @@ You can define an attribute to be a subtype. For example, a Python `list`:
{!> ../../../docs_src/body_nested_models/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial001.py!}
@ -73,7 +73,7 @@ So, in our example, we can make `tags` be specifically a "list of strings":
{!> ../../../docs_src/body_nested_models/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/body_nested_models/tutorial002.py!}
@ -99,7 +99,7 @@ Then we can declare `tags` as a set of strings:
{!> ../../../docs_src/body_nested_models/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 14"
{!> ../../../docs_src/body_nested_models/tutorial003.py!}
@ -137,7 +137,7 @@ For example, we can define an `Image` model:
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
@ -159,7 +159,7 @@ And then we can use it as the type of an attribute:
{!> ../../../docs_src/body_nested_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial004.py!}
@ -183,18 +183,18 @@ This would mean that **FastAPI** would expect a body similar to:
Again, doing just that declaration, with **FastAPI** you get:
* Editor support (completion, etc), even for nested models
* Editor support (completion, etc.), even for nested models
* Data conversion
* Data validation
* Automatic documentation
## Special types and validation
Apart from normal singular types like `str`, `int`, `float`, etc. You can use more complex singular types that inherit from `str`.
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 the docs for <a href="https://pydantic-docs.helpmanual.io/usage/types/" class="external-link" target="_blank">Pydantic's exotic types</a>. 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 instead of a `str`, a Pydantic's `HttpUrl`:
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`:
=== "Python 3.10+"
@ -208,7 +208,7 @@ For example, as in the `Image` model we have a `url` field, we can declare it to
{!> ../../../docs_src/body_nested_models/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 10"
{!> ../../../docs_src/body_nested_models/tutorial005.py!}
@ -218,7 +218,7 @@ The string will be checked to be a valid URL, and documented in JSON Schema / Op
## Attributes with lists of submodels
You can also use Pydantic models as subtypes of `list`, `set`, etc:
You can also use Pydantic models as subtypes of `list`, `set`, etc.:
=== "Python 3.10+"
@ -232,13 +232,13 @@ You can also use Pydantic models as subtypes of `list`, `set`, etc:
{!> ../../../docs_src/body_nested_models/tutorial006_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/body_nested_models/tutorial006.py!}
```
This will expect (convert, validate, document, etc) a JSON body like:
This will expect (convert, validate, document, etc.) a JSON body like:
```JSON hl_lines="11"
{
@ -283,7 +283,7 @@ You can define arbitrarily deeply nested models:
{!> ../../../docs_src/body_nested_models/tutorial007_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 14 20 23 27"
{!> ../../../docs_src/body_nested_models/tutorial007.py!}
@ -314,7 +314,7 @@ as in:
{!> ../../../docs_src/body_nested_models/tutorial008_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15"
{!> ../../../docs_src/body_nested_models/tutorial008.py!}
@ -334,15 +334,15 @@ But you don't have to worry about them either, incoming dicts are converted auto
## Bodies of arbitrary `dict`s
You can also declare a body as a `dict` with keys of some type and values of other type.
You can also declare a body as a `dict` with keys of some type and values of some other type.
Without having to know beforehand what are the valid field/attribute names (as would be the case with Pydantic models).
This way, you don't have to know beforehand what the valid field/attribute names are (as would be the case with Pydantic models).
This would be useful if you want to receive keys that you don't already know.
---
Other useful case is when you want to have keys of other type, e.g. `int`.
Another useful case is when you want to have keys of another type (e.g., `int`).
That's what we are going to see here.
@ -354,7 +354,7 @@ In this case, you would accept any `dict` as long as it has `int` keys with `flo
{!> ../../../docs_src/body_nested_models/tutorial009_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/body_nested_models/tutorial009.py!}

8
docs/en/docs/tutorial/body-updates.md

@ -18,7 +18,7 @@ You can use the `jsonable_encoder` to convert the input data to data that can be
{!> ../../../docs_src/body_updates/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="30-35"
{!> ../../../docs_src/body_updates/tutorial001.py!}
@ -79,7 +79,7 @@ Then you can use this to generate a `dict` with only the data that was set (sent
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="34"
{!> ../../../docs_src/body_updates/tutorial002.py!}
@ -103,7 +103,7 @@ Like `stored_item_model.copy(update=update_data)`:
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="35"
{!> ../../../docs_src/body_updates/tutorial002.py!}
@ -136,7 +136,7 @@ In summary, to apply partial updates you would:
{!> ../../../docs_src/body_updates/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="30-37"
{!> ../../../docs_src/body_updates/tutorial002.py!}

12
docs/en/docs/tutorial/body.md

@ -25,7 +25,7 @@ First, you need to import `BaseModel` from `pydantic`:
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4"
{!> ../../../docs_src/body/tutorial001.py!}
@ -43,7 +43,7 @@ Use standard Python types for all the attributes:
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7-11"
{!> ../../../docs_src/body/tutorial001.py!}
@ -81,7 +81,7 @@ To add it to your *path operation*, declare it the same way you declared path an
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial001.py!}
@ -155,7 +155,7 @@ Inside of the function, you can access all the attributes of the model object di
{!> ../../../docs_src/body/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/body/tutorial002.py!}
@ -173,7 +173,7 @@ You can declare path parameters and request body at the same time.
{!> ../../../docs_src/body/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17-18"
{!> ../../../docs_src/body/tutorial003.py!}
@ -191,7 +191,7 @@ You can also declare **body**, **path** and **query** parameters, all at the sam
{!> ../../../docs_src/body/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial004.py!}

8
docs/en/docs/tutorial/cookie-params.md

@ -18,7 +18,7 @@ First import `Cookie`:
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
@ -33,7 +33,7 @@ First import `Cookie`:
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -60,7 +60,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/cookie_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/cookie_params/tutorial001_an.py!}
@ -75,7 +75,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/cookie_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

52
docs/en/docs/tutorial/dependencies/classes-as-dependencies.md

@ -18,7 +18,7 @@ In the previous example, we were returning a `dict` from our dependency ("depend
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -33,7 +33,7 @@ In the previous example, we were returning a `dict` from our dependency ("depend
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -115,7 +115,7 @@ Then, we can change the dependency "dependable" `common_parameters` from above t
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12-16"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
@ -130,7 +130,7 @@ Then, we can change the dependency "dependable" `common_parameters` from above t
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -153,7 +153,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="13"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
@ -168,7 +168,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -191,7 +191,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -206,7 +206,7 @@ Pay attention to the `__init__` method used to create the instance of the class:
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -241,7 +241,7 @@ Now you can declare your dependency using this class.
{!> ../../../docs_src/dependencies/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial002_an.py!}
@ -256,7 +256,7 @@ Now you can declare your dependency using this class.
{!> ../../../docs_src/dependencies/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -271,7 +271,7 @@ Now you can declare your dependency using this class.
Notice how we write `CommonQueryParams` twice in the above code:
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -280,7 +280,7 @@ Notice how we write `CommonQueryParams` twice in the above code:
commons: CommonQueryParams = Depends(CommonQueryParams)
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
@ -300,13 +300,13 @@ From it is that FastAPI will extract the declared parameters and that is what Fa
In this case, the first `CommonQueryParams`, in:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, ...
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -319,13 +319,13 @@ In this case, the first `CommonQueryParams`, in:
You could actually write just:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[Any, Depends(CommonQueryParams)]
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -348,7 +348,7 @@ You could actually write just:
{!> ../../../docs_src/dependencies/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial003_an.py!}
@ -363,7 +363,7 @@ You could actually write just:
{!> ../../../docs_src/dependencies/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -380,7 +380,7 @@ But declaring the type is encouraged as that way your editor will know what will
But you see that we are having some code repetition here, writing `CommonQueryParams` twice:
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -389,7 +389,7 @@ But you see that we are having some code repetition here, writing `CommonQueryPa
commons: CommonQueryParams = Depends(CommonQueryParams)
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
@ -401,13 +401,13 @@ For those specific cases, you can do the following:
Instead of writing:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends(CommonQueryParams)]
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -418,13 +418,13 @@ Instead of writing:
...you write:
=== "Python 3.6+"
=== "Python 3.8+"
```Python
commons: Annotated[CommonQueryParams, Depends()]
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -449,7 +449,7 @@ The same example would then look like:
{!> ../../../docs_src/dependencies/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/dependencies/tutorial004_an.py!}
@ -464,7 +464,7 @@ The same example would then look like:
{!> ../../../docs_src/dependencies/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

16
docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md

@ -20,13 +20,13 @@ It should be a `list` of `Depends()`:
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -63,13 +63,13 @@ They can declare request requirements (like headers) or other sub-dependencies:
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7 12"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -88,13 +88,13 @@ These dependencies can `raise` exceptions, the same as normal dependencies:
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 14"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -115,13 +115,13 @@ So, you can re-use a normal dependency (that returns a value) you already use so
{!> ../../../docs_src/dependencies/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10 15"
{!> ../../../docs_src/dependencies/tutorial006_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/dependencies/dependencies-with-yield.md

@ -72,13 +72,13 @@ For example, `dependency_c` can have a dependency on `dependency_b`, and `depend
{!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 13 21"
{!> ../../../docs_src/dependencies/tutorial008_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -99,13 +99,13 @@ And, in turn, `dependency_b` needs the value from `dependency_a` (here named `de
{!> ../../../docs_src/dependencies/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17-18 25-26"
{!> ../../../docs_src/dependencies/tutorial008_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

4
docs/en/docs/tutorial/dependencies/global-dependencies.md

@ -12,13 +12,13 @@ In that case, they will be applied to all the *path operations* in the applicati
{!> ../../../docs_src/dependencies/tutorial012_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="16"
{!> ../../../docs_src/dependencies/tutorial012_an.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

14
docs/en/docs/tutorial/dependencies/index.md

@ -43,7 +43,7 @@ It is just a function that can take all the same parameters that a *path operati
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-12"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -58,7 +58,7 @@ It is just a function that can take all the same parameters that a *path operati
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -106,7 +106,7 @@ And then it just returns a `dict` containing those values.
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -121,7 +121,7 @@ And then it just returns a `dict` containing those values.
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -146,7 +146,7 @@ The same way you use `Body`, `Query`, etc. with your *path operation function* p
{!> ../../../docs_src/dependencies/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="16 21"
{!> ../../../docs_src/dependencies/tutorial001_an.py!}
@ -161,7 +161,7 @@ The same way you use `Body`, `Query`, etc. with your *path operation function* p
{!> ../../../docs_src/dependencies/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -231,7 +231,7 @@ But because we are using `Annotated`, we can store that `Annotated` value in a v
{!> ../../../docs_src/dependencies/tutorial001_02_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15 19 24"
{!> ../../../docs_src/dependencies/tutorial001_02_an.py!}

16
docs/en/docs/tutorial/dependencies/sub-dependencies.md

@ -22,7 +22,7 @@ You could create a first dependency ("dependable") like:
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-10"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
@ -37,7 +37,7 @@ You could create a first dependency ("dependable") like:
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -66,7 +66,7 @@ Then you can create another dependency function (a "dependable") that at the sam
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
@ -81,7 +81,7 @@ Then you can create another dependency function (a "dependable") that at the sam
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -113,7 +113,7 @@ Then we can use the dependency with:
{!> ../../../docs_src/dependencies/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/dependencies/tutorial005_an.py!}
@ -128,7 +128,7 @@ Then we can use the dependency with:
{!> ../../../docs_src/dependencies/tutorial005_py310.py!}
```
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -161,14 +161,14 @@ And it will save the returned value in a <abbr title="A utility/system to store
In an advanced scenario where you know you need the dependency to be called at every step (possibly multiple times) in the same request instead of using the "cached" value, you can set the parameter `use_cache=False` when using `Depends`:
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
async def needy_dependency(fresh_value: Annotated[str, Depends(get_value, use_cache=False)]):
return {"fresh_value": fresh_value}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

2
docs/en/docs/tutorial/encoder.md

@ -26,7 +26,7 @@ It receives an object, like a Pydantic model, and returns a JSON compatible vers
{!> ../../../docs_src/encoder/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 22"
{!> ../../../docs_src/encoder/tutorial001.py!}

8
docs/en/docs/tutorial/extra-data-types.md

@ -67,7 +67,7 @@ Here's an example *path operation* with parameters using some of the above types
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 3 13-17"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
@ -82,7 +82,7 @@ Here's an example *path operation* with parameters using some of the above types
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -105,7 +105,7 @@ Note that the parameters inside the function have their natural data type, and y
{!> ../../../docs_src/extra_data_types/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-20"
{!> ../../../docs_src/extra_data_types/tutorial001_an.py!}
@ -120,7 +120,7 @@ Note that the parameters inside the function have their natural data type, and y
{!> ../../../docs_src/extra_data_types/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

10
docs/en/docs/tutorial/extra-models.md

@ -23,7 +23,7 @@ Here's a general idea of how the models could look like with their password fiel
{!> ../../../docs_src/extra_models/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11 16 22 24 29-30 33-35 40-41"
{!> ../../../docs_src/extra_models/tutorial001.py!}
@ -164,7 +164,7 @@ That way, we can declare just the differences between the models (with plaintext
{!> ../../../docs_src/extra_models/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 15-16 19-20 23-24"
{!> ../../../docs_src/extra_models/tutorial002.py!}
@ -187,7 +187,7 @@ To do that, use the standard Python type hint <a href="https://docs.python.org/3
{!> ../../../docs_src/extra_models/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 14-15 18-20 33"
{!> ../../../docs_src/extra_models/tutorial003.py!}
@ -219,7 +219,7 @@ For that, use the standard Python `typing.List` (or just `list` in Python 3.9 an
{!> ../../../docs_src/extra_models/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 20"
{!> ../../../docs_src/extra_models/tutorial004.py!}
@ -239,7 +239,7 @@ In this case, you can use `typing.Dict` (or just `dict` in Python 3.9 and above)
{!> ../../../docs_src/extra_models/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1 8"
{!> ../../../docs_src/extra_models/tutorial005.py!}

16
docs/en/docs/tutorial/header-params.md

@ -18,7 +18,7 @@ First import `Header`:
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
@ -33,7 +33,7 @@ First import `Header`:
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -60,7 +60,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/header_params/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial001_an.py!}
@ -75,7 +75,7 @@ The first value is the default value, you can pass all the extra validation or a
{!> ../../../docs_src/header_params/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -120,7 +120,7 @@ If for some reason you need to disable automatic conversion of underscores to hy
{!> ../../../docs_src/header_params/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/header_params/tutorial002_an.py!}
@ -135,7 +135,7 @@ If for some reason you need to disable automatic conversion of underscores to hy
{!> ../../../docs_src/header_params/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -169,7 +169,7 @@ For example, to declare a header of `X-Token` that can appear more than once, yo
{!> ../../../docs_src/header_params/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/header_params/tutorial003_an.py!}
@ -193,7 +193,7 @@ For example, to declare a header of `X-Token` that can appear more than once, yo
{!> ../../../docs_src/header_params/tutorial003_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

2
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. <details><summary><code>contact</code> fields</summary><table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>str</code></td><td>The identifying name of the contact person/organization.</td></tr><tr><td><code>url</code></td><td><code>str</code></td><td>The URL pointing to the contact information. MUST be in the format of a URL.</td></tr><tr><td><code>email</code></td><td><code>str</code></td><td>The email address of the contact person/organization. MUST be in the format of an email address.</td></tr></tbody></table></details> |
| `license_info` | `dict` | The license information for the exposed API. It can contain several fields. <details><summary><code>license_info</code> fields</summary><table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>str</code></td><td><strong>REQUIRED</strong> (if a <code>license_info</code> is set). The license name used for the API.</td></tr><tr><td><code>identifier</code></td><td><code>str</code></td><td>An <a href="https://spdx.dev/spdx-specification-21-web-version/#h.jxpfx0ykyb60" class="external-link" target="_blank">SPDX</a> license expression for the API. The <code>identifier</code> field is mutually exclusive of the <code>url</code> field. <small>Available since OpenAPI 3.1.0, FastAPI 0.99.0.</small></td></tr><tr><td><code>url</code></td><td><code>str</code></td><td>A URL to the license used for the API. MUST be in the format of a URL.</td></tr></tbody></table></details> |
| `license_info` | `dict` | The license information for the exposed API. It can contain several fields. <details><summary><code>license_info</code> fields</summary><table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>str</code></td><td><strong>REQUIRED</strong> (if a <code>license_info</code> is set). The license name used for the API.</td></tr><tr><td><code>identifier</code></td><td><code>str</code></td><td>An <a href="https://spdx.org/licenses/" class="external-link" target="_blank">SPDX</a> license expression for the API. The <code>identifier</code> field is mutually exclusive of the <code>url</code> field. <small>Available since OpenAPI 3.1.0, FastAPI 0.99.0.</small></td></tr><tr><td><code>url</code></td><td><code>str</code></td><td>A URL to the license used for the API. MUST be in the format of a URL.</td></tr></tbody></table></details> |
You can set them as follows:

10
docs/en/docs/tutorial/path-operation-configuration.md

@ -25,7 +25,7 @@ But if you don't remember what each number code is for, you can use the shortcut
{!> ../../../docs_src/path_operation_configuration/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 17"
{!> ../../../docs_src/path_operation_configuration/tutorial001.py!}
@ -54,7 +54,7 @@ You can add tags to your *path operation*, pass the parameter `tags` with a `lis
{!> ../../../docs_src/path_operation_configuration/tutorial002_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 22 27"
{!> ../../../docs_src/path_operation_configuration/tutorial002.py!}
@ -92,7 +92,7 @@ You can add a `summary` and `description`:
{!> ../../../docs_src/path_operation_configuration/tutorial003_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20-21"
{!> ../../../docs_src/path_operation_configuration/tutorial003.py!}
@ -116,7 +116,7 @@ You can write <a href="https://en.wikipedia.org/wiki/Markdown" class="external-l
{!> ../../../docs_src/path_operation_configuration/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="19-27"
{!> ../../../docs_src/path_operation_configuration/tutorial004.py!}
@ -142,7 +142,7 @@ You can specify the response description with the parameter `response_descriptio
{!> ../../../docs_src/path_operation_configuration/tutorial005_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/path_operation_configuration/tutorial005.py!}

26
docs/en/docs/tutorial/path-params-numeric-validations.md

@ -18,7 +18,7 @@ First, import `Path` from `fastapi`, and import `Annotated`:
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3-4"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
@ -33,7 +33,7 @@ First, import `Path` from `fastapi`, and import `Annotated`:
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -67,7 +67,7 @@ For example, to declare a `title` metadata value for the path parameter `item_id
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
@ -82,7 +82,7 @@ For example, to declare a `title` metadata value for the path parameter `item_id
{!> ../../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -117,7 +117,7 @@ It doesn't matter for **FastAPI**. It will detect the parameters by their names,
So, you can declare your function as:
=== "Python 3.6 non-Annotated"
=== "Python 3.8 non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -134,7 +134,7 @@ But have in mind that if you use `Annotated`, you won't have this problem, it wo
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
@ -174,7 +174,7 @@ Have in mind that if you use `Annotated`, as you are not using function paramete
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
@ -192,13 +192,13 @@ Here, with `ge=1`, `item_id` will need to be an integer number "`g`reater than o
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -220,13 +220,13 @@ The same applies for:
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -251,13 +251,13 @@ And the same for <abbr title="less than"><code>lt</code></abbr>.
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

22
docs/en/docs/tutorial/path-params.md

@ -46,16 +46,18 @@ But if you go to the browser at <a href="http://127.0.0.1:8000/items/foo" class=
```JSON
{
"detail": [
{
"loc": [
"path",
"item_id"
],
"msg": "value is not a valid integer",
"type": "type_error.integer"
}
]
"detail": [
{
"type": "int_parsing",
"loc": [
"path",
"item_id"
],
"msg": "Input should be a valid integer, unable to parse string as an integer",
"input": "foo",
"url": "https://errors.pydantic.dev/2.1/v/int_parsing"
}
]
}
```

95
docs/en/docs/tutorial/query-params-str-validations.md

@ -10,7 +10,7 @@ Let's take this application as example:
{!> ../../../docs_src/query_params_str_validations/tutorial001_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial001.py!}
@ -42,7 +42,7 @@ To achieve that, first import:
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
In versions of Python below Python 3.9 you import `Annotated` from `typing_extensions`.
@ -73,7 +73,7 @@ We had this type annotation:
q: str | None = None
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
q: Union[str, None] = None
@ -87,7 +87,7 @@ What we will do is wrap that with `Annotated`, so it becomes:
q: Annotated[str | None] = None
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
q: Annotated[Union[str, None]] = None
@ -107,7 +107,7 @@ Now that we have this `Annotated` where we can put more metadata, add `Query` to
{!> ../../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial002_an.py!}
@ -138,7 +138,7 @@ This is how you would use `Query()` as the default value of your function parame
{!> ../../../docs_src/query_params_str_validations/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params_str_validations/tutorial002.py!}
@ -251,7 +251,7 @@ You can also add a parameter `min_length`:
{!> ../../../docs_src/query_params_str_validations/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial003_an.py!}
@ -266,7 +266,7 @@ You can also add a parameter `min_length`:
{!> ../../../docs_src/query_params_str_validations/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -291,7 +291,7 @@ You can define a <abbr title="A regular expression, regex or regexp is a sequenc
{!> ../../../docs_src/query_params_str_validations/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12"
{!> ../../../docs_src/query_params_str_validations/tutorial004_an.py!}
@ -306,7 +306,7 @@ You can define a <abbr title="A regular expression, regex or regexp is a sequenc
{!> ../../../docs_src/query_params_str_validations/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -351,13 +351,13 @@ Let's say that you want to declare the `q` query parameter to have a `min_length
{!> ../../../docs_src/query_params_str_validations/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial005_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -405,13 +405,13 @@ So, when you need to declare a value as required while using `Query`, you can si
{!> ../../../docs_src/query_params_str_validations/tutorial006_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -435,13 +435,13 @@ There's an alternative way to explicitly declare that a value is required. You c
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial006b_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -475,7 +475,7 @@ To do that, you can declare that `None` is a valid type but still use `...` as t
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial006c_an.py!}
@ -490,7 +490,7 @@ To do that, you can declare that `None` is a valid type but still use `...` as t
{!> ../../../docs_src/query_params_str_validations/tutorial006c_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -502,33 +502,8 @@ To do that, you can declare that `None` is a valid type but still use `...` as t
!!! tip
Pydantic, which is what powers all the data validation and serialization in FastAPI, has a special behavior when you use `Optional` or `Union[Something, None]` without a default value, you can read more about it in the Pydantic docs about <a href="https://pydantic-docs.helpmanual.io/usage/models/#required-optional-fields" class="external-link" target="_blank">Required Optional fields</a>.
### Use Pydantic's `Required` instead of Ellipsis (`...`)
If you feel uncomfortable using `...`, you can also import and use `Required` from Pydantic:
=== "Python 3.9+"
```Python hl_lines="4 10"
{!> ../../../docs_src/query_params_str_validations/tutorial006d_an_py39.py!}
```
=== "Python 3.6+"
```Python hl_lines="2 9"
{!> ../../../docs_src/query_params_str_validations/tutorial006d_an.py!}
```
=== "Python 3.6+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
```Python hl_lines="2 8"
{!> ../../../docs_src/query_params_str_validations/tutorial006d.py!}
```
!!! tip
Remember that in most of the cases, when something is required, you can simply omit the default, so you normally don't have to use `...` nor `Required`.
Remember that in most of the cases, when something is required, you can simply omit the default, so you normally don't have to use `...`.
## Query parameter list / multiple values
@ -548,7 +523,7 @@ For example, to declare a query parameter `q` that can appear multiple times in
{!> ../../../docs_src/query_params_str_validations/tutorial011_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial011_an.py!}
@ -572,7 +547,7 @@ For example, to declare a query parameter `q` that can appear multiple times in
{!> ../../../docs_src/query_params_str_validations/tutorial011_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -617,7 +592,7 @@ And you can also define a default `list` of values if none are provided:
{!> ../../../docs_src/query_params_str_validations/tutorial012_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial012_an.py!}
@ -632,7 +607,7 @@ And you can also define a default `list` of values if none are provided:
{!> ../../../docs_src/query_params_str_validations/tutorial012_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -668,13 +643,13 @@ You can also use `list` directly instead of `List[str]` (or `list[str]` in Pytho
{!> ../../../docs_src/query_params_str_validations/tutorial013_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/query_params_str_validations/tutorial013_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -713,7 +688,7 @@ You can add a `title`:
{!> ../../../docs_src/query_params_str_validations/tutorial007_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial007_an.py!}
@ -728,7 +703,7 @@ You can add a `title`:
{!> ../../../docs_src/query_params_str_validations/tutorial007_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -751,7 +726,7 @@ And a `description`:
{!> ../../../docs_src/query_params_str_validations/tutorial008_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15"
{!> ../../../docs_src/query_params_str_validations/tutorial008_an.py!}
@ -766,7 +741,7 @@ And a `description`:
{!> ../../../docs_src/query_params_str_validations/tutorial008_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -805,7 +780,7 @@ Then you can declare an `alias`, and that alias is what will be used to find the
{!> ../../../docs_src/query_params_str_validations/tutorial009_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params_str_validations/tutorial009_an.py!}
@ -820,7 +795,7 @@ Then you can declare an `alias`, and that alias is what will be used to find the
{!> ../../../docs_src/query_params_str_validations/tutorial009_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -849,7 +824,7 @@ Then pass the parameter `deprecated=True` to `Query`:
{!> ../../../docs_src/query_params_str_validations/tutorial010_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20"
{!> ../../../docs_src/query_params_str_validations/tutorial010_an.py!}
@ -864,7 +839,7 @@ Then pass the parameter `deprecated=True` to `Query`:
{!> ../../../docs_src/query_params_str_validations/tutorial010_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -893,7 +868,7 @@ To exclude a query parameter from the generated OpenAPI schema (and thus, from t
{!> ../../../docs_src/query_params_str_validations/tutorial014_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/query_params_str_validations/tutorial014_an.py!}
@ -908,7 +883,7 @@ To exclude a query parameter from the generated OpenAPI schema (and thus, from t
{!> ../../../docs_src/query_params_str_validations/tutorial014_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

30
docs/en/docs/tutorial/query-params.md

@ -69,7 +69,7 @@ The same way, you can declare optional query parameters, by setting their defaul
{!> ../../../docs_src/query_params/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial002.py!}
@ -90,7 +90,7 @@ You can also declare `bool` types, and they will be converted:
{!> ../../../docs_src/query_params/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/query_params/tutorial003.py!}
@ -143,7 +143,7 @@ They will be detected by name:
{!> ../../../docs_src/query_params/tutorial004_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 10"
{!> ../../../docs_src/query_params/tutorial004.py!}
@ -173,16 +173,18 @@ http://127.0.0.1:8000/items/foo-item
```JSON
{
"detail": [
{
"loc": [
"query",
"needy"
],
"msg": "field required",
"type": "value_error.missing"
}
]
"detail": [
{
"type": "missing",
"loc": [
"query",
"needy"
],
"msg": "Field required",
"input": null,
"url": "https://errors.pydantic.dev/2.1/v/missing"
}
]
}
```
@ -209,7 +211,7 @@ And of course, you can define some parameters as required, some as having a defa
{!> ../../../docs_src/query_params/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/query_params/tutorial006.py!}

28
docs/en/docs/tutorial/request-files.md

@ -19,13 +19,13 @@ Import `File` and `UploadFile` from `fastapi`:
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -44,13 +44,13 @@ Create file parameters the same way you would for `Body` or `Form`:
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -85,13 +85,13 @@ Define a file parameter with a type of `UploadFile`:
{!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="13"
{!> ../../../docs_src/request_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -181,7 +181,7 @@ You can make a file optional by using standard type annotations and setting a de
{!> ../../../docs_src/request_files/tutorial001_02_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10 18"
{!> ../../../docs_src/request_files/tutorial001_02_an.py!}
@ -196,7 +196,7 @@ You can make a file optional by using standard type annotations and setting a de
{!> ../../../docs_src/request_files/tutorial001_02_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -215,13 +215,13 @@ You can also use `File()` with `UploadFile`, for example, to set additional meta
{!> ../../../docs_src/request_files/tutorial001_03_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8 14"
{!> ../../../docs_src/request_files/tutorial001_03_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -244,7 +244,7 @@ To use that, declare a list of `bytes` or `UploadFile`:
{!> ../../../docs_src/request_files/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11 16"
{!> ../../../docs_src/request_files/tutorial002_an.py!}
@ -259,7 +259,7 @@ To use that, declare a list of `bytes` or `UploadFile`:
{!> ../../../docs_src/request_files/tutorial002_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -285,7 +285,7 @@ And the same way as before, you can use `File()` to set additional parameters, e
{!> ../../../docs_src/request_files/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="12 19-21"
{!> ../../../docs_src/request_files/tutorial003_an.py!}
@ -300,7 +300,7 @@ And the same way as before, you can use `File()` to set additional parameters, e
{!> ../../../docs_src/request_files/tutorial003_py39.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/request-forms-and-files.md

@ -15,13 +15,13 @@ You can define files and form fields at the same time using `File` and `Form`.
{!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -40,13 +40,13 @@ Create file and form parameters the same way you would for `Body` or `Query`:
{!> ../../../docs_src/request_forms_and_files/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-11"
{!> ../../../docs_src/request_forms_and_files/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

8
docs/en/docs/tutorial/request-forms.md

@ -17,13 +17,13 @@ Import `Form` from `fastapi`:
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="1"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -42,13 +42,13 @@ Create form parameters the same way you would for `Body` or `Query`:
{!> ../../../docs_src/request_forms/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="8"
{!> ../../../docs_src/request_forms/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

28
docs/en/docs/tutorial/response-model.md

@ -16,7 +16,7 @@ You can use **type annotations** the same way you would for input data in functi
{!> ../../../docs_src/response_model/tutorial001_01_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18 23"
{!> ../../../docs_src/response_model/tutorial001_01.py!}
@ -65,7 +65,7 @@ You can use the `response_model` parameter in any of the *path operations*:
{!> ../../../docs_src/response_model/tutorial001_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="17 22 24-27"
{!> ../../../docs_src/response_model/tutorial001.py!}
@ -101,7 +101,7 @@ Here we are declaring a `UserIn` model, it will contain a plaintext password:
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11"
{!> ../../../docs_src/response_model/tutorial002.py!}
@ -121,7 +121,7 @@ And we are using this model to declare our input and the same model to declare o
{!> ../../../docs_src/response_model/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/response_model/tutorial002.py!}
@ -146,7 +146,7 @@ We can instead create an input model with the plaintext password and an output m
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9 11 16"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -160,7 +160,7 @@ Here, even though our *path operation function* is returning the same input user
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -174,7 +174,7 @@ Here, even though our *path operation function* is returning the same input user
{!> ../../../docs_src/response_model/tutorial003_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="22"
{!> ../../../docs_src/response_model/tutorial003.py!}
@ -208,7 +208,7 @@ And in those cases, we can use classes and inheritance to take advantage of func
{!> ../../../docs_src/response_model/tutorial003_01_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9-13 15-16 20"
{!> ../../../docs_src/response_model/tutorial003_01.py!}
@ -284,7 +284,7 @@ The same would happen if you had something like a <abbr title='A union between m
{!> ../../../docs_src/response_model/tutorial003_04_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="10"
{!> ../../../docs_src/response_model/tutorial003_04.py!}
@ -306,7 +306,7 @@ In this case, you can disable the response model generation by setting `response
{!> ../../../docs_src/response_model/tutorial003_05_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/response_model/tutorial003_05.py!}
@ -330,7 +330,7 @@ Your response model could have default values, like:
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11 13-14"
{!> ../../../docs_src/response_model/tutorial004.py!}
@ -360,7 +360,7 @@ You can set the *path operation decorator* parameter `response_model_exclude_uns
{!> ../../../docs_src/response_model/tutorial004_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24"
{!> ../../../docs_src/response_model/tutorial004.py!}
@ -447,7 +447,7 @@ This can be used as a quick shortcut if you have only one Pydantic model and wan
{!> ../../../docs_src/response_model/tutorial005_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial005.py!}
@ -468,7 +468,7 @@ If you forget to use a `set` and use a `list` or `tuple` instead, FastAPI will s
{!> ../../../docs_src/response_model/tutorial006_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31 37"
{!> ../../../docs_src/response_model/tutorial006.py!}

18
docs/en/docs/tutorial/schema-extra-example.md

@ -20,13 +20,13 @@ You can declare `examples` for a Pydantic model that will be added to the genera
{!> ../../../docs_src/schema_extra_example/tutorial001_py310_pv1.py!}
```
=== "Python 3.6+ Pydantic v2"
=== "Python 3.8+ Pydantic v2"
```Python hl_lines="15-26"
{!> ../../../docs_src/schema_extra_example/tutorial001.py!}
```
=== "Python 3.6+ Pydantic v1"
=== "Python 3.8+ Pydantic v1"
```Python hl_lines="15-25"
{!> ../../../docs_src/schema_extra_example/tutorial001_pv1.py!}
@ -68,7 +68,7 @@ When using `Field()` with Pydantic models, you can also declare additional `exam
{!> ../../../docs_src/schema_extra_example/tutorial002_py310.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 10-13"
{!> ../../../docs_src/schema_extra_example/tutorial002.py!}
@ -104,7 +104,7 @@ Here we pass `examples` containing one example of the data expected in `Body()`:
{!> ../../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23-30"
{!> ../../../docs_src/schema_extra_example/tutorial003_an.py!}
@ -119,7 +119,7 @@ Here we pass `examples` containing one example of the data expected in `Body()`:
{!> ../../../docs_src/schema_extra_example/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -150,7 +150,7 @@ You can of course also pass multiple `examples`:
{!> ../../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24-39"
{!> ../../../docs_src/schema_extra_example/tutorial004_an.py!}
@ -165,7 +165,7 @@ You can of course also pass multiple `examples`:
{!> ../../../docs_src/schema_extra_example/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -225,7 +225,7 @@ You can use it like this:
{!> ../../../docs_src/schema_extra_example/tutorial005_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24-50"
{!> ../../../docs_src/schema_extra_example/tutorial005_an.py!}
@ -240,7 +240,7 @@ You can use it like this:
{!> ../../../docs_src/schema_extra_example/tutorial005_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

12
docs/en/docs/tutorial/security/first-steps.md

@ -26,13 +26,13 @@ Copy the example in a file `main.py`:
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -140,13 +140,13 @@ When we create an instance of the `OAuth2PasswordBearer` class we pass in the `t
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7"
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -191,13 +191,13 @@ Now you can pass that `oauth2_scheme` in a dependency with `Depends`.
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

24
docs/en/docs/tutorial/security/get-current-user.md

@ -8,13 +8,13 @@ In the previous chapter the security system (which is based on the dependency in
{!> ../../../docs_src/security/tutorial001_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="11"
{!> ../../../docs_src/security/tutorial001_an.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -45,7 +45,7 @@ The same way we use Pydantic to declare bodies, we can use it anywhere else:
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="5 13-17"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -60,7 +60,7 @@ The same way we use Pydantic to declare bodies, we can use it anywhere else:
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -91,7 +91,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="26"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -106,7 +106,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -131,7 +131,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="20-23 27-28"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -146,7 +146,7 @@ The same as we were doing before in the *path operation* directly, our new depen
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -171,7 +171,7 @@ So now we can use the same `Depends` with our `get_current_user` in the *path op
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="32"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -186,7 +186,7 @@ So now we can use the same `Depends` with our `get_current_user` in the *path op
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -253,7 +253,7 @@ And all these thousands of *path operations* can be as small as 3 lines:
{!> ../../../docs_src/security/tutorial002_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="31-33"
{!> ../../../docs_src/security/tutorial002_an.py!}
@ -268,7 +268,7 @@ And all these thousands of *path operations* can be as small as 3 lines:
{!> ../../../docs_src/security/tutorial002_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

16
docs/en/docs/tutorial/security/oauth2-jwt.md

@ -121,7 +121,7 @@ And another one to authenticate and return a user.
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="7 49 56-57 60-61 70-76"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -136,7 +136,7 @@ And another one to authenticate and return a user.
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -188,7 +188,7 @@ Create a utility function to generate a new access token.
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="6 13-15 29-31 79-87"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -203,7 +203,7 @@ Create a utility function to generate a new access token.
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -232,7 +232,7 @@ If the token is invalid, return an HTTP error right away.
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="90-107"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -247,7 +247,7 @@ If the token is invalid, return an HTTP error right away.
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -274,7 +274,7 @@ Create a real JWT access token and return it
{!> ../../../docs_src/security/tutorial004_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="118-133"
{!> ../../../docs_src/security/tutorial004_an.py!}
@ -289,7 +289,7 @@ Create a real JWT access token and return it
{!> ../../../docs_src/security/tutorial004_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

20
docs/en/docs/tutorial/security/simple-oauth2.md

@ -61,7 +61,7 @@ First, import `OAuth2PasswordRequestForm`, and use it as a dependency with `Depe
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="4 79"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -76,7 +76,7 @@ First, import `OAuth2PasswordRequestForm`, and use it as a dependency with `Depe
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -134,7 +134,7 @@ For the error, we use the exception `HTTPException`:
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 80-82"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -149,7 +149,7 @@ For the error, we use the exception `HTTPException`:
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -194,7 +194,7 @@ So, the thief won't be able to try to use those same passwords in another system
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="83-86"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -209,7 +209,7 @@ So, the thief won't be able to try to use those same passwords in another system
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -264,7 +264,7 @@ For this simple example, we are going to just be completely insecure and return
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="88"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -279,7 +279,7 @@ For this simple example, we are going to just be completely insecure and return
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.
@ -321,7 +321,7 @@ So, in our endpoint, we will only get a user if the user exists, was correctly a
{!> ../../../docs_src/security/tutorial003_an_py39.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="59-67 70-75 95"
{!> ../../../docs_src/security/tutorial003_an.py!}
@ -336,7 +336,7 @@ So, in our endpoint, we will only get a user if the user exists, was correctly a
{!> ../../../docs_src/security/tutorial003_py310.py!}
```
=== "Python 3.6+ non-Annotated"
=== "Python 3.8+ non-Annotated"
!!! tip
Prefer to use the `Annotated` version if possible.

20
docs/en/docs/tutorial/sql-databases.md

@ -281,7 +281,7 @@ But for security, the `password` won't be in other Pydantic *models*, for exampl
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="3 6-8 11-12 23-24 27-28"
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -325,7 +325,7 @@ Not only the IDs of those items, but all the data that we defined in the Pydanti
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15-17 31-34"
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -354,7 +354,7 @@ In the `Config` class, set the attribute `orm_mode = True`.
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15 19-20 31 36-37"
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -494,7 +494,7 @@ In a very simplistic way create the database tables:
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="9"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -528,7 +528,7 @@ Our dependency will create a new SQLAlchemy `SessionLocal` that will be used in
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="15-20"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -553,7 +553,7 @@ This will then give us better editor support inside the *path operation function
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="24 32 38 47 53"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -574,7 +574,7 @@ Now, finally, here's the standard **FastAPI** *path operations* code.
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="23-28 31-34 37-42 45-49 52-55"
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -673,7 +673,7 @@ For example, in a background task worker with <a href="https://docs.celeryq.dev"
{!> ../../../docs_src/sql_databases/sql_app_py39/schemas.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/sql_databases/sql_app/schemas.py!}
@ -693,7 +693,7 @@ For example, in a background task worker with <a href="https://docs.celeryq.dev"
{!> ../../../docs_src/sql_databases/sql_app_py39/main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python
{!> ../../../docs_src/sql_databases/sql_app/main.py!}
@ -752,7 +752,7 @@ The middleware we'll add (just a function) will create a new SQLAlchemy `Session
{!> ../../../docs_src/sql_databases/sql_app_py39/alt_main.py!}
```
=== "Python 3.6+"
=== "Python 3.8+"
```Python hl_lines="14-22"
{!> ../../../docs_src/sql_databases/sql_app/alt_main.py!}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save