Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/tutorial/header-param-models.md` (#13001)

pull/13018/head
hy.lee 4 months ago
committed by GitHub
parent
commit
f4a023451d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 56
      docs/ko/docs/tutorial/header-param-models.md

56
docs/ko/docs/tutorial/header-param-models.md

@ -0,0 +1,56 @@
# ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชจ๋ธ
๊ด€๋ จ ์žˆ๋Š” **ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜** ๊ทธ๋ฃน์ด ์žˆ๋Š” ๊ฒฝ์šฐ, **Pydantic ๋ชจ๋ธ**์„ ์ƒ์„ฑํ•˜์—ฌ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด๋ฅผ ํ†ตํ•ด **์—ฌ๋Ÿฌ ์œ„์น˜**์—์„œ **๋ชจ๋ธ์„ ์žฌ์‚ฌ์šฉ** ํ•  ์ˆ˜ ์žˆ๊ณ  ๋ชจ๋“  ๋งค๊ฐœ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๋ฐ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํ•œ ๋ฒˆ์— ์„ ์–ธํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜Ž
/// note | ์ฐธ๊ณ 
์ด ๊ธฐ๋Šฅ์€ FastAPI ๋ฒ„์ „ `0.115.0` ์ดํ›„๋ถ€ํ„ฐ ์ง€์›๋ฉ๋‹ˆ๋‹ค. ๐Ÿค“
///
## Pydantic ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•œ ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜
**Pydantic ๋ชจ๋ธ**์— ํ•„์š”ํ•œ **ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜**๋ฅผ ์„ ์–ธํ•œ ๋‹ค์Œ, ํ•ด๋‹น ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ `Header`๋กœ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค:
{* ../../docs_src/header_param_models/tutorial001_an_py310.py hl[9:14,18] *}
**FastAPI**๋Š” ์š”์ฒญ์—์„œ ๋ฐ›์€ **ํ—ค๋”**์—์„œ **๊ฐ ํ•„๋“œ**์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ **์ถ”์ถœ**ํ•˜๊ณ  ์ •์˜ํ•œ Pydantic ๋ชจ๋ธ์„ ์ค๋‹ˆ๋‹ค.
## ๋ฌธ์„œ ํ™•์ธํ•˜๊ธฐ
๋ฌธ์„œ UI `/docs`์—์„œ ํ•„์š”ํ•œ ํ—ค๋”๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
<div class="screenshot">
<img src="/img/tutorial/header-param-models/image01.png">
</div>
## ์ถ”๊ฐ€ ํ—ค๋” ๊ธˆ์ง€ํ•˜๊ธฐ
์ผ๋ถ€ ํŠน๋ณ„ํ•œ ์‚ฌ์šฉ ์‚ฌ๋ก€(ํ”ํ•˜์ง€๋Š” ์•Š๊ฒ ์ง€๋งŒ)์—์„œ๋Š” ์ˆ˜์‹ ํ•˜๋ ค๋Š” ํ—ค๋”๋ฅผ **์ œํ•œ**ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
Pydantic์˜ ๋ชจ๋ธ ๊ตฌ์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ถ”๊ฐ€(`extra`) ํ•„๋“œ๋ฅผ ๊ธˆ์ง€(`forbid`)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
{* ../../docs_src/header_param_models/tutorial002_an_py310.py hl[10] *}
ํด๋ผ์ด์–ธํŠธ๊ฐ€ **์ถ”๊ฐ€ ํ—ค๋”**๋ฅผ ๋ณด๋‚ด๋ ค๊ณ  ์‹œ๋„ํ•˜๋ฉด, **์˜ค๋ฅ˜** ์‘๋‹ต์„ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด, ํด๋ผ์ด์–ธํŠธ๊ฐ€ `plumbus` ๊ฐ’์œผ๋กœ `tool` ํ—ค๋”๋ฅผ ๋ณด๋‚ด๋ ค๊ณ  ํ•˜๋ฉด, ํด๋ผ์ด์–ธํŠธ๋Š” ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜ `tool`์ด ํ—ˆ์šฉ ๋˜์ง€ ์•Š๋Š”๋‹ค๋Š” **์˜ค๋ฅ˜** ์‘๋‹ต์„ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค:
```json
{
"detail": [
{
"type": "extra_forbidden",
"loc": ["header", "tool"],
"msg": "Extra inputs are not permitted",
"input": "plumbus",
}
]
}
```
## ์š”์•ฝ
**Pydantic ๋ชจ๋ธ**์„ ์‚ฌ์šฉํ•˜์—ฌ **FastAPI**์—์„œ **ํ—ค๋”**๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜Ž
Loadingโ€ฆ
Cancel
Save