From ac92c7ef8beb373c112d3e92bdbea4c23c5fcd2a Mon Sep 17 00:00:00 2001 From: "ryusuke.miyaji" Date: Sun, 14 Jun 2020 15:18:40 +0900 Subject: [PATCH] translate to end --- docs/ja/docs/index.md | 190 +++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/docs/ja/docs/index.md b/docs/ja/docs/index.md index 7e1dff1bf..f1f33e952 100644 --- a/docs/ja/docs/index.md +++ b/docs/ja/docs/index.md @@ -214,32 +214,32 @@ INFO: Application startup complete. もうすでに以下の API が作成されています: -- 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`. +- `/` と `/items/{item_id}`のパスで HTTP リクエストを受けます。 +- どちらのパスも `GET` 演算子 を取ります。(HTTP メソッドとしても知られています。) +- `/items/{item_id}` パスのパスパラメータ `item_id` は `int` でなければなりません。 +- パス `/items/{item_id}` はオプションの `str` クエリパラメータ `q` を持ちます。 -### Interactive API docs +### 自動対話型の API ドキュメント -Now go to http://127.0.0.1:8000/docs. +http://127.0.0.1:8000/docsにアクセスしてみてください。 -You will see the automatic interactive API documentation (provided by Swagger UI): +自動対話型の API ドキュメントが表示されます。 (Swagger UIが提供しています。): ![Swagger UI](https://fastapi.tiangolo.com/img/index/index-01-swagger-ui-simple.png) -### Alternative API docs +### 代替の API ドキュメント -And now, go to http://127.0.0.1:8000/redoc. +http://127.0.0.1:8000/redocにアクセスしてみてください。 -You will see the alternative automatic documentation (provided by ReDoc): +代替の自動ドキュメントが表示されます。(ReDocが提供しています。): ![ReDoc](https://fastapi.tiangolo.com/img/index/index-02-redoc-simple.png) -## Example upgrade +## アップグレード例 -Now modify the file `main.py` to receive a body from a `PUT` request. +`PUT`リクエストからボディを受け取るために`main.py`を修正しましょう。 -Declare the body using standard Python types, thanks to Pydantic. +Pydantic によって、Python の標準的な型を使ってボディを宣言します。 ```Python hl_lines="2 7 8 9 10 23 24 25" from fastapi import FastAPI @@ -269,137 +269,137 @@ 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). +サーバーは自動でリロードされます。(上述の`uvicorn`コマンドで`--reload`オプションを追加しているからです。) -### Interactive API docs upgrade +### 自動対話型の API ドキュメントのアップグレード -Now go to http://127.0.0.1:8000/docs. +http://127.0.0.1:8000/docsにアクセスしましょう。 -- The interactive API documentation will be automatically updated, including the new body: +- 自動対話型の API ドキュメントが新しいボディも含めて自動でアップデートされます: ![Swagger UI](https://fastapi.tiangolo.com/img/index/index-03-swagger-02.png) -- Click on the button "Try it out", it allows you to fill the parameters and directly interact with the API: +- "Try it out"ボタンをクリックしてください。パラメータを入力して API と直接やりとりすることができます: ![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-04-swagger-03.png) -- 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: +- それから、"Execute" ボタンをクリックしてください。 ユーザーインターフェースは API と通信し、パラメータを送信し、結果を取得して画面に表示します: ![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-05-swagger-04.png) -### Alternative API docs upgrade +### 代替の API ドキュメントのアップグレード -And now, go to http://127.0.0.1:8000/redoc. +http://127.0.0.1:8000/redocにアクセスしましょう。 -- The alternative documentation will also reflect the new query parameter and body: +- 代替の API ドキュメントに新しいクエリパラメータやボディが反映されます。 ![ReDoc](https://fastapi.tiangolo.com/img/index/index-06-redoc-02.png) -### Recap +### リキャップ -In summary, you declare **once** the types of parameters, body, etc. as function parameters. +要約すると、関数のパラメータ、body などの種類を**一度だけ**宣言します。 -You do that with standard modern Python types. +標準的な最新の Python の型を使っています。 -You don't have to learn a new syntax, the methods or classes of a specific library, etc. +新しい構文や特定のライブラリのメソッドやクラスなどを覚える必要はありません。 -Just standard **Python 3.6+**. +単なる標準的な**3.6 以降の Python**です -For example, for an `int`: +例えば、`int`の場合: ```Python item_id: int ``` -or for a more complex `Item` model: +または、より複雑な`Item`モデルの場合: ```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 オブジェクトでも検証が可能です。 +- 入力データの変換: ネットワークから Python のデータや型に変換してから読み取ります: - JSON. - - Path parameters. - - Query parameters. - - Cookies. - - Headers. - - Forms. - - Files. -- Conversion of output data: converting from Python data and types to network data (as JSON): + - パスパラメータ + - クエリパラメータ + - クッキー + - ヘッダー + - フォーム + - ファイル +- 出力データの変換: Python のデータや型からネットワークデータへ変換します (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: + - `datetime` オブジェクト + - `UUID` オブジェクト + - データベースモデル + - ...などなど +- 2 つの代替ユーザーインターフェースを含む自動インタラクティブ API ドキュメント: - Swagger UI. - ReDoc. --- -Coming back to the previous code example, **FastAPI** will: +コード例に戻りましょう、**FastAPI** は次のようになります: -- 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. +- 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 インターフェイスを直接提供します。 --- -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: +...そして、エディタが属性を自動補完し、そのタイプを知る方法をご覧ください。: ![editor support](https://fastapi.tiangolo.com/img/vscode-completion.png) -For a more complete example including more features, see the Tutorial - User Guide. +より多くの機能を含む、より完全な例については、チュートリアル - ユーザーガイドをご覧ください。 -**Spoiler alert**: the tutorial - user guide includes: +**Spoiler alert**: チュートリアル - ユーザーガイドは以下の情報が含まれています: - 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: +- 以下のようなたくさんのおまけ機能(Starlette のおかげです): - **WebSockets** - **GraphQL** - extremely easy tests based on `requests` and `pytest` @@ -409,35 +409,35 @@ For a more complete example including more features, see the one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (\*) +独立した TechEmpower のベンチマークでは、Uvicorn で動作する**FastAPI**アプリケーションのうち、Starlette と Ubicorn の下でのみ利用可能な Python フレームワークの中で最も高速なものの 1 つであることが示されており、Starlette と Uvicorn 自身の下にのみ(FastAPI で内部的に使用されています)(\*) -To understand more about it, see the section Benchmarks. +詳細はベンチマークセクションをご覧ください。 -## Optional Dependencies +## オプションの依存関係 -Used by Pydantic: +Pydantic によって使用されています: -- ujson - for faster JSON "parsing". -- email_validator - for email validation. +- ujson - より速い JSON への"変換". +- email_validator - E メールの検証 -Used by Starlette: +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`. +- requests - `TestClient`を使用するために必要です。 +- aiofiles - `FileResponse` または `StaticFiles`を使用したい場合は必要です。 +- jinja2 - デフォルトのテンプレート設定を使用する場合は必要です。 +- python-multipart - "parsing"`request.form()`からの変換をサポートしたい場合は必要です。 +- itsdangerous - `SessionMiddleware` サポートのためには必要です。 +- pyyaml - Starlette の `SchemaGenerator` サポートのために必要です。 (FastAPI では必要ないでしょう。) +- graphene - `GraphQLApp` サポートのためには必要です。 +- ujson - `UJSONResponse`を使用する場合は必須です。 -Used by FastAPI / Starlette: +FastAPI / Starlette によって使用されています: -- uvicorn - for the server that loads and serves your application. -- orjson - Required if you want to use `ORJSONResponse`. +- uvicorn - アプリケーションをロードしてサービスを提供するサーバーを指定します。 +- orjson - `ORJSONResponse`を使用したい場合は必要です。 -You can install all of these with `pip install fastapi[all]`. +これらは全て `pip install fastapi[all]`でインストールできます。 -## License +## ライセンス -This project is licensed under the terms of the MIT license. +このプロジェクトは MIT ライセンスです。