From 4f0a3a9e4d1fc082089755a628d857c04485d3ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ya=C4=9F=C4=B1zcan=20De=C4=9Firmenci?=
<62724709+ycd@users.noreply.github.com>
Date: Sat, 29 Aug 2020 12:43:29 +0300
Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=8C=90=20Initialize=20Turkish=20tra?=
=?UTF-8?q?nslations=20(#1905)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/mkdocs.yml | 1 +
docs/es/mkdocs.yml | 1 +
docs/it/mkdocs.yml | 1 +
docs/pt/mkdocs.yml | 1 +
docs/ru/mkdocs.yml | 1 +
docs/tr/docs/index.md | 453 ++++++++++++++++++++++++++++++++++++++++++
docs/tr/mkdocs.yml | 74 +++++++
docs/uk/mkdocs.yml | 1 +
docs/zh/mkdocs.yml | 1 +
9 files changed, 534 insertions(+)
create mode 100644 docs/tr/docs/index.md
create mode 100644 docs/tr/mkdocs.yml
diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml
index e72e87408..17eba4e0d 100644
--- a/docs/en/mkdocs.yml
+++ b/docs/en/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
- features.md
diff --git a/docs/es/mkdocs.yml b/docs/es/mkdocs.yml
index 0aee6a880..251ddfc26 100644
--- a/docs/es/mkdocs.yml
+++ b/docs/es/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
- features.md
diff --git a/docs/it/mkdocs.yml b/docs/it/mkdocs.yml
index c8edf3c49..56e1a17b4 100644
--- a/docs/it/mkdocs.yml
+++ b/docs/it/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
markdown_extensions:
diff --git a/docs/pt/mkdocs.yml b/docs/pt/mkdocs.yml
index 93cf48bf2..66b7e99aa 100644
--- a/docs/pt/mkdocs.yml
+++ b/docs/pt/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
- features.md
diff --git a/docs/ru/mkdocs.yml b/docs/ru/mkdocs.yml
index ad9d91c8c..5ce9742fe 100644
--- a/docs/ru/mkdocs.yml
+++ b/docs/ru/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
markdown_extensions:
diff --git a/docs/tr/docs/index.md b/docs/tr/docs/index.md
new file mode 100644
index 000000000..8db98885d
--- /dev/null
+++ b/docs/tr/docs/index.md
@@ -0,0 +1,453 @@
+
+{!../../../docs/missing-translation.md!}
+
+
+
+
+
+
+ FastAPI framework, high performance, easy to learn, fast to code, ready for production
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---
+
+**Documentation**: https://fastapi.tiangolo.com
+
+**Source Code**: https://github.com/tiangolo/fastapi
+
+---
+
+FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
+
+The key features are:
+
+* **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic). [One of the fastest Python frameworks available](#performance).
+
+* **Fast to code**: Increase the speed to develop features by about 200% to 300%. *
+* **Fewer bugs**: Reduce about 40% of human (developer) induced errors. *
+* **Intuitive**: Great editor support. Completion everywhere. Less time debugging.
+* **Easy**: Designed to be easy to use and learn. Less time reading docs.
+* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
+* **Robust**: Get production-ready code. With automatic interactive documentation.
+* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
+
+* estimation based on tests on an internal development team, building production applications.
+
+## Opinions
+
+"_[...] I'm using **FastAPI** a ton these days. [...] I'm actually planning to use it for all of my team's **ML services at Microsoft**. Some of them are getting integrated into the core **Windows** product and some **Office** products._"
+
+Kabir Khan -
Microsoft (ref)
+
+---
+
+"_We adopted the **FastAPI** library to spawn a **REST** server that can be queried to obtain **predictions**. [for Ludwig]_"
+
+Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala -
Uber (ref)
+
+---
+
+"_**Netflix** is pleased to announce the open-source release of our **crisis management** orchestration framework: **Dispatch**! [built with **FastAPI**]_"
+
+Kevin Glisson, Marc Vilanova, Forest Monsen -
Netflix (ref)
+
+---
+
+"_I’m over the moon excited about **FastAPI**. It’s so fun!_"
+
+
+
+---
+
+"_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._"
+
+
+
+---
+
+"_If you're looking to learn one **modern framework** for building REST APIs, check out **FastAPI** [...] It's fast, easy to use and easy to learn [...]_"
+
+"_We've switched over to **FastAPI** for our **APIs** [...] I think you'll like it [...]_"
+
+
+
+---
+
+## **Typer**, the FastAPI of CLIs
+
+
+
+If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**.
+
+**Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. ⌨️ 🚀
+
+## Requirements
+
+Python 3.6+
+
+FastAPI stands on the shoulders of giants:
+
+* Starlette for the web parts.
+* Pydantic for the data parts.
+
+## Installation
+
+
+
+```console
+$ pip install fastapi
+
+---> 100%
+```
+
+
+
+You will also need an ASGI server, for production such as Uvicorn or Hypercorn.
+
+
+
+```console
+$ pip install uvicorn
+
+---> 100%
+```
+
+
+
+## Example
+
+### Create it
+
+* Create a file `main.py` with:
+
+```Python
+from typing import Optional
+
+from fastapi import FastAPI
+
+app = FastAPI()
+
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: Optional[str] = None):
+ return {"item_id": item_id, "q": q}
+```
+
+
+Or use async def...
+
+If your code uses `async` / `await`, use `async def`:
+
+```Python hl_lines="9 14"
+from typing import Optional
+
+from fastapi import FastAPI
+
+app = FastAPI()
+
+
+@app.get("/")
+async def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+async def read_item(item_id: int, q: Optional[str] = None):
+ return {"item_id": item_id, "q": q}
+```
+
+**Note**:
+
+If you don't know, check the _"In a hurry?"_ section about `async` and `await` in the docs.
+
+
+
+### Run it
+
+Run the server with:
+
+
+
+```console
+$ uvicorn main:app --reload
+
+INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
+INFO: Started reloader process [28720]
+INFO: Started server process [28722]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+```
+
+
+
+
+About the command uvicorn main:app --reload...
+
+The command `uvicorn main:app` refers to:
+
+* `main`: the file `main.py` (the Python "module").
+* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
+* `--reload`: make the server restart after code changes. Only do this for development.
+
+
+
+### Check it
+
+Open your browser at http://127.0.0.1:8000/items/5?q=somequery.
+
+You will see the JSON response as:
+
+```JSON
+{"item_id": 5, "q": "somequery"}
+```
+
+You already created an API that:
+
+* Receives HTTP requests in the _paths_ `/` and `/items/{item_id}`.
+* Both _paths_ take `GET` operations (also known as HTTP _methods_).
+* The _path_ `/items/{item_id}` has a _path parameter_ `item_id` that should be an `int`.
+* The _path_ `/items/{item_id}` has an optional `str` _query parameter_ `q`.
+
+### Interactive API docs
+
+Now go to http://127.0.0.1:8000/docs.
+
+You will see the automatic interactive API documentation (provided by Swagger UI):
+
+
+
+### Alternative API docs
+
+And now, go to http://127.0.0.1:8000/redoc.
+
+You will see the alternative automatic documentation (provided by ReDoc):
+
+
+
+## Example upgrade
+
+Now modify the file `main.py` to receive a body from a `PUT` request.
+
+Declare the body using standard Python types, thanks to Pydantic.
+
+```Python hl_lines="4 9 10 11 12 25 26 27"
+from typing import Optional
+
+from fastapi import FastAPI
+from pydantic import BaseModel
+
+app = FastAPI()
+
+
+class Item(BaseModel):
+ name: str
+ price: float
+ is_offer: Optional[bool] = None
+
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: Optional[str] = None):
+ return {"item_id": item_id, "q": q}
+
+
+@app.put("/items/{item_id}")
+def update_item(item_id: int, item: Item):
+ return {"item_name": item.name, "item_id": item_id}
+```
+
+The server should reload automatically (because you added `--reload` to the `uvicorn` command above).
+
+### Interactive API docs upgrade
+
+Now go to http://127.0.0.1:8000/docs.
+
+* The interactive API documentation will be automatically updated, including the new body:
+
+
+
+* Click on the button "Try it out", it allows you to fill the parameters and directly interact with the API:
+
+
+
+* Then click on the "Execute" button, the user interface will communicate with your API, send the parameters, get the results and show them on the screen:
+
+
+
+### Alternative API docs upgrade
+
+And now, go to http://127.0.0.1:8000/redoc.
+
+* The alternative documentation will also reflect the new query parameter and body:
+
+
+
+### Recap
+
+In summary, you declare **once** the types of parameters, body, etc. as function parameters.
+
+You do that with standard modern Python types.
+
+You don't have to learn a new syntax, the methods or classes of a specific library, etc.
+
+Just standard **Python 3.6+**.
+
+For example, for an `int`:
+
+```Python
+item_id: int
+```
+
+or for a more complex `Item` model:
+
+```Python
+item: Item
+```
+
+...and with that single declaration you get:
+
+* Editor support, including:
+ * Completion.
+ * Type checks.
+* Validation of data:
+ * Automatic and clear errors when the data is invalid.
+ * Validation even for deeply nested JSON objects.
+* Conversion of input data: coming from the network to Python data and types. Reading from:
+ * JSON.
+ * Path parameters.
+ * Query parameters.
+ * Cookies.
+ * Headers.
+ * Forms.
+ * Files.
+* Conversion of output data: converting from Python data and types to network data (as JSON):
+ * Convert Python types (`str`, `int`, `float`, `bool`, `list`, etc).
+ * `datetime` objects.
+ * `UUID` objects.
+ * Database models.
+ * ...and many more.
+* Automatic interactive API documentation, including 2 alternative user interfaces:
+ * Swagger UI.
+ * ReDoc.
+
+---
+
+Coming back to the previous code example, **FastAPI** will:
+
+* Validate that there is an `item_id` in the path for `GET` and `PUT` requests.
+* Validate that the `item_id` is of type `int` for `GET` and `PUT` requests.
+ * If it is not, the client will see a useful, clear error.
+* Check if there is an optional query parameter named `q` (as in `http://127.0.0.1:8000/items/foo?q=somequery`) for `GET` requests.
+ * As the `q` parameter is declared with `= None`, it is optional.
+ * Without the `None` it would be required (as is the body in the case with `PUT`).
+* For `PUT` requests to `/items/{item_id}`, Read the body as JSON:
+ * Check that it has a required attribute `name` that should be a `str`.
+ * Check that it has a required attribute `price` that has to be a `float`.
+ * Check that it has an optional attribute `is_offer`, that should be a `bool`, if present.
+ * All this would also work for deeply nested JSON objects.
+* Convert from and to JSON automatically.
+* Document everything with OpenAPI, that can be used by:
+ * Interactive documentation systems.
+ * Automatic client code generation systems, for many languages.
+* Provide 2 interactive documentation web interfaces directly.
+
+---
+
+We just scratched the surface, but you already get the idea of how it all works.
+
+Try changing the line with:
+
+```Python
+ return {"item_name": item.name, "item_id": item_id}
+```
+
+...from:
+
+```Python
+ ... "item_name": item.name ...
+```
+
+...to:
+
+```Python
+ ... "item_price": item.price ...
+```
+
+...and see how your editor will auto-complete the attributes and know their types:
+
+
+
+For a more complete example including more features, see the Tutorial - User Guide.
+
+**Spoiler alert**: the tutorial - user guide includes:
+
+* Declaration of **parameters** from other different places as: **headers**, **cookies**, **form fields** and **files**.
+* How to set **validation constraints** as `maximum_length` or `regex`.
+* A very powerful and easy to use **Dependency Injection** system.
+* Security and authentication, including support for **OAuth2** with **JWT tokens** and **HTTP Basic** auth.
+* More advanced (but equally easy) techniques for declaring **deeply nested JSON models** (thanks to Pydantic).
+* Many extra features (thanks to Starlette) as:
+ * **WebSockets**
+ * **GraphQL**
+ * extremely easy tests based on `requests` and `pytest`
+ * **CORS**
+ * **Cookie Sessions**
+ * ...and more.
+
+## Performance
+
+Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)
+
+To understand more about it, see the section Benchmarks.
+
+## Optional Dependencies
+
+Used by Pydantic:
+
+* ujson - for faster JSON "parsing".
+* email_validator - for email validation.
+
+Used by Starlette:
+
+* requests - Required if you want to use the `TestClient`.
+* aiofiles - Required if you want to use `FileResponse` or `StaticFiles`.
+* jinja2 - Required if you want to use the default template configuration.
+* python-multipart - Required if you want to support form "parsing", with `request.form()`.
+* itsdangerous - Required for `SessionMiddleware` support.
+* pyyaml - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
+* graphene - Required for `GraphQLApp` support.
+* ujson - Required if you want to use `UJSONResponse`.
+
+Used by FastAPI / Starlette:
+
+* uvicorn - for the server that loads and serves your application.
+* orjson - Required if you want to use `ORJSONResponse`.
+
+You can install all of these with `pip install fastapi[all]`.
+
+## License
+
+This project is licensed under the terms of the MIT license.
diff --git a/docs/tr/mkdocs.yml b/docs/tr/mkdocs.yml
new file mode 100644
index 000000000..a5a956c21
--- /dev/null
+++ b/docs/tr/mkdocs.yml
@@ -0,0 +1,74 @@
+site_name: FastAPI
+site_description: FastAPI framework, high performance, easy to learn, fast to code, ready for production
+site_url: https://fastapi.tiangolo.com/tr/
+theme:
+ name: material
+ palette:
+ scheme: preference
+ primary: teal
+ accent: amber
+ icon:
+ repo: fontawesome/brands/github-alt
+ logo: https://fastapi.tiangolo.com/img/icon-white.svg
+ favicon: https://fastapi.tiangolo.com/img/favicon.png
+ language: tr
+repo_name: tiangolo/fastapi
+repo_url: https://github.com/tiangolo/fastapi
+edit_uri: ''
+google_analytics:
+- UA-133183413-1
+- auto
+plugins:
+- search
+- markdownextradata:
+ data: data
+nav:
+- FastAPI: index.md
+- Languages:
+ - en: /
+ - es: /es/
+ - it: /it/
+ - pt: /pt/
+ - ru: /ru/
+ - tr: /tr/
+ - uk: /uk/
+ - zh: /zh/
+markdown_extensions:
+- toc:
+ permalink: true
+- markdown.extensions.codehilite:
+ guess_lang: false
+- markdown_include.include:
+ base_path: docs
+- admonition
+- codehilite
+- extra
+- pymdownx.superfences:
+ custom_fences:
+ - name: mermaid
+ class: mermaid
+ format: !!python/name:pymdownx.superfences.fence_div_format ''
+- pymdownx.tabbed
+extra:
+ social:
+ - icon: fontawesome/brands/github-alt
+ link: https://github.com/tiangolo/typer
+ - icon: fontawesome/brands/twitter
+ link: https://twitter.com/tiangolo
+ - icon: fontawesome/brands/linkedin
+ link: https://www.linkedin.com/in/tiangolo
+ - icon: fontawesome/brands/dev
+ link: https://dev.to/tiangolo
+ - icon: fontawesome/brands/medium
+ link: https://medium.com/@tiangolo
+ - icon: fontawesome/solid/globe
+ link: https://tiangolo.com
+extra_css:
+- https://fastapi.tiangolo.com/css/termynal.css
+- https://fastapi.tiangolo.com/css/custom.css
+extra_javascript:
+- https://unpkg.com/mermaid@8.4.6/dist/mermaid.min.js
+- https://fastapi.tiangolo.com/js/termynal.js
+- https://fastapi.tiangolo.com/js/custom.js
+- https://fastapi.tiangolo.com/js/chat.js
+- https://sidecar.gitter.im/dist/sidecar.v1.js
diff --git a/docs/uk/mkdocs.yml b/docs/uk/mkdocs.yml
index c98b6c375..c368a5925 100644
--- a/docs/uk/mkdocs.yml
+++ b/docs/uk/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
markdown_extensions:
diff --git a/docs/zh/mkdocs.yml b/docs/zh/mkdocs.yml
index 11dddc532..45f0d8f6f 100644
--- a/docs/zh/mkdocs.yml
+++ b/docs/zh/mkdocs.yml
@@ -30,6 +30,7 @@ nav:
- it: /it/
- pt: /pt/
- ru: /ru/
+ - tr: /tr/
- uk: /uk/
- zh: /zh/
- features.md
From 2d7038e03ef9252bb4e6d3e52066a19c4e9538dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 11:47:13 +0200
Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index 4048ffab4..d07521221 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -2,6 +2,10 @@
## Latest changes
+### Translations
+
+* Initialize Turkish translations. PR [#1905](https://github.com/tiangolo/fastapi/pull/1905) by [@ycd](https://github.com/ycd).
+
## 0.61.0
### Features
From 0dfde6e284b221bf6695a98762a56d13a995e807 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 14:21:00 +0200
Subject: [PATCH 03/13] =?UTF-8?q?=F0=9F=90=9B=20Fix=20issues=20introduced?=
=?UTF-8?q?=20by=20removing=20sqlalchemy=20safeguard=20in=20jsonable=5Fenc?=
=?UTF-8?q?oder=20(#1987)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
fastapi/encoders.py | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/fastapi/encoders.py b/fastapi/encoders.py
index 1c324b915..1255b7497 100644
--- a/fastapi/encoders.py
+++ b/fastapi/encoders.py
@@ -32,6 +32,7 @@ def jsonable_encoder(
exclude_defaults: bool = False,
exclude_none: bool = False,
custom_encoder: dict = {},
+ sqlalchemy_safe: bool = True,
) -> Any:
if include is not None and not isinstance(include, set):
include = set(include)
@@ -56,6 +57,7 @@ def jsonable_encoder(
exclude_none=exclude_none,
exclude_defaults=exclude_defaults,
custom_encoder=encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
)
if isinstance(obj, Enum):
return obj.value
@@ -66,8 +68,14 @@ def jsonable_encoder(
if isinstance(obj, dict):
encoded_dict = {}
for key, value in obj.items():
- if (value is not None or not exclude_none) and (
- (include and key in include) or not exclude or key not in exclude
+ if (
+ (
+ not sqlalchemy_safe
+ or (not isinstance(key, str))
+ or (not key.startswith("_sa"))
+ )
+ and (value is not None or not exclude_none)
+ and ((include and key in include) or not exclude or key not in exclude)
):
encoded_key = jsonable_encoder(
key,
@@ -75,6 +83,7 @@ def jsonable_encoder(
exclude_unset=exclude_unset,
exclude_none=exclude_none,
custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
)
encoded_value = jsonable_encoder(
value,
@@ -82,6 +91,7 @@ def jsonable_encoder(
exclude_unset=exclude_unset,
exclude_none=exclude_none,
custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
)
encoded_dict[encoded_key] = encoded_value
return encoded_dict
@@ -98,6 +108,7 @@ def jsonable_encoder(
exclude_defaults=exclude_defaults,
exclude_none=exclude_none,
custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
)
)
return encoded_list
@@ -133,4 +144,5 @@ def jsonable_encoder(
exclude_defaults=exclude_defaults,
exclude_none=exclude_none,
custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
)
From eb547bd4fdb93d36b8b1431f3485a7595a592da4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 14:24:24 +0200
Subject: [PATCH 04/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index d07521221..b110474fd 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -2,6 +2,10 @@
## Latest changes
+### Fixes
+
+* Fix issues using `jsonable_encoder` with SQLAlchemy models directly. PR [#1987](https://github.com/tiangolo/fastapi/pull/1987).
+
### Translations
* Initialize Turkish translations. PR [#1905](https://github.com/tiangolo/fastapi/pull/1905) by [@ycd](https://github.com/ycd).
From 60aa63b68a601f98ec5c10d5939abe4c77c92be2 Mon Sep 17 00:00:00 2001
From: JulianMaurin <61803761+JulianMaurin-BM@users.noreply.github.com>
Date: Sat, 29 Aug 2020 14:27:34 +0200
Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=8C=90=20Initialize=20translations?=
=?UTF-8?q?=20for=20French=20(#1975)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: JulianMaurin
---
docs/en/mkdocs.yml | 1 +
docs/es/mkdocs.yml | 1 +
docs/fr/docs/index.md | 453 ++++++++++++++++++++++++++++++++++++++++++
docs/fr/mkdocs.yml | 74 +++++++
docs/it/mkdocs.yml | 1 +
docs/pt/mkdocs.yml | 1 +
docs/ru/mkdocs.yml | 1 +
docs/uk/mkdocs.yml | 1 +
docs/zh/mkdocs.yml | 1 +
9 files changed, 534 insertions(+)
create mode 100644 docs/fr/docs/index.md
create mode 100644 docs/fr/mkdocs.yml
diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml
index 17eba4e0d..6628580b4 100644
--- a/docs/en/mkdocs.yml
+++ b/docs/en/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/es/mkdocs.yml b/docs/es/mkdocs.yml
index 251ddfc26..de917b6f1 100644
--- a/docs/es/mkdocs.yml
+++ b/docs/es/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/fr/docs/index.md b/docs/fr/docs/index.md
new file mode 100644
index 000000000..5fb52cc3c
--- /dev/null
+++ b/docs/fr/docs/index.md
@@ -0,0 +1,453 @@
+
+{!../../../docs/missing-translation.md!}
+
+
+
+
+
+
+ FastAPI framework, high performance, easy to learn, fast to code, ready for production
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---
+
+**Documentation**: https://fastapi.tiangolo.com
+
+**Source Code**: https://github.com/tiangolo/fastapi
+
+---
+
+FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
+
+The key features are:
+
+* **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic). [One of the fastest Python frameworks available](#performance).
+
+* **Fast to code**: Increase the speed to develop features by about 200% to 300%. *
+* **Fewer bugs**: Reduce about 40% of human (developer) induced errors. *
+* **Intuitive**: Great editor support. Completion everywhere. Less time debugging.
+* **Easy**: Designed to be easy to use and learn. Less time reading docs.
+* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
+* **Robust**: Get production-ready code. With automatic interactive documentation.
+* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
+
+* estimation based on tests on an internal development team, building production applications.
+
+## Opinions
+
+"_[...] I'm using **FastAPI** a ton these days. [...] I'm actually planning to use it for all of my team's **ML services at Microsoft**. Some of them are getting integrated into the core **Windows** product and some **Office** products._"
+
+Kabir Khan -
Microsoft (ref)
+
+---
+
+"_We adopted the **FastAPI** library to spawn a **REST** server that can be queried to obtain **predictions**. [for Ludwig]_"
+
+Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala -
Uber (ref)
+
+---
+
+"_**Netflix** is pleased to announce the open-source release of our **crisis management** orchestration framework: **Dispatch**! [built with **FastAPI**]_"
+
+Kevin Glisson, Marc Vilanova, Forest Monsen -
Netflix (ref)
+
+---
+
+"_I’m over the moon excited about **FastAPI**. It’s so fun!_"
+
+
+
+---
+
+"_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._"
+
+
+
+---
+
+"_If you're looking to learn one **modern framework** for building REST APIs, check out **FastAPI** [...] It's fast, easy to use and easy to learn [...]_"
+
+"_We've switched over to **FastAPI** for our **APIs** [...] I think you'll like it [...]_"
+
+
+
+---
+
+## **Typer**, the FastAPI of CLIs
+
+
+
+If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**.
+
+**Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. ⌨️ 🚀
+
+## Requirements
+
+Python 3.6+
+
+FastAPI stands on the shoulders of giants:
+
+* Starlette for the web parts.
+* Pydantic for the data parts.
+
+## Installation
+
+
+
+```console
+$ pip install fastapi
+
+---> 100%
+```
+
+
+
+You will also need an ASGI server, for production such as Uvicorn or Hypercorn.
+
+
+
+```console
+$ pip install uvicorn
+
+---> 100%
+```
+
+
+
+## Example
+
+### Create it
+
+* Create a file `main.py` with:
+
+```Python
+from typing import Optional
+
+from fastapi import FastAPI
+
+app = FastAPI()
+
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: Optional[str] = None):
+ return {"item_id": item_id, "q": q}
+```
+
+
+Or use async def...
+
+If your code uses `async` / `await`, use `async def`:
+
+```Python hl_lines="9 14"
+from typing import Optional
+
+from fastapi import FastAPI
+
+app = FastAPI()
+
+
+@app.get("/")
+async def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+async def read_item(item_id: int, q: Optional[str] = None):
+ return {"item_id": item_id, "q": q}
+```
+
+**Note**:
+
+If you don't know, check the _"In a hurry?"_ section about `async` and `await` in the docs.
+
+
+
+### Run it
+
+Run the server with:
+
+
+
+```console
+$ uvicorn main:app --reload
+
+INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
+INFO: Started reloader process [28720]
+INFO: Started server process [28722]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+```
+
+
+
+
+About the command uvicorn main:app --reload...
+
+The command `uvicorn main:app` refers to:
+
+* `main`: the file `main.py` (the Python "module").
+* `app`: the object created inside of `main.py` with the line `app = FastAPI()`.
+* `--reload`: make the server restart after code changes. Only do this for development.
+
+
+
+### Check it
+
+Open your browser at http://127.0.0.1:8000/items/5?q=somequery.
+
+You will see the JSON response as:
+
+```JSON
+{"item_id": 5, "q": "somequery"}
+```
+
+You already created an API that:
+
+* Receives HTTP requests in the _paths_ `/` and `/items/{item_id}`.
+* Both _paths_ take `GET` operations (also known as HTTP _methods_).
+* The _path_ `/items/{item_id}` has a _path parameter_ `item_id` that should be an `int`.
+* The _path_ `/items/{item_id}` has an optional `str` _query parameter_ `q`.
+
+### Interactive API docs
+
+Now go to http://127.0.0.1:8000/docs.
+
+You will see the automatic interactive API documentation (provided by Swagger UI):
+
+
+
+### Alternative API docs
+
+And now, go to http://127.0.0.1:8000/redoc.
+
+You will see the alternative automatic documentation (provided by ReDoc):
+
+
+
+## Example upgrade
+
+Now modify the file `main.py` to receive a body from a `PUT` request.
+
+Declare the body using standard Python types, thanks to Pydantic.
+
+```Python hl_lines="4 9 10 11 12 25 26 27"
+from typing import Optional
+
+from fastapi import FastAPI
+from pydantic import BaseModel
+
+app = FastAPI()
+
+
+class Item(BaseModel):
+ name: str
+ price: float
+ is_offer: Optional[bool] = None
+
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: Optional[str] = None):
+ return {"item_id": item_id, "q": q}
+
+
+@app.put("/items/{item_id}")
+def update_item(item_id: int, item: Item):
+ return {"item_name": item.name, "item_id": item_id}
+```
+
+The server should reload automatically (because you added `--reload` to the `uvicorn` command above).
+
+### Interactive API docs upgrade
+
+Now go to http://127.0.0.1:8000/docs.
+
+* The interactive API documentation will be automatically updated, including the new body:
+
+
+
+* Click on the button "Try it out", it allows you to fill the parameters and directly interact with the API:
+
+
+
+* Then click on the "Execute" button, the user interface will communicate with your API, send the parameters, get the results and show them on the screen:
+
+
+
+### Alternative API docs upgrade
+
+And now, go to http://127.0.0.1:8000/redoc.
+
+* The alternative documentation will also reflect the new query parameter and body:
+
+
+
+### Recap
+
+In summary, you declare **once** the types of parameters, body, etc. as function parameters.
+
+You do that with standard modern Python types.
+
+You don't have to learn a new syntax, the methods or classes of a specific library, etc.
+
+Just standard **Python 3.6+**.
+
+For example, for an `int`:
+
+```Python
+item_id: int
+```
+
+or for a more complex `Item` model:
+
+```Python
+item: Item
+```
+
+...and with that single declaration you get:
+
+* Editor support, including:
+ * Completion.
+ * Type checks.
+* Validation of data:
+ * Automatic and clear errors when the data is invalid.
+ * Validation even for deeply nested JSON objects.
+* Conversion of input data: coming from the network to Python data and types. Reading from:
+ * JSON.
+ * Path parameters.
+ * Query parameters.
+ * Cookies.
+ * Headers.
+ * Forms.
+ * Files.
+* Conversion of output data: converting from Python data and types to network data (as JSON):
+ * Convert Python types (`str`, `int`, `float`, `bool`, `list`, etc).
+ * `datetime` objects.
+ * `UUID` objects.
+ * Database models.
+ * ...and many more.
+* Automatic interactive API documentation, including 2 alternative user interfaces:
+ * Swagger UI.
+ * ReDoc.
+
+---
+
+Coming back to the previous code example, **FastAPI** will:
+
+* Validate that there is an `item_id` in the path for `GET` and `PUT` requests.
+* Validate that the `item_id` is of type `int` for `GET` and `PUT` requests.
+ * If it is not, the client will see a useful, clear error.
+* Check if there is an optional query parameter named `q` (as in `http://127.0.0.1:8000/items/foo?q=somequery`) for `GET` requests.
+ * As the `q` parameter is declared with `= None`, it is optional.
+ * Without the `None` it would be required (as is the body in the case with `PUT`).
+* For `PUT` requests to `/items/{item_id}`, Read the body as JSON:
+ * Check that it has a required attribute `name` that should be a `str`.
+ * Check that it has a required attribute `price` that has to be a `float`.
+ * Check that it has an optional attribute `is_offer`, that should be a `bool`, if present.
+ * All this would also work for deeply nested JSON objects.
+* Convert from and to JSON automatically.
+* Document everything with OpenAPI, that can be used by:
+ * Interactive documentation systems.
+ * Automatic client code generation systems, for many languages.
+* Provide 2 interactive documentation web interfaces directly.
+
+---
+
+We just scratched the surface, but you already get the idea of how it all works.
+
+Try changing the line with:
+
+```Python
+ return {"item_name": item.name, "item_id": item_id}
+```
+
+...from:
+
+```Python
+ ... "item_name": item.name ...
+```
+
+...to:
+
+```Python
+ ... "item_price": item.price ...
+```
+
+...and see how your editor will auto-complete the attributes and know their types:
+
+
+
+For a more complete example including more features, see the Tutorial - User Guide.
+
+**Spoiler alert**: the tutorial - user guide includes:
+
+* Declaration of **parameters** from other different places as: **headers**, **cookies**, **form fields** and **files**.
+* How to set **validation constraints** as `maximum_length` or `regex`.
+* A very powerful and easy to use **Dependency Injection** system.
+* Security and authentication, including support for **OAuth2** with **JWT tokens** and **HTTP Basic** auth.
+* More advanced (but equally easy) techniques for declaring **deeply nested JSON models** (thanks to Pydantic).
+* Many extra features (thanks to Starlette) as:
+ * **WebSockets**
+ * **GraphQL**
+ * extremely easy tests based on `requests` and `pytest`
+ * **CORS**
+ * **Cookie Sessions**
+ * ...and more.
+
+## Performance
+
+Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)
+
+To understand more about it, see the section Benchmarks.
+
+## Optional Dependencies
+
+Used by Pydantic:
+
+* ujson - for faster JSON "parsing".
+* email_validator - for email validation.
+
+Used by Starlette:
+
+* requests - Required if you want to use the `TestClient`.
+* aiofiles - Required if you want to use `FileResponse` or `StaticFiles`.
+* jinja2 - Required if you want to use the default template configuration.
+* python-multipart - Required if you want to support form "parsing", with `request.form()`.
+* itsdangerous - Required for `SessionMiddleware` support.
+* pyyaml - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
+* graphene - Required for `GraphQLApp` support.
+* ujson - Required if you want to use `UJSONResponse`.
+
+Used by FastAPI / Starlette:
+
+* uvicorn - for the server that loads and serves your application.
+* orjson - Required if you want to use `ORJSONResponse`.
+
+You can install all of these with `pip install fastapi[all]`.
+
+## License
+
+This project is licensed under the terms of the MIT license.
\ No newline at end of file
diff --git a/docs/fr/mkdocs.yml b/docs/fr/mkdocs.yml
new file mode 100644
index 000000000..f5b5504c3
--- /dev/null
+++ b/docs/fr/mkdocs.yml
@@ -0,0 +1,74 @@
+site_name: FastAPI
+site_description: FastAPI framework, high performance, easy to learn, fast to code, ready for production
+site_url: https://fastapi.tiangolo.com/fr/
+theme:
+ name: material
+ palette:
+ scheme: preference
+ primary: teal
+ accent: amber
+ icon:
+ repo: fontawesome/brands/github-alt
+ logo: https://fastapi.tiangolo.com/img/icon-white.svg
+ favicon: https://fastapi.tiangolo.com/img/favicon.png
+ language: fr
+repo_name: tiangolo/fastapi
+repo_url: https://github.com/tiangolo/fastapi
+edit_uri: ''
+google_analytics:
+- UA-133183413-1
+- auto
+plugins:
+- search
+- markdownextradata:
+ data: data
+nav:
+- FastAPI: index.md
+- Languages:
+ - en: /
+ - es: /es/
+ - fr: /fr/
+ - it: /it/
+ - pt: /pt/
+ - ru: /ru/
+ - uk: /uk/
+ - zh: /zh/
+markdown_extensions:
+- toc:
+ permalink: true
+- markdown.extensions.codehilite:
+ guess_lang: false
+- markdown_include.include:
+ base_path: docs
+- admonition
+- codehilite
+- extra
+- pymdownx.superfences:
+ custom_fences:
+ - name: mermaid
+ class: mermaid
+ format: !!python/name:pymdownx.superfences.fence_div_format ''
+- pymdownx.tabbed
+extra:
+ social:
+ - icon: fontawesome/brands/github-alt
+ link: https://github.com/tiangolo/typer
+ - icon: fontawesome/brands/twitter
+ link: https://twitter.com/tiangolo
+ - icon: fontawesome/brands/linkedin
+ link: https://www.linkedin.com/in/tiangolo
+ - icon: fontawesome/brands/dev
+ link: https://dev.to/tiangolo
+ - icon: fontawesome/brands/medium
+ link: https://medium.com/@tiangolo
+ - icon: fontawesome/solid/globe
+ link: https://tiangolo.com
+extra_css:
+- https://fastapi.tiangolo.com/css/termynal.css
+- https://fastapi.tiangolo.com/css/custom.css
+extra_javascript:
+- https://unpkg.com/mermaid@8.4.6/dist/mermaid.min.js
+- https://fastapi.tiangolo.com/js/termynal.js
+- https://fastapi.tiangolo.com/js/custom.js
+- https://fastapi.tiangolo.com/js/chat.js
+- https://sidecar.gitter.im/dist/sidecar.v1.js
diff --git a/docs/it/mkdocs.yml b/docs/it/mkdocs.yml
index 56e1a17b4..92640ee3d 100644
--- a/docs/it/mkdocs.yml
+++ b/docs/it/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/pt/mkdocs.yml b/docs/pt/mkdocs.yml
index 66b7e99aa..8224afdef 100644
--- a/docs/pt/mkdocs.yml
+++ b/docs/pt/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/ru/mkdocs.yml b/docs/ru/mkdocs.yml
index 5ce9742fe..a4038b315 100644
--- a/docs/ru/mkdocs.yml
+++ b/docs/ru/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/uk/mkdocs.yml b/docs/uk/mkdocs.yml
index c368a5925..a4e9f54b9 100644
--- a/docs/uk/mkdocs.yml
+++ b/docs/uk/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/zh/mkdocs.yml b/docs/zh/mkdocs.yml
index 45f0d8f6f..f5edd98a7 100644
--- a/docs/zh/mkdocs.yml
+++ b/docs/zh/mkdocs.yml
@@ -27,6 +27,7 @@ nav:
- Languages:
- en: /
- es: /es/
+ - fr: /fr/
- it: /it/
- pt: /pt/
- ru: /ru/
From 483d092af8844ac264492e0979a544ea8800e91c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 14:29:00 +0200
Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index b110474fd..0f104916f 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -8,6 +8,7 @@
### Translations
+* Initialize French translations. PR [#1975](https://github.com/tiangolo/fastapi/pull/1975) by [@JulianMaurin-BM](https://github.com/JulianMaurin-BM).
* Initialize Turkish translations. PR [#1905](https://github.com/tiangolo/fastapi/pull/1905) by [@ycd](https://github.com/ycd).
## 0.61.0
From 11656f7bd5227adf9ce92e24cacaaa573806a295 Mon Sep 17 00:00:00 2001
From: Facundo Maero
Date: Sat, 29 Aug 2020 09:30:23 -0300
Subject: [PATCH 07/13] =?UTF-8?q?=E2=9C=8F=20Fix=20typo=20in=20nosql-datab?=
=?UTF-8?q?ases.md=20(#1980)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Facundo Maero
---
docs/en/docs/advanced/nosql-databases.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/en/docs/advanced/nosql-databases.md b/docs/en/docs/advanced/nosql-databases.md
index 9d8c95086..acbd61313 100644
--- a/docs/en/docs/advanced/nosql-databases.md
+++ b/docs/en/docs/advanced/nosql-databases.md
@@ -143,7 +143,7 @@ UserInDB(username="johndoe", hashed_password="some_hash")
As our code is calling Couchbase and we are not using the experimental Python await support, we should declare our function with normal `def` instead of `async def`.
-Also, Couchbase recommends not using a single `Bucket` object in multiple "threads", so, we can get just get the bucket directly and pass it to our utility functions:
+Also, Couchbase recommends not using a single `Bucket` object in multiple "threads", so, we can just get the bucket directly and pass it to our utility functions:
```Python hl_lines="49 50 51 52 53"
{!../../../docs_src/nosql_databases/tutorial001.py!}
From 0916c1c3ef7439c507c4b8b3568982c0008a9961 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 14:32:08 +0200
Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index 0f104916f..00e3f68fa 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -6,6 +6,10 @@
* Fix issues using `jsonable_encoder` with SQLAlchemy models directly. PR [#1987](https://github.com/tiangolo/fastapi/pull/1987).
+### Docs
+
+* Fix typo in NoSQL docs. PR [#1980](https://github.com/tiangolo/fastapi/pull/1980) by [@facundojmaero](https://github.com/facundojmaero).
+
### Translations
* Initialize French translations. PR [#1975](https://github.com/tiangolo/fastapi/pull/1975) by [@JulianMaurin-BM](https://github.com/JulianMaurin-BM).
From e1e862716879409a64d37e5977e80ca78ddf575b Mon Sep 17 00:00:00 2001
From: ryuckel <36391432+ryuckel@users.noreply.github.com>
Date: Sat, 29 Aug 2020 22:34:08 +0900
Subject: [PATCH 09/13] =?UTF-8?q?=F0=9F=8C=90=20Add=20Japanese=20translati?=
=?UTF-8?q?on=20for=20index.md=20(#1571)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/mkdocs.yml | 1 +
docs/es/mkdocs.yml | 1 +
docs/ja/docs/index.md | 443 ++++++++++++++++++++++++++++++++++++++++++
docs/ja/mkdocs.yml | 66 +++++++
docs/pt/mkdocs.yml | 1 +
docs/zh/mkdocs.yml | 1 +
6 files changed, 513 insertions(+)
create mode 100644 docs/ja/docs/index.md
create mode 100644 docs/ja/mkdocs.yml
diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml
index 6628580b4..dcd78f70c 100644
--- a/docs/en/mkdocs.yml
+++ b/docs/en/mkdocs.yml
@@ -28,6 +28,7 @@ nav:
- en: /
- es: /es/
- fr: /fr/
+ - ja: /ja/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/es/mkdocs.yml b/docs/es/mkdocs.yml
index de917b6f1..acd4dcc11 100644
--- a/docs/es/mkdocs.yml
+++ b/docs/es/mkdocs.yml
@@ -28,6 +28,7 @@ nav:
- en: /
- es: /es/
- fr: /fr/
+ - ja: /ja/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/ja/docs/index.md b/docs/ja/docs/index.md
new file mode 100644
index 000000000..9fdce0ef2
--- /dev/null
+++ b/docs/ja/docs/index.md
@@ -0,0 +1,443 @@
+
+
+
+
+ FastAPI framework, high performance, easy to learn, fast to code, ready for production
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---
+
+**ドキュメント**: https://fastapi.tiangolo.com
+
+**ソースコード**: https://github.com/tiangolo/fastapi
+
+---
+
+FastAPI は、Pythonの標準である型ヒントに基づいてPython 3.6 以降でAPI を構築するための、モダンで、高速(高パフォーマンス)な、Web フレームワークです。
+
+主な特徴:
+
+- **高速**: **NodeJS** や **Go** 並みのとても高いパフォーマンス (Starlette と Pydantic のおかげです)。 [最も高速な Python フレームワークの一つです](#performance).
+
+- **高速なコーディング**: 開発速度を約 200%~300%向上させます。 \*
+- **少ないバグ**: 開発者起因のヒューマンエラーを約 40%削減します。 \*
+- **直感的**: 素晴らしいエディタのサポートや オートコンプリート。 デバッグ時間を削減します。
+- **簡単**: 簡単に利用、習得できるようにデザインされています。ドキュメントを読む時間を削減します。
+- **短い**: コードの重複を最小限にしています。各パラメータからの複数の機能。少ないバグ。
+- **堅牢性**: 自動対話ドキュメントを使用して、本番環境で使用できるコードを取得します。
+- **Standards-based**: API のオープンスタンダードに基づいており、完全に互換性があります: OpenAPI (以前は Swagger として知られていました) や JSON スキーマ.
+
+\* 本番アプリケーションを構築している開発チームのテストによる見積もり。
+
+## 評価
+
+"_[...] 最近 **FastAPI** を使っています。 [...] 実際に私のチームの全ての **Microsoft の機械学習サービス** で使用する予定です。 そのうちのいくつかのコアな**Windows**製品と**Office**製品に統合されつつあります。_"
+
+Kabir Khan -
Microsoft (ref)
+
+---
+
+"_FastAPIライブラリを採用し、クエリで**予測値**を取得できる**REST**サーバを構築しました。 [for Ludwig]_"
+
+Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala -
Uber (ref)
+
+---
+
+"_**Netflix** は、**危機管理**オーケストレーションフレームワーク、**Dispatch**のオープンソースリリースを発表できることをうれしく思います。 [built with **FastAPI**]_"
+
+Kevin Glisson, Marc Vilanova, Forest Monsen -
Netflix (ref)
+
+---
+
+"_私は**FastAPI**にワクワクしています。 めちゃくちゃ楽しいです!_"
+
+
+
+---
+
+"_正直、超堅実で洗練されているように見えます。いろんな意味で、それは私がハグしたかったものです。_"
+
+
+
+---
+
+"_REST API を構築するための**モダンなフレームワーク**を学びたい方は、**FastAPI** [...] をチェックしてみてください。 [...] 高速で, 使用、習得が簡単です。[...]_"
+
+"_私たちの**API**は**FastAPI**に切り替えました。[...] きっと気に入ると思います。 [...]_"
+
+
+
+---
+
+## **Typer**, the FastAPI of CLIs
+
+
+
+もし Web API の代わりにターミナルで使用するCLIアプリを構築する場合は、**Typer**を確認してください。
+
+**Typer**は FastAPI の弟分です。そして、**CLI 版 の FastAPI**を意味しています。
+
+## 必要条件
+
+Python 3.6+
+
+FastAPI は巨人の肩の上に立っています。
+
+- Web の部分はStarlette
+- データの部分はPydantic
+
+## インストール
+
+
+
+```console
+$ pip install fastapi
+
+---> 100%
+```
+
+
+
+本番環境では、Uvicorn または、 Hypercornのような、 ASGI サーバーが必要になります。
+
+
+
+```console
+$ pip install uvicorn
+
+---> 100%
+```
+
+
+
+## アプリケーション例
+
+### アプリケーションの作成
+
+- `main.py` を作成し、以下のコードを入力します:
+
+```Python
+from fastapi import FastAPI
+
+app = FastAPI()
+
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: str = None):
+ return {"item_id": item_id, "q": q}
+```
+
+
+またはasync defを使います...
+
+`async` / `await`を使用するときは、 `async def`を使います:
+
+```Python hl_lines="7 12"
+from fastapi import FastAPI
+
+app = FastAPI()
+
+
+@app.get("/")
+async def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+async def read_item(item_id: int, q: str = None):
+ return {"item_id": item_id, "q": q}
+```
+
+**注**:
+
+わからない場合は、ドキュメントの`async` と `await`にある"In a hurry?"セクションをチェックしてください。
+
+
+
+### 実行
+
+以下のコマンドでサーバーを起動します:
+
+
+
+```console
+$ uvicorn main:app --reload
+
+INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
+INFO: Started reloader process [28720]
+INFO: Started server process [28722]
+INFO: Waiting for application startup.
+INFO: Application startup complete.
+```
+
+
+
+
+uvicorn main:app --reloadコマンドについて
+
+`uvicorn main:app`コマンドは以下の項目を参照します:
+
+- `main`: `main.py`ファイル (Python "モジュール")
+- `app`: `main.py` の`app = FastAPI()`の行で生成されたオブジェクト
+- `--reload`: コードを変更したらサーバーを再起動します。このオプションは開発環境でのみ使用します
+
+
+
+### 動作確認
+
+ブラウザからhttp://127.0.0.1:8000/items/5?q=somequeryを開きます。
+
+以下の JSON のレスポンスが確認できます:
+
+```JSON
+{"item_id": 5, "q": "somequery"}
+```
+
+もうすでに以下の API が作成されています:
+
+- `/` と `/items/{item_id}`のパスで HTTP リクエストを受けます。
+- どちらのパスも `GET` 操作 を取ります。(HTTP メソッドとしても知られています。)
+- `/items/{item_id}` パスのパスパラメータ `item_id` は `int` でなければなりません。
+- パス `/items/{item_id}` はオプションの `str` クエリパラメータ `q` を持ちます。
+
+### 自動対話型の API ドキュメント
+
+http://127.0.0.1:8000/docsにアクセスしてみてください。
+
+自動対話型の API ドキュメントが表示されます。 (Swagger UIが提供しています。):
+
+
+
+### 代替の API ドキュメント
+
+http://127.0.0.1:8000/redocにアクセスしてみてください。
+
+代替の自動ドキュメントが表示されます。(ReDocが提供しています。):
+
+
+
+## アップグレード例
+
+`PUT`リクエストからボディを受け取るために`main.py`を修正しましょう。
+
+Pydantic によって、Python の標準的な型を使ってボディを宣言します。
+
+```Python hl_lines="2 7 8 9 10 23 24 25"
+from fastapi import FastAPI
+from pydantic import BaseModel
+
+app = FastAPI()
+
+
+class Item(BaseModel):
+ name: str
+ price: float
+ is_offer: bool = None
+
+
+@app.get("/")
+def read_root():
+ return {"Hello": "World"}
+
+
+@app.get("/items/{item_id}")
+def read_item(item_id: int, q: str = None):
+ return {"item_id": item_id, "q": q}
+
+
+@app.put("/items/{item_id}")
+def update_item(item_id: int, item: Item):
+ return {"item_name": item.name, "item_id": item_id}
+```
+
+サーバーは自動でリロードされます。(上述の`uvicorn`コマンドで`--reload`オプションを追加しているからです。)
+
+### 自動対話型の API ドキュメントのアップグレード
+
+http://127.0.0.1:8000/docsにアクセスしましょう。
+
+- 自動対話型の API ドキュメントが新しいボディも含めて自動でアップデートされます:
+
+
+
+- "Try it out"ボタンをクリックしてください。パラメータを入力して API と直接やりとりすることができます:
+
+
+
+- それから、"Execute" ボタンをクリックしてください。 ユーザーインターフェースは API と通信し、パラメータを送信し、結果を取得して画面に表示します:
+
+
+
+### 代替の API ドキュメントのアップグレード
+
+http://127.0.0.1:8000/redocにアクセスしましょう。
+
+- 代替の API ドキュメントにも新しいクエリパラメータやボディが反映されます。
+
+
+
+### まとめ
+
+要約すると、関数のパラメータとして、パラメータやボディ などの型を**一度だけ**宣言します。
+
+標準的な最新の Python の型を使っています。
+
+新しい構文や特定のライブラリのメソッドやクラスなどを覚える必要はありません。
+
+単なる標準的な**3.6 以降の Python**です。
+
+例えば、`int`の場合:
+
+```Python
+item_id: int
+```
+
+または、より複雑な`Item`モデルの場合:
+
+```Python
+item: Item
+```
+
+...そして、この一度の宣言で、以下のようになります:
+
+- 以下を含むエディタサポート:
+ - 補完
+ - タイプチェック
+- データの検証:
+ - データが無効な場合に自動でエラーをクリアします。
+ - 深い入れ子になった JSON オブジェクトでも検証が可能です。
+- 入力データの変換: ネットワークから Python のデータや型に変換してから読み取ります:
+ - JSON.
+ - パスパラメータ
+ - クエリパラメータ
+ - クッキー
+ - ヘッダー
+ - フォーム
+ - ファイル
+- 出力データの変換: Python のデータや型からネットワークデータへ変換します (JSON として):
+ - Convert Python types (`str`, `int`, `float`, `bool`, `list`, etc).
+ - `datetime` オブジェクト
+ - `UUID` オブジェクト
+ - データベースモデル
+ - ...などなど
+- 2 つの代替ユーザーインターフェースを含む自動インタラクティブ API ドキュメント:
+ - Swagger UI.
+ - ReDoc.
+
+---
+
+コード例に戻りましょう、**FastAPI** は次のようになります:
+
+- `GET`および`PUT`リクエストのパスに`item_id` があることを検証します。
+- `item_id`が`GET`および`PUT`リクエストに対して`int` 型であることを検証します。
+ - そうでない場合は、クライアントは有用で明確なエラーが表示されます。
+- `GET` リクエストに対してオプションのクエリパラメータ `q` (`http://127.0.0.1:8000/items/foo?q=somequery` のように) が存在するかどうかを調べます。
+ - パラメータ `q` は `= None` で宣言されているので、オプションです。
+ - `None`がなければ必須になります(`PUT`の場合のボディと同様です)。
+- `PUT` リクエストを `/items/{item_id}` に送信する場合は、ボディを JSON として読み込みます:
+ - 必須の属性 `name` を確認してください。 それは `str` であるべきです。
+ - 必須の属性 `price` を確認してください。それは `float` でなければならないです。
+ - オプションの属性 `is_offer` を確認してください。値がある場合は、`bool` であるべきです。
+ - これらはすべて、深くネストされた JSON オブジェクトに対しても動作します。
+- JSON から JSON に自動的に変換します。
+- OpenAPIですべてを文書化し、以下を使用することができます:
+ - 対話的なドキュメントシステム。
+ - 多くの言語に対応した自動クライアントコード生成システム。
+- 2 つの対話的なドキュメントのWebインターフェイスを直接提供します。
+
+---
+
+まだ表面的な部分に触れただけですが、もう全ての仕組みは分かっているはずです。
+
+以下の行を変更してみてください:
+
+```Python
+ return {"item_name": item.name, "item_id": item_id}
+```
+
+...以下を:
+
+```Python
+ ... "item_name": item.name ...
+```
+
+...以下のように:
+
+```Python
+ ... "item_price": item.price ...
+```
+
+...そして、エディタが属性を自動補完し、そのタイプを知る方法を確認してください。:
+
+
+
+より多くの機能を含む、より完全な例については、チュートリアル - ユーザーガイドをご覧ください。
+
+**ネタバレ注意**: チュートリアル - ユーザーガイドは以下の情報が含まれています:
+
+- **ヘッダー**、**クッキー**、**フォームフィールド**、**ファイル**などの他の場所からの **パラメータ** 宣言。
+- `maximum_length`や`regex`のような**検証や制約**を設定する方法。
+- 非常に強力で使いやすい **依存性注入**システム。
+- **JWT トークン**を用いた **OAuth2** や **HTTP Basic 認証** のサポートを含む、セキュリティと認証。
+- **深くネストされた JSON モデル**を宣言するためのより高度な(しかし同様に簡単な)技術(Pydantic のおかげです)。
+- 以下のようなたくさんのおまけ機能(Starlette のおかげです):
+ - **WebSockets**
+ - **GraphQL**
+ - `requests` や `pytest`をもとにした極限に簡単なテスト
+ - **CORS**
+ - **クッキーセッション**
+ - ...などなど。
+
+## パフォーマンス
+
+独立した TechEmpower のベンチマークでは、Uvicorn で動作する**FastAPI**アプリケーションが、Python フレームワークの中で最も高速なものの 1 つであり、Starlette と Uvicorn(FastAPI で内部的に使用されています)にのみ下回っていると示されています。
+
+詳細はベンチマークセクションをご覧ください。
+
+## オプションの依存関係
+
+Pydantic によって使用されるもの:
+
+- ujson - より速い JSON への"変換".
+- email_validator - E メールの検証
+
+Starlette によって使用されるもの:
+
+- requests - `TestClient`を使用するために必要です。
+- aiofiles - `FileResponse` または `StaticFiles`を使用したい場合は必要です。
+- jinja2 - デフォルトのテンプレート設定を使用する場合は必要です。
+- python-multipart - "parsing"`request.form()`からの変換をサポートしたい場合は必要です。
+- itsdangerous - `SessionMiddleware` サポートのためには必要です。
+- pyyaml - Starlette の `SchemaGenerator` サポートのために必要です。 (FastAPI では必要ないでしょう。)
+- graphene - `GraphQLApp` サポートのためには必要です。
+- ujson - `UJSONResponse`を使用する場合は必須です。
+
+FastAPI / Starlette に使用されるもの:
+
+- uvicorn - アプリケーションをロードしてサーブするサーバーのため。
+- orjson - `ORJSONResponse`を使用したい場合は必要です。
+
+これらは全て `pip install fastapi[all]`でインストールできます。
+
+## ライセンス
+
+このプロジェクトは MIT ライセンスです。
diff --git a/docs/ja/mkdocs.yml b/docs/ja/mkdocs.yml
new file mode 100644
index 000000000..8f55ea67c
--- /dev/null
+++ b/docs/ja/mkdocs.yml
@@ -0,0 +1,66 @@
+site_name: FastAPI
+site_description: FastAPI framework, high performance, easy to learn, fast to code, ready for production
+site_url: https://fastapi.tiangolo.com/ja/
+theme:
+ name: material
+ palette:
+ primary: teal
+ accent: amber
+ icon:
+ repo: fontawesome/brands/github-alt
+ logo: https://fastapi.tiangolo.com/img/icon-white.svg
+ favicon: https://fastapi.tiangolo.com/img/favicon.png
+ language: ja
+repo_name: tiangolo/fastapi
+repo_url: https://github.com/tiangolo/fastapi
+edit_uri: ''
+google_analytics:
+- UA-133183413-1
+- auto
+nav:
+- FastAPI: index.md
+- Languages:
+ - en: /
+ - es: /es/
+ - ja: /ja/
+ - pt: /pt/
+ - zh: /zh/
+markdown_extensions:
+- toc:
+ permalink: true
+- markdown.extensions.codehilite:
+ guess_lang: false
+- markdown_include.include:
+ base_path: docs
+- admonition
+- codehilite
+- extra
+- pymdownx.superfences:
+ custom_fences:
+ - name: mermaid
+ class: mermaid
+ format: !!python/name:pymdownx.superfences.fence_div_format ''
+- pymdownx.tabbed
+extra:
+ social:
+ - icon: fontawesome/brands/github-alt
+ link: https://github.com/tiangolo/typer
+ - icon: fontawesome/brands/twitter
+ link: https://twitter.com/tiangolo
+ - icon: fontawesome/brands/linkedin
+ link: https://www.linkedin.com/in/tiangolo
+ - icon: fontawesome/brands/dev
+ link: https://dev.to/tiangolo
+ - icon: fontawesome/brands/medium
+ link: https://medium.com/@tiangolo
+ - icon: fontawesome/solid/globe
+ link: https://tiangolo.com
+extra_css:
+- https://fastapi.tiangolo.com/css/termynal.css
+- https://fastapi.tiangolo.com/css/custom.css
+extra_javascript:
+- https://unpkg.com/mermaid@8.4.6/dist/mermaid.min.js
+- https://fastapi.tiangolo.com/js/termynal.js
+- https://fastapi.tiangolo.com/js/custom.js
+- https://fastapi.tiangolo.com/js/chat.js
+- https://sidecar.gitter.im/dist/sidecar.v1.js
diff --git a/docs/pt/mkdocs.yml b/docs/pt/mkdocs.yml
index 8224afdef..0f182bf04 100644
--- a/docs/pt/mkdocs.yml
+++ b/docs/pt/mkdocs.yml
@@ -28,6 +28,7 @@ nav:
- en: /
- es: /es/
- fr: /fr/
+ - ja: /ja/
- it: /it/
- pt: /pt/
- ru: /ru/
diff --git a/docs/zh/mkdocs.yml b/docs/zh/mkdocs.yml
index f5edd98a7..a55edcc47 100644
--- a/docs/zh/mkdocs.yml
+++ b/docs/zh/mkdocs.yml
@@ -28,6 +28,7 @@ nav:
- en: /
- es: /es/
- fr: /fr/
+ - ja: /ja/
- it: /it/
- pt: /pt/
- ru: /ru/
From dfdd371c52564e3e6522b950b0c510731412f257 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 15:38:44 +0200
Subject: [PATCH 10/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index 00e3f68fa..6cf375d3d 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -12,6 +12,7 @@
### Translations
+* Add translation for [main page to Japanese](https://fastapi.tiangolo.com/ja/) PR [#1571](https://github.com/tiangolo/fastapi/pull/1571) by [@ryuckel](https://github.com/ryuckel).
* Initialize French translations. PR [#1975](https://github.com/tiangolo/fastapi/pull/1975) by [@JulianMaurin-BM](https://github.com/JulianMaurin-BM).
* Initialize Turkish translations. PR [#1905](https://github.com/tiangolo/fastapi/pull/1905) by [@ycd](https://github.com/ycd).
From be669059fbc64dd36a5544d19eeaef5de8468f41 Mon Sep 17 00:00:00 2001
From: Brock Friedrich
Date: Sat, 29 Aug 2020 09:02:58 -0500
Subject: [PATCH 11/13] =?UTF-8?q?=F0=9F=8E=A8=20Simplify=20docs=20hl=5Flin?=
=?UTF-8?q?es=20ranges=20and=20standardize=202=20spaces=20between=20each?=
=?UTF-8?q?=20range=20(#1863)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +--
docs/en/docs/advanced/additional-responses.md | 12 ++++----
docs/en/docs/advanced/async-sql-databases.md | 14 +++++-----
docs/en/docs/advanced/async-tests.md | 2 +-
docs/en/docs/advanced/behind-a-proxy.md | 6 ++--
.../docs/advanced/custom-request-and-route.md | 10 +++----
docs/en/docs/advanced/custom-response.md | 14 +++++-----
docs/en/docs/advanced/extending-openapi.md | 14 +++++-----
docs/en/docs/advanced/graphql.md | 4 +--
docs/en/docs/advanced/middleware.md | 2 +-
docs/en/docs/advanced/nosql-databases.md | 12 ++++----
docs/en/docs/advanced/openapi-callbacks.md | 6 ++--
.../path-operation-advanced-configuration.md | 4 +--
docs/en/docs/advanced/response-cookies.md | 4 +--
docs/en/docs/advanced/response-directly.md | 2 +-
docs/en/docs/advanced/response-headers.md | 4 +--
.../docs/advanced/security/http-basic-auth.md | 6 ++--
.../docs/advanced/security/oauth2-scopes.md | 10 +++----
docs/en/docs/advanced/settings.md | 14 +++++-----
docs/en/docs/advanced/sql-databases-peewee.md | 20 ++++++-------
docs/en/docs/advanced/sub-applications.md | 6 ++--
docs/en/docs/advanced/templates.md | 2 +-
docs/en/docs/advanced/testing-database.md | 8 +++---
docs/en/docs/advanced/testing-dependencies.md | 2 +-
docs/en/docs/advanced/testing-events.md | 2 +-
docs/en/docs/advanced/testing-websockets.md | 2 +-
.../docs/advanced/using-request-directly.md | 2 +-
docs/en/docs/advanced/websockets.md | 8 +++---
docs/en/docs/advanced/wsgi.md | 2 +-
docs/en/docs/async.md | 2 +-
docs/en/docs/index.md | 4 +--
docs/en/docs/python-types.md | 8 +++---
docs/en/docs/tutorial/background-tasks.md | 6 ++--
docs/en/docs/tutorial/bigger-applications.md | 12 ++++----
docs/en/docs/tutorial/body-fields.md | 2 +-
docs/en/docs/tutorial/body-multiple-params.md | 2 +-
docs/en/docs/tutorial/body-nested-models.md | 8 +++---
docs/en/docs/tutorial/body-updates.md | 4 +--
docs/en/docs/tutorial/body.md | 4 +--
docs/en/docs/tutorial/cors.md | 2 +-
docs/en/docs/tutorial/debugging.md | 2 +-
.../dependencies/classes-as-dependencies.md | 2 +-
...pendencies-in-path-operation-decorators.md | 6 ++--
.../dependencies/dependencies-with-yield.md | 12 ++++----
docs/en/docs/tutorial/dependencies/index.md | 2 +-
.../tutorial/dependencies/sub-dependencies.md | 2 +-
docs/en/docs/tutorial/encoder.md | 2 +-
docs/en/docs/tutorial/extra-data-types.md | 4 +--
docs/en/docs/tutorial/extra-models.md | 10 +++----
docs/en/docs/tutorial/handling-errors.md | 10 +++----
docs/en/docs/tutorial/metadata.md | 4 +--
docs/en/docs/tutorial/middleware.md | 4 +--
.../tutorial/path-operation-configuration.md | 6 ++--
docs/en/docs/tutorial/path-params.md | 6 ++--
docs/en/docs/tutorial/query-params.md | 4 +--
docs/en/docs/tutorial/request-files.md | 2 +-
docs/en/docs/tutorial/response-model.md | 16 +++++------
docs/en/docs/tutorial/response-status-code.md | 2 +-
docs/en/docs/tutorial/schema-extra-example.md | 6 ++--
.../tutorial/security/get-current-user.md | 6 ++--
docs/en/docs/tutorial/security/oauth2-jwt.md | 8 +++---
.../docs/tutorial/security/simple-oauth2.md | 6 ++--
docs/en/docs/tutorial/sql-databases.md | 28 +++++++++----------
docs/en/docs/tutorial/static-files.md | 2 +-
docs/en/docs/tutorial/testing.md | 2 +-
docs/es/docs/async.md | 2 +-
docs/es/docs/index.md | 4 +--
docs/es/docs/python-types.md | 6 ++--
docs/it/docs/index.md | 4 +--
docs/pt/docs/index.md | 4 +--
docs/ru/docs/index.md | 4 +--
docs/uk/docs/index.md | 4 +--
docs/zh/docs/index.md | 4 +--
docs/zh/docs/python-types.md | 6 ++--
docs/zh/docs/tutorial/body-fields.md | 2 +-
docs/zh/docs/tutorial/body-multiple-params.md | 2 +-
docs/zh/docs/tutorial/body.md | 4 +--
docs/zh/docs/tutorial/path-params.md | 8 +++---
docs/zh/docs/tutorial/query-params.md | 4 +--
79 files changed, 232 insertions(+), 232 deletions(-)
diff --git a/README.md b/README.md
index 9fed5de82..d0b73f9fc 100644
--- a/README.md
+++ b/README.md
@@ -153,7 +153,7 @@ def read_item(item_id: int, q: Optional[str] = None):
If your code uses `async` / `await`, use `async def`:
-```Python hl_lines="9 14"
+```Python hl_lines="9 14"
from typing import Optional
from fastapi import FastAPI
@@ -245,7 +245,7 @@ Now modify the file `main.py` to receive a body from a `PUT` request.
Declare the body using standard Python types, thanks to Pydantic.
-```Python hl_lines="4 9 10 11 12 25 26 27"
+```Python hl_lines="4 9-12 25-27"
from typing import Optional
from fastapi import FastAPI
diff --git a/docs/en/docs/advanced/additional-responses.md b/docs/en/docs/advanced/additional-responses.md
index c8d443c3c..4b8b3b71e 100644
--- a/docs/en/docs/advanced/additional-responses.md
+++ b/docs/en/docs/advanced/additional-responses.md
@@ -23,7 +23,7 @@ Each of those response `dict`s can have a key `model`, containing a Pydantic mod
For example, to declare another response with a status code `404` and a Pydantic model `Message`, you can write:
-```Python hl_lines="18 23"
+```Python hl_lines="18 23"
{!../../../docs_src/additional_responses/tutorial001.py!}
```
@@ -44,7 +44,7 @@ For example, to declare another response with a status code `404` and a Pydantic
The generated responses in the OpenAPI for this *path operation* will be:
-```JSON hl_lines="3 4 5 6 7 8 9 10 11 12"
+```JSON hl_lines="3-12"
{
"responses": {
"404": {
@@ -83,7 +83,7 @@ The generated responses in the OpenAPI for this *path operation* will be:
The schemas are referenced to another place inside the OpenAPI schema:
-```JSON hl_lines="4 5 6 7 8 9 10 11 12 13 14 15 16"
+```JSON hl_lines="4-16"
{
"components": {
"schemas": {
@@ -168,7 +168,7 @@ You can use this same `responses` parameter to add different media types for the
For example, you can add an additional media type of `image/png`, declaring that your *path operation* can return a JSON object (with media type `application/json`) or a PNG image:
-```Python hl_lines="19 20 21 22 23 24 28"
+```Python hl_lines="19-24 28"
{!../../../docs_src/additional_responses/tutorial002.py!}
```
@@ -192,7 +192,7 @@ For example, you can declare a response with a status code `404` that uses a Pyd
And a response with a status code `200` that uses your `response_model`, but includes a custom `example`:
-```Python hl_lines="20 21 22 23 24 25 26 27 28 29 30 31"
+```Python hl_lines="20-31"
{!../../../docs_src/additional_responses/tutorial003.py!}
```
@@ -228,7 +228,7 @@ You can use that technique to re-use some predefined responses in your *path ope
For example:
-```Python hl_lines="13 14 15 16 17 26"
+```Python hl_lines="13-17 26"
{!../../../docs_src/additional_responses/tutorial004.py!}
```
diff --git a/docs/en/docs/advanced/async-sql-databases.md b/docs/en/docs/advanced/async-sql-databases.md
index 523bc91bf..93c288e1b 100644
--- a/docs/en/docs/advanced/async-sql-databases.md
+++ b/docs/en/docs/advanced/async-sql-databases.md
@@ -23,7 +23,7 @@ Later, for your production application, you might want to use a database server
* Create a `metadata` object.
* Create a table `notes` using the `metadata` object.
-```Python hl_lines="4 14 16 17 18 19 20 21 22"
+```Python hl_lines="4 14 16-22"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
@@ -38,7 +38,7 @@ Later, for your production application, you might want to use a database server
* Create a `DATABASE_URL`.
* Create a `database` object.
-```Python hl_lines="3 9 12"
+```Python hl_lines="3 9 12"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
@@ -54,7 +54,7 @@ Here, this section would run directly, right before starting your **FastAPI** ap
* Create an `engine`.
* Create all the tables from the `metadata` object.
-```Python hl_lines="25 26 27 28"
+```Python hl_lines="25-28"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
@@ -65,7 +65,7 @@ Create Pydantic models for:
* Notes to be created (`NoteIn`).
* Notes to be returned (`Note`).
-```Python hl_lines="31 32 33 36 37 38 39"
+```Python hl_lines="31-33 36-39"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
@@ -78,7 +78,7 @@ So, you will be able to see it all in the interactive API docs.
* Create your `FastAPI` application.
* Create event handlers to connect and disconnect from the database.
-```Python hl_lines="42 45 46 47 50 51 52"
+```Python hl_lines="42 45-47 50-52"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
@@ -86,7 +86,7 @@ So, you will be able to see it all in the interactive API docs.
Create the *path operation function* to read notes:
-```Python hl_lines="55 56 57 58"
+```Python hl_lines="55-58"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
@@ -103,7 +103,7 @@ That documents (and validates, serializes, filters) the output data, as a `list`
Create the *path operation function* to create notes:
-```Python hl_lines="61 62 63 64 65"
+```Python hl_lines="61-65"
{!../../../docs_src/async_sql_databases/tutorial001.py!}
```
diff --git a/docs/en/docs/advanced/async-tests.md b/docs/en/docs/advanced/async-tests.md
index 9e7cc70a9..921bdb708 100644
--- a/docs/en/docs/advanced/async-tests.md
+++ b/docs/en/docs/advanced/async-tests.md
@@ -77,7 +77,7 @@ The marker `@pytest.mark.asyncio` tells pytest that this test function should be
Then we can create an `AsyncClient` with the app, and send async requests to it, using `await`.
-```Python hl_lines="9 10"
+```Python hl_lines="9-10"
{!../../../docs_src/async_tests/test_main.py!}
```
diff --git a/docs/en/docs/advanced/behind-a-proxy.md b/docs/en/docs/advanced/behind-a-proxy.md
index 70cd5a170..766a218aa 100644
--- a/docs/en/docs/advanced/behind-a-proxy.md
+++ b/docs/en/docs/advanced/behind-a-proxy.md
@@ -44,7 +44,7 @@ proxy --> server
The docs UI would also need the OpenAPI schema to declare that this API `server` is located at `/api/v1` (behind the proxy). For example:
-```JSON hl_lines="4 5 6 7 8"
+```JSON hl_lines="4-8"
{
"openapi": "3.0.2",
// More stuff here
@@ -290,13 +290,13 @@ If you pass a custom list of `servers` and there's a `root_path` (because your A
For example:
-```Python hl_lines="4 5 6 7"
+```Python hl_lines="4-7"
{!../../../docs_src/behind_a_proxy/tutorial003.py!}
```
Will generate an OpenAPI schema like:
-```JSON hl_lines="5 6 7"
+```JSON hl_lines="5-7"
{
"openapi": "3.0.2",
// More stuff here
diff --git a/docs/en/docs/advanced/custom-request-and-route.md b/docs/en/docs/advanced/custom-request-and-route.md
index 6c5e97a18..bca0c7603 100644
--- a/docs/en/docs/advanced/custom-request-and-route.md
+++ b/docs/en/docs/advanced/custom-request-and-route.md
@@ -36,7 +36,7 @@ If there's no `gzip` in the header, it will not try to decompress the body.
That way, the same route class can handle gzip compressed or uncompressed requests.
-```Python hl_lines="8 9 10 11 12 13 14 15"
+```Python hl_lines="8-15"
{!../../../docs_src/custom_request_and_route/tutorial001.py!}
```
@@ -50,7 +50,7 @@ This method returns a function. And that function is what will receive a request
Here we use it to create a `GzipRequest` from the original request.
-```Python hl_lines="18 19 20 21 22 23 24 25 26"
+```Python hl_lines="18-26"
{!../../../docs_src/custom_request_and_route/tutorial001.py!}
```
@@ -84,13 +84,13 @@ We can also use this same approach to access the request body in an exception ha
All we need to do is handle the request inside a `try`/`except` block:
-```Python hl_lines="13 15"
+```Python hl_lines="13 15"
{!../../../docs_src/custom_request_and_route/tutorial002.py!}
```
If an exception occurs, the`Request` instance will still be in scope, so we can read and make use of the request body when handling the error:
-```Python hl_lines="16 17 18"
+```Python hl_lines="16-18"
{!../../../docs_src/custom_request_and_route/tutorial002.py!}
```
@@ -104,6 +104,6 @@ You can also set the `route_class` parameter of an `APIRouter`:
In this example, the *path operations* under the `router` will use the custom `TimedRoute` class, and will have an extra `X-Response-Time` header in the response with the time it took to generate the response:
-```Python hl_lines="13 14 15 16 17 18 19 20"
+```Python hl_lines="13-20"
{!../../../docs_src/custom_request_and_route/tutorial003.py!}
```
diff --git a/docs/en/docs/advanced/custom-response.md b/docs/en/docs/advanced/custom-response.md
index f753cc300..e9cac6df0 100644
--- a/docs/en/docs/advanced/custom-response.md
+++ b/docs/en/docs/advanced/custom-response.md
@@ -21,7 +21,7 @@ For example, if you are squeezing performance, you can install and use unit tests for it:
-```Python hl_lines="36 37 38 39 40 41 42"
+```Python hl_lines="36-42"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
@@ -145,7 +145,7 @@ As our code is calling Couchbase and we are not using the threads", so, we can just get the bucket directly and pass it to our utility functions:
-```Python hl_lines="49 50 51 52 53"
+```Python hl_lines="49-53"
{!../../../docs_src/nosql_databases/tutorial001.py!}
```
diff --git a/docs/en/docs/advanced/openapi-callbacks.md b/docs/en/docs/advanced/openapi-callbacks.md
index 4c3d97e38..e927aea4d 100644
--- a/docs/en/docs/advanced/openapi-callbacks.md
+++ b/docs/en/docs/advanced/openapi-callbacks.md
@@ -31,7 +31,7 @@ It will have a *path operation* that will receive an `Invoice` body, and a query
This part is pretty normal, most of the code is probably already familiar to you:
-```Python hl_lines="10 11 12 13 14 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54"
+```Python hl_lines="10-14 37-54"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
@@ -92,7 +92,7 @@ Because of that, you need to declare what will be the `default_response_class`,
But as we are never calling `app.include_router(some_router)`, we need to set the `default_response_class` during creation of the `APIRouter`.
-```Python hl_lines="5 26"
+```Python hl_lines="5 26"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
@@ -105,7 +105,7 @@ It should look just like a normal FastAPI *path operation*:
* It should probably have a declaration of the body it should receive, e.g. `body: InvoiceEvent`.
* And it could also have a declaration of the response it should return, e.g. `response_model=InvoiceEventReceived`.
-```Python hl_lines="17 18 19 22 23 29 30 31 32 33"
+```Python hl_lines="17-19 22-23 29-33"
{!../../../docs_src/openapi_callbacks/tutorial001.py!}
```
diff --git a/docs/en/docs/advanced/path-operation-advanced-configuration.md b/docs/en/docs/advanced/path-operation-advanced-configuration.md
index 7a3247a64..8d085d754 100644
--- a/docs/en/docs/advanced/path-operation-advanced-configuration.md
+++ b/docs/en/docs/advanced/path-operation-advanced-configuration.md
@@ -19,7 +19,7 @@ If you want to use your APIs' function names as `operationId`s, you can iterate
You should do it after adding all your *path operations*.
-```Python hl_lines="2 12 13 14 15 16 17 18 19 20 21 24"
+```Python hl_lines="2 12-21 24"
{!../../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
```
@@ -47,6 +47,6 @@ Adding an `\f` (an escaped "form feed" character) causes **FastAPI** to truncate
It won't show up in the documentation, but other tools (such as Sphinx) will be able to use the rest.
-```Python hl_lines="19 20 21 22 23 24 25 26 27 28 29"
+```Python hl_lines="19-29"
{!../../../docs_src/path_operation_advanced_configuration/tutorial004.py!}
```
diff --git a/docs/en/docs/advanced/response-cookies.md b/docs/en/docs/advanced/response-cookies.md
index e46ae755f..9178ef816 100644
--- a/docs/en/docs/advanced/response-cookies.md
+++ b/docs/en/docs/advanced/response-cookies.md
@@ -6,7 +6,7 @@ You can declare a parameter of type `Response` in your *path operation function*
And then you can set cookies in that *temporal* response object.
-```Python hl_lines="1 8 9"
+```Python hl_lines="1 8-9"
{!../../../docs_src/response_cookies/tutorial002.py!}
```
@@ -26,7 +26,7 @@ To do that, you can create a response as described in [Return a Response Directl
Then set Cookies in it, and then return it:
-```Python hl_lines="10 11 12"
+```Python hl_lines="10-12"
{!../../../docs_src/response_cookies/tutorial001.py!}
```
diff --git a/docs/en/docs/advanced/response-directly.md b/docs/en/docs/advanced/response-directly.md
index f0ab2831d..8836140ec 100644
--- a/docs/en/docs/advanced/response-directly.md
+++ b/docs/en/docs/advanced/response-directly.md
@@ -31,7 +31,7 @@ For example, you cannot put a Pydantic model in a `JSONResponse` without first c
For those cases, you can use the `jsonable_encoder` to convert your data before passing it to a response:
-```Python hl_lines="6 7 21 22"
+```Python hl_lines="6-7 21-22"
{!../../../docs_src/response_directly/tutorial001.py!}
```
diff --git a/docs/en/docs/advanced/response-headers.md b/docs/en/docs/advanced/response-headers.md
index 914bd4401..758bd6455 100644
--- a/docs/en/docs/advanced/response-headers.md
+++ b/docs/en/docs/advanced/response-headers.md
@@ -6,7 +6,7 @@ You can declare a parameter of type `Response` in your *path operation function*
And then you can set headers in that *temporal* response object.
-```Python hl_lines="1 7 8"
+```Python hl_lines="1 7-8"
{!../../../docs_src/response_headers/tutorial002.py!}
```
@@ -24,7 +24,7 @@ You can also add headers when you return a `Response` directly.
Create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank} and pass the headers as an additional parameter:
-```Python hl_lines="10 11 12"
+```Python hl_lines="10-12"
{!../../../docs_src/response_headers/tutorial001.py!}
```
diff --git a/docs/en/docs/advanced/security/http-basic-auth.md b/docs/en/docs/advanced/security/http-basic-auth.md
index c0ebea4fe..6c589cd9a 100644
--- a/docs/en/docs/advanced/security/http-basic-auth.md
+++ b/docs/en/docs/advanced/security/http-basic-auth.md
@@ -20,7 +20,7 @@ Then, when you type that username and password, the browser sends them in the he
* It returns an object of type `HTTPBasicCredentials`:
* It contains the `username` and `password` sent.
-```Python hl_lines="2 6 10"
+```Python hl_lines="2 6 10"
{!../../../docs_src/security/tutorial006.py!}
```
@@ -36,7 +36,7 @@ Use a dependency to check if the username and password are correct.
For this, use the Python standard module `secrets` to check the username and password:
-```Python hl_lines="1 11 12 13"
+```Python hl_lines="1 11-13"
{!../../../docs_src/security/tutorial007.py!}
```
@@ -102,6 +102,6 @@ That way, using `secrets.compare_digest()` in your application code, it will be
After detecting that the credentials are incorrect, return an `HTTPException` with a status code 401 (the same returned when no credentials are provided) and add the header `WWW-Authenticate` to make the browser show the login prompt again:
-```Python hl_lines="15 16 17 18 19"
+```Python hl_lines="15-19"
{!../../../docs_src/security/tutorial007.py!}
```
diff --git a/docs/en/docs/advanced/security/oauth2-scopes.md b/docs/en/docs/advanced/security/oauth2-scopes.md
index 5b3d57d7f..c40695ba6 100644
--- a/docs/en/docs/advanced/security/oauth2-scopes.md
+++ b/docs/en/docs/advanced/security/oauth2-scopes.md
@@ -56,7 +56,7 @@ They are normally used to declare specific security permissions, for example:
First, let's quickly see the parts that change from the examples in the main **Tutorial - User Guide** for [OAuth2 with Password (and hashing), Bearer with JWT tokens](../../tutorial/security/oauth2-jwt.md){.internal-link target=_blank}. Now using OAuth2 scopes:
-```Python hl_lines="2 4 8 12 46 64 105 107 108 109 110 111 112 113 114 115 121 122 123 124 128 129 130 131 132 133 134 139 153"
+```Python hl_lines="2 4 8 12 46 64 105 107-115 121-124 128-134 139 153"
{!../../../docs_src/security/tutorial005.py!}
```
@@ -68,7 +68,7 @@ The first change is that now we are declaring the OAuth2 security scheme with tw
The `scopes` parameter receives a `dict` with each scope as a key and the description as the value:
-```Python hl_lines="62 63 64 65"
+```Python hl_lines="62-65"
{!../../../docs_src/security/tutorial005.py!}
```
@@ -159,7 +159,7 @@ We create an `HTTPException` that we can re-use (`raise`) later at several point
In this exception, we include the scopes required (if any) as a string separated by spaces (using `scope_str`). We put that string containing the scopes in in the `WWW-Authenticate` header (this is part of the spec).
-```Python hl_lines="105 107 108 109 110 111 112 113 114 115"
+```Python hl_lines="105 107-115"
{!../../../docs_src/security/tutorial005.py!}
```
@@ -177,7 +177,7 @@ Instead of, for example, a `dict`, or something else, as it could break the appl
We also verify that we have a user with that username, and if not, we raise that same exception we created before.
-```Python hl_lines="46 116 117 118 119 120 121 122 123 124 125 126 127"
+```Python hl_lines="46 116-127"
{!../../../docs_src/security/tutorial005.py!}
```
@@ -187,7 +187,7 @@ We now verify that all the scopes required, by this dependency and all the depen
For this, we use `security_scopes.scopes`, that contains a `list` with all these scopes as `str`.
-```Python hl_lines="128 129 130 131 132 133 134"
+```Python hl_lines="128-134"
{!../../../docs_src/security/tutorial005.py!}
```
diff --git a/docs/en/docs/advanced/settings.md b/docs/en/docs/advanced/settings.md
index f30de226c..706a71173 100644
--- a/docs/en/docs/advanced/settings.md
+++ b/docs/en/docs/advanced/settings.md
@@ -135,7 +135,7 @@ The same way as with Pydantic models, you declare class attributes with type ann
You can use all the same validation features and tools you use for Pydantic models, like different data types and additional validations with `Field()`.
-```Python hl_lines="2 5 6 7 8 11"
+```Python hl_lines="2 5-8 11"
{!../../../docs_src/settings/tutorial001.py!}
```
@@ -150,7 +150,7 @@ Next it will convert and validate the data. So, when you use that `settings` obj
Then you can use the new `settings` object in your application:
-```Python hl_lines="18 19 20"
+```Python hl_lines="18-20"
{!../../../docs_src/settings/tutorial001.py!}
```
@@ -189,7 +189,7 @@ For example, you could have a file `config.py` with:
And then use it in a file `main.py`:
-```Python hl_lines="3 11 12 13"
+```Python hl_lines="3 11-13"
{!../../../docs_src/settings/app01/main.py!}
```
@@ -216,7 +216,7 @@ Notice that now we don't create a default instance `settings = Settings()`.
Now we create a dependency that returns a new `config.Settings()`.
-```Python hl_lines="5 11 12"
+```Python hl_lines="5 11-12"
{!../../../docs_src/settings/app02/main.py!}
```
@@ -227,7 +227,7 @@ Now we create a dependency that returns a new `config.Settings()`.
And then we can require it from the *path operation function* as a dependency and use it anywhere we need it.
-```Python hl_lines="16 18 19 20"
+```Python hl_lines="16 18-20"
{!../../../docs_src/settings/app02/main.py!}
```
@@ -235,7 +235,7 @@ And then we can require it from the *path operation function* as a dependency an
Then it would be very easy to provide a different settings object during testing by creating a dependency override for `get_settings`:
-```Python hl_lines="8 9 12 21"
+```Python hl_lines="8-9 12 21"
{!../../../docs_src/settings/app02/test_main.py!}
```
@@ -272,7 +272,7 @@ APP_NAME="ChimichangApp"
And then update your `config.py` with:
-```Python hl_lines="9 10"
+```Python hl_lines="9-10"
{!../../../docs_src/settings/app03/config.py!}
```
diff --git a/docs/en/docs/advanced/sql-databases-peewee.md b/docs/en/docs/advanced/sql-databases-peewee.md
index 761029006..536a08fb9 100644
--- a/docs/en/docs/advanced/sql-databases-peewee.md
+++ b/docs/en/docs/advanced/sql-databases-peewee.md
@@ -113,7 +113,7 @@ This might seem a bit complex (and it actually is), you don't really need to com
We will create a `PeeweeConnectionState`:
-```Python hl_lines="10 11 12 13 14 15 16 17 18 19"
+```Python hl_lines="10-19"
{!../../../docs_src/sql_databases_peewee/sql_app/database.py!}
```
@@ -161,7 +161,7 @@ This is the same you would do if you followed the Peewee tutorial and updated th
Import `db` from `database` (the file `database.py` from above) and use it here.
-```Python hl_lines="3 6 7 8 9 10 11 12 15 16 17 18 19 20 21"
+```Python hl_lines="3 6-12 15-21"
{!../../../docs_src/sql_databases_peewee/sql_app/models.py!}
```
@@ -189,7 +189,7 @@ Now let's check the file `sql_app/schemas.py`.
Create all the same Pydantic models as in the SQLAlchemy tutorial:
-```Python hl_lines="16 17 18 21 22 25 26 27 28 29 30 34 35 38 39 42 43 44 45 46 47 48"
+```Python hl_lines="16-18 21-22 25-30 34-35 38-39 42-48"
{!../../../docs_src/sql_databases_peewee/sql_app/schemas.py!}
```
@@ -214,7 +214,7 @@ But recent versions of Pydantic allow providing a custom class that inherits fro
We are going to create a custom `PeeweeGetterDict` class and use it in all the same Pydantic *models* / schemas that use `orm_mode`:
-```Python hl_lines="3 8 9 10 11 12 13 31 49"
+```Python hl_lines="3 8-13 31 49"
{!../../../docs_src/sql_databases_peewee/sql_app/schemas.py!}
```
@@ -235,7 +235,7 @@ Now let's see the file `sql_app/crud.py`.
Create all the same CRUD utils as in the SQLAlchemy tutorial, all the code is very similar:
-```Python hl_lines="1 4 5 8 9 12 13 16 17 18 19 20 23 24 27 28 29 30"
+```Python hl_lines="1 4-5 8-9 12-13 16-20 23-24 27-30"
{!../../../docs_src/sql_databases_peewee/sql_app/crud.py!}
```
@@ -259,7 +259,7 @@ And now in the file `sql_app/main.py` let's integrate and use all the other part
In a very simplistic way create the database tables:
-```Python hl_lines="9 10 11"
+```Python hl_lines="9-11"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
@@ -267,7 +267,7 @@ In a very simplistic way create the database tables:
Create a dependency that will connect the database right at the beginning of a request and disconnect it at the end:
-```Python hl_lines="23 24 25 26 27 28 29"
+```Python hl_lines="23-29"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
@@ -291,7 +291,7 @@ For all the `contextvars` parts to work, we need to make sure we have an indepen
For that, we need to create another `async` dependency `reset_db_state()` that is used as a sub-dependency in `get_db()`. It will set the value for the context variable (with just a default `dict`) that will be used as the database state for the whole request. And then the dependency `get_db()` will store in it the database state (connection, transactions, etc).
-```Python hl_lines="18 19 20"
+```Python hl_lines="18-20"
{!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
```
@@ -310,7 +310,7 @@ If you are using a `Union`, include the most specific type first, followed by the less specific type. In the example below, the more specific `PlaneItem` comes before `CarItem` in `Union[PlaneItem, CarItem]`.
-```Python hl_lines="1 14 15 18 19 20 33"
+```Python hl_lines="1 14-15 18-20 33"
{!../../../docs_src/extra_models/tutorial003.py!}
```
@@ -175,7 +175,7 @@ The same way, you can declare responses of lists of objects.
For that, use the standard Python `typing.List`:
-```Python hl_lines="1 20"
+```Python hl_lines="1 20"
{!../../../docs_src/extra_models/tutorial004.py!}
```
@@ -187,7 +187,7 @@ This is useful if you don't know the valid field/attribute names (that would be
In this case, you can use `typing.Dict`:
-```Python hl_lines="1 8"
+```Python hl_lines="1 8"
{!../../../docs_src/extra_models/tutorial005.py!}
```
diff --git a/docs/en/docs/tutorial/handling-errors.md b/docs/en/docs/tutorial/handling-errors.md
index 714c4c94a..9ea2f2ad8 100644
--- a/docs/en/docs/tutorial/handling-errors.md
+++ b/docs/en/docs/tutorial/handling-errors.md
@@ -92,7 +92,7 @@ And you want to handle this exception globally with FastAPI.
You could add a custom exception handler with `@app.exception_handler()`:
-```Python hl_lines="5 6 7 13 14 15 16 17 18 24"
+```Python hl_lines="5-7 13-18 24"
{!../../../docs_src/handling_errors/tutorial003.py!}
```
@@ -129,7 +129,7 @@ To override it, import the `RequestValidationError` and use it with `@app.except
The exception handler will receive a `Request` and the exception.
-```Python hl_lines="2 14 15 16"
+```Python hl_lines="2 14-16"
{!../../../docs_src/handling_errors/tutorial004.py!}
```
@@ -179,7 +179,7 @@ The same way, you can override the `HTTPException` handler.
For example, you could want to return a plain text response instead of JSON for these errors:
-```Python hl_lines="3 4 9 10 11 22"
+```Python hl_lines="3-4 9-11 22"
{!../../../docs_src/handling_errors/tutorial004.py!}
```
@@ -209,7 +209,7 @@ Now try sending an invalid item like:
You will receive a response telling you that the data is invalid containing the received body:
-```JSON hl_lines="12 13 14 15"
+```JSON hl_lines="12-15"
{
"detail": [
{
@@ -256,7 +256,7 @@ You could also just want to use the exception somehow, but then use the same def
You can import and re-use the default exception handlers from `fastapi.exception_handlers`:
-```Python hl_lines="2 3 4 5 15 21"
+```Python hl_lines="2-5 15 21"
{!../../../docs_src/handling_errors/tutorial006.py!}
```
diff --git a/docs/en/docs/tutorial/metadata.md b/docs/en/docs/tutorial/metadata.md
index 25c00db70..7ec305421 100644
--- a/docs/en/docs/tutorial/metadata.md
+++ b/docs/en/docs/tutorial/metadata.md
@@ -13,7 +13,7 @@ You can set the:
To set them, use the parameters `title`, `description`, and `version`:
-```Python hl_lines="4 5 6"
+```Python hl_lines="4-6"
{!../../../docs_src/metadata/tutorial001.py!}
```
@@ -41,7 +41,7 @@ Let's try that in an example with tags for `users` and `items`.
Create metadata for your tags and pass it to the `openapi_tags` parameter:
-```Python hl_lines="3 4 5 6 7 8 9 10 11 12 13 14 15 16 18"
+```Python hl_lines="3-16 18"
{!../../../docs_src/metadata/tutorial004.py!}
```
diff --git a/docs/en/docs/tutorial/middleware.md b/docs/en/docs/tutorial/middleware.md
index 6f7ca000a..3c6868fe4 100644
--- a/docs/en/docs/tutorial/middleware.md
+++ b/docs/en/docs/tutorial/middleware.md
@@ -28,7 +28,7 @@ The middleware function receives:
* Then it returns the `response` generated by the corresponding *path operation*.
* You can then modify further the `response` before returning it.
-```Python hl_lines="8 9 11 14"
+```Python hl_lines="8-9 11 14"
{!../../../docs_src/middleware/tutorial001.py!}
```
@@ -50,7 +50,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"
+```Python hl_lines="10 12-13"
{!../../../docs_src/middleware/tutorial001.py!}
```
diff --git a/docs/en/docs/tutorial/path-operation-configuration.md b/docs/en/docs/tutorial/path-operation-configuration.md
index c2c300894..0d606331d 100644
--- a/docs/en/docs/tutorial/path-operation-configuration.md
+++ b/docs/en/docs/tutorial/path-operation-configuration.md
@@ -28,7 +28,7 @@ That status code will be used in the response and will be added to the OpenAPI s
You can add tags to your *path operation*, pass the parameter `tags` with a `list` of `str` (commonly just one `str`):
-```Python hl_lines="17 22 27"
+```Python hl_lines="17 22 27"
{!../../../docs_src/path_operation_configuration/tutorial002.py!}
```
@@ -40,7 +40,7 @@ They will be added to the OpenAPI schema and used by the automatic documentation
You can add a `summary` and `description`:
-```Python hl_lines="20 21"
+```Python hl_lines="20-21"
{!../../../docs_src/path_operation_configuration/tutorial003.py!}
```
@@ -50,7 +50,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).
-```Python hl_lines="19 20 21 22 23 24 25 26 27"
+```Python hl_lines="19-27"
{!../../../docs_src/path_operation_configuration/tutorial004.py!}
```
diff --git a/docs/en/docs/tutorial/path-params.md b/docs/en/docs/tutorial/path-params.md
index 77c5c02e2..4f59069fd 100644
--- a/docs/en/docs/tutorial/path-params.md
+++ b/docs/en/docs/tutorial/path-params.md
@@ -2,7 +2,7 @@
You can declare path "parameters" or "variables" with the same syntax used by Python format strings:
-```Python hl_lines="6 7"
+```Python hl_lines="6-7"
{!../../../docs_src/path_params/tutorial001.py!}
```
@@ -109,7 +109,7 @@ And then you can also have a path `/users/{user_id}` to get data about a specifi
Because *path operations* are evaluated in order, you need to make sure that the path for `/users/me` is declared before the one for `/users/{user_id}`:
-```Python hl_lines="6 11"
+```Python hl_lines="6 11"
{!../../../docs_src/path_params/tutorial003.py!}
```
@@ -127,7 +127,7 @@ By inheriting from `str` the API docs will be able to know that the values must
Then create class attributes with fixed values, which will be the available valid values:
-```Python hl_lines="1 6 7 8 9"
+```Python hl_lines="1 6-9"
{!../../../docs_src/path_params/tutorial005.py!}
```
diff --git a/docs/en/docs/tutorial/query-params.md b/docs/en/docs/tutorial/query-params.md
index d5dec36de..f741b99a0 100644
--- a/docs/en/docs/tutorial/query-params.md
+++ b/docs/en/docs/tutorial/query-params.md
@@ -126,7 +126,7 @@ And you don't have to declare them in any specific order.
They will be detected by name:
-```Python hl_lines="8 10"
+```Python hl_lines="8 10"
{!../../../docs_src/query_params/tutorial004.py!}
```
@@ -138,7 +138,7 @@ If you don't want to add a specific value but just make it optional, set the def
But when you want to make a query parameter required, you can just not declare any default value:
-```Python hl_lines="6 7"
+```Python hl_lines="6-7"
{!../../../docs_src/query_params/tutorial005.py!}
```
diff --git a/docs/en/docs/tutorial/request-files.md b/docs/en/docs/tutorial/request-files.md
index 260a5e190..3bdf8d002 100644
--- a/docs/en/docs/tutorial/request-files.md
+++ b/docs/en/docs/tutorial/request-files.md
@@ -121,7 +121,7 @@ They would be associated to the same "form field" sent using "form data".
To use that, declare a `List` of `bytes` or `UploadFile`:
-```Python hl_lines="10 15"
+```Python hl_lines="10 15"
{!../../../docs_src/request_files/tutorial002.py!}
```
diff --git a/docs/en/docs/tutorial/response-model.md b/docs/en/docs/tutorial/response-model.md
index b7201ee77..fdf661134 100644
--- a/docs/en/docs/tutorial/response-model.md
+++ b/docs/en/docs/tutorial/response-model.md
@@ -35,13 +35,13 @@ But most importantly:
Here we are declaring a `UserIn` model, it will contain a plaintext password:
-```Python hl_lines="9 11"
+```Python hl_lines="9 11"
{!../../../docs_src/response_model/tutorial002.py!}
```
And we are using this model to declare our input and the same model to declare our output:
-```Python hl_lines="17 18"
+```Python hl_lines="17-18"
{!../../../docs_src/response_model/tutorial002.py!}
```
@@ -58,7 +58,7 @@ But if we use the same model for another *path operation*, we could be sending o
We can instead create an input model with the plaintext password and an output model without it:
-```Python hl_lines="9 11 16"
+```Python hl_lines="9 11 16"
{!../../../docs_src/response_model/tutorial003.py!}
```
@@ -90,7 +90,7 @@ And both models will be used for the interactive API documentation:
Your response model could have default values, like:
-```Python hl_lines="11 13 14"
+```Python hl_lines="11 13-14"
{!../../../docs_src/response_model/tutorial004.py!}
```
@@ -136,7 +136,7 @@ So, if you send a request to that *path operation* for the item with ID `foo`, t
But if your data has values for the model's fields with default values, like the item with ID `bar`:
-```Python hl_lines="3 5"
+```Python hl_lines="3 5"
{
"name": "Bar",
"description": "The bartenders",
@@ -151,7 +151,7 @@ they will be included in the response.
If the data has the same values as the default ones, like the item with ID `baz`:
-```Python hl_lines="3 5 6"
+```Python hl_lines="3 5-6"
{
"name": "Baz",
"description": None,
@@ -185,7 +185,7 @@ This can be used as a quick shortcut if you have only one Pydantic model and wan
This also applies to `response_model_by_alias` that works similarly.
-```Python hl_lines="31 37"
+```Python hl_lines="31 37"
{!../../../docs_src/response_model/tutorial005.py!}
```
@@ -198,7 +198,7 @@ This can be used as a quick shortcut if you have only one Pydantic model and wan
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:
-```Python hl_lines="31 37"
+```Python hl_lines="31 37"
{!../../../docs_src/response_model/tutorial006.py!}
```
diff --git a/docs/en/docs/tutorial/response-status-code.md b/docs/en/docs/tutorial/response-status-code.md
index 7915624fa..646378aa1 100644
--- a/docs/en/docs/tutorial/response-status-code.md
+++ b/docs/en/docs/tutorial/response-status-code.md
@@ -71,7 +71,7 @@ But you don't have to memorize what each of these codes mean.
You can use the convenience variables from `fastapi.status`.
-```Python hl_lines="1 6"
+```Python hl_lines="1 6"
{!../../../docs_src/response_status_code/tutorial002.py!}
```
diff --git a/docs/en/docs/tutorial/schema-extra-example.md b/docs/en/docs/tutorial/schema-extra-example.md
index d0f1b843e..d1f9bfec4 100644
--- a/docs/en/docs/tutorial/schema-extra-example.md
+++ b/docs/en/docs/tutorial/schema-extra-example.md
@@ -10,7 +10,7 @@ There are several ways you can declare extra JSON Schema information.
You can declare an example for a Pydantic model using `Config` and `schema_extra`, as described in Pydantic's docs: Schema customization:
-```Python hl_lines="15 16 17 18 19 20 21 22 23"
+```Python hl_lines="15-23"
{!../../../docs_src/schema_extra_example/tutorial001.py!}
```
@@ -20,7 +20,7 @@ That extra info will be added as-is to the output JSON Schema.
In `Field`, `Path`, `Query`, `Body` and others you'll see later, you can also declare extra info for the JSON Schema by passing any other arbitrary arguments to the function, for example, to add an `example`:
-```Python hl_lines="4 10 11 12 13"
+```Python hl_lines="4 10-13"
{!../../../docs_src/schema_extra_example/tutorial002.py!}
```
@@ -33,7 +33,7 @@ The same way you can pass extra info to `Field`, you can do the same with `Path`
For example, you can pass an `example` for a body request to `Body`:
-```Python hl_lines="21 22 23 24 25 26"
+```Python hl_lines="21-26"
{!../../../docs_src/schema_extra_example/tutorial003.py!}
```
diff --git a/docs/en/docs/tutorial/security/get-current-user.md b/docs/en/docs/tutorial/security/get-current-user.md
index 3fc0164c3..f50b69acf 100644
--- a/docs/en/docs/tutorial/security/get-current-user.md
+++ b/docs/en/docs/tutorial/security/get-current-user.md
@@ -16,7 +16,7 @@ First, let's create a Pydantic user model.
The same way we use Pydantic to declare bodies, we can use it anywhere else:
-```Python hl_lines="5 12 13 14 15 16"
+```Python hl_lines="5 12-16"
{!../../../docs_src/security/tutorial002.py!}
```
@@ -38,7 +38,7 @@ The same as we were doing before in the *path operation* directly, our new depen
`get_current_user` will use a (fake) utility function we created, that takes a token as a `str` and returns our Pydantic `User` model:
-```Python hl_lines="19 20 21 22 26 27"
+```Python hl_lines="19-22 26-27"
{!../../../docs_src/security/tutorial002.py!}
```
@@ -98,7 +98,7 @@ And all of them (or any portion of them that you want) can take the advantage of
And all these thousands of *path operations* can be as small as 3 lines:
-```Python hl_lines="30 31 32"
+```Python hl_lines="30-32"
{!../../../docs_src/security/tutorial002.py!}
```
diff --git a/docs/en/docs/tutorial/security/oauth2-jwt.md b/docs/en/docs/tutorial/security/oauth2-jwt.md
index b65a9f58c..47b0d75d0 100644
--- a/docs/en/docs/tutorial/security/oauth2-jwt.md
+++ b/docs/en/docs/tutorial/security/oauth2-jwt.md
@@ -109,7 +109,7 @@ And another utility to verify if a received password matches the hash stored.
And another one to authenticate and return a user.
-```Python hl_lines="7 48 55 56 59 60 69 70 71 72 73 74 75"
+```Python hl_lines="7 48 55-56 59-60 69-75"
{!../../../docs_src/security/tutorial004.py!}
```
@@ -144,7 +144,7 @@ Define a Pydantic Model that will be used in the token endpoint for the response
Create a utility function to generate a new access token.
-```Python hl_lines="6 12 13 14 28 29 30 78 79 80 81 82 83 84 85 86"
+```Python hl_lines="6 12-14 28-30 78-86"
{!../../../docs_src/security/tutorial004.py!}
```
@@ -156,7 +156,7 @@ Decode the received token, verify it, and return the current user.
If the token is invalid, return an HTTP error right away.
-```Python hl_lines="89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106"
+```Python hl_lines="89-106"
{!../../../docs_src/security/tutorial004.py!}
```
@@ -166,7 +166,7 @@ Create a `timedelta` with the expiration time of the token.
Create a real JWT access token and return it.
-```Python hl_lines="115 116 117 118 119 120 121 122 123 124 125 126 127 128"
+```Python hl_lines="115-128"
{!../../../docs_src/security/tutorial004.py!}
```
diff --git a/docs/en/docs/tutorial/security/simple-oauth2.md b/docs/en/docs/tutorial/security/simple-oauth2.md
index e6882c7e2..2aa747847 100644
--- a/docs/en/docs/tutorial/security/simple-oauth2.md
+++ b/docs/en/docs/tutorial/security/simple-oauth2.md
@@ -90,7 +90,7 @@ If there is no such user, we return an error saying "incorrect username or passw
For the error, we use the exception `HTTPException`:
-```Python hl_lines="3 77 78 79"
+```Python hl_lines="3 77-79"
{!../../../docs_src/security/tutorial003.py!}
```
@@ -118,7 +118,7 @@ If your database is stolen, the thief won't have your users' plaintext passwords
So, the thief won't be able to try to use those same passwords in another system (as many users use the same password everywhere, this would be dangerous).
-```Python hl_lines="80 81 82 83"
+```Python hl_lines="80-83"
{!../../../docs_src/security/tutorial003.py!}
```
@@ -181,7 +181,7 @@ Both of these dependencies will just return an HTTP error if the user doesn't ex
So, in our endpoint, we will only get a user if the user exists, was correctly authenticated, and is active:
-```Python hl_lines="58 59 60 61 62 63 64 65 66 67 69 70 71 72 90"
+```Python hl_lines="58-67 69-72 90"
{!../../../docs_src/security/tutorial003.py!}
```
diff --git a/docs/en/docs/tutorial/sql-databases.md b/docs/en/docs/tutorial/sql-databases.md
index a3f7fae05..59eb6a4fb 100644
--- a/docs/en/docs/tutorial/sql-databases.md
+++ b/docs/en/docs/tutorial/sql-databases.md
@@ -86,13 +86,13 @@ Let's refer to the file `sql_app/database.py`.
### Import the SQLAlchemy parts
-```Python hl_lines="1 2 3"
+```Python hl_lines="1-3"
{!../../../docs_src/sql_databases/sql_app/database.py!}
```
### Create a database URL for SQLAlchemy
-```Python hl_lines="5 6"
+```Python hl_lines="5-6"
{!../../../docs_src/sql_databases/sql_app/database.py!}
```
@@ -120,7 +120,7 @@ The first step is to create a SQLAlchemy "engine".
We will later use this `engine` in other places.
-```Python hl_lines="8 9 10"
+```Python hl_lines="8-10"
{!../../../docs_src/sql_databases/sql_app/database.py!}
```
@@ -189,7 +189,7 @@ Create classes that inherit from it.
These classes are the SQLAlchemy models.
-```Python hl_lines="4 7 8 18 19"
+```Python hl_lines="4 7-8 18-19"
{!../../../docs_src/sql_databases/sql_app/models.py!}
```
@@ -205,7 +205,7 @@ We use `Column` from SQLAlchemy as the default value.
And we pass a SQLAlchemy class "type", as `Integer`, `String`, and `Boolean`, that defines the type in the database, as an argument.
-```Python hl_lines="1 10 11 12 13 21 22 23 24"
+```Python hl_lines="1 10-13 21-24"
{!../../../docs_src/sql_databases/sql_app/models.py!}
```
@@ -217,7 +217,7 @@ For this, we use `relationship` provided by SQLAlchemy ORM.
This will become, more or less, a "magic" attribute that will contain the values from other tables related to this one.
-```Python hl_lines="2 15 26"
+```Python hl_lines="2 15 26"
{!../../../docs_src/sql_databases/sql_app/models.py!}
```
@@ -248,7 +248,7 @@ So, the user will also have a `password` when creating it.
But for security, the `password` won't be in other Pydantic *models*, for example, it won't be sent from the API when reading a user.
-```Python hl_lines="3 6 7 8 11 12 23 24 27 28"
+```Python hl_lines="3 6-8 11-12 23-24 27-28"
{!../../../docs_src/sql_databases/sql_app/schemas.py!}
```
@@ -278,7 +278,7 @@ The same way, when reading a user, we can now declare that `items` will contain
Not only the IDs of those items, but all the data that we defined in the Pydantic *model* for reading items: `Item`.
-```Python hl_lines="15 16 17 31 32 33 34"
+```Python hl_lines="15-17 31-34"
{!../../../docs_src/sql_databases/sql_app/schemas.py!}
```
@@ -293,7 +293,7 @@ This
Date: Sat, 29 Aug 2020 16:06:32 +0200
Subject: [PATCH 12/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index 6cf375d3d..fcbe86cf2 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -16,6 +16,10 @@
* Initialize French translations. PR [#1975](https://github.com/tiangolo/fastapi/pull/1975) by [@JulianMaurin-BM](https://github.com/JulianMaurin-BM).
* Initialize Turkish translations. PR [#1905](https://github.com/tiangolo/fastapi/pull/1905) by [@ycd](https://github.com/ycd).
+### Internal
+
+* Improve docs maintainability by updating `hl_lines` syntax to use ranges. PR [#1863](https://github.com/tiangolo/fastapi/pull/1863) by [@la-mar](https://github.com/la-mar).
+
## 0.61.0
### Features
From e77ea635777d2494690ba3eb62bd005b9edeefde Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?=
Date: Sat, 29 Aug 2020 16:30:50 +0200
Subject: [PATCH 13/13] =?UTF-8?q?=F0=9F=94=96=20Release=20version=200.61.1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/en/docs/release-notes.md | 2 ++
fastapi/__init__.py | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md
index fcbe86cf2..e6611c7a6 100644
--- a/docs/en/docs/release-notes.md
+++ b/docs/en/docs/release-notes.md
@@ -2,6 +2,8 @@
## Latest changes
+## 0.61.1
+
### Fixes
* Fix issues using `jsonable_encoder` with SQLAlchemy models directly. PR [#1987](https://github.com/tiangolo/fastapi/pull/1987).
diff --git a/fastapi/__init__.py b/fastapi/__init__.py
index 6169e1452..626e92a73 100644
--- a/fastapi/__init__.py
+++ b/fastapi/__init__.py
@@ -1,6 +1,6 @@
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
-__version__ = "0.61.0"
+__version__ = "0.61.1"
from starlette import status