diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml
index 2fd46df6b..387063f12 100644
--- a/.github/workflows/deploy-docs.yml
+++ b/.github/workflows/deploy-docs.yml
@@ -62,7 +62,10 @@ jobs:
env:
PROJECT_NAME: fastapitiangolo
BRANCH: ${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
- uses: cloudflare/wrangler-action@v3
+ # TODO: Use v3 when it's fixed, probably in v3.11
+ # https://github.com/cloudflare/wrangler-action/issues/307
+ uses: cloudflare/wrangler-action@v3.12
+ # uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
diff --git a/.github/workflows/latest-changes.yml b/.github/workflows/latest-changes.yml
index 16da3bc63..b8b5c42ee 100644
--- a/.github/workflows/latest-changes.yml
+++ b/.github/workflows/latest-changes.yml
@@ -34,7 +34,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- - uses: tiangolo/latest-changes@0.3.1
+ - uses: tiangolo/latest-changes@0.3.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
latest_changes_file: docs/en/docs/release-notes.md
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index c8ea4e18c..fc61c3fca 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -35,7 +35,7 @@ jobs:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish
- uses: pypa/gh-action-pypi-publish@v1.10.3
+ uses: pypa/gh-action-pypi-publish@v1.12.2
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a62acccfe..d90e7281e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.6.9
+ rev: v0.7.2
hooks:
- id: ruff
args:
diff --git a/README.md b/README.md
index f274265de..62eeda03b 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,7 @@ The key features are:
+
@@ -95,7 +96,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
-
get
-Operation gehen
-/// info | "`@decorator` Information"
+/// info | `@decorator` Information
Diese `@something`-Syntax wird in Python „Dekorator“ genannt.
@@ -286,7 +286,7 @@ Oder die exotischeren:
* `@app.patch()`
* `@app.trace()`
-/// tip | "Tipp"
+/// tip | Tipp
Es steht Ihnen frei, jede Operation (HTTP-Methode) so zu verwenden, wie Sie es möchten.
@@ -324,7 +324,7 @@ Sie könnten sie auch als normale Funktion anstelle von `async def` definieren:
{!../../docs_src/first_steps/tutorial003.py!}
```
-/// note | "Hinweis"
+/// note | Hinweis
Wenn Sie den Unterschied nicht kennen, lesen Sie [Async: *„In Eile?“*](../async.md#in-eile){.internal-link target=_blank}.
diff --git a/docs/de/docs/tutorial/handling-errors.md b/docs/de/docs/tutorial/handling-errors.md
index 70dc0c523..85de76ef1 100644
--- a/docs/de/docs/tutorial/handling-errors.md
+++ b/docs/de/docs/tutorial/handling-errors.md
@@ -63,7 +63,7 @@ Aber wenn der Client `http://example.com/items/bar` anfragt (ein nicht-existiere
}
```
-/// tip | "Tipp"
+/// tip | Tipp
Wenn Sie eine `HTTPException` auslösen, können Sie dem Parameter `detail` jeden Wert übergeben, der nach JSON konvertiert werden kann, nicht nur `str`.
@@ -109,7 +109,7 @@ Sie erhalten also einen sauberen Error mit einem Statuscode `418` und dem JSON-I
{"message": "Oops! yolo did something. There goes a rainbow..."}
```
-/// note | "Technische Details"
+/// note | Technische Details
Sie können auch `from starlette.requests import Request` und `from starlette.responses import JSONResponse` verwenden.
@@ -166,7 +166,7 @@ path -> item_id
#### `RequestValidationError` vs. `ValidationError`
-/// warning | "Achtung"
+/// warning | Achtung
Das folgende sind technische Details, die Sie überspringen können, wenn sie für Sie nicht wichtig sind.
@@ -192,7 +192,7 @@ Zum Beispiel könnten Sie eine Klartext-Response statt JSON für diese Fehler zu
{!../../docs_src/handling_errors/tutorial004.py!}
```
-/// note | "Technische Details"
+/// note | Technische Details
Sie können auch `from starlette.responses import PlainTextResponse` verwenden.
diff --git a/docs/de/docs/tutorial/header-params.md b/docs/de/docs/tutorial/header-params.md
index c4901c2ee..40a773f50 100644
--- a/docs/de/docs/tutorial/header-params.md
+++ b/docs/de/docs/tutorial/header-params.md
@@ -32,7 +32,7 @@ Importieren Sie zuerst `Header`:
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -46,7 +46,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -90,7 +90,7 @@ Der erste Wert ist der Typ. Sie können `Header` die gehabten Extra Validierungs
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -104,7 +104,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -116,7 +116,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
////
-/// note | "Technische Details"
+/// note | Technische Details
`Header` ist eine Schwesterklasse von `Path`, `Query` und `Cookie`. Sie erbt von derselben gemeinsamen `Param`-Elternklasse.
@@ -172,7 +172,7 @@ Wenn Sie aus irgendeinem Grund das automatische Konvertieren von Unterstrichen z
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -186,7 +186,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -198,7 +198,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
////
-/// warning | "Achtung"
+/// warning | Achtung
Bevor Sie `convert_underscores` auf `False` setzen, bedenken Sie, dass manche HTTP-Proxys und Server die Verwendung von Headern mit Unterstrichen nicht erlauben.
@@ -240,7 +240,7 @@ Um zum Beispiel einen Header `X-Token` zu deklarieren, der mehrmals vorkommen ka
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -254,7 +254,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.9+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -268,7 +268,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
diff --git a/docs/de/docs/tutorial/index.md b/docs/de/docs/tutorial/index.md
index c15d0b0bd..3cbfe37f4 100644
--- a/docs/de/docs/tutorial/index.md
+++ b/docs/de/docs/tutorial/index.md
@@ -52,7 +52,7 @@ $ pip install "fastapi[all]"
... das beinhaltet auch `uvicorn`, welchen Sie als Server verwenden können, der ihren Code ausführt.
-/// note | "Hinweis"
+/// note | Hinweis
Sie können die einzelnen Teile auch separat installieren.
diff --git a/docs/de/docs/tutorial/metadata.md b/docs/de/docs/tutorial/metadata.md
index 98724e1e8..5a0b723c5 100644
--- a/docs/de/docs/tutorial/metadata.md
+++ b/docs/de/docs/tutorial/metadata.md
@@ -22,7 +22,7 @@ Sie können diese wie folgt setzen:
{!../../docs_src/metadata/tutorial001.py!}
```
-/// tip | "Tipp"
+/// tip | Tipp
Sie können Markdown in das Feld `description` schreiben und es wird in der Ausgabe gerendert.
@@ -68,7 +68,7 @@ Erstellen Sie Metadaten für Ihre Tags und übergeben Sie sie an den Parameter `
Beachten Sie, dass Sie Markdown in den Beschreibungen verwenden können. Beispielsweise wird „login“ in Fettschrift (**login**) und „fancy“ in Kursivschrift (_fancy_) angezeigt.
-/// tip | "Tipp"
+/// tip | Tipp
Sie müssen nicht für alle von Ihnen verwendeten Tags Metadaten hinzufügen.
diff --git a/docs/de/docs/tutorial/middleware.md b/docs/de/docs/tutorial/middleware.md
index 410dc0247..d3699be1b 100644
--- a/docs/de/docs/tutorial/middleware.md
+++ b/docs/de/docs/tutorial/middleware.md
@@ -11,7 +11,7 @@ Eine „Middleware“ ist eine Funktion, die mit jedem **Request** arbeitet, bev
* Sie kann etwas mit dieser **Response** tun oder beliebigen Code ausführen.
* Dann gibt sie die **Response** zurück.
-/// note | "Technische Details"
+/// note | Technische Details
Wenn Sie Abhängigkeiten mit `yield` haben, wird der Exit-Code *nach* der Middleware ausgeführt.
@@ -31,11 +31,9 @@ Die Middleware-Funktion erhält:
* Dann gibt es die von der entsprechenden *Pfadoperation* generierte `response` zurück.
* Sie können die `response` dann weiter modifizieren, bevor Sie sie zurückgeben.
-```Python hl_lines="8-9 11 14"
-{!../../docs_src/middleware/tutorial001.py!}
-```
+{* ../../docs_src/middleware/tutorial001.py hl[8:9,11,14] *}
-/// tip | "Tipp"
+/// tip | Tipp
Beachten Sie, dass benutzerdefinierte proprietäre Header hinzugefügt werden können. Verwenden Sie dafür das Präfix 'X-'.
@@ -43,7 +41,7 @@ Wenn Sie jedoch benutzerdefinierte Header haben, die ein Client in einem Browser
///
-/// note | "Technische Details"
+/// note | Technische Details
Sie könnten auch `from starlette.requests import Request` verwenden.
@@ -59,9 +57,7 @@ Und auch nachdem die `response` generiert wurde, bevor sie zurückgegeben wird.
Sie könnten beispielsweise einen benutzerdefinierten Header `X-Process-Time` hinzufügen, der die Zeit in Sekunden enthält, die benötigt wurde, um den Request zu verarbeiten und eine Response zu generieren:
-```Python hl_lines="10 12-13"
-{!../../docs_src/middleware/tutorial001.py!}
-```
+{* ../../docs_src/middleware/tutorial001.py hl[10,12:13] *}
## Andere Middlewares
diff --git a/docs/de/docs/tutorial/path-operation-configuration.md b/docs/de/docs/tutorial/path-operation-configuration.md
index 411916e9c..55d0f2a91 100644
--- a/docs/de/docs/tutorial/path-operation-configuration.md
+++ b/docs/de/docs/tutorial/path-operation-configuration.md
@@ -2,7 +2,7 @@
Es gibt mehrere Konfigurations-Parameter, die Sie Ihrem *Pfadoperation-Dekorator* übergeben können.
-/// warning | "Achtung"
+/// warning | Achtung
Beachten Sie, dass diese Parameter direkt dem *Pfadoperation-Dekorator* übergeben werden, nicht der *Pfadoperation-Funktion*.
@@ -42,7 +42,7 @@ Aber falls Sie sich nicht mehr erinnern, wofür jede Nummer steht, können Sie d
Dieser Statuscode wird in der Response verwendet und zum OpenAPI-Schema hinzugefügt.
-/// note | "Technische Details"
+/// note | Technische Details
Sie können auch `from starlette import status` verwenden.
diff --git a/docs/de/docs/tutorial/path-params-numeric-validations.md b/docs/de/docs/tutorial/path-params-numeric-validations.md
index fc2d5dff1..b74fc8a04 100644
--- a/docs/de/docs/tutorial/path-params-numeric-validations.md
+++ b/docs/de/docs/tutorial/path-params-numeric-validations.md
@@ -32,7 +32,7 @@ Importieren Sie zuerst `Path` von `fastapi`, und importieren Sie `Annotated`.
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -46,7 +46,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -100,7 +100,7 @@ Um zum Beispiel einen `title`-Metadaten-Wert für den Pfad-Parameter `item_id` z
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -114,7 +114,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -126,7 +126,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
////
-/// note | "Hinweis"
+/// note | Hinweis
Ein Pfad-Parameter ist immer erforderlich, weil er Teil des Pfads sein muss.
@@ -138,7 +138,7 @@ Doch selbst wenn Sie ihn mit `None` deklarieren, oder einen Defaultwert setzen,
## Sortieren Sie die Parameter, wie Sie möchten
-/// tip | "Tipp"
+/// tip | Tipp
Wenn Sie `Annotated` verwenden, ist das folgende nicht so wichtig / nicht notwendig.
@@ -160,7 +160,7 @@ Sie können Ihre Funktion also so deklarieren:
//// tab | Python 3.8 nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -192,7 +192,7 @@ Aber bedenken Sie, dass Sie dieses Problem nicht haben, wenn Sie `Annotated` ver
## Sortieren Sie die Parameter wie Sie möchten: Tricks
-/// tip | "Tipp"
+/// tip | Tipp
Wenn Sie `Annotated` verwenden, ist das folgende nicht so wichtig / nicht notwendig.
@@ -260,7 +260,7 @@ Hier, mit `ge=1`, wird festgelegt, dass `item_id` eine Ganzzahl benötigt, die g
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -297,7 +297,7 @@ Das Gleiche trifft zu auf:
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -337,7 +337,7 @@ Das gleiche gilt für lt
Modellen für maschinelles Lernen.
@@ -199,7 +199,7 @@ Den tatsächlichen Wert (in diesem Fall ein `str`) erhalten Sie via `model_name.
{!../../docs_src/path_params/tutorial005.py!}
```
-/// tip | "Tipp"
+/// tip | Tipp
Sie können den Wert `"lenet"` außerdem mittels `ModelName.lenet.value` abrufen.
@@ -256,7 +256,7 @@ Sie verwenden das also wie folgt:
{!../../docs_src/path_params/tutorial004.py!}
```
-/// tip | "Tipp"
+/// tip | Tipp
Der Parameter könnte einen führenden Schrägstrich (`/`) haben, wie etwa in `/home/johndoe/myfile.txt`.
diff --git a/docs/de/docs/tutorial/query-params-str-validations.md b/docs/de/docs/tutorial/query-params-str-validations.md
index a9f1e0f39..d71a23dc2 100644
--- a/docs/de/docs/tutorial/query-params-str-validations.md
+++ b/docs/de/docs/tutorial/query-params-str-validations.md
@@ -22,7 +22,7 @@ Nehmen wir als Beispiel die folgende Anwendung:
Der Query-Parameter `q` hat den Typ `Union[str, None]` (oder `str | None` in Python 3.10), was bedeutet, er ist entweder ein `str` oder `None`. Der Defaultwert ist `None`, also weiß FastAPI, der Parameter ist nicht erforderlich.
-/// note | "Hinweis"
+/// note | Hinweis
FastAPI weiß nur dank des definierten Defaultwertes `=None`, dass der Wert von `q` nicht erforderlich ist
@@ -153,7 +153,7 @@ FastAPI wird nun:
Frühere Versionen von FastAPI (vor 0.95.0) benötigten `Query` als Defaultwert des Parameters, statt es innerhalb von `Annotated` unterzubringen. Die Chance ist groß, dass Sie Quellcode sehen, der das immer noch so macht, darum erkläre ich es Ihnen.
-/// tip | "Tipp"
+/// tip | Tipp
Verwenden Sie für neuen Code, und wann immer möglich, `Annotated`, wie oben erklärt. Es gibt mehrere Vorteile (unten erläutert) und keine Nachteile. 🍰
@@ -301,7 +301,7 @@ Sie können auch einen Parameter `min_length` hinzufügen:
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -315,7 +315,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -357,7 +357,7 @@ Sie können einen ../../docs_src/query_params_str_validations/tutorial006.py!}
```
-/// tip | "Tipp"
+/// tip | Tipp
Beachten Sie, dass, obwohl in diesem Fall `Query()` der Funktionsparameter-Defaultwert ist, wir nicht `default=None` zu `Query()` hinzufügen.
@@ -545,7 +545,7 @@ Es gibt eine Alternative, die explizit deklariert, dass ein Wert erforderlich is
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -599,7 +599,7 @@ Um das zu machen, deklarieren Sie, dass `None` ein gültiger Typ ist, aber verwe
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -613,7 +613,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -625,13 +625,13 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
////
-/// tip | "Tipp"
+/// tip | Tipp
Pydantic, welches die gesamte Datenvalidierung und Serialisierung in FastAPI antreibt, hat ein spezielles Verhalten, wenn Sie `Optional` oder `Union[Something, None]` ohne Defaultwert verwenden, Sie können mehr darüber in der Pydantic-Dokumentation unter Required fields erfahren.
///
-/// tip | "Tipp"
+/// tip | Tipp
Denken Sie daran, dass Sie in den meisten Fällen, wenn etwas erforderlich ist, einfach den Defaultwert weglassen können. Sie müssen also normalerweise `...` nicht verwenden.
@@ -669,7 +669,7 @@ Um zum Beispiel einen Query-Parameter `q` zu deklarieren, der mehrere Male in de
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -683,7 +683,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.9+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -697,7 +697,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -728,7 +728,7 @@ Die Response für diese URL wäre also:
}
```
-/// tip | "Tipp"
+/// tip | Tipp
Um einen Query-Parameter vom Typ `list` zu deklarieren, wie im Beispiel oben, müssen Sie explizit `Query` verwenden, sonst würde der Parameter als Requestbody interpretiert werden.
@@ -760,7 +760,7 @@ Und Sie können auch eine Default-`list`e von Werten definieren, wenn keine übe
//// tab | Python 3.9+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -774,7 +774,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -825,7 +825,7 @@ Sie können auch `list` direkt verwenden, anstelle von `List[str]` (oder `list[s
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -837,7 +837,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
////
-/// note | "Hinweis"
+/// note | Hinweis
Beachten Sie, dass FastAPI in diesem Fall den Inhalt der Liste nicht überprüft.
@@ -851,7 +851,7 @@ Sie können mehr Informationen zum Parameter hinzufügen.
Diese Informationen werden zur generierten OpenAPI hinzugefügt, und von den Dokumentations-Oberflächen und von externen Tools verwendet.
-/// note | "Hinweis"
+/// note | Hinweis
Beachten Sie, dass verschiedene Tools OpenAPI möglicherweise unterschiedlich gut unterstützen.
@@ -887,7 +887,7 @@ Sie können einen Titel hinzufügen – `title`:
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -901,7 +901,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -941,7 +941,7 @@ Und eine Beschreibung – `description`:
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -955,7 +955,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -1011,7 +1011,7 @@ Dann können Sie einen `alias` deklarieren, und dieser Alias wird verwendet, um
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -1025,7 +1025,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -1071,7 +1071,7 @@ In diesem Fall fügen Sie den Parameter `deprecated=True` zu `Query` hinzu.
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -1085,7 +1085,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -1131,7 +1131,7 @@ Um einen Query-Parameter vom generierten OpenAPI-Schema auszuschließen (und dah
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -1145,7 +1145,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
diff --git a/docs/de/docs/tutorial/query-params.md b/docs/de/docs/tutorial/query-params.md
index bb1dbdf9c..e67fef79d 100644
--- a/docs/de/docs/tutorial/query-params.md
+++ b/docs/de/docs/tutorial/query-params.md
@@ -241,7 +241,7 @@ In diesem Fall gibt es drei Query-Parameter:
* `skip`, ein `int` mit einem Defaultwert `0`.
* `limit`, ein optionales `int`.
-/// tip | "Tipp"
+/// tip | Tipp
Sie können auch `Enum`s verwenden, auf die gleiche Weise wie mit [Pfad-Parametern](path-params.md#vordefinierte-parameterwerte){.internal-link target=_blank}.
diff --git a/docs/de/docs/tutorial/request-files.md b/docs/de/docs/tutorial/request-files.md
index c0d0ef3f2..cbfb4271f 100644
--- a/docs/de/docs/tutorial/request-files.md
+++ b/docs/de/docs/tutorial/request-files.md
@@ -34,7 +34,7 @@ Importieren Sie `File` und `UploadFile` von `fastapi`:
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -68,7 +68,7 @@ Erstellen Sie Datei-Parameter, so wie Sie es auch mit `Body` und `Form` machen w
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -88,7 +88,7 @@ Aber erinnern Sie sich, dass, wenn Sie `Query`, `Path`, `File` und andere von `
///
-/// tip | "Tipp"
+/// tip | Tipp
Um Dateibodys zu deklarieren, müssen Sie `File` verwenden, da diese Parameter sonst als Query-Parameter oder Body(-JSON)-Parameter interpretiert werden würden.
@@ -124,7 +124,7 @@ Definieren Sie einen Datei-Parameter mit dem Typ `UploadFile`:
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -177,13 +177,13 @@ Wenn Sie sich innerhalb einer normalen `def`-*Pfadoperation-Funktion* befinden,
contents = myfile.file.read()
```
-/// note | "Technische Details zu `async`"
+/// note | Technische Details zu `async`
Wenn Sie die `async`-Methoden verwenden, führt **FastAPI** die Datei-Methoden in einem Threadpool aus und erwartet sie.
///
-/// note | "Technische Details zu Starlette"
+/// note | Technische Details zu Starlette
**FastAPI**s `UploadFile` erbt direkt von **Starlette**s `UploadFile`, fügt aber ein paar notwendige Teile hinzu, um es kompatibel mit **Pydantic** und anderen Teilen von FastAPI zu machen.
@@ -195,7 +195,7 @@ HTML-Formulare (``) senden die Daten in einer „speziellen“ Kodi
**FastAPI** stellt sicher, dass diese Daten korrekt ausgelesen werden, statt JSON zu erwarten.
-/// note | "Technische Details"
+/// note | Technische Details
Daten aus Formularen werden, wenn es keine Dateien sind, normalerweise mit dem „media type“ `application/x-www-form-urlencoded` kodiert.
@@ -205,7 +205,7 @@ Wenn Sie mehr über Formularfelder und ihre Kodierungen lesen möchten, besuchen
///
-/// warning | "Achtung"
+/// warning | Achtung
Sie können mehrere `File`- und `Form`-Parameter in einer *Pfadoperation* deklarieren, aber Sie können nicht gleichzeitig auch `Body`-Felder deklarieren, welche Sie als JSON erwarten, da der Request den Body mittels `multipart/form-data` statt `application/json` kodiert.
@@ -243,7 +243,7 @@ Sie können eine Datei optional machen, indem Sie Standard-Typannotationen verwe
//// tab | Python 3.10+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -257,7 +257,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -291,7 +291,7 @@ Sie können auch `File()` zusammen mit `UploadFile` verwenden, um zum Beispiel z
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -329,7 +329,7 @@ Um das zu machen, deklarieren Sie eine Liste von `bytes` oder `UploadFile`s:
//// tab | Python 3.9+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -343,7 +343,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -357,7 +357,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
Sie erhalten, wie deklariert, eine `list`e von `bytes` oder `UploadFile`s.
-/// note | "Technische Details"
+/// note | Technische Details
Sie können auch `from starlette.responses import HTMLResponse` verwenden.
@@ -387,7 +387,7 @@ Und so wie zuvor können Sie `File()` verwenden, um zusätzliche Parameter zu se
//// tab | Python 3.9+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -401,7 +401,7 @@ Bevorzugen Sie die `Annotated`-Version, falls möglich.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
diff --git a/docs/de/docs/tutorial/request-forms-and-files.md b/docs/de/docs/tutorial/request-forms-and-files.md
index 2b89edbb4..bdd1e0fac 100644
--- a/docs/de/docs/tutorial/request-forms-and-files.md
+++ b/docs/de/docs/tutorial/request-forms-and-files.md
@@ -30,7 +30,7 @@ Z. B. `pip install python-multipart`.
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -64,7 +64,7 @@ Erstellen Sie Datei- und Formularparameter, so wie Sie es auch mit `Body` und `Q
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -80,7 +80,7 @@ Die Datei- und Formularfelder werden als Formulardaten hochgeladen, und Sie erha
Und Sie können einige der Dateien als `bytes` und einige als `UploadFile` deklarieren.
-/// warning | "Achtung"
+/// warning | Achtung
Sie können mehrere `File`- und `Form`-Parameter in einer *Pfadoperation* deklarieren, aber Sie können nicht gleichzeitig auch `Body`-Felder deklarieren, welche Sie als JSON erwarten, da der Request den Body mittels `multipart/form-data` statt `application/json` kodiert.
diff --git a/docs/de/docs/tutorial/request-forms.md b/docs/de/docs/tutorial/request-forms.md
index 0784aa8c0..2b6aeb41c 100644
--- a/docs/de/docs/tutorial/request-forms.md
+++ b/docs/de/docs/tutorial/request-forms.md
@@ -32,7 +32,7 @@ Importieren Sie `Form` von `fastapi`:
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -66,7 +66,7 @@ Erstellen Sie Formular-Parameter, so wie Sie es auch mit `Body` und `Query` mach
//// tab | Python 3.8+ nicht annotiert
-/// tip | "Tipp"
+/// tip | Tipp
Bevorzugen Sie die `Annotated`-Version, falls möglich.
@@ -90,7 +90,7 @@ Mit `Form` haben Sie die gleichen Konfigurationsmöglichkeiten wie mit `Body` (u
///
-/// tip | "Tipp"
+/// tip | Tipp
Um Formularbodys zu deklarieren, verwenden Sie explizit `Form`, da diese Parameter sonst als Query-Parameter oder Body(-JSON)-Parameter interpretiert werden würden.
@@ -102,7 +102,7 @@ HTML-Formulare (``) senden die Daten in einer „speziellen“ Kodi
**FastAPI** stellt sicher, dass diese Daten korrekt ausgelesen werden, statt JSON zu erwarten.
-/// note | "Technische Details"
+/// note | Technische Details
Daten aus Formularen werden normalerweise mit dem „media type“ `application/x-www-form-urlencoded` kodiert.
@@ -112,7 +112,7 @@ Wenn Sie mehr über Formularfelder und ihre Kodierungen lesen möchten, besuchen
///
-/// warning | "Achtung"
+/// warning | Achtung
Sie können mehrere `Form`-Parameter in einer *Pfadoperation* deklarieren, aber Sie können nicht gleichzeitig auch `Body`-Felder deklarieren, welche Sie als JSON erwarten, da der Request den Body mittels `application/x-www-form-urlencoded` statt `application/json` kodiert.
diff --git a/docs/de/docs/tutorial/response-model.md b/docs/de/docs/tutorial/response-model.md
index 31ad73c77..aa27e0726 100644
--- a/docs/de/docs/tutorial/response-model.md
+++ b/docs/de/docs/tutorial/response-model.md
@@ -83,7 +83,7 @@ Sie können `response_model` in jeder möglichen *Pfadoperation* verwenden:
////
-/// note | "Hinweis"
+/// note | Hinweis
Beachten Sie, dass `response_model` ein Parameter der „Dekorator“-Methode ist (`get`, `post`, usw.). Nicht der *Pfadoperation-Funktion*, so wie die anderen Parameter.
@@ -93,7 +93,7 @@ Beachten Sie, dass `response_model` ein Parameter der „Dekorator“-Methode is
FastAPI wird dieses `response_model` nehmen, um die Daten zu dokumentieren, validieren, usw. und auch, um **die Ausgabedaten** entsprechend der Typdeklaration **zu konvertieren und filtern**.
-/// tip | "Tipp"
+/// tip | Tipp
Wenn Sie in Ihrem Editor strikte Typchecks haben, mypy, usw., können Sie den Funktions-Rückgabetyp als `Any` deklarieren.
@@ -162,7 +162,7 @@ Hier ist das möglicherweise kein Problem, da es derselbe Benutzer ist, der das
Aber wenn wir dasselbe Modell für eine andere *Pfadoperation* verwenden, könnten wir das Passwort dieses Benutzers zu jedem Client schicken.
-/// danger | "Gefahr"
+/// danger | Gefahr
Speichern Sie niemals das Klartext-Passwort eines Benutzers, oder versenden Sie es in einer Response wie dieser, wenn Sie sich nicht der resultierenden Gefahren bewusst sind und nicht wissen, was Sie tun.
@@ -503,7 +503,7 @@ dann ist FastAPI klug genug (tatsächlich ist Pydantic klug genug) zu erkennen,
Diese Felder werden also in der JSON-Response enthalten sein.
-/// tip | "Tipp"
+/// tip | Tipp
Beachten Sie, dass Defaultwerte alles Mögliche sein können, nicht nur `None`.
@@ -519,7 +519,7 @@ Diese nehmen ein `set` von `str`s entgegen, welches Namen von Attributen sind, d
Das kann als schnelle Abkürzung verwendet werden, wenn Sie nur ein Pydantic-Modell haben und ein paar Daten von der Ausgabe ausschließen wollen.
-/// tip | "Tipp"
+/// tip | Tipp
Es wird dennoch empfohlen, dass Sie die Ideen von oben verwenden, also mehrere Klassen statt dieser Parameter.
@@ -545,7 +545,7 @@ Das trifft auch auf `response_model_by_alias` zu, welches ähnlich funktioniert.
////
-/// tip | "Tipp"
+/// tip | Tipp
Die Syntax `{"name", "description"}` erzeugt ein `set` mit diesen zwei Werten.
diff --git a/docs/de/docs/tutorial/response-status-code.md b/docs/de/docs/tutorial/response-status-code.md
index 872007a12..a1b388a0a 100644
--- a/docs/de/docs/tutorial/response-status-code.md
+++ b/docs/de/docs/tutorial/response-status-code.md
@@ -8,11 +8,9 @@ So wie ein Responsemodell, können Sie auch einen HTTP-Statuscode für die Respo
* `@app.delete()`
* usw.
-```Python hl_lines="6"
-{!../../docs_src/response_status_code/tutorial001.py!}
-```
+{* ../../docs_src/response_status_code/tutorial001.py hl[6] *}
-/// note | "Hinweis"
+/// note | Hinweis
Beachten Sie, dass `status_code` ein Parameter der „Dekorator“-Methode ist (`get`, `post`, usw.). Nicht der *Pfadoperation-Funktion*, so wie die anderen Parameter und der Body.
@@ -33,7 +31,7 @@ Das wird:
get
🛠️
-/// info | "`@decorator` ℹ"
+/// info | `@decorator` ℹ
👈 `@something` ❕ 🐍 🤙 "👨🎨".
diff --git a/docs/em/docs/tutorial/handling-errors.md b/docs/em/docs/tutorial/handling-errors.md
index 7f6a704eb..e0edae51a 100644
--- a/docs/em/docs/tutorial/handling-errors.md
+++ b/docs/em/docs/tutorial/handling-errors.md
@@ -109,7 +109,7 @@
{"message": "Oops! yolo did something. There goes a rainbow..."}
```
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
👆 💪 ⚙️ `from starlette.requests import Request` & `from starlette.responses import JSONResponse`.
@@ -192,7 +192,7 @@ path -> item_id
{!../../docs_src/handling_errors/tutorial004.py!}
```
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
👆 💪 ⚙️ `from starlette.responses import PlainTextResponse`.
diff --git a/docs/em/docs/tutorial/header-params.md b/docs/em/docs/tutorial/header-params.md
index 34abd3a4c..d9eafe77e 100644
--- a/docs/em/docs/tutorial/header-params.md
+++ b/docs/em/docs/tutorial/header-params.md
@@ -44,7 +44,7 @@
////
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
`Header` "👭" 🎓 `Path`, `Query` & `Cookie`. ⚫️ 😖 ⚪️➡️ 🎏 ⚠ `Param` 🎓.
diff --git a/docs/em/docs/tutorial/middleware.md b/docs/em/docs/tutorial/middleware.md
index cd0777ebb..a794ab019 100644
--- a/docs/em/docs/tutorial/middleware.md
+++ b/docs/em/docs/tutorial/middleware.md
@@ -11,7 +11,7 @@
* ⚫️ 💪 🕳 👈 **📨** ⚖️ 🏃 🙆 💪 📟.
* ⤴️ ⚫️ 📨 **📨**.
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
🚥 👆 ✔️ 🔗 ⏮️ `yield`, 🚪 📟 🔜 🏃 *⏮️* 🛠️.
@@ -43,7 +43,7 @@
///
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
👆 💪 ⚙️ `from starlette.requests import Request`.
diff --git a/docs/em/docs/tutorial/path-operation-configuration.md b/docs/em/docs/tutorial/path-operation-configuration.md
index 9529928fb..deb71c807 100644
--- a/docs/em/docs/tutorial/path-operation-configuration.md
+++ b/docs/em/docs/tutorial/path-operation-configuration.md
@@ -42,7 +42,7 @@
👈 👔 📟 🔜 ⚙️ 📨 & 🔜 🚮 🗄 🔗.
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
👆 💪 ⚙️ `from starlette import status`.
diff --git a/docs/em/docs/tutorial/path-params-numeric-validations.md b/docs/em/docs/tutorial/path-params-numeric-validations.md
index c25f0323e..74dbb55f7 100644
--- a/docs/em/docs/tutorial/path-params-numeric-validations.md
+++ b/docs/em/docs/tutorial/path-params-numeric-validations.md
@@ -140,7 +140,7 @@
///
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
🕐❔ 👆 🗄 `Query`, `Path` & 🎏 ⚪️➡️ `fastapi`, 👫 🤙 🔢.
diff --git a/docs/em/docs/tutorial/request-files.md b/docs/em/docs/tutorial/request-files.md
index 102690f4b..9dcad81b4 100644
--- a/docs/em/docs/tutorial/request-files.md
+++ b/docs/em/docs/tutorial/request-files.md
@@ -99,13 +99,13 @@ contents = await myfile.read()
contents = myfile.file.read()
```
-/// note | "`async` 📡 ℹ"
+/// note | `async` 📡 ℹ
🕐❔ 👆 ⚙️ `async` 👩🔬, **FastAPI** 🏃 📁 👩🔬 🧵 & ⌛ 👫.
///
-/// note | "💃 📡 ℹ"
+/// note | 💃 📡 ℹ
**FastAPI**'Ⓜ `UploadFile` 😖 🔗 ⚪️➡️ **💃**'Ⓜ `UploadFile`, ✋️ 🚮 💪 🍕 ⚒ ⚫️ 🔗 ⏮️ **Pydantic** & 🎏 🍕 FastAPI.
@@ -117,7 +117,7 @@ contents = myfile.file.read()
**FastAPI** 🔜 ⚒ 💭 ✍ 👈 📊 ⚪️➡️ ▶️️ 🥉 ↩️ 🎻.
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
📊 ⚪️➡️ 📨 🛎 🗜 ⚙️ "📻 🆎" `application/x-www-form-urlencoded` 🕐❔ ⚫️ 🚫 🔌 📁.
@@ -189,7 +189,7 @@ contents = myfile.file.read()
👆 🔜 📨, 📣, `list` `bytes` ⚖️ `UploadFile`Ⓜ.
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
👆 💪 ⚙️ `from starlette.responses import HTMLResponse`.
diff --git a/docs/em/docs/tutorial/request-forms.md b/docs/em/docs/tutorial/request-forms.md
index cbe4e2862..d364d2c92 100644
--- a/docs/em/docs/tutorial/request-forms.md
+++ b/docs/em/docs/tutorial/request-forms.md
@@ -50,7 +50,7 @@
**FastAPI** 🔜 ⚒ 💭 ✍ 👈 📊 ⚪️➡️ ▶️️ 🥉 ↩️ 🎻.
-/// note | "📡 ℹ"
+/// note | 📡 ℹ
📊 ⚪️➡️ 📨 🛎 🗜 ⚙️ "📻 🆎" `application/x-www-form-urlencoded`.
diff --git a/docs/em/docs/tutorial/response-status-code.md b/docs/em/docs/tutorial/response-status-code.md
index cefff708f..478060326 100644
--- a/docs/em/docs/tutorial/response-status-code.md
+++ b/docs/em/docs/tutorial/response-status-code.md
@@ -94,7 +94,7 @@ FastAPI 💭 👉, & 🔜 🏭 🗄 🩺 👈 🇵🇸 📤 🙅♂ 📨
get
operation
-/// info | "`@decorator` Info"
+/// info | `@decorator` Info
That `@something` syntax in Python is called a "decorator".
@@ -300,9 +292,7 @@ This is our "**path operation function**":
* **operation**: is `get`.
* **function**: is the function below the "decorator" (below `@app.get("/")`).
-```Python hl_lines="7"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[7] *}
This is a Python function.
@@ -314,9 +304,7 @@ In this case, it is an `async` function.
You could also define it as a normal function instead of `async def`:
-```Python hl_lines="7"
-{!../../docs_src/first_steps/tutorial003.py!}
-```
+{* ../../docs_src/first_steps/tutorial003.py hl[7] *}
/// note
@@ -326,9 +314,7 @@ If you don't know the difference, check the [Async: *"In a hurry?"*](../async.md
### Step 5: return the content
-```Python hl_lines="8"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[8] *}
You can return a `dict`, `list`, singular values as `str`, `int`, etc.
diff --git a/docs/en/docs/tutorial/handling-errors.md b/docs/en/docs/tutorial/handling-errors.md
index 38c15761b..537cb3e72 100644
--- a/docs/en/docs/tutorial/handling-errors.md
+++ b/docs/en/docs/tutorial/handling-errors.md
@@ -109,7 +109,7 @@ So, you will receive a clean error, with an HTTP status code of `418` and a JSON
{"message": "Oops! yolo did something. There goes a rainbow..."}
```
-/// note | "Technical Details"
+/// note | Technical Details
You could also use `from starlette.requests import Request` and `from starlette.responses import JSONResponse`.
@@ -192,7 +192,7 @@ For example, you could want to return a plain text response instead of JSON for
{!../../docs_src/handling_errors/tutorial004.py!}
```
-/// note | "Technical Details"
+/// note | Technical Details
You could also use `from starlette.responses import PlainTextResponse`.
diff --git a/docs/en/docs/tutorial/header-params.md b/docs/en/docs/tutorial/header-params.md
index 293de897f..49ad7aa25 100644
--- a/docs/en/docs/tutorial/header-params.md
+++ b/docs/en/docs/tutorial/header-params.md
@@ -6,57 +6,7 @@ You can define Header parameters the same way you define `Query`, `Path` and `Co
First import `Header`:
-//// tab | Python 3.10+
-
-```Python hl_lines="3"
-{!> ../../docs_src/header_params/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="3"
-{!> ../../docs_src/header_params/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="3"
-{!> ../../docs_src/header_params/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="1"
-{!> ../../docs_src/header_params/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="3"
-{!> ../../docs_src/header_params/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/header_params/tutorial001_an_py310.py hl[3] *}
## Declare `Header` parameters
@@ -64,59 +14,9 @@ Then declare the header parameters using the same structure as with `Path`, `Que
You can define the default value as well as all the extra validation or annotation parameters:
-//// tab | Python 3.10+
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_params/tutorial001_an.py!}
-```
+{* ../../docs_src/header_params/tutorial001_an_py310.py hl[9] *}
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7"
-{!> ../../docs_src/header_params/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial001.py!}
-```
-
-////
-
-/// note | "Technical Details"
+/// note | Technical Details
`Header` is a "sister" class of `Path`, `Query` and `Cookie`. It also inherits from the same common `Param` class.
@@ -146,57 +46,7 @@ So, you can use `user_agent` as you normally would in Python code, instead of ne
If for some reason you need to disable automatic conversion of underscores to hyphens, set the parameter `convert_underscores` of `Header` to `False`:
-//// tab | Python 3.10+
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_params/tutorial002_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="11"
-{!> ../../docs_src/header_params/tutorial002_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="12"
-{!> ../../docs_src/header_params/tutorial002_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/header_params/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_params/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/header_params/tutorial002_an_py310.py hl[10] *}
/// warning
@@ -214,71 +64,7 @@ You will receive all the values from the duplicate header as a Python `list`.
For example, to declare a header of `X-Token` that can appear more than once, you can write:
-//// tab | Python 3.10+
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial003_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial003_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_params/tutorial003_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7"
-{!> ../../docs_src/header_params/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial003_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9"
-{!> ../../docs_src/header_params/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/header_params/tutorial003_an_py310.py hl[9] *}
If you communicate with that *path operation* sending two HTTP headers like:
diff --git a/docs/en/docs/tutorial/middleware.md b/docs/en/docs/tutorial/middleware.md
index 7c4954c7b..53c47a085 100644
--- a/docs/en/docs/tutorial/middleware.md
+++ b/docs/en/docs/tutorial/middleware.md
@@ -11,7 +11,7 @@ A "middleware" is a function that works with every **request** before it is proc
* It can do something to that **response** or run any needed code.
* Then it returns the **response**.
-/// note | "Technical Details"
+/// note | Technical Details
If you have dependencies with `yield`, the exit code will run *after* the middleware.
@@ -31,9 +31,7 @@ The middleware function receives:
* Then it returns the `response` generated by the corresponding *path operation*.
* You can then further modify the `response` before returning it.
-```Python hl_lines="8-9 11 14"
-{!../../docs_src/middleware/tutorial001.py!}
-```
+{* ../../docs_src/middleware/tutorial001.py hl[8:9,11,14] *}
/// tip
@@ -43,7 +41,7 @@ But if you have custom headers that you want a client in a browser to be able to
///
-/// note | "Technical Details"
+/// note | Technical Details
You could also use `from starlette.requests import Request`.
@@ -59,9 +57,7 @@ And also after the `response` is generated, before returning it.
For example, you could add a custom header `X-Process-Time` containing the time in seconds that it took to process the request and generate a response:
-```Python hl_lines="10 12-13"
-{!../../docs_src/middleware/tutorial001.py!}
-```
+{* ../../docs_src/middleware/tutorial001.py hl[10,12:13] *}
/// tip
diff --git a/docs/en/docs/tutorial/path-operation-configuration.md b/docs/en/docs/tutorial/path-operation-configuration.md
index 4ca6ebf13..f2b5fd795 100644
--- a/docs/en/docs/tutorial/path-operation-configuration.md
+++ b/docs/en/docs/tutorial/path-operation-configuration.md
@@ -16,33 +16,11 @@ You can pass directly the `int` code, like `404`.
But if you don't remember what each number code is for, you can use the shortcut constants in `status`:
-//// tab | Python 3.10+
-
-```Python hl_lines="1 15"
-{!> ../../docs_src/path_operation_configuration/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="3 17"
-{!> ../../docs_src/path_operation_configuration/tutorial001_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="3 17"
-{!> ../../docs_src/path_operation_configuration/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial001_py310.py hl[1,15] *}
That status code will be used in the response and will be added to the OpenAPI schema.
-/// note | "Technical Details"
+/// note | Technical Details
You could also use `from starlette import status`.
@@ -54,29 +32,7 @@ You could also use `from starlette import status`.
You can add tags to your *path operation*, pass the parameter `tags` with a `list` of `str` (commonly just one `str`):
-//// tab | Python 3.10+
-
-```Python hl_lines="15 20 25"
-{!> ../../docs_src/path_operation_configuration/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="17 22 27"
-{!> ../../docs_src/path_operation_configuration/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="17 22 27"
-{!> ../../docs_src/path_operation_configuration/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial002_py310.py hl[15,20,25] *}
They will be added to the OpenAPI schema and used by the automatic documentation interfaces:
@@ -90,37 +46,13 @@ In these cases, it could make sense to store the tags in an `Enum`.
**FastAPI** supports that the same way as with plain strings:
-```Python hl_lines="1 8-10 13 18"
-{!../../docs_src/path_operation_configuration/tutorial002b.py!}
-```
+{* ../../docs_src/path_operation_configuration/tutorial002b.py hl[1,8:10,13,18] *}
## Summary and description
You can add a `summary` and `description`:
-//// tab | Python 3.10+
-
-```Python hl_lines="18-19"
-{!> ../../docs_src/path_operation_configuration/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="20-21"
-{!> ../../docs_src/path_operation_configuration/tutorial003_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="20-21"
-{!> ../../docs_src/path_operation_configuration/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial003_py310.py hl[18:19] *}
## Description from docstring
@@ -128,29 +60,7 @@ As descriptions tend to be long and cover multiple lines, you can declare the *p
You can write Markdown in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation).
-//// tab | Python 3.10+
-
-```Python hl_lines="17-25"
-{!> ../../docs_src/path_operation_configuration/tutorial004_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="19-27"
-{!> ../../docs_src/path_operation_configuration/tutorial004_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="19-27"
-{!> ../../docs_src/path_operation_configuration/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial004_py310.py hl[17:25] *}
It will be used in the interactive docs:
@@ -160,29 +70,7 @@ It will be used in the interactive docs:
You can specify the response description with the parameter `response_description`:
-//// tab | Python 3.10+
-
-```Python hl_lines="19"
-{!> ../../docs_src/path_operation_configuration/tutorial005_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="21"
-{!> ../../docs_src/path_operation_configuration/tutorial005_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="21"
-{!> ../../docs_src/path_operation_configuration/tutorial005.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial005_py310.py hl[19] *}
/// info
@@ -204,9 +92,7 @@ So, if you don't provide one, **FastAPI** will automatically generate one of "Su
If you need to mark a *path operation* as deprecated, but without removing it, pass the parameter `deprecated`:
-```Python hl_lines="16"
-{!../../docs_src/path_operation_configuration/tutorial006.py!}
-```
+{* ../../docs_src/path_operation_configuration/tutorial006.py hl[16] *}
It will be clearly marked as deprecated in the interactive docs:
diff --git a/docs/en/docs/tutorial/path-params-numeric-validations.md b/docs/en/docs/tutorial/path-params-numeric-validations.md
index 9ddf49ea9..9440bcc03 100644
--- a/docs/en/docs/tutorial/path-params-numeric-validations.md
+++ b/docs/en/docs/tutorial/path-params-numeric-validations.md
@@ -6,57 +6,7 @@ In the same way that you can declare more validations and metadata for query par
First, import `Path` from `fastapi`, and import `Annotated`:
-//// tab | Python 3.10+
-
-```Python hl_lines="1 3"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="1 3"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="3-4"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="1"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="3"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py hl[1,3] *}
/// info
@@ -74,57 +24,7 @@ You can declare all the same parameters as for `Query`.
For example, to declare a `title` metadata value for the path parameter `item_id` you can type:
-//// tab | Python 3.10+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="11"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py hl[10] *}
/// note
@@ -162,29 +62,13 @@ Prefer to use the `Annotated` version if possible.
///
-```Python hl_lines="7"
-{!> ../../docs_src/path_params_numeric_validations/tutorial002.py!}
-```
+{* ../../docs_src/path_params_numeric_validations/tutorial002.py hl[7] *}
////
But keep in mind that if you use `Annotated`, you won't have this problem, it won't matter as you're not using the function parameter default values for `Query()` or `Path()`.
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py *}
## Order the parameters as you need, tricks
@@ -209,29 +93,13 @@ Pass `*`, as the first parameter of the function.
Python won't do anything with that `*`, but it will know that all the following parameters should be called as keyword arguments (key-value pairs), also known as kwargs
. Even if they don't have a default value.
-```Python hl_lines="7"
-{!../../docs_src/path_params_numeric_validations/tutorial003.py!}
-```
+{* ../../docs_src/path_params_numeric_validations/tutorial003.py hl[7] *}
### Better with `Annotated`
Keep in mind that if you use `Annotated`, as you are not using function parameter default values, you won't have this problem, and you probably won't need to use `*`.
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py hl[10] *}
## Number validations: greater than or equal
@@ -239,35 +107,7 @@ With `Query` and `Path` (and others you'll see later) you can declare number con
Here, with `ge=1`, `item_id` will need to be an integer number "`g`reater than or `e`qual" to `1`.
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py hl[10] *}
## Number validations: greater than and less than or equal
@@ -276,35 +116,7 @@ The same applies for:
* `gt`: `g`reater `t`han
* `le`: `l`ess than or `e`qual
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial005.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py hl[10] *}
## Number validations: floats, greater than and less than
@@ -316,35 +128,7 @@ So, `0.5` would be a valid value. But `0.0` or `0` would not.
And the same for lt
.
-//// tab | Python 3.9+
-
-```Python hl_lines="13"
-{!> ../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="12"
-{!> ../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="11"
-{!> ../../docs_src/path_params_numeric_validations/tutorial006.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py hl[13] *}
## Recap
@@ -365,7 +149,7 @@ All of them share the same parameters for additional validation and metadata you
///
-/// note | "Technical Details"
+/// note | Technical Details
When you import `Query`, `Path` and others from `fastapi`, they are actually functions.
diff --git a/docs/en/docs/tutorial/path-params.md b/docs/en/docs/tutorial/path-params.md
index fd9e74585..7e83d3ae5 100644
--- a/docs/en/docs/tutorial/path-params.md
+++ b/docs/en/docs/tutorial/path-params.md
@@ -2,9 +2,7 @@
You can declare path "parameters" or "variables" with the same syntax used by Python format strings:
-```Python hl_lines="6-7"
-{!../../docs_src/path_params/tutorial001.py!}
-```
+{* ../../docs_src/path_params/tutorial001.py hl[6:7] *}
The value of the path parameter `item_id` will be passed to your function as the argument `item_id`.
@@ -18,9 +16,7 @@ So, if you run this example and go to ../../docs_src/query_param_models/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="8-12 16"
-{!> ../../docs_src/query_param_models/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="10-14 18"
-{!> ../../docs_src/query_param_models/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9-13 17"
-{!> ../../docs_src/query_param_models/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8-12 16"
-{!> ../../docs_src/query_param_models/tutorial001_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9-13 17"
-{!> ../../docs_src/query_param_models/tutorial001_py310.py!}
-```
-
-////
+{* ../../docs_src/query_param_models/tutorial001_an_py310.py hl[9:13,17] *}
**FastAPI** will **extract** the data for **each field** from the **query parameters** in the request and give you the Pydantic model you defined.
@@ -96,71 +32,7 @@ In some special use cases (probably not very common), you might want to **restri
You can use Pydantic's model configuration to `forbid` any `extra` fields:
-//// tab | Python 3.10+
-
-```Python hl_lines="10"
-{!> ../../docs_src/query_param_models/tutorial002_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="9"
-{!> ../../docs_src/query_param_models/tutorial002_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="11"
-{!> ../../docs_src/query_param_models/tutorial002_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="10"
-{!> ../../docs_src/query_param_models/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9"
-{!> ../../docs_src/query_param_models/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="11"
-{!> ../../docs_src/query_param_models/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/query_param_models/tutorial002_an_py310.py hl[10] *}
If a client tries to send some **extra** data in the **query parameters**, they will receive an **error** response.
diff --git a/docs/en/docs/tutorial/request-files.md b/docs/en/docs/tutorial/request-files.md
index f3f1eb103..0d57f3566 100644
--- a/docs/en/docs/tutorial/request-files.md
+++ b/docs/en/docs/tutorial/request-files.md
@@ -20,69 +20,13 @@ This is because uploaded files are sent as "form data".
Import `File` and `UploadFile` from `fastapi`:
-//// tab | Python 3.9+
-
-```Python hl_lines="3"
-{!> ../../docs_src/request_files/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="1"
-{!> ../../docs_src/request_files/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="1"
-{!> ../../docs_src/request_files/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial001_an_py39.py hl[3] *}
## Define `File` Parameters
Create file parameters the same way you would for `Body` or `Form`:
-//// tab | Python 3.9+
-
-```Python hl_lines="9"
-{!> ../../docs_src/request_files/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="8"
-{!> ../../docs_src/request_files/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7"
-{!> ../../docs_src/request_files/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial001_an_py39.py hl[9] *}
/// info
@@ -110,35 +54,7 @@ But there are several cases in which you might benefit from using `UploadFile`.
Define a file parameter with a type of `UploadFile`:
-//// tab | Python 3.9+
-
-```Python hl_lines="14"
-{!> ../../docs_src/request_files/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="13"
-{!> ../../docs_src/request_files/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="12"
-{!> ../../docs_src/request_files/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial001_an_py39.py hl[14] *}
Using `UploadFile` has several advantages over `bytes`:
@@ -181,13 +97,13 @@ If you are inside of a normal `def` *path operation function*, you can access th
contents = myfile.file.read()
```
-/// note | "`async` Technical Details"
+/// note | `async` Technical Details
When you use the `async` methods, **FastAPI** runs the file methods in a threadpool and awaits for them.
///
-/// note | "Starlette Technical Details"
+/// note | Starlette Technical Details
**FastAPI**'s `UploadFile` inherits directly from **Starlette**'s `UploadFile`, but adds some necessary parts to make it compatible with **Pydantic** and the other parts of FastAPI.
@@ -199,7 +115,7 @@ The way HTML forms (``) sends the data to the server normally uses
**FastAPI** will make sure to read that data from the right place instead of JSON.
-/// note | "Technical Details"
+/// note | Technical Details
Data from forms is normally encoded using the "media type" `application/x-www-form-urlencoded` when it doesn't include files.
@@ -221,91 +137,13 @@ This is not a limitation of **FastAPI**, it's part of the HTTP protocol.
You can make a file optional by using standard type annotations and setting a default value of `None`:
-//// tab | Python 3.10+
-
-```Python hl_lines="9 17"
-{!> ../../docs_src/request_files/tutorial001_02_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="9 17"
-{!> ../../docs_src/request_files/tutorial001_02_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="10 18"
-{!> ../../docs_src/request_files/tutorial001_02_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7 15"
-{!> ../../docs_src/request_files/tutorial001_02_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9 17"
-{!> ../../docs_src/request_files/tutorial001_02.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial001_02_an_py310.py hl[9,17] *}
## `UploadFile` with Additional Metadata
You can also use `File()` with `UploadFile`, for example, to set additional metadata:
-//// tab | Python 3.9+
-
-```Python hl_lines="9 15"
-{!> ../../docs_src/request_files/tutorial001_03_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="8 14"
-{!> ../../docs_src/request_files/tutorial001_03_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7 13"
-{!> ../../docs_src/request_files/tutorial001_03.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial001_03_an_py39.py hl[9,15] *}
## Multiple File Uploads
@@ -315,53 +153,11 @@ They would be associated to the same "form field" sent using "form data".
To use that, declare a list of `bytes` or `UploadFile`:
-//// tab | Python 3.9+
-
-```Python hl_lines="10 15"
-{!> ../../docs_src/request_files/tutorial002_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="11 16"
-{!> ../../docs_src/request_files/tutorial002_an.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8 13"
-{!> ../../docs_src/request_files/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="10 15"
-{!> ../../docs_src/request_files/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial002_an_py39.py hl[10,15] *}
You will receive, as declared, a `list` of `bytes` or `UploadFile`s.
-/// note | "Technical Details"
+/// note | Technical Details
You could also use `from starlette.responses import HTMLResponse`.
@@ -373,49 +169,7 @@ You could also use `from starlette.responses import HTMLResponse`.
And the same way as before, you can use `File()` to set additional parameters, even for `UploadFile`:
-//// tab | Python 3.9+
-
-```Python hl_lines="11 18-20"
-{!> ../../docs_src/request_files/tutorial003_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="12 19-21"
-{!> ../../docs_src/request_files/tutorial003_an.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9 16"
-{!> ../../docs_src/request_files/tutorial003_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="11 18"
-{!> ../../docs_src/request_files/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/request_files/tutorial003_an_py39.py hl[11,18:20] *}
## Recap
diff --git a/docs/en/docs/tutorial/request-forms.md b/docs/en/docs/tutorial/request-forms.md
index 2ccc6886e..c65e9874c 100644
--- a/docs/en/docs/tutorial/request-forms.md
+++ b/docs/en/docs/tutorial/request-forms.md
@@ -106,7 +106,7 @@ The way HTML forms (``) sends the data to the server normally uses
**FastAPI** will make sure to read that data from the right place instead of JSON.
-/// note | "Technical Details"
+/// note | Technical Details
Data from forms is normally encoded using the "media type" `application/x-www-form-urlencoded`.
diff --git a/docs/en/docs/tutorial/response-model.md b/docs/en/docs/tutorial/response-model.md
index 36ccfc4ce..e7837086f 100644
--- a/docs/en/docs/tutorial/response-model.md
+++ b/docs/en/docs/tutorial/response-model.md
@@ -4,29 +4,7 @@ You can declare the type used for the response by annotating the *path operation
You can use **type annotations** the same way you would for input data in function **parameters**, you can use Pydantic models, lists, dictionaries, scalar values like integers, booleans, etc.
-//// tab | Python 3.10+
-
-```Python hl_lines="16 21"
-{!> ../../docs_src/response_model/tutorial001_01_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="18 23"
-{!> ../../docs_src/response_model/tutorial001_01_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="18 23"
-{!> ../../docs_src/response_model/tutorial001_01.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial001_01_py310.py hl[16,21] *}
FastAPI will use this return type to:
@@ -59,29 +37,7 @@ You can use the `response_model` parameter in any of the *path operations*:
* `@app.delete()`
* etc.
-//// tab | Python 3.10+
-
-```Python hl_lines="17 22 24-27"
-{!> ../../docs_src/response_model/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="17 22 24-27"
-{!> ../../docs_src/response_model/tutorial001_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="17 22 24-27"
-{!> ../../docs_src/response_model/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial001_py310.py hl[17,22,24:27] *}
/// note
@@ -113,21 +69,7 @@ You can also use `response_model=None` to disable creating a response model for
Here we are declaring a `UserIn` model, it will contain a plaintext password:
-//// tab | Python 3.10+
-
-```Python hl_lines="7 9"
-{!> ../../docs_src/response_model/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9 11"
-{!> ../../docs_src/response_model/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial002_py310.py hl[7,9] *}
/// info
@@ -149,21 +91,7 @@ $ pip install "pydantic[email]"
And we are using this model to declare our input and the same model to declare our output:
-//// tab | Python 3.10+
-
-```Python hl_lines="16"
-{!> ../../docs_src/response_model/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="18"
-{!> ../../docs_src/response_model/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial002_py310.py hl[16] *}
Now, whenever a browser is creating a user with a password, the API will return the same password in the response.
@@ -181,57 +109,15 @@ Never store the plain password of a user or send it in a response like this, unl
We can instead create an input model with the plaintext password and an output model without it:
-//// tab | Python 3.10+
-
-```Python hl_lines="9 11 16"
-{!> ../../docs_src/response_model/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9 11 16"
-{!> ../../docs_src/response_model/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial003_py310.py hl[9,11,16] *}
Here, even though our *path operation function* is returning the same input user that contains the password:
-//// tab | Python 3.10+
-
-```Python hl_lines="24"
-{!> ../../docs_src/response_model/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="24"
-{!> ../../docs_src/response_model/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial003_py310.py hl[24] *}
...we declared the `response_model` to be our model `UserOut`, that doesn't include the password:
-//// tab | Python 3.10+
-
-```Python hl_lines="22"
-{!> ../../docs_src/response_model/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="22"
-{!> ../../docs_src/response_model/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial003_py310.py hl[22] *}
So, **FastAPI** will take care of filtering out all the data that is not declared in the output model (using Pydantic).
@@ -255,21 +141,7 @@ But in most of the cases where we need to do something like this, we want the mo
And in those cases, we can use classes and inheritance to take advantage of function **type annotations** to get better support in the editor and tools, and still get the FastAPI **data filtering**.
-//// tab | Python 3.10+
-
-```Python hl_lines="7-10 13-14 18"
-{!> ../../docs_src/response_model/tutorial003_01_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9-13 15-16 20"
-{!> ../../docs_src/response_model/tutorial003_01.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial003_01_py310.py hl[7:10,13:14,18] *}
With this, we get tooling support, from editors and mypy as this code is correct in terms of types, but we also get the data filtering from FastAPI.
@@ -311,9 +183,7 @@ There might be cases where you return something that is not a valid Pydantic fie
The most common case would be [returning a Response directly as explained later in the advanced docs](../advanced/response-directly.md){.internal-link target=_blank}.
-```Python hl_lines="8 10-11"
-{!> ../../docs_src/response_model/tutorial003_02.py!}
-```
+{* ../../docs_src/response_model/tutorial003_02.py hl[8,10:11] *}
This simple case is handled automatically by FastAPI because the return type annotation is the class (or a subclass of) `Response`.
@@ -323,9 +193,7 @@ And tools will also be happy because both `RedirectResponse` and `JSONResponse`
You can also use a subclass of `Response` in the type annotation:
-```Python hl_lines="8-9"
-{!> ../../docs_src/response_model/tutorial003_03.py!}
-```
+{* ../../docs_src/response_model/tutorial003_03.py hl[8:9] *}
This will also work because `RedirectResponse` is a subclass of `Response`, and FastAPI will automatically handle this simple case.
@@ -335,21 +203,7 @@ But when you return some other arbitrary object that is not a valid Pydantic typ
The same would happen if you had something like a union between different types where one or more of them are not valid Pydantic types, for example this would fail 💥:
-//// tab | Python 3.10+
-
-```Python hl_lines="8"
-{!> ../../docs_src/response_model/tutorial003_04_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="10"
-{!> ../../docs_src/response_model/tutorial003_04.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial003_04_py310.py hl[8] *}
...this fails because the type annotation is not a Pydantic type and is not just a single `Response` class or subclass, it's a union (any of the two) between a `Response` and a `dict`.
@@ -361,21 +215,7 @@ But you might want to still keep the return type annotation in the function to g
In this case, you can disable the response model generation by setting `response_model=None`:
-//// tab | Python 3.10+
-
-```Python hl_lines="7"
-{!> ../../docs_src/response_model/tutorial003_05_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/response_model/tutorial003_05.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial003_05_py310.py hl[7] *}
This will make FastAPI skip the response model generation and that way you can have any return type annotations you need without it affecting your FastAPI application. 🤓
@@ -383,29 +223,7 @@ This will make FastAPI skip the response model generation and that way you can h
Your response model could have default values, like:
-//// tab | Python 3.10+
-
-```Python hl_lines="9 11-12"
-{!> ../../docs_src/response_model/tutorial004_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="11 13-14"
-{!> ../../docs_src/response_model/tutorial004_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="11 13-14"
-{!> ../../docs_src/response_model/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial004_py310.py hl[9,11:12] *}
* `description: Union[str, None] = None` (or `str | None = None` in Python 3.10) has a default of `None`.
* `tax: float = 10.5` has a default of `10.5`.
@@ -419,29 +237,7 @@ For example, if you have models with many optional attributes in a NoSQL databas
You can set the *path operation decorator* parameter `response_model_exclude_unset=True`:
-//// tab | Python 3.10+
-
-```Python hl_lines="22"
-{!> ../../docs_src/response_model/tutorial004_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="24"
-{!> ../../docs_src/response_model/tutorial004_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="24"
-{!> ../../docs_src/response_model/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial004_py310.py hl[22] *}
and those default values won't be included in the response, only the values actually set.
@@ -538,21 +334,7 @@ This also applies to `response_model_by_alias` that works similarly.
///
-//// tab | Python 3.10+
-
-```Python hl_lines="29 35"
-{!> ../../docs_src/response_model/tutorial005_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="31 37"
-{!> ../../docs_src/response_model/tutorial005.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial005_py310.py hl[29,35] *}
/// tip
@@ -566,21 +348,7 @@ It is equivalent to `set(["name", "description"])`.
If you forget to use a `set` and use a `list` or `tuple` instead, FastAPI will still convert it to a `set` and it will work correctly:
-//// tab | Python 3.10+
-
-```Python hl_lines="29 35"
-{!> ../../docs_src/response_model/tutorial006_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="31 37"
-{!> ../../docs_src/response_model/tutorial006.py!}
-```
-
-////
+{* ../../docs_src/response_model/tutorial006_py310.py hl[29,35] *}
## Recap
diff --git a/docs/en/docs/tutorial/response-status-code.md b/docs/en/docs/tutorial/response-status-code.md
index 73af62aed..711042a46 100644
--- a/docs/en/docs/tutorial/response-status-code.md
+++ b/docs/en/docs/tutorial/response-status-code.md
@@ -8,9 +8,7 @@ The same way you can specify a response model, you can also declare the HTTP sta
* `@app.delete()`
* etc.
-```Python hl_lines="6"
-{!../../docs_src/response_status_code/tutorial001.py!}
-```
+{* ../../docs_src/response_status_code/tutorial001.py hl[6] *}
/// note
@@ -76,9 +74,7 @@ To know more about each status code and which code is for what, check the
-/// note | "Technical Details"
+/// note | Technical Details
You could also use `from starlette import status`.
diff --git a/docs/en/docs/tutorial/schema-extra-example.md b/docs/en/docs/tutorial/schema-extra-example.md
index 5896b54d9..32a1f5ca2 100644
--- a/docs/en/docs/tutorial/schema-extra-example.md
+++ b/docs/en/docs/tutorial/schema-extra-example.md
@@ -8,35 +8,15 @@ Here are several ways to do it.
You can declare `examples` for a Pydantic model that will be added to the generated JSON Schema.
-//// tab | Python 3.10+ Pydantic v2
-
-```Python hl_lines="13-24"
-{!> ../../docs_src/schema_extra_example/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.10+ Pydantic v1
-
-```Python hl_lines="13-23"
-{!> ../../docs_src/schema_extra_example/tutorial001_py310_pv1.py!}
-```
-
-////
-
-//// tab | Python 3.8+ Pydantic v2
+//// tab | Pydantic v2
-```Python hl_lines="15-26"
-{!> ../../docs_src/schema_extra_example/tutorial001.py!}
-```
+{* ../../docs_src/schema_extra_example/tutorial001_py310.py hl[13:24] *}
////
-//// tab | Python 3.8+ Pydantic v1
+//// tab | Pydantic v1
-```Python hl_lines="15-25"
-{!> ../../docs_src/schema_extra_example/tutorial001_pv1.py!}
-```
+{* ../../docs_src/schema_extra_example/tutorial001_pv1_py310.py hl[13:23] *}
////
@@ -80,21 +60,7 @@ You can read more at the end of this page.
When using `Field()` with Pydantic models, you can also declare additional `examples`:
-//// tab | Python 3.10+
-
-```Python hl_lines="2 8-11"
-{!> ../../docs_src/schema_extra_example/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="4 10-13"
-{!> ../../docs_src/schema_extra_example/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/schema_extra_example/tutorial002_py310.py hl[2,8:11] *}
## `examples` in JSON Schema - OpenAPI
@@ -114,57 +80,7 @@ you can also declare a group of `examples` with additional information that will
Here we pass `examples` containing one example of the data expected in `Body()`:
-//// tab | Python 3.10+
-
-```Python hl_lines="22-29"
-{!> ../../docs_src/schema_extra_example/tutorial003_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="22-29"
-{!> ../../docs_src/schema_extra_example/tutorial003_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="23-30"
-{!> ../../docs_src/schema_extra_example/tutorial003_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="18-25"
-{!> ../../docs_src/schema_extra_example/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="20-27"
-{!> ../../docs_src/schema_extra_example/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/schema_extra_example/tutorial003_an_py310.py hl[22:29] *}
### Example in the docs UI
@@ -176,57 +92,7 @@ With any of the methods above it would look like this in the `/docs`:
You can of course also pass multiple `examples`:
-//// tab | Python 3.10+
-
-```Python hl_lines="23-38"
-{!> ../../docs_src/schema_extra_example/tutorial004_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="23-38"
-{!> ../../docs_src/schema_extra_example/tutorial004_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="24-39"
-{!> ../../docs_src/schema_extra_example/tutorial004_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="19-34"
-{!> ../../docs_src/schema_extra_example/tutorial004_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="21-36"
-{!> ../../docs_src/schema_extra_example/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/schema_extra_example/tutorial004_an_py310.py hl[23:38] *}
When you do this, the examples will be part of the internal **JSON Schema** for that body data.
@@ -267,57 +133,7 @@ Each specific example `dict` in the `examples` can contain:
You can use it like this:
-//// tab | Python 3.10+
-
-```Python hl_lines="23-49"
-{!> ../../docs_src/schema_extra_example/tutorial005_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="23-49"
-{!> ../../docs_src/schema_extra_example/tutorial005_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="24-50"
-{!> ../../docs_src/schema_extra_example/tutorial005_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="19-45"
-{!> ../../docs_src/schema_extra_example/tutorial005_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="21-47"
-{!> ../../docs_src/schema_extra_example/tutorial005.py!}
-```
-
-////
+{* ../../docs_src/schema_extra_example/tutorial005_an_py310.py hl[23:49] *}
### OpenAPI Examples in the Docs UI
diff --git a/docs/en/docs/tutorial/security/first-steps.md b/docs/en/docs/tutorial/security/first-steps.md
index ead2aa799..8f6578e12 100644
--- a/docs/en/docs/tutorial/security/first-steps.md
+++ b/docs/en/docs/tutorial/security/first-steps.md
@@ -20,35 +20,7 @@ Let's first just use the code and see how it works, and then we'll come back to
Copy the example in a file `main.py`:
-//// tab | Python 3.9+
-
-```Python
-{!> ../../docs_src/security/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python
-{!> ../../docs_src/security/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python
-{!> ../../docs_src/security/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/security/tutorial001_an_py39.py *}
## Run it
@@ -88,7 +60,7 @@ You will see something like this:
get
-/// info | "`@décorateur` Info"
+/// info | `@décorateur` Info
Cette syntaxe `@something` en Python est appelée un "décorateur".
@@ -286,7 +276,7 @@ Tout comme celles les plus exotiques :
* `@app.patch()`
* `@app.trace()`
-/// tip | "Astuce"
+/// tip | Astuce
Vous êtes libres d'utiliser chaque opération (méthode HTTP) comme vous le désirez.
@@ -306,9 +296,7 @@ Voici notre "**fonction de chemin**" (ou fonction d'opération de chemin) :
* **opération** : `get`.
* **fonction** : la fonction sous le "décorateur" (sous `@app.get("/")`).
-```Python hl_lines="7"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[7] *}
C'est une fonction Python.
@@ -320,9 +308,7 @@ Ici, c'est une fonction asynchrone (définie avec `async def`).
Vous pourriez aussi la définir comme une fonction classique plutôt qu'avec `async def` :
-```Python hl_lines="7"
-{!../../docs_src/first_steps/tutorial003.py!}
-```
+{* ../../docs_src/first_steps/tutorial003.py hl[7] *}
/// note
@@ -332,9 +318,7 @@ Si vous ne connaissez pas la différence, allez voir la section [Concurrence : *
### Étape 5 : retourner le contenu
-```Python hl_lines="8"
-{!../../docs_src/first_steps/tutorial001.py!}
-```
+{* ../../docs_src/first_steps/tutorial001.py hl[8] *}
Vous pouvez retourner un dictionnaire (`dict`), une liste (`list`), des valeurs seules comme des chaines de caractères (`str`) et des entiers (`int`), etc.
diff --git a/docs/fr/docs/tutorial/path-params-numeric-validations.md b/docs/fr/docs/tutorial/path-params-numeric-validations.md
index 82e317ff7..3f3280e64 100644
--- a/docs/fr/docs/tutorial/path-params-numeric-validations.md
+++ b/docs/fr/docs/tutorial/path-params-numeric-validations.md
@@ -6,57 +6,7 @@ De la même façon que vous pouvez déclarer plus de validations et de métadonn
Tout d'abord, importez `Path` de `fastapi`, et importez `Annotated` :
-//// tab | Python 3.10+
-
-```Python hl_lines="1 3"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="1 3"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="3-4"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="1"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="3"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py hl[1,3] *}
/// info
@@ -74,57 +24,7 @@ Vous pouvez déclarer les mêmes paramètres que pour `Query`.
Par exemple, pour déclarer une valeur de métadonnée `title` pour le paramètre de chemin `item_id`, vous pouvez écrire :
-//// tab | Python 3.10+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="11"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial001_an_py310.py hl[10] *}
/// note
@@ -154,37 +54,11 @@ Cela n'a pas d'importance pour **FastAPI**. Il détectera les paramètres par le
Ainsi, vous pouvez déclarer votre fonction comme suit :
-//// tab | Python 3.8 non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="7"
-{!> ../../docs_src/path_params_numeric_validations/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial002.py hl[7] *}
Mais gardez à l'esprit que si vous utilisez `Annotated`, vous n'aurez pas ce problème, cela n'aura pas d'importance car vous n'utilisez pas les valeurs par défaut des paramètres de fonction pour `Query()` ou `Path()`.
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial002_an.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial002_an_py39.py hl[10] *}
## Ordonnez les paramètres comme vous le souhaitez (astuces)
@@ -209,29 +83,13 @@ Passez `*`, comme premier paramètre de la fonction.
Python ne fera rien avec ce `*`, mais il saura que tous les paramètres suivants doivent être appelés comme arguments "mots-clés" (paires clé-valeur), également connus sous le nom de kwargs
. Même s'ils n'ont pas de valeur par défaut.
-```Python hl_lines="7"
-{!../../docs_src/path_params_numeric_validations/tutorial003.py!}
-```
+{* ../../docs_src/path_params_numeric_validations/tutorial003.py hl[7] *}
# Avec `Annotated`
Gardez à l'esprit que si vous utilisez `Annotated`, comme vous n'utilisez pas les valeurs par défaut des paramètres de fonction, vous n'aurez pas ce problème, et vous n'aurez probablement pas besoin d'utiliser `*`.
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial003_an.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial003_an_py39.py hl[10] *}
## Validations numériques : supérieur ou égal
@@ -239,35 +97,7 @@ Avec `Query` et `Path` (et d'autres que vous verrez plus tard) vous pouvez décl
Ici, avec `ge=1`, `item_id` devra être un nombre entier "`g`reater than or `e`qual" à `1`.
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py hl[10] *}
## Validations numériques : supérieur ou égal et inférieur ou égal
@@ -276,35 +106,7 @@ La même chose s'applique pour :
* `gt` : `g`reater `t`han
* `le` : `l`ess than or `e`qual
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/path_params_numeric_validations/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial004_an_py39.py hl[10] *}
## Validations numériques : supérieur et inférieur ou égal
@@ -313,35 +115,7 @@ La même chose s'applique pour :
* `gt` : `g`reater `t`han
* `le` : `l`ess than or `e`qual
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial005_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="9"
-{!> ../../docs_src/path_params_numeric_validations/tutorial005.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial005_an_py39.py hl[10] *}
## Validations numériques : flottants, supérieur et inférieur
@@ -353,35 +127,7 @@ Ainsi, `0.5` serait une valeur valide. Mais `0.0` ou `0` ne le serait pas.
Et la même chose pour lt
.
-//// tab | Python 3.9+
-
-```Python hl_lines="13"
-{!> ../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="12"
-{!> ../../docs_src/path_params_numeric_validations/tutorial006_an.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Préférez utiliser la version `Annotated` si possible.
-
-///
-
-```Python hl_lines="11"
-{!> ../../docs_src/path_params_numeric_validations/tutorial006.py!}
-```
-
-////
+{* ../../docs_src/path_params_numeric_validations/tutorial006_an_py39.py hl[13] *}
## Pour résumer
@@ -402,7 +148,7 @@ Tous partagent les mêmes paramètres pour des validations supplémentaires et d
///
-/// note | "Détails techniques"
+/// note | Détails techniques
Lorsque vous importez `Query`, `Path` et d'autres de `fastapi`, ce sont en fait des fonctions.
diff --git a/docs/fr/docs/tutorial/path-params.md b/docs/fr/docs/tutorial/path-params.md
index 34012c278..71c96b18e 100644
--- a/docs/fr/docs/tutorial/path-params.md
+++ b/docs/fr/docs/tutorial/path-params.md
@@ -4,9 +4,7 @@ Vous pouvez déclarer des "paramètres" ou "variables" de chemin avec la même s
formatage de chaîne Python :
-```Python hl_lines="6-7"
-{!../../docs_src/path_params/tutorial001.py!}
-```
+{* ../../docs_src/path_params/tutorial001.py hl[6:7] *}
La valeur du paramètre `item_id` sera transmise à la fonction dans l'argument `item_id`.
@@ -22,13 +20,11 @@ vous verrez comme réponse :
Vous pouvez déclarer le type d'un paramètre de chemin dans la fonction, en utilisant les annotations de type Python :
-```Python hl_lines="7"
-{!../../docs_src/path_params/tutorial002.py!}
-```
+{* ../../docs_src/path_params/tutorial002.py hl[7] *}
Ici, `item_id` est déclaré comme `int`.
-/// check | "vérifier"
+/// check | vérifier
Ceci vous permettra d'obtenir des fonctionnalités de l'éditeur dans votre fonction, telles
que des vérifications d'erreur, de l'auto-complétion, etc.
@@ -43,7 +39,7 @@ Si vous exécutez cet exemple et allez sur http://127.0.0.1:8000/items/4.2.
-/// check | "vérifier"
+/// check | vérifier
Donc, avec ces mêmes déclarations de type Python, **FastAPI** vous fournit de la validation de données.
@@ -131,9 +127,7 @@ Et vous avez un second chemin : `/users/{user_id}` pour récupérer de la donné
Les *fonctions de chemin* étant évaluées dans l'ordre, il faut s'assurer que la fonction correspondant à `/users/me` est déclarée avant celle de `/users/{user_id}` :
-```Python hl_lines="6 11"
-{!../../docs_src/path_params/tutorial003.py!}
-```
+{* ../../docs_src/path_params/tutorial003.py hl[6,11] *}
Sinon, le chemin `/users/{user_id}` correspondrait aussi à `/users/me`, la fonction "croyant" qu'elle a reçu un paramètre `user_id` avec pour valeur `"me"`.
@@ -149,9 +143,7 @@ En héritant de `str` la documentation sera capable de savoir que les valeurs do
Créez ensuite des attributs de classe avec des valeurs fixes, qui seront les valeurs autorisées pour cette énumération.
-```Python hl_lines="1 6-9"
-{!../../docs_src/path_params/tutorial005.py!}
-```
+{* ../../docs_src/path_params/tutorial005.py hl[1,6:9] *}
/// info
@@ -159,7 +151,7 @@ Créez ensuite des attributs de classe avec des valeurs fixes, qui seront les va
///
-/// tip | "Astuce"
+/// tip | Astuce
Pour ceux qui se demandent, "AlexNet", "ResNet", et "LeNet" sont juste des noms de modèles de Machine Learning.
@@ -169,9 +161,7 @@ Pour ceux qui se demandent, "AlexNet", "ResNet", et "LeNet" sont juste des noms
Créez ensuite un *paramètre de chemin* avec une annotation de type désignant l'énumération créée précédemment (`ModelName`) :
-```Python hl_lines="16"
-{!../../docs_src/path_params/tutorial005.py!}
-```
+{* ../../docs_src/path_params/tutorial005.py hl[16] *}
### Documentation
@@ -187,19 +177,15 @@ La valeur du *paramètre de chemin* sera un des "membres" de l'énumération.
Vous pouvez comparer ce paramètre avec les membres de votre énumération `ModelName` :
-```Python hl_lines="17"
-{!../../docs_src/path_params/tutorial005.py!}
-```
+{* ../../docs_src/path_params/tutorial005.py hl[17] *}
#### Récupérer la *valeur de l'énumération*
Vous pouvez obtenir la valeur réel d'un membre (une chaîne de caractères ici), avec `model_name.value`, ou en général, `votre_membre_d'enum.value` :
-```Python hl_lines="20"
-{!../../docs_src/path_params/tutorial005.py!}
-```
+{* ../../docs_src/path_params/tutorial005.py hl[20] *}
-/// tip | "Astuce"
+/// tip | Astuce
Vous pouvez aussi accéder la valeur `"lenet"` avec `ModelName.lenet.value`.
@@ -211,9 +197,7 @@ Vous pouvez retourner des *membres d'énumération* dans vos *fonctions de chemi
Ils seront convertis vers leurs valeurs correspondantes (chaînes de caractères ici) avant d'être transmis au client :
-```Python hl_lines="18 21 23"
-{!../../docs_src/path_params/tutorial005.py!}
-```
+{* ../../docs_src/path_params/tutorial005.py hl[18,21,23] *}
Le client recevra une réponse JSON comme celle-ci :
@@ -252,11 +236,9 @@ Dans ce cas, le nom du paramètre est `file_path`, et la dernière partie, `:pat
Vous pouvez donc l'utilisez comme tel :
-```Python hl_lines="6"
-{!../../docs_src/path_params/tutorial004.py!}
-```
+{* ../../docs_src/path_params/tutorial004.py hl[6] *}
-/// tip | "Astuce"
+/// tip | Astuce
Vous pourriez avoir besoin que le paramètre contienne `/home/johndoe/myfile.txt`, avec un slash au début (`/`).
diff --git a/docs/fr/docs/tutorial/query-params-str-validations.md b/docs/fr/docs/tutorial/query-params-str-validations.md
index b71d1548a..c54c0c717 100644
--- a/docs/fr/docs/tutorial/query-params-str-validations.md
+++ b/docs/fr/docs/tutorial/query-params-str-validations.md
@@ -4,9 +4,7 @@
Commençons avec cette application pour exemple :
-```Python hl_lines="9"
-{!../../docs_src/query_params_str_validations/tutorial001.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial001.py hl[9] *}
Le paramètre de requête `q` a pour type `Union[str, None]` (ou `str | None` en Python 3.10), signifiant qu'il est de type `str` mais pourrait aussi être égal à `None`, et bien sûr, la valeur par défaut est `None`, donc **FastAPI** saura qu'il n'est pas requis.
@@ -26,17 +24,13 @@ Nous allons imposer que bien que `q` soit un paramètre optionnel, dès qu'il es
Pour cela, importez d'abord `Query` depuis `fastapi` :
-```Python hl_lines="3"
-{!../../docs_src/query_params_str_validations/tutorial002.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial002.py hl[3] *}
## Utiliser `Query` comme valeur par défaut
Construisez ensuite la valeur par défaut de votre paramètre avec `Query`, en choisissant 50 comme `max_length` :
-```Python hl_lines="9"
-{!../../docs_src/query_params_str_validations/tutorial002.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial002.py hl[9] *}
Comme nous devons remplacer la valeur par défaut `None` dans la fonction par `Query()`, nous pouvons maintenant définir la valeur par défaut avec le paramètre `Query(default=None)`, il sert le même objectif qui est de définir cette valeur par défaut.
@@ -86,17 +80,13 @@ Cela va valider les données, montrer une erreur claire si ces dernières ne son
Vous pouvez aussi rajouter un second paramètre `min_length` :
-```Python hl_lines="9"
-{!../../docs_src/query_params_str_validations/tutorial003.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial003.py hl[9] *}
## Ajouter des validations par expressions régulières
On peut définir une expression régulière à laquelle le paramètre doit correspondre :
-```Python hl_lines="10"
-{!../../docs_src/query_params_str_validations/tutorial004.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial004.py hl[10] *}
Cette expression régulière vérifie que la valeur passée comme paramètre :
@@ -114,11 +104,9 @@ De la même façon que vous pouvez passer `None` comme premier argument pour l'u
Disons que vous déclarez le paramètre `q` comme ayant une longueur minimale de `3`, et une valeur par défaut étant `"fixedquery"` :
-```Python hl_lines="7"
-{!../../docs_src/query_params_str_validations/tutorial005.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial005.py hl[7] *}
-/// note | "Rappel"
+/// note | Rappel
Avoir une valeur par défaut rend le paramètre optionnel.
@@ -146,9 +134,7 @@ q: Union[str, None] = Query(default=None, min_length=3)
Donc pour déclarer une valeur comme requise tout en utilisant `Query`, il faut utiliser `...` comme premier argument :
-```Python hl_lines="7"
-{!../../docs_src/query_params_str_validations/tutorial006.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial006.py hl[7] *}
/// info
@@ -164,9 +150,7 @@ Quand on définit un paramètre de requête explicitement avec `Query` on peut a
Par exemple, pour déclarer un paramètre de requête `q` qui peut apparaître plusieurs fois dans une URL, on écrit :
-```Python hl_lines="9"
-{!../../docs_src/query_params_str_validations/tutorial011.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial011.py hl[9] *}
Ce qui fait qu'avec une URL comme :
@@ -187,7 +171,7 @@ Donc la réponse de cette URL serait :
}
```
-/// tip | "Astuce"
+/// tip | Astuce
Pour déclarer un paramètre de requête de type `list`, comme dans l'exemple ci-dessus, il faut explicitement utiliser `Query`, sinon cela sera interprété comme faisant partie du corps de la requête.
@@ -201,9 +185,7 @@ La documentation sera donc mise à jour automatiquement pour autoriser plusieurs
Et l'on peut aussi définir une liste de valeurs par défaut si aucune n'est fournie :
-```Python hl_lines="9"
-{!../../docs_src/query_params_str_validations/tutorial012.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial012.py hl[9] *}
Si vous allez à :
@@ -228,9 +210,7 @@ et la réponse sera :
Il est aussi possible d'utiliser directement `list` plutôt que `List[str]` :
-```Python hl_lines="7"
-{!../../docs_src/query_params_str_validations/tutorial013.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial013.py hl[7] *}
/// note
@@ -256,15 +236,11 @@ Il se peut donc que certains d'entre eux n'utilisent pas toutes les métadonnée
Vous pouvez ajouter un `title` :
-```Python hl_lines="10"
-{!../../docs_src/query_params_str_validations/tutorial007.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial007.py hl[10] *}
Et une `description` :
-```Python hl_lines="13"
-{!../../docs_src/query_params_str_validations/tutorial008.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial008.py hl[13] *}
## Alias de paramètres
@@ -284,9 +260,7 @@ Mais vous avez vraiment envie que ce soit exactement `item-query`...
Pour cela vous pouvez déclarer un `alias`, et cet alias est ce qui sera utilisé pour trouver la valeur du paramètre :
-```Python hl_lines="9"
-{!../../docs_src/query_params_str_validations/tutorial009.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial009.py hl[9] *}
## Déprécier des paramètres
@@ -296,9 +270,7 @@ Il faut qu'il continue à exister pendant un certain temps car vos clients l'uti
On utilise alors l'argument `deprecated=True` de `Query` :
-```Python hl_lines="18"
-{!../../docs_src/query_params_str_validations/tutorial010.py!}
-```
+{* ../../docs_src/query_params_str_validations/tutorial010.py hl[18] *}
La documentation le présentera comme il suit :
diff --git a/docs/fr/docs/tutorial/query-params.md b/docs/fr/docs/tutorial/query-params.md
index c847a8f5b..b87c26c78 100644
--- a/docs/fr/docs/tutorial/query-params.md
+++ b/docs/fr/docs/tutorial/query-params.md
@@ -2,9 +2,7 @@
Quand vous déclarez des paramètres dans votre fonction de chemin qui ne font pas partie des paramètres indiqués dans le chemin associé, ces paramètres sont automatiquement considérés comme des paramètres de "requête".
-```Python hl_lines="9"
-{!../../docs_src/query_params/tutorial001.py!}
-```
+{* ../../docs_src/query_params/tutorial001.py hl[9] *}
La partie appelée requête (ou **query**) dans une URL est l'ensemble des paires clés-valeurs placées après le `?` , séparées par des `&`.
@@ -63,13 +61,11 @@ Les valeurs des paramètres de votre fonction seront :
De la même façon, vous pouvez définir des paramètres de requête comme optionnels, en leur donnant comme valeur par défaut `None` :
-```Python hl_lines="9"
-{!../../docs_src/query_params/tutorial002.py!}
-```
+{* ../../docs_src/query_params/tutorial002.py hl[9] *}
Ici, le paramètre `q` sera optionnel, et aura `None` comme valeur par défaut.
-/// check | "Remarque"
+/// check | Remarque
On peut voir que **FastAPI** est capable de détecter que le paramètre de chemin `item_id` est un paramètre de chemin et que `q` n'en est pas un, c'est donc un paramètre de requête.
@@ -87,9 +83,7 @@ Le `Optional` dans `Optional[str]` n'est pas utilisé par **FastAPI** (**FastAPI
Vous pouvez aussi déclarer des paramètres de requête comme booléens (`bool`), **FastAPI** les convertira :
-```Python hl_lines="9"
-{!../../docs_src/query_params/tutorial003.py!}
-```
+{* ../../docs_src/query_params/tutorial003.py hl[9] *}
Avec ce code, en allant sur :
@@ -131,9 +125,7 @@ Et vous n'avez pas besoin de les déclarer dans un ordre spécifique.
Ils seront détectés par leurs noms :
-```Python hl_lines="8 10"
-{!../../docs_src/query_params/tutorial004.py!}
-```
+{* ../../docs_src/query_params/tutorial004.py hl[8,10] *}
## Paramètres de requête requis
@@ -143,9 +135,7 @@ Si vous ne voulez pas leur donner de valeur par défaut mais juste les rendre op
Mais si vous voulez rendre un paramètre de requête obligatoire, vous pouvez juste ne pas y affecter de valeur par défaut :
-```Python hl_lines="6-7"
-{!../../docs_src/query_params/tutorial005.py!}
-```
+{* ../../docs_src/query_params/tutorial005.py hl[6:7] *}
Ici le paramètre `needy` est un paramètre requis (ou obligatoire) de type `str`.
@@ -189,9 +179,7 @@ http://127.0.0.1:8000/items/foo-item?needy=sooooneedy
Et bien sur, vous pouvez définir certains paramètres comme requis, certains avec des valeurs par défaut et certains entièrement optionnels :
-```Python hl_lines="10"
-{!../../docs_src/query_params/tutorial006.py!}
-```
+{* ../../docs_src/query_params/tutorial006.py hl[10] *}
Ici, on a donc 3 paramètres de requête :
@@ -199,7 +187,7 @@ Ici, on a donc 3 paramètres de requête :
* `skip`, un `int` avec comme valeur par défaut `0`.
* `limit`, un `int` optionnel.
-/// tip | "Astuce"
+/// tip | Astuce
Vous pouvez utiliser les `Enum`s de la même façon qu'avec les [Paramètres de chemin](path-params.md#valeurs-predefinies){.internal-link target=_blank}.
diff --git a/docs/he/docs/index.md b/docs/he/docs/index.md
index 23a2eb824..6498d15e1 100644
--- a/docs/he/docs/index.md
+++ b/docs/he/docs/index.md
@@ -94,7 +94,7 @@ FastAPI היא תשתית רשת מודרנית ומהירה (ביצועים ג
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
-
+
---
diff --git a/docs/hu/docs/index.md b/docs/hu/docs/index.md
index 8e326a78b..c6f596650 100644
--- a/docs/hu/docs/index.md
+++ b/docs/hu/docs/index.md
@@ -87,7 +87,7 @@ Kulcs funkciók:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
-
+
---
diff --git a/docs/id/docs/tutorial/index.md b/docs/id/docs/tutorial/index.md
index f0dee3d73..c01ec9a89 100644
--- a/docs/id/docs/tutorial/index.md
+++ b/docs/id/docs/tutorial/index.md
@@ -52,7 +52,7 @@ $ pip install "fastapi[all]"
...yang juga termasuk `uvicorn`, yang dapat kamu gunakan sebagai server yang menjalankan kodemu.
-/// note | "Catatan"
+/// note | Catatan
Kamu juga dapat meng-installnya bagian demi bagian.
diff --git a/docs/it/docs/index.md b/docs/it/docs/index.md
index 3bfff82f1..8a1039bc5 100644
--- a/docs/it/docs/index.md
+++ b/docs/it/docs/index.md
@@ -84,7 +84,7 @@ Le sue caratteristiche principali sono:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
-
+
---
diff --git a/docs/ja/docs/advanced/additional-status-codes.md b/docs/ja/docs/advanced/additional-status-codes.md
index 904d539e7..fb3164328 100644
--- a/docs/ja/docs/advanced/additional-status-codes.md
+++ b/docs/ja/docs/advanced/additional-status-codes.md
@@ -18,7 +18,7 @@
{!../../docs_src/additional_status_codes/tutorial001.py!}
```
-/// warning | "注意"
+/// warning | 注意
上記の例のように `Response` を明示的に返す場合、それは直接返されます。
@@ -28,7 +28,7 @@
///
-/// note | "技術詳細"
+/// note | 技術詳細
`from starlette.responses import JSONResponse` を利用することもできます。
diff --git a/docs/ja/docs/advanced/custom-response.md b/docs/ja/docs/advanced/custom-response.md
index 88269700e..15edc11ad 100644
--- a/docs/ja/docs/advanced/custom-response.md
+++ b/docs/ja/docs/advanced/custom-response.md
@@ -12,7 +12,7 @@
そしてもし、`Response` が、`JSONResponse` や `UJSONResponse` の場合のようにJSONメディアタイプ (`application/json`) ならば、データは *path operationデコレータ* に宣言したPydantic `response_model` により自動的に変換 (もしくはフィルタ) されます。
-/// note | "備考"
+/// note | 備考
メディアタイプを指定せずにレスポンスクラスを利用すると、FastAPIは何もコンテンツがないことを期待します。そのため、生成されるOpenAPIドキュメントにレスポンスフォーマットが記載されません。
@@ -28,7 +28,7 @@
{!../../docs_src/custom_response/tutorial001b.py!}
```
-/// info | "情報"
+/// info | 情報
パラメータ `response_class` は、レスポンスの「メディアタイプ」を定義するために利用することもできます。
@@ -38,7 +38,7 @@
///
-/// tip | "豆知識"
+/// tip | 豆知識
`ORJSONResponse` は、現在はFastAPIのみで利用可能で、Starletteでは利用できません。
@@ -55,7 +55,7 @@
{!../../docs_src/custom_response/tutorial002.py!}
```
-/// info | "情報"
+/// info | 情報
パラメータ `response_class` は、レスポンスの「メディアタイプ」を定義するために利用されます。
@@ -75,13 +75,13 @@
{!../../docs_src/custom_response/tutorial003.py!}
```
-/// warning | "注意"
+/// warning | 注意
*path operation関数* から直接返される `Response` は、OpenAPIにドキュメントされず (例えば、 `Content-Type` がドキュメントされない) 、自動的な対話的ドキュメントからも閲覧できません。
///
-/// info | "情報"
+/// info | 情報
もちろん、実際の `Content-Type` ヘッダーやステータスコードなどは、返された `Response` オブジェクトに由来しています。
@@ -115,7 +115,7 @@
`Response` を使って他の何かを返せますし、カスタムのサブクラスも作れることを覚えておいてください。
-/// note | "技術詳細"
+/// note | 技術詳細
`from starlette.responses import HTMLResponse` も利用できます。
@@ -168,7 +168,7 @@ FastAPI (実際にはStarlette) は自動的にContent-Lengthヘッダーを含
`ujson`を使った、代替のJSONレスポンスです。
-/// warning | "注意"
+/// warning | 注意
`ujson` は、いくつかのエッジケースの取り扱いについて、Pythonにビルトインされた実装よりも作りこまれていません。
@@ -178,7 +178,7 @@ FastAPI (実際にはStarlette) は自動的にContent-Lengthヘッダーを含
{!../../docs_src/custom_response/tutorial001.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
`ORJSONResponse` のほうが高速な代替かもしれません。
@@ -210,7 +210,7 @@ HTTPリダイレクトを返します。デフォルトでは307ステータス
{!../../docs_src/custom_response/tutorial008.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
ここでは `async` や `await` をサポートしていない標準の `open()` を使っているので、通常の `def` でpath operationを宣言していることに注意してください。
@@ -245,7 +245,7 @@ HTTPリダイレクトを返します。デフォルトでは307ステータス
{!../../docs_src/custom_response/tutorial010.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
前に見たように、 *path operation* の中で `response_class` をオーバーライドできます。
diff --git a/docs/ja/docs/advanced/index.md b/docs/ja/docs/advanced/index.md
index da3c2a2bf..22eaf6eb8 100644
--- a/docs/ja/docs/advanced/index.md
+++ b/docs/ja/docs/advanced/index.md
@@ -6,7 +6,7 @@
以降のセクションでは、チュートリアルでは説明しきれなかったオプションや設定、および機能について説明します。
-/// tip | "豆知識"
+/// tip | 豆知識
以降のセクションは、 **必ずしも"応用編"ではありません**。
diff --git a/docs/ja/docs/advanced/path-operation-advanced-configuration.md b/docs/ja/docs/advanced/path-operation-advanced-configuration.md
index 2dab4aec1..99428bcbe 100644
--- a/docs/ja/docs/advanced/path-operation-advanced-configuration.md
+++ b/docs/ja/docs/advanced/path-operation-advanced-configuration.md
@@ -2,7 +2,7 @@
## OpenAPI operationId
-/// warning | "注意"
+/// warning | 注意
あなたがOpenAPIの「エキスパート」でなければ、これは必要ないかもしれません。
@@ -26,13 +26,13 @@ APIの関数名を `operationId` として利用したい場合、すべてのAP
{!../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
`app.openapi()` を手動でコールする場合、その前に`operationId`を更新する必要があります。
///
-/// warning | "注意"
+/// warning | 注意
この方法をとる場合、各 *path operation関数* が一意な名前である必要があります。
diff --git a/docs/ja/docs/advanced/response-directly.md b/docs/ja/docs/advanced/response-directly.md
index 167d15589..dc66e238c 100644
--- a/docs/ja/docs/advanced/response-directly.md
+++ b/docs/ja/docs/advanced/response-directly.md
@@ -14,7 +14,7 @@
実際は、`Response` やそのサブクラスを返すことができます。
-/// tip | "豆知識"
+/// tip | 豆知識
`JSONResponse` それ自体は、 `Response` のサブクラスです。
@@ -38,7 +38,7 @@
{!../../docs_src/response_directly/tutorial001.py!}
```
-/// note | "技術詳細"
+/// note | 技術詳細
また、`from starlette.responses import JSONResponse` も利用できます。
diff --git a/docs/ja/docs/advanced/websockets.md b/docs/ja/docs/advanced/websockets.md
index f7bcb6af3..365ceca9d 100644
--- a/docs/ja/docs/advanced/websockets.md
+++ b/docs/ja/docs/advanced/websockets.md
@@ -50,7 +50,7 @@ $ pip install websockets
{!../../docs_src/websockets/tutorial001.py!}
```
-/// note | "技術詳細"
+/// note | 技術詳細
`from starlette.websockets import WebSocket` を使用しても構いません.
@@ -119,7 +119,7 @@ WebSocketエンドポイントでは、`fastapi` から以下をインポート
{!../../docs_src/websockets/tutorial002.py!}
```
-/// info | "情報"
+/// info | 情報
WebSocket で `HTTPException` を発生させることはあまり意味がありません。したがって、WebSocketの接続を直接閉じる方がよいでしょう。
@@ -150,7 +150,7 @@ $ uvicorn main:app --reload
* パスで使用される「Item ID」
* クエリパラメータとして使用される「Token」
-/// tip | "豆知識"
+/// tip | 豆知識
クエリ `token` は依存パッケージによって処理されることに注意してください。
@@ -180,7 +180,7 @@ WebSocket接続が閉じられると、 `await websocket.receive_text()` は例
Client #1596980209979 left the chat
```
-/// tip | "豆知識"
+/// tip | 豆知識
上記のアプリは、複数の WebSocket 接続に対してメッセージを処理し、ブロードキャストする方法を示すための最小限のシンプルな例です。
diff --git a/docs/ja/docs/alternatives.md b/docs/ja/docs/alternatives.md
index 343ae4ed8..8129a7002 100644
--- a/docs/ja/docs/alternatives.md
+++ b/docs/ja/docs/alternatives.md
@@ -30,13 +30,13 @@ Mozilla、Red Hat、Eventbrite など多くの企業で利用されています
これは**自動的なAPIドキュメント生成**の最初の例であり、これは**FastAPI**に向けた「調査」を触発した最初のアイデアの一つでした。
-/// note | "備考"
+/// note | 備考
Django REST Framework は Tom Christie によって作成されました。StarletteとUvicornの生みの親であり、**FastAPI**のベースとなっています。
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
自動でAPIドキュメントを生成するWebユーザーインターフェースを持っている点。
@@ -56,7 +56,7 @@ Flask は「マイクロフレームワーク」であり、データベース
Flaskのシンプルさを考えると、APIを構築するのに適しているように思えました。次に見つけるべきは、Flask 用の「Django REST Framework」でした。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
マイクロフレームワークであること。ツールやパーツを目的に合うように簡単に組み合わせられる点。
@@ -98,7 +98,7 @@ def read_url():
`requests.get(...)` と`@app.get(...)` には類似点が見受けられます。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
* シンプルで直感的なAPIを持っている点。
* HTTPメソッド名を直接利用し、単純で直感的である。
@@ -118,7 +118,7 @@ def read_url():
そのため、バージョン2.0では「Swagger」、バージョン3以上では「OpenAPI」と表記するのが一般的です。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
独自のスキーマの代わりに、API仕様のオープンな標準を採用しました。
@@ -147,7 +147,7 @@ APIが必要とするもう一つの大きな機能はデータのバリデー
しかし、それはPythonの型ヒントが存在する前に作られたものです。そのため、すべてのスキーマを定義するためには、Marshmallowが提供する特定のユーティリティやクラスを使用する必要があります。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
コードで「スキーマ」を定義し、データの型やバリデーションを自動で提供する点。
@@ -163,13 +163,13 @@ WebargsはFlaskをはじめとするいくつかのフレームワークの上
素晴らしいツールで、私も**FastAPI**を持つ前はよく使っていました。
-/// info | "情報"
+/// info | 情報
Webargsは、Marshmallowと同じ開発者により作られました。
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
受信したデータに対する自動的なバリデーションを持っている点。
@@ -193,13 +193,13 @@ Flask, Starlette, Responderなどにおいてはそのように動作します
エディタでは、この問題を解決することはできません。また、パラメータやMarshmallowスキーマを変更したときに、YAMLのdocstringを変更するのを忘れてしまうと、生成されたスキーマが古くなってしまいます。
-/// info | "情報"
+/// info | 情報
APISpecは、Marshmallowと同じ開発者により作成されました。
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
OpenAPIという、APIについてのオープンな標準をサポートしている点。
@@ -225,13 +225,13 @@ Flask、Flask-apispec、Marshmallow、Webargsの組み合わせは、**FastAPI**
そして、これらのフルスタックジェネレーターは、[**FastAPI** Project Generators](project-generation.md){.internal-link target=_blank}の元となっていました。
-/// info | "情報"
+/// info | 情報
Flask-apispecはMarshmallowと同じ開発者により作成されました。
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
シリアライゼーションとバリデーションを定義したコードから、OpenAPIスキーマを自動的に生成する点。
@@ -251,7 +251,7 @@ Angular 2にインスピレーションを受けた、統合された依存性
入れ子になったモデルをうまく扱えません。そのため、リクエストのJSONボディが内部フィールドを持つJSONオブジェクトで、それが順番にネストされたJSONオブジェクトになっている場合、適切にドキュメント化やバリデーションをすることができません。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
素晴らしいエディターの補助を得るために、Pythonの型ヒントを利用している点。
@@ -263,7 +263,7 @@ Angular 2にインスピレーションを受けた、統合された依存性
`asyncio`に基づいた、Pythonのフレームワークの中でも非常に高速なものの一つです。Flaskと非常に似た作りになっています。
-/// note | "技術詳細"
+/// note | 技術詳細
Pythonの`asyncio`ループの代わりに、`uvloop`が利用されています。それにより、非常に高速です。
@@ -271,7 +271,7 @@ Pythonの`asyncio`ループの代わりに、`uvloop`が利用されています
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
物凄い性能を出す方法を見つけた点。
@@ -289,7 +289,7 @@ Pythonのウェブフレームワーク標準規格 (WSGI) を使用していま
そのため、データのバリデーション、シリアライゼーション、ドキュメント化は、自動的にできずコードの中で行わなければなりません。あるいは、HugのようにFalconの上にフレームワークとして実装されなければなりません。このような分断は、パラメータとして1つのリクエストオブジェクトと1つのレスポンスオブジェクトを持つというFalconのデザインにインスピレーションを受けた他のフレームワークでも起こります。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
素晴らしい性能を得るための方法を見つけた点。
@@ -315,7 +315,7 @@ Pydanticのようなデータのバリデーション、シリアライゼーシ
ルーティングは一つの場所で宣言され、他の場所で宣言された関数を使用します (エンドポイントを扱う関数のすぐ上に配置できるデコレータを使用するのではなく) 。これはFlask (やStarlette) よりも、Djangoに近いです。これは、比較的緊密に結合されているものをコードの中で分離しています。
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
モデルの属性の「デフォルト」値を使用したデータ型の追加バリデーションを定義します。これはエディタの補助を改善するもので、以前はPydanticでは利用できませんでした。
@@ -337,13 +337,13 @@ OpenAPIやJSON Schemaのような標準に基づいたものではありませ
以前のPythonの同期型Webフレームワーク標準 (WSGI) をベースにしているため、Websocketなどは扱えませんが、それでも高性能です。
-/// info | "情報"
+/// info | 情報
HugはTimothy Crosleyにより作成されました。彼は`isort`など、Pythonのファイル内のインポートの並び替えを自動的におこうなう素晴らしいツールの開発者です。
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
HugはAPIStarに部分的なインスピレーションを与えており、私が発見した中ではAPIStarと同様に最も期待の持てるツールの一つでした。
@@ -377,7 +377,7 @@ Hugは、**FastAPI**がヘッダーやクッキーを設定するために関数
今ではAPIStarはOpenAPI仕様を検証するためのツールセットであり、ウェブフレームワークではありません。
-/// info | "情報"
+/// info | 情報
APIStarはTom Christieにより開発されました。以下の開発者でもあります:
@@ -387,7 +387,7 @@ APIStarはTom Christieにより開発されました。以下の開発者でも
///
-/// check | "**FastAPI**へ与えたインスピレーション"
+/// check | **FastAPI**へ与えたインスピレーション
存在そのもの。
@@ -411,7 +411,7 @@ Pydanticは、Pythonの型ヒントを元にデータのバリデーション、
Marshmallowに匹敵しますが、ベンチマークではMarshmallowよりも高速です。また、Pythonの型ヒントを元にしているので、エディタの補助が素晴らしいです。
-/// check | "**FastAPI**での使用用途"
+/// check | **FastAPI**での使用用途
データのバリデーション、データのシリアライゼーション、自動的なモデルの (JSON Schemaに基づいた) ドキュメント化の全てを扱えます。
@@ -447,7 +447,7 @@ Starletteは基本的なWebマイクロフレームワークの機能をすべ
これは **FastAPI** が追加する主な機能の一つで、すべての機能は Pythonの型ヒントに基づいています (Pydanticを使用しています) 。これに加えて、依存性注入の仕組み、セキュリティユーティリティ、OpenAPIスキーマ生成などがあります。
-/// note | "技術詳細"
+/// note | 技術詳細
ASGIはDjangoのコアチームメンバーにより開発された新しい「標準」です。まだ「Pythonの標準 (PEP) 」ではありませんが、現在そうなるように進めています。
@@ -455,7 +455,7 @@ ASGIはDjangoのコアチームメンバーにより開発された新しい「
///
-/// check | "**FastAPI**での使用用途"
+/// check | **FastAPI**での使用用途
webに関するコアな部分を全て扱います。その上に機能を追加します。
@@ -473,7 +473,7 @@ Uvicornは非常に高速なASGIサーバーで、uvloopとhttptoolsにより構
Starletteや**FastAPI**のサーバーとして推奨されています。
-/// check | "**FastAPI**が推奨する理由"
+/// check | **FastAPI**が推奨する理由
**FastAPI**アプリケーションを実行するメインのウェブサーバーである点。
diff --git a/docs/ja/docs/async.md b/docs/ja/docs/async.md
index ce9dac56f..d1da1f82d 100644
--- a/docs/ja/docs/async.md
+++ b/docs/ja/docs/async.md
@@ -21,7 +21,7 @@ async def read_results():
return results
```
-/// note | "備考"
+/// note | 備考
`async def` を使用して作成された関数の内部でしか `await` は使用できません。
@@ -358,7 +358,7 @@ async def read_burgers():
## 非常に発展的な技術的詳細
-/// warning | "注意"
+/// warning | 注意
恐らくスキップしても良いでしょう。
diff --git a/docs/ja/docs/contributing.md b/docs/ja/docs/contributing.md
index 86926b213..3ee742ec2 100644
--- a/docs/ja/docs/contributing.md
+++ b/docs/ja/docs/contributing.md
@@ -95,7 +95,7 @@ some/directory/fastapi/env/bin/pip
`env/bin/pip`に`pip`バイナリが表示される場合は、正常に機能しています。🎉
-/// tip | "豆知識"
+/// tip | 豆知識
この環境で`pip`を使って新しいパッケージをインストールするたびに、仮想環境を再度有効化します。
@@ -165,7 +165,7 @@ $ bash scripts/format-imports.sh
そして、翻訳を処理するためのツール/スクリプトが、`./scripts/docs.py`に用意されています。
-/// tip | "豆知識"
+/// tip | 豆知識
`./scripts/docs.py`のコードを見る必要はなく、コマンドラインからただ使うだけです。
@@ -254,7 +254,7 @@ Uvicornはデフォルトでポート`8000`を使用するため、ポート`800
* あなたの言語の今あるプルリクエストを確認し、変更や承認をするレビューを追加します。
-/// tip | "豆知識"
+/// tip | 豆知識
すでにあるプルリクエストに修正提案つきのコメントを追加できます。
@@ -282,7 +282,7 @@ Uvicornはデフォルトでポート`8000`を使用するため、ポート`800
スペイン語の場合、2文字のコードは`es`です。したがって、スペイン語のディレクトリは`docs/es/`です。
-/// tip | "豆知識"
+/// tip | 豆知識
メイン (「公式」) 言語は英語で、`docs/en/`にあります。
@@ -323,7 +323,7 @@ docs/en/docs/features.md
docs/es/docs/features.md
```
-/// tip | "豆知識"
+/// tip | 豆知識
パスとファイル名の変更は、`en`から`es`への言語コードだけであることに注意してください。
@@ -398,7 +398,7 @@ Updating en
これで、新しく作成された`docs/ht/`ディレクトリをコードエディターから確認できます。
-/// tip | "豆知識"
+/// tip | 豆知識
翻訳を追加する前に、これだけで最初のプルリクエストを作成し、新しい言語の設定をセットアップします。
diff --git a/docs/ja/docs/deployment/manually.md b/docs/ja/docs/deployment/manually.md
index c17e63728..4ea6bd8ff 100644
--- a/docs/ja/docs/deployment/manually.md
+++ b/docs/ja/docs/deployment/manually.md
@@ -20,7 +20,7 @@ $ pip install "uvicorn[standard]"
////
-/// tip | "豆知識"
+/// tip | 豆知識
`standard` を加えることで、Uvicornがインストールされ、いくつかの推奨される依存関係を利用するようになります。
diff --git a/docs/ja/docs/deployment/versions.md b/docs/ja/docs/deployment/versions.md
index 941ddb71b..7575fc4f7 100644
--- a/docs/ja/docs/deployment/versions.md
+++ b/docs/ja/docs/deployment/versions.md
@@ -42,7 +42,7 @@ PoetryやPipenvなど、他のインストール管理ツールを使用して
FastAPIでは「パッチ」バージョンはバグ修正と非破壊的な変更に留めるという規約に従っています。
-/// tip | "豆知識"
+/// tip | 豆知識
「パッチ」は最後の数字を指します。例えば、`0.2.3` ではパッチバージョンは `3` です。
@@ -56,7 +56,7 @@ fastapi>=0.45.0,<0.46.0
破壊的な変更と新機能実装は「マイナー」バージョンで加えられます。
-/// tip | "豆知識"
+/// tip | 豆知識
「マイナー」は真ん中の数字です。例えば、`0.2.3` ではマイナーバージョンは `2` です。
diff --git a/docs/ja/docs/features.md b/docs/ja/docs/features.md
index 73c0192c7..4024590cf 100644
--- a/docs/ja/docs/features.md
+++ b/docs/ja/docs/features.md
@@ -62,7 +62,7 @@ second_user_data = {
my_second_user: User = User(**second_user_data)
```
-/// info | "情報"
+/// info | 情報
`**second_user_data` は以下を意味します:
diff --git a/docs/ja/docs/index.md b/docs/ja/docs/index.md
index 72a0e98bc..682c94e83 100644
--- a/docs/ja/docs/index.md
+++ b/docs/ja/docs/index.md
@@ -91,7 +91,7 @@ FastAPI は、Pythonの標準である型ヒントに基づいてPython 以降
"_正直、超堅実で洗練されているように見えます。いろんな意味で、それは私がハグしたかったものです。_"
-
+
---
diff --git a/docs/ja/docs/python-types.md b/docs/ja/docs/python-types.md
index 7af6ce0c0..77ddf4654 100644
--- a/docs/ja/docs/python-types.md
+++ b/docs/ja/docs/python-types.md
@@ -12,7 +12,7 @@
しかしたとえまったく **FastAPI** を使用しない場合でも、それらについて少し学ぶことで利点を得ることができるでしょう。
-/// note | "備考"
+/// note | 備考
もしあなたがPythonの専門家で、すでに型ヒントについてすべて知っているのであれば、次の章まで読み飛ばしてください。
@@ -175,7 +175,7 @@ John Doe
{!../../docs_src/python_types/tutorial006.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
角括弧内の内部の型は「型パラメータ」と呼ばれています。
@@ -288,7 +288,7 @@ Pydanticの公式ドキュメントから引用:
{!../../docs_src/python_types/tutorial011.py!}
```
-/// info | "情報"
+/// info | 情報
Pydanticについてより学びたい方はドキュメントを参照してください.
@@ -320,7 +320,7 @@ Pydanticについてより学びたい方は`mypy`のチートシートを参照してください
diff --git a/docs/ja/docs/tutorial/body-fields.md b/docs/ja/docs/tutorial/body-fields.md
index 1d386040a..5b3b3622b 100644
--- a/docs/ja/docs/tutorial/body-fields.md
+++ b/docs/ja/docs/tutorial/body-fields.md
@@ -10,7 +10,7 @@
{!../../docs_src/body_fields/tutorial001.py!}
```
-/// warning | "注意"
+/// warning | 注意
`Field`は他の全てのもの(`Query`、`Path`、`Body`など)とは違い、`fastapi`からではなく、`pydantic`から直接インポートされていることに注意してください。
@@ -26,7 +26,7 @@
`Field`は`Query`や`Path`、`Body`と同じように動作し、全く同様のパラメータなどを持ちます。
-/// note | "技術詳細"
+/// note | 技術詳細
実際には次に見る`Query`や`Path`などは、共通の`Param`クラスのサブクラスのオブジェクトを作成しますが、それ自体はPydanticの`FieldInfo`クラスのサブクラスです。
@@ -38,7 +38,7 @@
///
-/// tip | "豆知識"
+/// tip | 豆知識
型、デフォルト値、`Field`を持つ各モデルの属性が、`Path`や`Query`、`Body`の代わりに`Field`を持つ、*path operation 関数の*パラメータと同じ構造になっていることに注目してください。
diff --git a/docs/ja/docs/tutorial/body-multiple-params.md b/docs/ja/docs/tutorial/body-multiple-params.md
index 647143ee5..982c23565 100644
--- a/docs/ja/docs/tutorial/body-multiple-params.md
+++ b/docs/ja/docs/tutorial/body-multiple-params.md
@@ -12,7 +12,7 @@
{!../../docs_src/body_multiple_params/tutorial001.py!}
```
-/// note | "備考"
+/// note | 備考
この場合、ボディから取得する`item`はオプションであることに注意してください。デフォルト値は`None`です。
@@ -56,7 +56,7 @@
}
```
-/// note | "備考"
+/// note | 備考
以前と同じように`item`が宣言されていたにもかかわらず、`item`はキー`item`を持つボディの内部にあることが期待されていることに注意してください。
@@ -118,7 +118,7 @@ q: str = None
{!../../docs_src/body_multiple_params/tutorial004.py!}
```
-/// info | "情報"
+/// info | 情報
`Body`もまた、後述する `Query` や `Path` などと同様に、すべての検証パラメータとメタデータパラメータを持っています。
diff --git a/docs/ja/docs/tutorial/body-nested-models.md b/docs/ja/docs/tutorial/body-nested-models.md
index 8703a40e7..dc2d5e81a 100644
--- a/docs/ja/docs/tutorial/body-nested-models.md
+++ b/docs/ja/docs/tutorial/body-nested-models.md
@@ -162,7 +162,7 @@ Pydanticモデルを`list`や`set`などのサブタイプとして使用する
}
```
-/// info | "情報"
+/// info | 情報
`images`キーが画像オブジェクトのリストを持つようになったことに注目してください。
@@ -176,7 +176,7 @@ Pydanticモデルを`list`や`set`などのサブタイプとして使用する
{!../../docs_src/body_nested_models/tutorial007.py!}
```
-/// info | "情報"
+/// info | 情報
`Offer`は`Item`のリストであり、オプションの`Image`のリストを持っていることに注目してください。
@@ -228,7 +228,7 @@ Pydanticモデルではなく、`dict`を直接使用している場合はこの
{!../../docs_src/body_nested_models/tutorial009.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
JSONはキーとして`str`しかサポートしていないことに注意してください。
diff --git a/docs/ja/docs/tutorial/body-updates.md b/docs/ja/docs/tutorial/body-updates.md
index fde9f4f5e..fcaeb0d16 100644
--- a/docs/ja/docs/tutorial/body-updates.md
+++ b/docs/ja/docs/tutorial/body-updates.md
@@ -34,7 +34,7 @@
つまり、更新したいデータだけを送信して、残りはそのままにしておくことができます。
-/// note | "備考"
+/// note | 備考
`PATCH`は`PUT`よりもあまり使われておらず、知られていません。
@@ -89,7 +89,7 @@
{!../../docs_src/body_updates/tutorial002.py!}
```
-/// tip | "豆知識"
+/// tip | 豆知識
実際には、HTTPの`PUT`操作でも同じテクニックを使用することができます。
@@ -97,7 +97,7 @@
///
-/// note | "備考"
+/// note | 備考
入力モデルがまだ検証されていることに注目してください。
diff --git a/docs/ja/docs/tutorial/body.md b/docs/ja/docs/tutorial/body.md
index 888d4388a..277ee79c8 100644
--- a/docs/ja/docs/tutorial/body.md
+++ b/docs/ja/docs/tutorial/body.md
@@ -8,7 +8,7 @@ APIはほとんどの場合 **レスポンス** ボディを送らなければ
**リクエスト** ボディを宣言するために Pydantic モデルを使用します。そして、その全てのパワーとメリットを利用します。
-/// info | "情報"
+/// info | 情報
データを送るには、`POST` (もっともよく使われる)、`PUT`、`DELETE` または `PATCH` を使うべきです。
@@ -113,7 +113,7 @@ GET リクエストでボディを送信することは、仕様では未定義
get
작동 사용
-/// info | "`@decorator` 정보"
+/// info | `@decorator` 정보
이 `@something` 문법은 파이썬에서 "데코레이터"라 부릅니다.
@@ -286,7 +286,7 @@ API를 설계할 때 일반적으로 특정 행동을 수행하기 위해 특정
* `@app.patch()`
* `@app.trace()`
-/// tip | "팁"
+/// tip | 팁
각 작동(HTTP 메소드)을 원하는 대로 사용해도 됩니다.
@@ -324,7 +324,7 @@ URL "`/`"에 대한 `GET` 작동을 사용하는 요청을 받을 때마다 **Fa
{!../../docs_src/first_steps/tutorial003.py!}
```
-/// note | "참고"
+/// note | 참고
차이점을 모르겠다면 [Async: *"바쁘신 경우"*](../async.md#_1){.internal-link target=_blank}을 확인하세요.
diff --git a/docs/ko/docs/tutorial/header-params.md b/docs/ko/docs/tutorial/header-params.md
index 26e198869..972f52a33 100644
--- a/docs/ko/docs/tutorial/header-params.md
+++ b/docs/ko/docs/tutorial/header-params.md
@@ -20,7 +20,7 @@
{!../../docs_src/header_params/tutorial001.py!}
```
-/// note | "기술 세부사항"
+/// note | 기술 세부사항
`Header`는 `Path`, `Query` 및 `Cookie`의 "자매"클래스입니다. 이 역시 동일한 공통 `Param` 클래스를 상속합니다.
@@ -28,7 +28,7 @@
///
-/// info | "정보"
+/// info | 정보
헤더를 선언하기 위해서 `Header`를 사용해야 합니다. 그렇지 않으면 해당 매개변수를 쿼리 매개변수로 해석하기 때문입니다.
@@ -54,7 +54,7 @@
{!../../docs_src/header_params/tutorial002.py!}
```
-/// warning | "경고"
+/// warning | 경고
`convert_underscore`를 `False`로 설정하기 전에, 어떤 HTTP 프록시들과 서버들은 언더스코어가 포함된 헤더 사용을 허락하지 않는다는 것을 명심하십시오.
diff --git a/docs/ko/docs/tutorial/index.md b/docs/ko/docs/tutorial/index.md
index a148bc76e..9f5328992 100644
--- a/docs/ko/docs/tutorial/index.md
+++ b/docs/ko/docs/tutorial/index.md
@@ -53,7 +53,7 @@ $ pip install "fastapi[all]"
...이는 코드를 실행하는 서버로 사용할 수 있는 `uvicorn` 또한 포함하고 있습니다.
-/// note | "참고"
+/// note | 참고
부분적으로 설치할 수도 있습니다.
diff --git a/docs/ko/docs/tutorial/metadata.md b/docs/ko/docs/tutorial/metadata.md
new file mode 100644
index 000000000..87531152c
--- /dev/null
+++ b/docs/ko/docs/tutorial/metadata.md
@@ -0,0 +1,131 @@
+
+# 메타데이터 및 문서화 URL
+
+**FastAPI** 응용 프로그램에서 다양한 메타데이터 구성을 사용자 맞춤 설정할 수 있습니다.
+
+## API에 대한 메타데이터
+
+OpenAPI 명세 및 자동화된 API 문서 UI에 사용되는 다음 필드를 설정할 수 있습니다:
+
+| 매개변수 | 타입 | 설명 |
+|----------|------|-------|
+| `title` | `str` | API의 제목입니다. |
+| `summary` | `str` | API에 대한 짧은 요약입니다. OpenAPI 3.1.0, FastAPI 0.99.0부터 사용 가능 |
+| `description` | `str` | API에 대한 짧은 설명입니다. 마크다운을 사용할 수 있습니다. |
+| `version` | `string` | API의 버전입니다. OpenAPI의 버전이 아닌, 여러분의 애플리케이션의 버전을 나타냅니다. 예: `2.5.0` |
+| `terms_of_service` | `str` | API 이용 약관의 URL입니다. 제공하는 경우 URL 형식이어야 합니다. |
+| `contact` | `dict` | 노출된 API에 대한 연락처 정보입니다. 여러 필드를 포함할 수 있습니다. contact
필드매개변수 | 타입 | 설명 |
---|---|---|
name | str | 연락처 인물/조직의 식별명입니다. |
url | str | 연락처 정보가 담긴 URL입니다. URL 형식이어야 합니다. |
email | str | 연락처 인물/조직의 이메일 주소입니다. 이메일 주소 형식이어야 합니다. |
license_info
필드매개변수 | 타입 | 설명 |
---|---|---|
name | str | 필수 (license_info 가 설정된 경우). API에 사용된 라이선스 이름입니다. |
identifier | str | API에 대한 SPDX 라이선스 표현입니다. identifier 필드는 url 필드와 상호 배타적입니다. OpenAPI 3.1.0, FastAPI 0.99.0부터 사용 가능 |
url | str | API에 사용된 라이선스의 URL입니다. URL 형식이어야 합니다. |
get
POST
.
+
+///
+
+/// warning | Aviso
+
+Você pode declarar múltiplos parâmetros `File` e `Form` em uma *operação de rota*, mas você não pode declarar campos `Body` que você espera receber como JSON, pois a requisição terá o corpo codificado usando `multipart/form-data` ao invés de `application/json`.
+
+Isso não é uma limitação do **FastAPI**, é parte do protocolo HTTP.
+
+///
+
+## Upload de Arquivo Opcional
+
+Você pode tornar um arquivo opcional usando anotações de tipo padrão e definindo um valor padrão de `None`:
+
+{* ../../docs_src/request_files/tutorial001_02_an_py310.py hl[9,17] *}
+
+## `UploadFile` com Metadados Adicionais
+
+Você também pode usar `File()` com `UploadFile`, por exemplo, para definir metadados adicionais:
+
+{* ../../docs_src/request_files/tutorial001_03_an_py39.py hl[9,15] *}
+
+## Uploads de Múltiplos Arquivos
+
+É possível realizar o upload de vários arquivos ao mesmo tempo.
+
+Eles serão associados ao mesmo "campo de formulário" enviado usando "dados de formulário".
+
+Para usar isso, declare uma lista de `bytes` ou `UploadFile`:
+
+{* ../../docs_src/request_files/tutorial002_an_py39.py hl[10,15] *}
+
+Você receberá, tal como declarado, uma `list` de `bytes` ou `UploadFile`.
+
+/// note | Detalhes Técnicos
+
+Você pode também pode usar `from starlette.responses import HTMLResponse`.
+
+**FastAPI** providencia o mesmo `starlette.responses` que `fastapi.responses` apenas como uma conveniência para você, o desenvolvedor. Mas a maioria das respostas disponíveis vem diretamente do Starlette.
+
+///
+
+### Uploads de Múltiplos Arquivos com Metadados Adicionais
+
+Da mesma forma de antes, você pode usar `File()` para definir parâmetros adicionais, mesmo para `UploadFile`:
+
+{* ../../docs_src/request_files/tutorial003_an_py39.py hl[11,18:20] *}
+
+## Recapitulando
+
+Utilize `File`, `bytes` e `UploadFile` para declarar arquivos a serem enviados na requisição, enviados como dados de formulário.
diff --git a/docs/pt/docs/tutorial/request-form-models.md b/docs/pt/docs/tutorial/request-form-models.md
index 837e24c34..7128a0ae2 100644
--- a/docs/pt/docs/tutorial/request-form-models.md
+++ b/docs/pt/docs/tutorial/request-form-models.md
@@ -2,7 +2,7 @@
Você pode utilizar **Modelos Pydantic** para declarar **campos de formulários** no FastAPI.
-/// info | "Informação"
+/// info | Informação
Para utilizar formulários, instale primeiramente o `python-multipart`.
@@ -14,7 +14,7 @@ $ pip install python-multipart
///
-/// note | "Nota"
+/// note | Nota
Isto é suportado desde a versão `0.113.0` do FastAPI. 🤓
@@ -42,7 +42,7 @@ Você precisa apenas declarar um **modelo Pydantic** com os campos que deseja re
//// tab | Python 3.8+ non-Annotated
-/// tip | "Dica"
+/// tip | Dica
Prefira utilizar a versão `Annotated` se possível.
@@ -68,7 +68,7 @@ Você pode verificar na UI de documentação em `/docs`:
Em alguns casos de uso especiais (provavelmente não muito comum), você pode desejar **restringir** os campos do formulário para aceitar apenas os declarados no modelo Pydantic. E **proibir** qualquer campo **extra**.
-/// note | "Nota"
+/// note | Nota
Isso é suportado deste a versão `0.114.0` do FastAPI. 🤓
diff --git a/docs/pt/docs/tutorial/request-forms-and-files.md b/docs/pt/docs/tutorial/request-forms-and-files.md
index 29488b4f2..77c099eb3 100644
--- a/docs/pt/docs/tutorial/request-forms-and-files.md
+++ b/docs/pt/docs/tutorial/request-forms-and-files.md
@@ -2,7 +2,7 @@
Você pode definir arquivos e campos de formulário ao mesmo tempo usando `File` e `Form`.
-/// info | "Informação"
+/// info | Informação
Para receber arquivos carregados e/ou dados de formulário, primeiro instale `python-multipart`.
@@ -28,7 +28,7 @@ Os arquivos e campos de formulário serão carregados como dados de formulário
E você pode declarar alguns dos arquivos como `bytes` e alguns como `UploadFile`.
-/// warning | "Aviso"
+/// warning | Aviso
Você pode declarar vários parâmetros `File` e `Form` em uma *operação de caminho*, mas não é possível declarar campos `Body` para receber como JSON, pois a requisição terá o corpo codificado usando `multipart/form-data` ao invés de `application/json`.
diff --git a/docs/pt/docs/tutorial/request-forms.md b/docs/pt/docs/tutorial/request-forms.md
index 1e2faf269..367fca072 100644
--- a/docs/pt/docs/tutorial/request-forms.md
+++ b/docs/pt/docs/tutorial/request-forms.md
@@ -2,7 +2,7 @@
Quando você precisar receber campos de formulário ao invés de JSON, você pode usar `Form`.
-/// info | "Informação"
+/// info | Informação
Para usar formulários, primeiro instale `python-multipart`.
@@ -32,13 +32,13 @@ A spec exige que os campos sejam exatamente
Com `Form` você pode declarar os mesmos metadados e validação que com `Body` (e `Query`, `Path`, `Cookie`).
-/// info | "Informação"
+/// info | Informação
`Form` é uma classe que herda diretamente de `Body`.
///
-/// tip | "Dica"
+/// tip | Dica
Para declarar corpos de formulário, você precisa usar `Form` explicitamente, porque sem ele os parâmetros seriam interpretados como parâmetros de consulta ou parâmetros de corpo (JSON).
@@ -50,7 +50,7 @@ A forma como os formulários HTML (``) enviam os dados para o servi
O **FastAPI** fará a leitura desses dados no lugar certo em vez de JSON.
-/// note | "Detalhes técnicos"
+/// note | Detalhes técnicos
Os dados dos formulários são normalmente codificados usando o "tipo de mídia" `application/x-www-form-urlencoded`.
@@ -60,7 +60,7 @@ Se você quiser ler mais sobre essas codificações e campos de formulário, vá
///
-/// warning | "Aviso"
+/// warning | Aviso
Você pode declarar vários parâmetros `Form` em uma *operação de caminho*, mas não pode declarar campos `Body` que espera receber como JSON, pois a solicitação terá o corpo codificado usando `application/x-www- form-urlencoded` em vez de `application/json`.
diff --git a/docs/pt/docs/tutorial/response-status-code.md b/docs/pt/docs/tutorial/response-status-code.md
index bc4a2cd34..2c8924925 100644
--- a/docs/pt/docs/tutorial/response-status-code.md
+++ b/docs/pt/docs/tutorial/response-status-code.md
@@ -12,7 +12,7 @@ Da mesma forma que você pode especificar um modelo de resposta, você também p
{!../../docs_src/response_status_code/tutorial001.py!}
```
-/// note | "Nota"
+/// note | Nota
Observe que `status_code` é um parâmetro do método "decorador" (get, post, etc). Não da sua função de *operação de caminho*, como todos os parâmetros e corpo.
@@ -20,7 +20,7 @@ Observe que `status_code` é um parâmetro do método "decorador" (get, post, et
O parâmetro `status_code` recebe um número com o código de status HTTP.
-/// info | "Informação"
+/// info | Informação
`status_code` também pode receber um `IntEnum`, como o do Python `http.HTTPStatus`.
@@ -33,7 +33,7 @@ Dessa forma:
get
операцию
-/// info | "`@decorator` Дополнительная информация"
+/// info | `@decorator` Дополнительная информация
Синтаксис `@something` в Python называется "декоратор".
@@ -286,7 +286,7 @@ https://example.com/items/foo
* `@app.patch()`
* `@app.trace()`
-/// tip | "Подсказка"
+/// tip | Подсказка
Вы можете использовать каждую операцию (HTTP-метод) по своему усмотрению.
@@ -324,7 +324,7 @@ https://example.com/items/foo
{!../../docs_src/first_steps/tutorial003.py!}
```
-/// note | "Технические детали"
+/// note | Технические детали
Если не знаете в чём разница, посмотрите [Конкурентность: *"Нет времени?"*](../async.md#_1){.internal-link target=_blank}.
diff --git a/docs/ru/docs/tutorial/handling-errors.md b/docs/ru/docs/tutorial/handling-errors.md
index e7bfb85aa..a06644376 100644
--- a/docs/ru/docs/tutorial/handling-errors.md
+++ b/docs/ru/docs/tutorial/handling-errors.md
@@ -63,7 +63,7 @@
}
```
-/// tip | "Подсказка"
+/// tip | Подсказка
При вызове `HTTPException` в качестве параметра `detail` можно передавать любое значение, которое может быть преобразовано в JSON, а не только `str`.
@@ -109,7 +109,7 @@
{"message": "Oops! yolo did something. There goes a rainbow..."}
```
-/// note | "Технические детали"
+/// note | Технические детали
Также можно использовать `from starlette.requests import Request` и `from starlette.responses import JSONResponse`.
@@ -166,7 +166,7 @@ path -> item_id
#### `RequestValidationError` или `ValidationError`
-/// warning | "Внимание"
+/// warning | Внимание
Это технические детали, которые можно пропустить, если они не важны для вас сейчас.
@@ -192,7 +192,7 @@ path -> item_id
{!../../docs_src/handling_errors/tutorial004.py!}
```
-/// note | "Технические детали"
+/// note | Технические детали
Можно также использовать `from starlette.responses import PlainTextResponse`.
diff --git a/docs/ru/docs/tutorial/header-params.md b/docs/ru/docs/tutorial/header-params.md
index 18e1e60d0..904709b04 100644
--- a/docs/ru/docs/tutorial/header-params.md
+++ b/docs/ru/docs/tutorial/header-params.md
@@ -32,7 +32,7 @@
//// tab | Python 3.10+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -46,7 +46,7 @@
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -90,7 +90,7 @@
//// tab | Python 3.10+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -104,7 +104,7 @@
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -116,7 +116,7 @@
////
-/// note | "Технические детали"
+/// note | Технические детали
`Header` - это "родственный" класс `Path`, `Query` и `Cookie`. Он также наследуется от того же общего класса `Param`.
@@ -124,7 +124,7 @@
///
-/// info | "Дополнительная информация"
+/// info | Дополнительная информация
Чтобы объявить заголовки, важно использовать `Header`, иначе параметры интерпретируются как query-параметры.
@@ -172,7 +172,7 @@
//// tab | Python 3.10+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -186,7 +186,7 @@
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -198,7 +198,7 @@
////
-/// warning | "Внимание"
+/// warning | Внимание
Прежде чем установить для `convert_underscores` значение `False`, имейте в виду, что некоторые HTTP-прокси и серверы запрещают использование заголовков с подчеркиванием.
@@ -240,7 +240,7 @@
//// tab | Python 3.10+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -254,7 +254,7 @@
//// tab | Python 3.9+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
@@ -268,7 +268,7 @@
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Предпочтительнее использовать версию с аннотацией, если это возможно.
diff --git a/docs/ru/docs/tutorial/index.md b/docs/ru/docs/tutorial/index.md
index 4cf45c0ed..ddca2fbb1 100644
--- a/docs/ru/docs/tutorial/index.md
+++ b/docs/ru/docs/tutorial/index.md
@@ -52,7 +52,7 @@ $ pip install "fastapi[all]"
...это также включает `uvicorn`, который вы можете использовать в качестве сервера, который запускает ваш код.
-/// note | "Технические детали"
+/// note | Технические детали
Вы также можете установить его по частям.
diff --git a/docs/ru/docs/tutorial/metadata.md b/docs/ru/docs/tutorial/metadata.md
index 246458f42..ae739a043 100644
--- a/docs/ru/docs/tutorial/metadata.md
+++ b/docs/ru/docs/tutorial/metadata.md
@@ -21,7 +21,7 @@
{!../../docs_src/metadata/tutorial001.py!}
```
-/// tip | "Подсказка"
+/// tip | Подсказка
Вы можете использовать Markdown в поле `description`, и оно будет отображено в выводе.
@@ -57,7 +57,7 @@
Помните, что вы можете использовать Markdown внутри описания, к примеру "login" будет отображен жирным шрифтом (**login**) и "fancy" будет отображаться курсивом (_fancy_).
-/// tip | "Подсказка"
+/// tip | Подсказка
Вам необязательно добавлять метаданные для всех используемых тегов
@@ -70,7 +70,7 @@
{!../../docs_src/metadata/tutorial004.py!}
```
-/// info | "Дополнительная информация"
+/// info | Дополнительная информация
Узнайте больше о тегах в [Конфигурации операции пути](path-operation-configuration.md#_3){.internal-link target=_blank}.
diff --git a/docs/ru/docs/tutorial/path-operation-configuration.md b/docs/ru/docs/tutorial/path-operation-configuration.md
index 5f3855af2..ac12b7084 100644
--- a/docs/ru/docs/tutorial/path-operation-configuration.md
+++ b/docs/ru/docs/tutorial/path-operation-configuration.md
@@ -2,7 +2,7 @@
Существует несколько параметров, которые вы можете передать вашему *декоратору операций пути* для его настройки.
-/// warning | "Внимание"
+/// warning | Внимание
Помните, что эти параметры передаются непосредственно *декоратору операций пути*, а не вашей *функции-обработчику операций пути*.
@@ -42,7 +42,7 @@
Этот код состояния будет использован в ответе и будет добавлен в схему OpenAPI.
-/// note | "Технические детали"
+/// note | Технические детали
Вы также можете использовать `from starlette import status`.
@@ -184,13 +184,13 @@
////
-/// info | "Дополнительная информация"
+/// info | Дополнительная информация
Помните, что `response_description` относится конкретно к ответу, а `description` относится к *операции пути* в целом.
///
-/// check | "Технические детали"
+/// check | Технические детали
OpenAPI указывает, что каждой *операции пути* необходимо описание ответа.
diff --git a/docs/ru/docs/tutorial/path-params-numeric-validations.md b/docs/ru/docs/tutorial/path-params-numeric-validations.md
index bf42ec725..ed19576a2 100644
--- a/docs/ru/docs/tutorial/path-params-numeric-validations.md
+++ b/docs/ru/docs/tutorial/path-params-numeric-validations.md
@@ -32,7 +32,7 @@
//// tab | Python 3.10+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -46,7 +46,7 @@
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -58,7 +58,7 @@
////
-/// info | "Информация"
+/// info | Информация
Поддержка `Annotated` была добавлена в FastAPI начиная с версии 0.95.0 (и с этой версии рекомендуется использовать этот подход).
@@ -100,7 +100,7 @@
//// tab | Python 3.10+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -114,7 +114,7 @@
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -126,7 +126,7 @@
////
-/// note | "Примечание"
+/// note | Примечание
Path-параметр всегда является обязательным, поскольку он составляет часть пути.
@@ -138,7 +138,7 @@ Path-параметр всегда является обязательным, п
## Задайте нужный вам порядок параметров
-/// tip | "Подсказка"
+/// tip | Подсказка
Это не имеет большого значения, если вы используете `Annotated`.
@@ -160,7 +160,7 @@ Path-параметр всегда является обязательным, п
//// tab | Python 3.8 без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -192,7 +192,7 @@ Path-параметр всегда является обязательным, п
## Задайте нужный вам порядок параметров, полезные приёмы
-/// tip | "Подсказка"
+/// tip | Подсказка
Это не имеет большого значения, если вы используете `Annotated`.
@@ -261,7 +261,7 @@ Python не будет ничего делать с `*`, но он будет з
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -298,7 +298,7 @@ Python не будет ничего делать с `*`, но он будет з
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -338,7 +338,7 @@ Python не будет ничего делать с `*`, но он будет з
//// tab | Python 3.8+ без Annotated
-/// tip | "Подсказка"
+/// tip | Подсказка
Рекомендуется использовать версию с `Annotated` если возможно.
@@ -361,7 +361,7 @@ Python не будет ничего делать с `*`, но он будет з
* `lt`: меньше (`l`ess `t`han)
* `le`: меньше или равно (`l`ess than or `e`qual)
-/// info | "Информация"
+/// info | Информация
`Query`, `Path` и другие классы, которые мы разберём позже, являются наследниками общего класса `Param`.
@@ -369,7 +369,7 @@ Python не будет ничего делать с `*`, но он будет з
///
-/// note | "Технические детали"
+/// note | Технические детали
`Query`, `Path` и другие "классы", которые вы импортируете из `fastapi`, на самом деле являются функциями, которые при вызове возвращают экземпляры одноимённых классов.
diff --git a/docs/ru/docs/tutorial/path-params.md b/docs/ru/docs/tutorial/path-params.md
index d1d76cf7b..ba23ba5ea 100644
--- a/docs/ru/docs/tutorial/path-params.md
+++ b/docs/ru/docs/tutorial/path-params.md
@@ -24,7 +24,7 @@
Здесь, `item_id` объявлен типом `int`.
-/// check | "Заметка"
+/// check | Заметка
Это обеспечит поддержку редактора внутри функции (проверка ошибок, автодополнение и т.п.).
@@ -38,7 +38,7 @@
{"item_id":3}
```
-/// check | "Заметка"
+/// check | Заметка
Обратите внимание на значение `3`, которое получила (и вернула) функция. Это целочисленный Python `int`, а не строка `"3"`.
@@ -69,7 +69,7 @@
Та же ошибка возникнет, если вместо `int` передать `float` , например: http://127.0.0.1:8000/items/4.2
-/// check | "Заметка"
+/// check | Заметка
**FastAPI** обеспечивает проверку типов, используя всё те же определения типов.
@@ -85,7 +85,7 @@
get
operasyonu ile
* `/` yoluna gelen istekler
-/// info | "`@decorator` Bilgisi"
+/// info | `@decorator` Bilgisi
Python'da `@something` sözdizimi "dekoratör" olarak adlandırılır.
@@ -286,7 +286,7 @@ Daha az kullanılanları da kullanabilirsiniz:
* `@app.patch()`
* `@app.trace()`
-/// tip | "İpucu"
+/// tip | İpucu
Her işlemi (HTTP metod) istediğiniz gibi kullanmakta özgürsünüz.
@@ -324,7 +324,7 @@ Bu fonksiyonu `async def` yerine normal bir fonksiyon olarak da tanımlayabilirs
{!../../docs_src/first_steps/tutorial003.py!}
```
-/// note | "Not"
+/// note | Not
Eğer farkı bilmiyorsanız, [Async: *"Aceleniz mi var?"*](../async.md#in-a-hurry){.internal-link target=_blank} sayfasını kontrol edebilirsiniz.
diff --git a/docs/tr/docs/tutorial/path-params.md b/docs/tr/docs/tutorial/path-params.md
index 9017d99ab..c883c2f9f 100644
--- a/docs/tr/docs/tutorial/path-params.md
+++ b/docs/tr/docs/tutorial/path-params.md
@@ -24,7 +24,7 @@ Standart Python tip belirteçlerini kullanarak yol parametresinin tipini fonksiy
Bu durumda, `item_id` bir `int` olarak tanımlanacaktır.
-/// check | "Ek bilgi"
+/// check | Ek bilgi
Bu sayede, fonksiyon içerisinde hata denetimi, kod tamamlama gibi konularda editör desteğine kavuşacaksınız.
@@ -38,7 +38,7 @@ Eğer bu örneği çalıştırıp tarayıcınızda http://127.0.0.1:8000/items/4.2 sayfasında olduğu gibi `int` yerine `float` bir değer verseydik de ortaya çıkardı.
-/// check | "Ek bilgi"
+/// check | Ek bilgi
Böylece, aynı Python tip tanımlaması ile birlikte, **FastAPI** veri doğrulama özelliği sağlar.
@@ -87,7 +87,7 @@ Ayrıca, tarayıcınızı
-/// check | "Ek bilgi"
+/// check | Ek bilgi
Üstelik, sadece aynı Python tip tanımlaması ile, **FastAPI** size otomatik ve interaktif (Swagger UI ile entegre) bir dokümantasyon sağlar.
@@ -153,13 +153,13 @@ Sonrasında, sınıf içerisinde, mevcut ve geçerli değerler olacak olan sabit
{!../../docs_src/path_params/tutorial005.py!}
```
-/// info | "Bilgi"
+/// info | Bilgi
3.4 sürümünden beri enumerationlar (ya da enumlar) Python'da mevcuttur.
///
-/// tip | "İpucu"
+/// tip | İpucu
Merak ediyorsanız söyleyeyim, "AlexNet", "ResNet" ve "LeNet" isimleri Makine Öğrenmesi modellerini temsil eder.
@@ -199,7 +199,7 @@ Parametreyi, yarattığınız enum olan `ModelName` içerisindeki *enumeration
{!../../docs_src/path_params/tutorial005.py!}
```
-/// tip | "İpucu"
+/// tip | İpucu
`"lenet"` değerine `ModelName.lenet.value` tanımı ile de ulaşabilirsiniz.
@@ -256,7 +256,7 @@ Böylece şunun gibi bir kullanım yapabilirsiniz:
{!../../docs_src/path_params/tutorial004.py!}
```
-/// tip | "İpucu"
+/// tip | İpucu
Parametrenin başında `/home/johndoe/myfile.txt` yolunda olduğu gibi (`/`) işareti ile birlikte kullanmanız gerektiği durumlar olabilir.
diff --git a/docs/tr/docs/tutorial/query-params.md b/docs/tr/docs/tutorial/query-params.md
index 886f5783f..b31d13be4 100644
--- a/docs/tr/docs/tutorial/query-params.md
+++ b/docs/tr/docs/tutorial/query-params.md
@@ -81,7 +81,7 @@ Aynı şekilde, varsayılan değerlerini `None` olarak atayarak isteğe bağlı
Bu durumda, `q` fonksiyon parametresi isteğe bağlı olacak ve varsayılan değer olarak `None` alacaktır.
-/// check | "Ek bilgi"
+/// check | Ek bilgi
Ayrıca, dikkatinizi çekerim ki; **FastAPI**, `item_id` parametresinin bir yol parametresi olduğunu ve `q` parametresinin yol değil bir sorgu parametresi olduğunu fark edecek kadar beceriklidir.
@@ -242,7 +242,7 @@ Bu durumda, 3 tane sorgu parametresi var olacaktır:
* `skip`, varsayılan değeri `0` olan bir `int`.
* `limit`, isteğe bağlı bir `int`.
-/// tip | "İpucu"
+/// tip | İpucu
Ayrıca, [Yol Parametrelerinde](path-params.md#on-tanml-degerler){.internal-link target=_blank} de kullanıldığı şekilde `Enum` sınıfından faydalanabilirsiniz.
diff --git a/docs/tr/docs/tutorial/request-forms.md b/docs/tr/docs/tutorial/request-forms.md
index 19b6150ff..4ed8ac021 100644
--- a/docs/tr/docs/tutorial/request-forms.md
+++ b/docs/tr/docs/tutorial/request-forms.md
@@ -2,7 +2,7 @@
İstek gövdesinde JSON verisi yerine form alanlarını karşılamanız gerketiğinde `Form` sınıfını kullanabilirsiniz.
-/// info | "Bilgi"
+/// info | Bilgi
Formları kullanmak için öncelikle `python-multipart` paketini indirmeniz gerekmektedir.
@@ -84,13 +84,13 @@ Bu spesifikasyon form alanlar
`Form` sınıfıyla tanımlama yaparken `Body`, `Query`, `Path` ve `Cookie` sınıflarında kullandığınız aynı validasyon, örnekler, isimlendirme (örneğin `username` yerine `user-name` kullanımı) ve daha fazla konfigurasyonu kullanabilirsiniz.
-/// info | "Bilgi"
+/// info | Bilgi
`Form` doğrudan `Body` sınıfını miras alan bir sınıftır.
///
-/// tip | "İpucu"
+/// tip | İpucu
Form gövdelerini tanımlamak için `Form` sınıfını kullanmanız gerekir; çünkü bu olmadan parametreler sorgu parametreleri veya gövde (JSON) parametreleri olarak yorumlanır.
@@ -102,7 +102,7 @@ HTML formlarının (``) verileri sunucuya gönderirken JSON'dan far
**FastAPI** bu verilerin JSON yerine doğru şekilde okunmasını sağlayacaktır.
-/// note | "Teknik Detaylar"
+/// note | Teknik Detaylar
Form verileri normalde `application/x-www-form-urlencoded` medya tipiyle kodlanır.
@@ -112,7 +112,7 @@ Form kodlama türleri ve form alanları hakkında daha fazla bilgi edinmek istiy
///
-/// warning | "Uyarı"
+/// warning | Uyarı
*Yol operasyonları* içerisinde birden fazla `Form` parametresi tanımlayabilirsiniz ancak bunlarla birlikte JSON verisi kabul eden `Body` alanları tanımlayamazsınız çünkü bu durumda istek gövdesi `application/json` yerine `application/x-www-form-urlencoded` ile kodlanmış olur.
diff --git a/docs/tr/docs/tutorial/static-files.md b/docs/tr/docs/tutorial/static-files.md
index 8bff59744..da8bed86a 100644
--- a/docs/tr/docs/tutorial/static-files.md
+++ b/docs/tr/docs/tutorial/static-files.md
@@ -11,7 +11,7 @@
{!../../docs_src/static_files/tutorial001.py!}
```
-/// note | "Teknik Detaylar"
+/// note | Teknik Detaylar
Projenize dahil etmek için `from starlette.staticfiles import StaticFiles` kullanabilirsiniz.
diff --git a/docs/uk/docs/alternatives.md b/docs/uk/docs/alternatives.md
index eb48d6be7..1acbe237a 100644
--- a/docs/uk/docs/alternatives.md
+++ b/docs/uk/docs/alternatives.md
@@ -30,13 +30,13 @@
Це був один із перших прикладів **автоматичної документації API**, і саме це була одна з перших ідей, яка надихнула на «пошук» **FastAPI**.
-/// note | "Примітка"
+/// note | Примітка
Django REST Framework створив Том Крісті. Той самий творець Starlette і Uvicorn, на яких базується **FastAPI**.
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Мати автоматичний веб-інтерфейс документації API.
@@ -56,7 +56,7 @@ Flask — це «мікрофреймворк», він не включає ін
Враховуючи простоту Flask, він здавався хорошим підходом для створення API. Наступним, що знайшов, був «Django REST Framework» для Flask.
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Бути мікрофреймоворком. Зробити легким комбінування та поєднання необхідних інструментів та частин.
@@ -98,7 +98,7 @@ def read_url():
Зверніть увагу на схожість у `requests.get(...)` і `@app.get(...)`.
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
* Майте простий та інтуїтивно зрозумілий API.
* Використовуйте імена (операції) методів HTTP безпосередньо, простим та інтуїтивно зрозумілим способом.
@@ -118,7 +118,7 @@ def read_url():
Тому, коли говорять про версію 2.0, прийнято говорити «Swagger», а про версію 3+ «OpenAPI».
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Прийняти і використовувати відкритий стандарт для специфікацій API замість спеціальної схеми.
@@ -147,7 +147,7 @@ Marshmallow створено для забезпечення цих функці
Але він був створений до того, як існували підказки типу Python. Отже, щоб визначити кожну схему, вам потрібно використовувати спеціальні утиліти та класи, надані Marshmallow.
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Використовувати код для автоматичного визначення "схем", які надають типи даних і перевірку.
@@ -163,13 +163,13 @@ Webargs — це інструмент, створений, щоб забезпе
Це чудовий інструмент, і я також часто використовував його, перш ніж створити **FastAPI**.
-/// info | "Інформація"
+/// info | Інформація
Webargs був створений тими ж розробниками Marshmallow.
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Мати автоматичну перевірку даних вхідного запиту.
@@ -193,13 +193,13 @@ Marshmallow і Webargs забезпечують перевірку, аналіз
Редактор тут нічим не може допомогти. І якщо ми змінимо параметри чи схеми Marshmallow і забудемо також змінити цю строку документа YAML, згенерована схема буде застарілою.
-/// info | "Інформація"
+/// info | Інформація
APISpec був створений тими ж розробниками Marshmallow.
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Підтримувати відкритий стандарт API, OpenAPI.
@@ -225,13 +225,13 @@ APISpec був створений тими ж розробниками Marshmall
І ці самі генератори повного стеку були основою [**FastAPI** генераторів проектів](project-generation.md){.internal-link target=_blank}.
-/// info | "Інформація"
+/// info | Інформація
Flask-apispec був створений тими ж розробниками Marshmallow.
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Створення схеми OpenAPI автоматично з того самого коду, який визначає серіалізацію та перевірку.
@@ -251,7 +251,7 @@ Flask-apispec був створений тими ж розробниками Mar
Він не дуже добре обробляє вкладені моделі. Отже, якщо тіло JSON у запиті є об’єктом JSON із внутрішніми полями, які, у свою чергу, є вкладеними об’єктами JSON, його неможливо належним чином задокументувати та перевірити.
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Використовувати типи Python, щоб мати чудову підтримку редактора.
@@ -263,7 +263,7 @@ Flask-apispec був створений тими ж розробниками Mar
Це був один із перших надзвичайно швидких фреймворків Python на основі `asyncio`. Він був дуже схожий на Flask.
-/// note | "Технічні деталі"
+/// note | Технічні деталі
Він використовував `uvloop` замість стандартного циклу Python `asyncio`. Ось що зробило його таким швидким.
@@ -271,7 +271,7 @@ Flask-apispec був створений тими ж розробниками Mar
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Знайти спосіб отримати божевільну продуктивність.
@@ -287,7 +287,7 @@ Falcon — ще один високопродуктивний фреймворк
Таким чином, перевірка даних, серіалізація та документація повинні виконуватися в коді, а не автоматично. Або вони повинні бути реалізовані як фреймворк поверх Falcon, як Hug. Така сама відмінність спостерігається в інших фреймворках, натхненних дизайном Falcon, що мають один об’єкт запиту та один об’єкт відповіді як параметри.
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Знайти способи отримати чудову продуктивність.
@@ -313,7 +313,7 @@ Falcon — ще один високопродуктивний фреймворк
Маршрути оголошуються в одному місці з використанням функцій, оголошених в інших місцях (замість використання декораторів, які можна розмістити безпосередньо поверх функції, яка обробляє кінцеву точку). Це ближче до того, як це робить Django, ніж до Flask (і Starlette). Він розділяє в коді речі, які відносно тісно пов’язані.
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Визначити додаткові перевірки для типів даних, використовуючи значення "за замовчуванням" атрибутів моделі. Це покращує підтримку редактора, а раніше вона була недоступна в Pydantic.
@@ -321,7 +321,7 @@ Falcon — ще один високопродуктивний фреймворк
///
-### Hug
+### Hug
Hug був одним із перших фреймворків, який реалізував оголошення типів параметрів API за допомогою підказок типу Python. Це була чудова ідея, яка надихнула інші інструменти зробити те саме.
@@ -335,13 +335,13 @@ Hug був одним із перших фреймворків, який реа
Оскільки він заснований на попередньому стандарті для синхронних веб-фреймворків Python (WSGI), він не може працювати з Websockets та іншими речами, хоча він також має високу продуктивність.
-/// info | "Інформація"
+/// info | Інформація
Hug створив Тімоті Крослі, той самий творець `isort`, чудовий інструмент для автоматичного сортування імпорту у файлах Python.
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Hug надихнув частину APIStar і був одним із найбільш перспективних інструментів, поряд із APIStar.
@@ -375,7 +375,7 @@ Hug надихнув частину APIStar і був одним із найбі
Тепер APIStar — це набір інструментів для перевірки специфікацій OpenAPI, а не веб-фреймворк.
-/// info | "Інформація"
+/// info | Інформація
APIStar створив Том Крісті. Той самий хлопець, який створив:
@@ -385,7 +385,7 @@ APIStar створив Том Крісті. Той самий хлопець, я
///
-/// check | "Надихнуло **FastAPI** на"
+/// check | Надихнуло **FastAPI** на
Існувати.
@@ -407,7 +407,7 @@ Pydantic — це бібліотека для визначення переві
Його можна порівняти з Marshmallow. Хоча він швидший за Marshmallow у тестах. Оскільки він базується на тих самих підказках типу Python, підтримка редактора чудова.
-/// check | "**FastAPI** використовує його для"
+/// check | **FastAPI** використовує його для
Виконання перевірки всіх даних, серіалізації даних і автоматичної документацію моделі (на основі схеми JSON).
@@ -442,7 +442,7 @@ Starlette надає всі основні функції веб-мікрофр
Це одна з головних речей, які **FastAPI** додає зверху, все на основі підказок типу Python (з використанням Pydantic). Це, а також система впровадження залежностей, утиліти безпеки, створення схеми OpenAPI тощо.
-/// note | "Технічні деталі"
+/// note | Технічні деталі
ASGI — це новий «стандарт», який розробляється членами основної команди Django. Це ще не «стандарт Python» (PEP), хоча вони в процесі цього.
@@ -450,7 +450,7 @@ ASGI — це новий «стандарт», який розробляєтьс
///
-/// check | "**FastAPI** використовує його для"
+/// check | **FastAPI** використовує його для
Керування всіма основними веб-частинами. Додавання функцій зверху.
@@ -468,7 +468,7 @@ Uvicorn — це блискавичний сервер ASGI, побудован
Це рекомендований сервер для Starlette і **FastAPI**.
-/// check | "**FastAPI** рекомендує це як"
+/// check | **FastAPI** рекомендує це як
Основний веб-сервер для запуску програм **FastAPI**.
diff --git a/docs/uk/docs/index.md b/docs/uk/docs/index.md
index 4c8c54af2..012bac2e2 100644
--- a/docs/uk/docs/index.md
+++ b/docs/uk/docs/index.md
@@ -88,7 +88,7 @@ FastAPI - це сучасний, швидкий (високопродуктив
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
-
+
---
diff --git a/docs/uk/docs/tutorial/body-fields.md b/docs/uk/docs/tutorial/body-fields.md
index b1f645932..c286744a8 100644
--- a/docs/uk/docs/tutorial/body-fields.md
+++ b/docs/uk/docs/tutorial/body-fields.md
@@ -122,7 +122,7 @@
`Field` працює так само, як `Query`, `Path` і `Body`, у нього такі самі параметри тощо.
-/// note | "Технічні деталі"
+/// note | Технічні деталі
Насправді, `Query`, `Path` та інші, що ви побачите далі, створюють об'єкти підкласів загального класу `Param`, котрий сам є підкласом класу `FieldInfo` з Pydantic.
diff --git a/docs/uk/docs/tutorial/cookie-params.md b/docs/uk/docs/tutorial/cookie-params.md
index 40ca4f6e6..229f81b63 100644
--- a/docs/uk/docs/tutorial/cookie-params.md
+++ b/docs/uk/docs/tutorial/cookie-params.md
@@ -116,7 +116,7 @@
////
-/// note | "Технічні Деталі"
+/// note | Технічні Деталі
`Cookie` це "сестра" класів `Path` і `Query`. Вони наслідуються від одного батьківського класу `Param`.
Але пам'ятайте, що коли ви імпортуєте `Query`, `Path`, `Cookie` та інше з `fastapi`, це фактично функції, що повертають спеціальні класи.
diff --git a/docs/uk/docs/tutorial/encoder.md b/docs/uk/docs/tutorial/encoder.md
index 39dca9be8..77b0baf4d 100644
--- a/docs/uk/docs/tutorial/encoder.md
+++ b/docs/uk/docs/tutorial/encoder.md
@@ -42,7 +42,7 @@
Вона не повертає велику строку `str`, яка містить дані у форматі JSON (як строка). Вона повертає стандартну структуру даних Python (наприклад `dict`) із значеннями та підзначеннями, які є сумісними з JSON.
-/// note | "Примітка"
+/// note | Примітка
`jsonable_encoder` фактично використовується **FastAPI** внутрішньо для перетворення даних. Проте вона корисна в багатьох інших сценаріях.
diff --git a/docs/uk/docs/tutorial/first-steps.md b/docs/uk/docs/tutorial/first-steps.md
index 6f79c0d1d..63fec207d 100644
--- a/docs/uk/docs/tutorial/first-steps.md
+++ b/docs/uk/docs/tutorial/first-steps.md
@@ -163,7 +163,7 @@ OpenAPI описує схему для вашого API. І ця схема вк
`FastAPI` це клас у Python, який надає всю функціональність для API.
-/// note | "Технічні деталі"
+/// note | Технічні деталі
`FastAPI` це клас, який успадковується безпосередньо від `Starlette`.
@@ -198,7 +198,7 @@ https://example.com/items/foo
/items/foo
```
-/// info | "Додаткова інформація"
+/// info | Додаткова інформація
"Шлях" (path) також зазвичай називають "ендпоінтом" (endpoint) або "маршрутом" (route).
@@ -250,7 +250,7 @@ https://example.com/items/foo
* шлях `/`
* використовуючи get
операцію
-/// info | "`@decorator` Додаткова інформація"
+/// info | `@decorator` Додаткова інформація
Синтаксис `@something` у Python називається "декоратором".
@@ -277,7 +277,7 @@ https://example.com/items/foo
* `@app.patch()`
* `@app.trace()`
-/// tip | "Порада"
+/// tip | Порада
Ви можете використовувати кожну операцію (HTTP-метод) на свій розсуд.
@@ -315,7 +315,7 @@ FastAPI викликатиме її щоразу, коли отримає зап
{!../../docs_src/first_steps/tutorial003.py!}
```
-/// note | "Примітка"
+/// note | Примітка
Якщо не знаєте в чому різниця, подивіться [Конкурентність: *"Поспішаєш?"*](../async.md#in-a-hurry){.internal-link target=_blank}.
diff --git a/docs/vi/docs/index.md b/docs/vi/docs/index.md
index 09deac6f2..5e346ded8 100644
--- a/docs/vi/docs/index.md
+++ b/docs/vi/docs/index.md
@@ -93,7 +93,7 @@ Những tính năng như:
"_Thành thật, những gì bạn đã xây dựng nhìn siêu chắc chắn và bóng bẩy. Theo nhiều cách, nó là những gì tôi đã muốn Hug trở thành - thật sự truyền cảm hứng để thấy ai đó xây dựng nó._"
-
+
---
diff --git a/docs/vi/docs/tutorial/first-steps.md b/docs/vi/docs/tutorial/first-steps.md
index d80d78506..934527b8e 100644
--- a/docs/vi/docs/tutorial/first-steps.md
+++ b/docs/vi/docs/tutorial/first-steps.md
@@ -139,7 +139,7 @@ Bạn cũng có thể sử dụng nó để sinh code tự động, với các c
`FastAPI` là một Python class cung cấp tất cả chức năng cho API của bạn.
-/// note | "Chi tiết kĩ thuật"
+/// note | Chi tiết kĩ thuật
`FastAPI` là một class kế thừa trực tiếp `Starlette`.
diff --git a/docs/yo/docs/index.md b/docs/yo/docs/index.md
index ee7f56220..3ad1483de 100644
--- a/docs/yo/docs/index.md
+++ b/docs/yo/docs/index.md
@@ -93,7 +93,7 @@ FastAPI jẹ́ ìgbàlódé, tí ó yára (iṣẹ-giga), ìlànà wẹ́ẹ́b
"_Ní tòótọ́, ohun tí o kọ dára ó sì tún dán. Ní ọ̀pọ̀lọpọ̀ ọ̀nà, ohun tí mo fẹ́ kí **Hug** jẹ́ nìyẹn - ó wúni lórí gan-an láti rí ẹnìkan tí ó kọ́ nǹkan bí èyí._"
-
+
---
diff --git a/docs/zh-hant/docs/deployment/cloud.md b/docs/zh-hant/docs/deployment/cloud.md
index 5d645b6c2..29ebe3ff5 100644
--- a/docs/zh-hant/docs/deployment/cloud.md
+++ b/docs/zh-hant/docs/deployment/cloud.md
@@ -1,14 +1,14 @@
# 在雲端部署 FastAPI
-你幾乎可以使用 **任何雲端供應商** 來部署你的 FastAPI 應用程式。
+你幾乎可以使用**任何雲端供應商**來部署你的 FastAPI 應用程式。
在大多數情況下,主要的雲端供應商都有部署 FastAPI 的指南。
## 雲端供應商 - 贊助商
-一些雲端供應商 ✨ [**贊助 FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨,這確保了 FastAPI 及其 **生態系統** 持續健康地 **發展**。
+一些雲端供應商 ✨ [**贊助 FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨,這確保了 FastAPI 及其**生態系統**持續健康地**發展**。
-這也展現了他們對 FastAPI 和其 **社群**(包括你)的真正承諾,他們不僅希望為你提供 **優質的服務**,還希望確保你擁有一個 **良好且健康的框架**:FastAPI。🙇
+這也展現了他們對 FastAPI 和其**社群**(包括你)的真正承諾,他們不僅希望為你提供**優質的服務**,還希望確保你擁有一個**良好且健康的框架**:FastAPI。🙇
你可能會想嘗試他們的服務,以下有他們的指南:
diff --git a/docs/zh-hant/docs/deployment/index.md b/docs/zh-hant/docs/deployment/index.md
new file mode 100644
index 000000000..1726562b4
--- /dev/null
+++ b/docs/zh-hant/docs/deployment/index.md
@@ -0,0 +1,21 @@
+# 部署
+
+部署 **FastAPI** 應用程式相對容易。
+
+## 部署是什麼意思
+
+**部署**應用程式指的是執行一系列必要的步驟,使其能夠**讓使用者存取和使用**。
+
+對於一個 **Web API**,部署通常涉及將其放置在**遠端伺服器**上,並使用性能優良且穩定的**伺服器程式**,確保使用者能夠高效、無中斷地存取應用程式,且不會遇到問題。
+
+這與**開發**階段形成鮮明對比,在**開發**階段,你會不斷更改程式碼、破壞程式碼、修復程式碼,然後停止和重新啟動伺服器等。
+
+## 部署策略
+
+根據你的使用場景和使用工具,有多種方法可以實現此目的。
+
+你可以使用一些工具自行**部署伺服器**,你也可以使用能為你完成部分工作的**雲端服務**,或其他可能的選項。
+
+我將向你展示在部署 **FastAPI** 應用程式時你可能應該記住的一些主要概念(儘管其中大部分適用於任何其他類型的 Web 應用程式)。
+
+在接下來的部分中,你將看到更多需要記住的細節以及一些技巧。 ✨
diff --git a/docs/zh-hant/docs/environment-variables.md b/docs/zh-hant/docs/environment-variables.md
new file mode 100644
index 000000000..a1598fc01
--- /dev/null
+++ b/docs/zh-hant/docs/environment-variables.md
@@ -0,0 +1,298 @@
+# 環境變數
+
+/// tip
+
+如果你已經知道什麼是「環境變數」並且知道如何使用它們,你可以放心跳過這一部分。
+
+///
+
+環境變數(也稱為「**env var**」)是一個獨立於 Python 程式碼**之外**的變數,它存在於**作業系統**中,可以被你的 Python 程式碼(或其他程式)讀取。
+
+環境變數對於處理應用程式**設定**(作為 Python **安裝**的一部分等方面)非常有用。
+
+## 建立和使用環境變數
+
+你在 **shell(終端機)**中就可以**建立**和使用環境變數,並不需要用到 Python:
+
+//// tab | Linux, macOS, Windows Bash
+
+get
操作
-/// info | "`@decorator` Info"
+/// info | `@decorator` Info
`@something` 语法在 Python 中被称为「装饰器」。
diff --git a/docs/zh/docs/tutorial/handling-errors.md b/docs/zh/docs/tutorial/handling-errors.md
index 0820c363c..799e81eb2 100644
--- a/docs/zh/docs/tutorial/handling-errors.md
+++ b/docs/zh/docs/tutorial/handling-errors.md
@@ -67,7 +67,7 @@
```
-/// tip | "提示"
+/// tip | 提示
触发 `HTTPException` 时,可以用参数 `detail` 传递任何能转换为 JSON 的值,不仅限于 `str`。
@@ -116,7 +116,7 @@
```
-/// note | "技术细节"
+/// note | 技术细节
`from starlette.requests import Request` 和 `from starlette.responses import JSONResponse` 也可以用于导入 `Request` 和 `JSONResponse`。
@@ -176,7 +176,7 @@ path -> item_id
### `RequestValidationError` vs `ValidationError`
-/// warning | "警告"
+/// warning | 警告
如果您觉得现在还用不到以下技术细节,可以先跳过下面的内容。
@@ -203,7 +203,7 @@ path -> item_id
```
-/// note | "技术细节"
+/// note | 技术细节
还可以使用 `from starlette.responses import PlainTextResponse`。
diff --git a/docs/zh/docs/tutorial/header-params.md b/docs/zh/docs/tutorial/header-params.md
index 4de8bf4df..c45a6b095 100644
--- a/docs/zh/docs/tutorial/header-params.md
+++ b/docs/zh/docs/tutorial/header-params.md
@@ -116,7 +116,7 @@
////
-/// note | "技术细节"
+/// note | 技术细节
`Header` 是 `Path`、`Query`、`Cookie` 的**兄弟类**,都继承自共用的 `Param` 类。
@@ -124,7 +124,7 @@
///
-/// info | "说明"
+/// info | 说明
必须使用 `Header` 声明 header 参数,否则该参数会被解释为查询参数。
@@ -198,7 +198,7 @@
////
-/// warning | "警告"
+/// warning | 警告
注意,使用 `convert_underscores = False` 要慎重,有些 HTTP 代理和服务器不支持使用带有下划线的请求头。
diff --git a/docs/zh/docs/tutorial/metadata.md b/docs/zh/docs/tutorial/metadata.md
index 7252db9f6..2398f3e01 100644
--- a/docs/zh/docs/tutorial/metadata.md
+++ b/docs/zh/docs/tutorial/metadata.md
@@ -46,7 +46,7 @@
注意你可以在描述内使用 Markdown,例如「login」会显示为粗体(**login**)以及「fancy」会显示为斜体(_fancy_)。
-/// tip | "提示"
+/// tip | 提示
不必为你使用的所有标签都添加元数据。
@@ -60,7 +60,7 @@
{!../../docs_src/metadata/tutorial004.py!}
```
-/// info | "信息"
+/// info | 信息
阅读更多关于标签的信息[路径操作配置](path-operation-configuration.md#tags){.internal-link target=_blank}。
diff --git a/docs/zh/docs/tutorial/middleware.md b/docs/zh/docs/tutorial/middleware.md
index fb2874ba3..8076f8d52 100644
--- a/docs/zh/docs/tutorial/middleware.md
+++ b/docs/zh/docs/tutorial/middleware.md
@@ -11,7 +11,7 @@
* 它可以对该**响应**做些什么或者执行任何需要的代码.
* 然后它返回这个 **响应**.
-/// note | "技术细节"
+/// note | 技术细节
如果你使用了 `yield` 关键字依赖, 依赖中的退出代码将在执行中间件*后*执行.
@@ -43,7 +43,7 @@
///
-/// note | "技术细节"
+/// note | 技术细节
你也可以使用 `from starlette.requests import Request`.
diff --git a/docs/zh/docs/tutorial/path-operation-configuration.md b/docs/zh/docs/tutorial/path-operation-configuration.md
index 12e1f24ba..add370d1c 100644
--- a/docs/zh/docs/tutorial/path-operation-configuration.md
+++ b/docs/zh/docs/tutorial/path-operation-configuration.md
@@ -2,7 +2,7 @@
*路径操作装饰器*支持多种配置参数。
-/// warning | "警告"
+/// warning | 警告
注意:以下参数应直接传递给**路径操作装饰器**,不能传递给*路径操作函数*。
@@ -22,7 +22,7 @@
状态码在响应中使用,并会被添加到 OpenAPI 概图。
-/// note | "技术细节"
+/// note | 技术细节
也可以使用 `from starlette import status` 导入状态码。
@@ -72,13 +72,13 @@ OpenAPI 概图会自动添加标签,供 API 文档接口使用:
{!../../docs_src/path_operation_configuration/tutorial005.py!}
```
-/// info | "说明"
+/// info | 说明
注意,`response_description` 只用于描述响应,`description` 一般则用于描述*路径操作*。
///
-/// check | "检查"
+/// check | 检查
OpenAPI 规定每个*路径操作*都要有响应描述。
diff --git a/docs/zh/docs/tutorial/path-params-numeric-validations.md b/docs/zh/docs/tutorial/path-params-numeric-validations.md
index 29197ac53..3a1ebdbca 100644
--- a/docs/zh/docs/tutorial/path-params-numeric-validations.md
+++ b/docs/zh/docs/tutorial/path-params-numeric-validations.md
@@ -222,7 +222,7 @@ Python 不会对该 `*` 做任何事情,但是它将知道之后的所有参
///
-/// note | "技术细节"
+/// note | 技术细节
当你从 `fastapi` 导入 `Query`、`Path` 和其他同类对象时,它们实际上是函数。
diff --git a/docs/zh/docs/tutorial/path-params.md b/docs/zh/docs/tutorial/path-params.md
index a29ee0e2b..0666783e2 100644
--- a/docs/zh/docs/tutorial/path-params.md
+++ b/docs/zh/docs/tutorial/path-params.md
@@ -24,7 +24,7 @@ FastAPI 支持使用 Python 字符串格式化语法声明**路径参数**(**
本例把 `item_id` 的类型声明为 `int`。
-/// check | "检查"
+/// check | 检查
类型声明将为函数提供错误检查、代码补全等编辑器支持。
@@ -38,7 +38,7 @@ FastAPI 支持使用 Python 字符串格式化语法声明**路径参数**(**
{"item_id":3}
```
-/// check | "检查"
+/// check | 检查
注意,函数接收并返回的值是 `3`( `int`),不是 `"3"`(`str`)。
@@ -69,7 +69,7 @@ FastAPI 支持使用 Python 字符串格式化语法声明**路径参数**(**
值的类型不是 `int ` 而是浮点数(`float`)时也会显示同样的错误,比如: http://127.0.0.1:8000/items/4.2。
-/// check | "检查"
+/// check | 检查
**FastAPI** 使用 Python 类型声明实现了数据校验。
@@ -85,7 +85,7 @@ FastAPI 支持使用 Python 字符串格式化语法声明**路径参数**(**