From: timothy <53824764+timothy-jeong@users.noreply.github.com>
Date: Fri, 30 May 2025 13:38:33 +0000 (+0900)
Subject: 🌐 Add Korean translation for `docs/ko/docs/tutorial/extra-models.md` (#13063)
X-Git-Tag: 0.115.13~64
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=645d6457378e89fc2b21123db13386197225496e;p=thirdparty%2Ffastapi%2Ffastapi.git
🌐 Add Korean translation for `docs/ko/docs/tutorial/extra-models.md` (#13063)
---
diff --git a/docs/ko/docs/tutorial/extra-models.md b/docs/ko/docs/tutorial/extra-models.md
new file mode 100644
index 0000000000..8e45590613
--- /dev/null
+++ b/docs/ko/docs/tutorial/extra-models.md
@@ -0,0 +1,223 @@
+# ì¶ê° 모ë¸
+
+ì§ë ìì ì ì´ì´ì, ì°ê´ë 모ë¸ì ì¬ë¬ê° ê°ë ê²ì íí ì¼ì
ëë¤.
+
+í¹í ì¬ì©ì 모ë¸ì ê²½ì°ì ê·¸ë¬íë°, ìëíë©´:
+
+* **ì
ë ¥ 모ë¸** ì ë¹ë°ë²í¸ë¥¼ ê°ì ¸ì¼ í©ëë¤.
+* **ì¶ë ¥ 모ë¸** ì ë¹ë°ë²í¸ë¥¼ ê°ì§ë©´ ìë©ëë¤.
+* **ë°ì´í°ë² ì´ì¤ 모ë¸** ì í´ìì²ë¦¬ë ë¹ë°ë²í¸ë¥¼ ê°ì§ ê²ì
ëë¤.
+
+/// danger | ìí
+
+ì ë ì¬ì©ìì ë¹ë°ë²í¸ë¥¼ í문ì¼ë¡ ì ì¥íì§ ë§ì¸ì. íì ì´íì ê²ì¦ ê°ë¥í "ìì í í´ì(secure hash)"ë¡ ì ì¥íì¸ì.
+
+ë§ì½ ì´ê² 무ìì¸ì§ ëª¨ë¥´ê² ë¤ë©´, [security chapters](security/simple-oauth2.md#password-hashing){.internal-link target=_blank}.ìì ë¹ë°ë²í¸ í´ìì ëí´ ë°°ì¸ ì ììµëë¤.
+
+///
+
+## ë¤ì¤ 모ë¸
+
+ìëë ë¹ë°ë²í¸ íëì í´ë¹ íëê° ì¬ì©ëë ìì¹ë¥¼ í¬í¨íì¬, ê° ëª¨ë¸ë¤ì´ ì´ë¤ íí를 ê°ì§ ì ìëì§ ì ë°ì ì¸ ììì
ëë¤:
+
+{* ../../docs_src/extra_models/tutorial001_py310.py hl[7,9,14,20,22,27:28,31:33,38:39] *}
+
+
+/// info | ì ë³´
+
+Pydantic v1ììë í´ë¹ ë©ìëê° `.dict()`ë¡ ë¶ë ¸ì¼ë©°, Pydantic v2ììë `.model_dump()`ë¡ ì´ë¦ì´ ë³ê²½ëììµëë¤. `.dict()`ë ì¬ì í ì§ìëì§ë§ ë ì´ì ê¶ì¥ëì§ ììµëë¤.
+
+ì¬ê¸°ìì ì¬ì©íë ìì ë Pydantic v1ê³¼ì í¸íì±ì ìí´ `.dict()`를 ì¬ì©íì§ë§, Pydantic v2를 ì¬ì©í ì ìë¤ë©´ `.model_dump()`를 ì¬ì©íë ê²ì´ ì¢ìµëë¤.
+
+///
+
+### `**user_in.dict()` ì ëíì¬
+
+#### Pydanticì `.dict()`
+
+`user_in`ì Pydantic ëª¨ë¸ í´ëì¤ì¸ `UserIn`ì
ëë¤.
+
+Pydantic 모ë¸ì ëª¨ë¸ ë°ì´í°ë¥¼ í¬í¨í `dict`를 ë°ííë `.dict()` ë©ìë를 ì ê³µí©ëë¤.
+
+ë°ë¼ì, ë¤ìê³¼ ê°ì´ Pydantic ê°ì²´ `user_in`ì ìì±í ì ììµëë¤:
+
+```Python
+user_in = UserIn(username="john", password="secret", email="john.doe@example.com")
+```
+
+ê·¸ ë¤ì, ë¤ìê³¼ ê°ì´ í¸ì¶í©ëë¤:
+
+```Python
+user_dict = user_in.dict()
+```
+
+ì´ì ë³ì `user_dict`ì ë°ì´í°ê° í¬í¨ë `dict`를 ê°ì§ê² ë©ëë¤(ì´ë Pydantic ëª¨ë¸ ê°ì²´ê° ìë `dict`ì
ëë¤).
+
+ê·¸ë¦¬ê³ ë¤ìê³¼ ê°ì´ í¸ì¶íë©´:
+
+```Python
+print(user_dict)
+```
+
+Pythonì `dict`ê° ë¤ìê³¼ ê°ì´ ì¶ë ¥ë©ëë¤:
+
+```Python
+{
+ 'username': 'john',
+ 'password': 'secret',
+ 'email': 'john.doe@example.com',
+ 'full_name': None,
+}
+```
+
+#### `dict` ì¸í¨í¹(Unpacking)
+
+`user_dict`ì ê°ì `dict`를 í¨ì(ëë í´ëì¤)ì `**user_dict`ë¡ ì ë¬íë©´, Pythonì ì´ë¥¼ "ì¸í©(unpack)"í©ëë¤. ì´ ê³¼ì ìì `user_dict`ì í¤ì ê°ì ê°ê° í¤-ê° ì¸ìë¡ ì§ì ì ë¬í©ëë¤.
+
+ë°ë¼ì, ììì ìì±í `user_dict`를 ì¬ì©íì¬ ë¤ìê³¼ ê°ì´ ìì±íë©´:
+
+```Python
+UserInDB(**user_dict)
+```
+
+ë¤ìê³¼ ê°ì 결과를 ìì±í©ëë¤:
+
+```Python
+UserInDB(
+ username="john",
+ password="secret",
+ email="john.doe@example.com",
+ full_name=None,
+)
+```
+
+í¹ì ë ì íí ë§íìë©´, `user_dict`를 ì§ì ì¬ì©íë ê²ì, ëì¤ì ì´ë¤ ê°ì´ ì¶ê°ëëë¼ë ìëì ëì¼í í¨ê³¼ë¥¼ ë
ëë¤:
+
+```Python
+UserInDB(
+ username = user_dict["username"],
+ password = user_dict["password"],
+ email = user_dict["email"],
+ full_name = user_dict["full_name"],
+)
+```
+
+#### ë¤ë¥¸ ëª¨ë¸ ë°ì´í°ë¡ ì Pydantic ëª¨ë¸ ìì±
+
+ìì ìì ìì `user_in.dict()`ë¡ë¶í° `user_dict`를 ìì±í ê²ì²ë¼, ìë ì½ëë:
+
+```Python
+user_dict = user_in.dict()
+UserInDB(**user_dict)
+```
+
+ë¤ìê³¼ ëì¼í©ëë¤:
+
+```Python
+UserInDB(**user_in.dict())
+```
+
+...ìëíë©´ `user_in.dict()`ë `dict`ì´ë©°, ì´ë¥¼ `**`ë¡ Pythonì´ "ì¸í©(unpack)"íëë¡ íì¬ `UserInDB`ì ì ë¬í기 ë문ì
ëë¤.
+
+ë°ë¼ì, ë¤ë¥¸ Pydantic 모ë¸ì ë°ì´í°ë¥¼ ì¬ì©íì¬ ìë¡ì´ Pydantic 모ë¸ì ìì±í ì ììµëë¤.
+
+#### `dict` ì¸í¨í¹(Unpacking)ê³¼ ì¶ê° í¤ìë
+
+ê·¸ë¦¬ê³ ë¤ìê³¼ ê°ì´ ì¶ê° í¤ìë ì¸ì `hashed_password=hashed_password`를 ì¶ê°íë©´:
+
+```Python
+UserInDB(**user_in.dict(), hashed_password=hashed_password)
+```
+
+ë¤ìê³¼ ê°ì 결과를 ìì±í©ëë¤:
+
+```Python
+UserInDB(
+ username = user_dict["username"],
+ password = user_dict["password"],
+ email = user_dict["email"],
+ full_name = user_dict["full_name"],
+ hashed_password = hashed_password,
+)
+```
+
+/// warning | ê²½ê³
+
+ì¶ê°ì ì¼ë¡ ì ê³µë í¨ì `fake_password_hasher`ì `fake_save_user`ë ë°ì´í° íë¦ì ìì°í기 ìí ìì ì¼ ë¿ì´ë©°, ì¤ì ë³´ìì ì ê³µíì§ ììµëë¤.
+
+///
+
+## ì¤ë³µ ì¤ì´ê¸°
+
+ì½ë ì¤ë³µì ì¤ì´ë ê²ì **FastAPI**ì íµì¬ ìì´ëì´ ì¤ íëì
ëë¤.
+
+ì½ë ì¤ë³µì ë²ê·¸, ë³´ì 문ì , ì½ë ë¹ë기í 문ì (í ê³³ì ì
ë°ì´í¸ëìì§ë§ ë¤ë¥¸ ê³³ì ì
ë°ì´í¸ëì§ ìë 문ì ) ë±ì ê°ë¥ì±ì ì¦ê°ìíµëë¤.
+
+ê·¸ë¦¬ê³ ì´ ëª¨ë¸ë¤ì ë§ì ë°ì´í°ë¥¼ ê³µì íë©´ì ìì± ì´ë¦ê³¼ íì
ì ì¤ë³µíê³ ììµëë¤.
+
+ë ëì ë°©ë²ì´ ììµëë¤.
+
+`UserBase` 모ë¸ì ì ì¸íì¬ ë¤ë¥¸ 모ë¸ë¤ì 기본(base)ì¼ë¡ ì¬ì©í ì ììµëë¤. ê·¸ë° ë¤ì ì´ ëª¨ë¸ì ììë°ì ìì±ê³¼ íì
ì ì¸(ì í ì ì¸, ê²ì¦ ë±)ì ììíë ìë¸í´ëì¤ë¥¼ ë§ë¤ ì ììµëë¤.
+
+모ë ë°ì´í° ë³í, ê²ì¦, 문ìí ë±ì ì ìì ì¼ë¡ ìëí ê²ì
ëë¤.
+
+ì´ë ê² íë©´ ê° ëª¨ë¸ ê°ì ì°¨ì´ì ë§ ì ì¸í ì ììµëë¤(í문 `password`ê° ìë ê²½ì°, `hashed_password`ë§ ìë ê²½ì°, í¹ì ë¹ë°ë²í¸ê° ìë ê²½ì°):
+
+{* ../../docs_src/extra_models/tutorial002_py310.py hl[7,13:14,17:18,21:22] *}
+
+## `Union` ëë `anyOf`
+
+ë ê°ì§ ì´ìì íì
ì í¬í¨íë `Union`ì¼ë¡ ìëµì ì ì¸í ì ììµëë¤. ì´ë ìëµì´ ê·¸ ì¤ íëì íì
ì¼ ì ììì ì미í©ëë¤.
+
+OpenAPIììë ì´ë¥¼ `anyOf`ë¡ ì ìí©ëë¤.
+
+ì´ë¥¼ ìí´ íì¤ Python íì
íí¸ì¸ `typing.Union`ì ì¬ì©í ì ììµëë¤:
+
+/// note | ì°¸ê³
+
+`Union`ì ì ìí ëë ë 구체ì ì¸ íì
ì 먼ì í¬í¨íê³ , ë 구체ì ì¸ íì
ì ê·¸ ë¤ì ëì´í´ì¼í©ëë¤. ìë ìì ììë `Union[PlaneItem, CarItem]` 를 ë³´ë©´, ë 구체ì ì¸ `PlaneItem`ì´ `CarItem`ë³´ë¤ ìì ìì¹í©ëë¤.
+
+///
+
+{* ../../docs_src/extra_models/tutorial003_py310.py hl[1,14:15,18:20,33] *}
+
+
+### Python 3.10ìì `Union`
+
+ìì ìì ììë `response_model` ì¸ì ê°ì¼ë¡ `Union[PlaneItem, CarItem]`ì ì ë¬í©ëë¤.
+
+ì´ ê²½ì°, ì´ë¥¼ **íì
ì´ë
¸í
ì´ì
(type annotation)** ì´ ìë **ì¸ì ê°(argument value)** ì¼ë¡ ì ë¬íê³ ì기 ë문ì Python 3.10ììë `Union`ì ì¬ì©í´ì¼ í©ëë¤.
+
+ë§ì½ íì
ì´ë
¸í
ì´ì
ì ì¬ì©íë¤ë©´, ë¤ìê³¼ ê°ì´ ìì§ ë§ë(|)를 ì¬ì©í ì ììµëë¤:
+
+```Python
+some_variable: PlaneItem | CarItem
+```
+
+íì§ë§ ì´ë¥¼ `response_model=PlaneItem | CarItem`ê³¼ ê°ì´ í ë¹íë©´ ìë¬ê° ë°ìí©ëë¤. ì´ë Pythonì´ ì´ë¥¼ íì
ì´ë
¸í
ì´ì
ì¼ë¡ í´ìíì§ ìê³ , `PlaneItem`ê³¼ `CarItem` ì¬ì´ì **ì못ë ì°ì°(invalid operation)**ì ìëí기 ë문ì
ëë¤
+
+## ëª¨ë¸ ë¦¬ì¤í¸
+
+ë§ì°¬ê°ì§ë¡, ê°ì²´ 리ì¤í¸ ííì ìëµì ì ì¸í ìë ììµëë¤.
+
+ì´ë¥¼ ìí´ íì¤ Pythonì `typing.List`를 ì¬ì©íì¸ì(ëë Python 3.9 ì´ìììë ë¨ìí `list`를 ì¬ì©í ì ììµëë¤):
+
+{* ../../docs_src/extra_models/tutorial004_py39.py hl[18] *}
+
+
+## ììì `dict` ìëµ
+
+Pydantic 모ë¸ì ì¬ì©íì§ ìê³ , í¤ì ê°ì íì
ë§ ì ì¸íì¬ íë²í ììì `dict`ë¡ ìëµì ì ì¸í ìë ììµëë¤.
+
+ì´ë Pydantic 모ë¸ì íìí ì í¨í íë/ìì± ì´ë¦ì ì¬ì ì ì ì ìë ê²½ì°ì ì ì©í©ëë¤.
+
+ì´ ê²½ì°, `typing.Dict`를 ì¬ì©í ì ììµëë¤(ëë Python 3.9 ì´ìììë ë¨ìí `dict`를 ì¬ì©í ì ììµëë¤):
+
+{* ../../docs_src/extra_models/tutorial005_py39.py hl[6] *}
+
+
+## ìì½
+
+ì¬ë¬ Pydantic 모ë¸ì ì¬ì©íê³ , ê° ê²½ì°ì ë§ê² ìì ë¡ê² ììíì¸ì.
+
+ìí°í°ê° ìë¡ ë¤ë¥¸ "ìí"를 ê°ì ¸ì¼ íë ê²½ì°, ìí°í°ë¹ ë¨ì¼ ë°ì´í° 모ë¸ì ì¬ì©í íìë ììµëë¤. ì를 ë¤ì´, ì¬ì©ì "ìí°í°"ê° `password`, `password_hash`, ëë ë¹ë°ë²í¸ê° ìë ìí를 í¬í¨í ì ìë ê²½ì°ì²ë¼ ë§ì
ëë¤.