New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌐 Add Japanese translation for docs/ja/docs/tutorial/response-model.md
#1938
🌐 Add Japanese translation for docs/ja/docs/tutorial/response-model.md
#1938
Conversation
…/ryuckel/fastapi into feature/add-japanese-translation
Codecov Report
@@ Coverage Diff @@
## master #1938 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 239 239
Lines 7079 7079
=========================================
Hits 7079 7079 Continue to review full report at Codecov.
|
📝 Docs preview for commit 8182bcd at: https://5f3ecaa40cca8f755feb49fd--fastapi.netlify.app |
|
||
ここでは`UserIn`モデルを宣言しています。それは平文のパスワードが含まれています: | ||
|
||
```Python hl_lines="7 9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="9 11"
|
||
そして、このモデルを使用して入力を宣言し、同じモデルを使って出力を宣言しています: | ||
|
||
```Python hl_lines="15 16" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="17 18"
|
||
代わりに、平文のパスワードを持つ入力モデルと、パスワードを持たない出力モデルを作成することができます: | ||
|
||
```Python hl_lines="7 9 14" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="9 11 16"
|
||
ここでは、*path operation関数*がパスワードを含む同じ入力ユーザーを返しているにもかかわらず: | ||
|
||
```Python hl_lines="22" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="24"
|
||
...`response_model`を`UserOut`と宣言したことで、パスワードが含まれていません: | ||
|
||
```Python hl_lines="20" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="22"
|
||
これは`response_model_include`や`response_mode_exclude`を使用していくつかの属性を省略しても、アプリケーションのOpenAPI(とドキュメント)で生成されたJSON Schemaが完全なモデルになるからです。 | ||
|
||
```Python hl_lines="29 35" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="31 37"
|
||
もし`set`を使用することを忘れて、代わりに`list`や`tuple`を使用しても、FastAPIはそれを`set`に変換して正しく動作します: | ||
|
||
```Python hl_lines="29 35" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hl_lines="31 37"
|
||
## まとめ | ||
|
||
*path operationデコレータの*`response_model`パラメータを使用して、レスポンスモデルを定義し、特にプライベートデータがフィルタリングされていることを確認します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path operationデコレータのresponse_model
パラメータを使用して、レスポンスモデルを定義し、特にプライベートデータがフィルタリングされていることを確認します。
@tokusumi |
📝 Docs preview for commit d99da75 at: https://5f4160a0442f8ee17ac9c500--fastapi.netlify.app |
📝 Docs preview for commit bd47a16 at: https://5f4cbfa2b85066092143d2cc--fastapi.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work 👍
Please check out some of the comments I made.
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
Co-authored-by: atsumi <atsumi.tatsuya@gmail.com>
📝 Docs preview for commit f82f73d at: https://5f9aa66b8b8d8319b2fce839--fastapi.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks mostly good.
I pointed out some details.
* 出力データをモデルのデータに限定します。これがどのように重要なのか以下で見ていきましょう。 | ||
|
||
!!! note "技術詳細" | ||
レスポンスモデルは、関数の戻り値のアノテーションではなく、このパラメータで宣言されています。なぜなら、パス関数は実際にはそのレスポンスモデルを返すのではなく、`dict`やデータベースオブジェクト、あるいは他のモデルを返し、`response_model`を使用してフィールドの制限やシリアライズを行うからです。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be a little better to modify "このパラメータ" to "関数のパラメータ" because it's a little hard for readers to undeastand what “この” refers to.
} | ||
``` | ||
|
||
FastAPIは十分に賢いので(実際には、Pydanticが十分に賢い)`description`や`tax`、`tags`はデフォルト値と同じ値を持っているにもかかわらず、明示的に設定されていることを理解しています。(デフォルトから取得するのではなく) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to modify "デフォルトから取得するのではなく" to "デフォルトから取得されたのではなく" because " taken from" is the passive voice.
|
||
### `response_model_include`と`response_model_exclude` | ||
|
||
*path operationデコレータ*として`response_model_include`と`response_model_exclude`も使用することができます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little better to add "のパラメータ" after "path operationデコレータ".
|
||
*path operationデコレータ*として`response_model_include`と`response_model_exclude`も使用することができます。 | ||
|
||
属性名を持つ`str`の`set`を受け取り、含める(残りを省略する)か、除外(残りを含む)します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following sentence is better .
「これらのパラメータは、含める(残りを省略する)もしくは除外(残りを含む)する対象の属性名のstrのsetを受け取ります。」
[理由]
- ベースの文は"They take a set of str"です。
- "str"に"with the name of the attributes"がかかっています。
- "attributes"に"to include (omitting the rest) or to exclude (including the rest)."がかかっています。("attributes"は"include","exclude"の目的語です。)
docs/ja/docs/tutorial/response-model.md
📝 Docs preview for commit b6e0d80 at: https://6499ca738f963504c47ce17f--fastapi.netlify.app |
Thanks @SwftAlpc 🤓 Thanks for the reviews @tokusumi @Attsun1031 ✌️ |
This PR translates the tutorial/response-model.md to Japanese.
Please review tutorial/response-model.md.
Issue #1571 generates a new directory to support Japanese.PR #1656 generates a new directory for tutorial.
I will fix dependency after #1571 & #1656 are merged.