Browse Source

๐ŸŒ Add Korean translation for `/docs/ko/docs/tutorial/body.md` (#11000)

pull/11038/head
Kani Kim 1 year ago
committed by GitHub
parent
commit
2378cfd56a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 213
      docs/ko/docs/tutorial/body.md

213
docs/ko/docs/tutorial/body.md

@ -0,0 +1,213 @@
# ์š”์ฒญ ๋ณธ๋ฌธ
ํด๋ผ์ด์–ธํŠธ(๋ธŒ๋ผ์šฐ์ €๋ผ๊ณ  ํ•ด๋ด…์‹œ๋‹ค)๋กœ๋ถ€ํ„ฐ ์—ฌ๋Ÿฌ๋ถ„์˜ API๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด์•ผ ํ•  ๋•Œ, **์š”์ฒญ ๋ณธ๋ฌธ**์œผ๋กœ ๋ณด๋ƒ…๋‹ˆ๋‹ค.
**์š”์ฒญ** ๋ณธ๋ฌธ์€ ํด๋ผ์ด์–ธํŠธ์—์„œ API๋กœ ๋ณด๋‚ด์ง€๋Š” ๋ฐ์ดํ„ฐ์ž…๋‹ˆ๋‹ค. **์‘๋‹ต** ๋ณธ๋ฌธ์€ API๊ฐ€ ํด๋ผ์ด์–ธํŠธ๋กœ ๋ณด๋‚ด๋Š” ๋ฐ์ดํ„ฐ์ž…๋‹ˆ๋‹ค.
์—ฌ๋Ÿฌ๋ถ„์˜ API๋Š” ๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ **์‘๋‹ต** ๋ณธ๋ฌธ์„ ๋ณด๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ํด๋ผ์ด์–ธํŠธ๋Š” **์š”์ฒญ** ๋ณธ๋ฌธ์„ ๋งค ๋ฒˆ ๋ณด๋‚ผ ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
**์š”์ฒญ** ๋ณธ๋ฌธ์„ ์„ ์–ธํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ชจ๋“  ๊ฐ•๋ ฅํ•จ๊ณผ ์ด์ ์„ ๊ฐ–์ถ˜ <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
!!! ์ •๋ณด
๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด, (์ข€ ๋” ๋ณดํŽธ์ ์ธ) `POST`, `PUT`, `DELETE` ํ˜น์€ `PATCH` ์ค‘์— ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
`GET` ์š”์ฒญ์— ๋ณธ๋ฌธ์„ ๋‹ด์•„ ๋ณด๋‚ด๋Š” ๊ฒƒ์€ ๋ช…์„ธ์„œ์— ์ •์˜๋˜์ง€ ์•Š์€ ํ–‰๋™์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ , ์ด ๋ฐฉ์‹์€ ์•„์ฃผ ๋ณต์žกํ•œ/๊ทนํ•œ์˜ ์‚ฌ์šฉ ์ƒํ™ฉ์—์„œ๋งŒ FastAPI์— ์˜ํ•ด ์ง€์›๋ฉ๋‹ˆ๋‹ค.
`GET` ์š”์ฒญ์— ๋ณธ๋ฌธ์„ ๋‹ด๋Š” ๊ฒƒ์€ ๊ถŒ์žฅ๋˜์ง€ ์•Š๊ธฐ์—, Swagger UI๊ฐ™์€ ๋Œ€ํ™”ํ˜• ๋ฌธ์„œ์—์„œ๋Š” `GET` ์‚ฌ์šฉ์‹œ ๋‹ด๊ธฐ๋Š” ๋ณธ๋ฌธ์— ๋Œ€ํ•œ ๋ฌธ์„œ๋ฅผ ํ‘œ์‹œํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์ค‘๊ฐ„์— ์žˆ๋Š” ํ”„๋ก์‹œ๋Š” ์ด๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
## Pydantic์˜ `BaseModel` ์ž„ํฌํŠธ
๋จผ์ € `pydantic`์—์„œ `BaseModel`๋ฅผ ์ž„ํฌํŠธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:
=== "Python 3.10+"
```Python hl_lines="2"
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.8+"
```Python hl_lines="4"
{!> ../../../docs_src/body/tutorial001.py!}
```
## ์—ฌ๋Ÿฌ๋ถ„์˜ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ ๋งŒ๋“ค๊ธฐ
`BaseModel`๋ฅผ ์ƒ์†๋ฐ›์€ ํด๋ž˜์Šค๋กœ ์—ฌ๋Ÿฌ๋ถ„์˜ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ์„ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.
๋ชจ๋“  ์–ดํŠธ๋ฆฌ๋ทฐํŠธ์— ๋Œ€ํ•ด ํ‘œ์ค€ ํŒŒ์ด์ฌ ํƒ€์ž…์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:
=== "Python 3.10+"
```Python hl_lines="5-9"
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.8+"
```Python hl_lines="7-11"
{!> ../../../docs_src/body/tutorial001.py!}
```
์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ๋•Œ์™€ ๊ฐ™์ด, ๋ชจ๋ธ ์–ดํŠธ๋ฆฌ๋ทฐํŠธ๊ฐ€ ๊ธฐ๋ณธ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ์–ด๋„ ์ด๋Š” ํ•„์ˆ˜๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ๊ทธ์™ธ์—๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค. ๊ทธ์ € `None`์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ ํƒ์ ์œผ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค๋ฉด, ์œ„์˜ ์ด ๋ชจ๋ธ์€ JSON "`object`" (ํ˜น์€ ํŒŒ์ด์ฌ `dict`)์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค:
```JSON
{
"name": "Foo",
"description": "์„ ํƒ์ ์ธ ์„ค๋ช…๋ž€",
"price": 45.2,
"tax": 3.5
}
```
...`description`๊ณผ `tax`๋Š” (๊ธฐ๋ณธ ๊ฐ’์ด `None`์œผ๋กœ ๋˜์–ด ์žˆ์–ด) ์„ ํƒ์ ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์ด JSON "`object`"๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ƒํ™ฉ์—์„œ๋„ ์œ ํšจํ•ฉ๋‹ˆ๋‹ค:
```JSON
{
"name": "Foo",
"price": 45.2
}
```
## ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ์„œ ์„ ์–ธํ•˜๊ธฐ
์—ฌ๋Ÿฌ๋ถ„์˜ *๊ฒฝ๋กœ ์ž‘๋™*์— ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด, ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜ ๊ทธ๋ฆฌ๊ณ  ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜์—์„œ ์„ ์–ธํ–ˆ๋˜ ๊ฒƒ๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์„ ์–ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
=== "Python 3.10+"
```Python hl_lines="16"
{!> ../../../docs_src/body/tutorial001_py310.py!}
```
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial001.py!}
```
...๊ทธ๋ฆฌ๊ณ  ๋งŒ๋“ค์–ด๋‚ธ ๋ชจ๋ธ์ธ `Item`์œผ๋กœ ํƒ€์ž…์„ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.
## ๊ฒฐ๊ณผ
์œ„์—์„œ์˜ ๋‹จ์ˆœํ•œ ํŒŒ์ด์ฌ ํƒ€์ž… ์„ ์–ธ์œผ๋กœ, **FastAPI**๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค:
* ์š”์ฒญ์˜ ๋ณธ๋ฌธ์„ JSON์œผ๋กœ ์ฝ์–ด ๋“ค์ž…๋‹ˆ๋‹ค.
* (ํ•„์š”ํ•˜๋‹ค๋ฉด) ๋Œ€์‘๋˜๋Š” ํƒ€์ž…์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
* ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ฆํ•ฉ๋‹ˆ๋‹ค.
* ๋งŒ์•ฝ ๋ฐ์ดํ„ฐ๊ฐ€ ์œ ํšจํ•˜์ง€ ์•Š๋‹ค๋ฉด, ์ •ํ™•ํžˆ ์–ด๋–ค ๊ฒƒ์ด ๊ทธ๋ฆฌ๊ณ  ์–ด๋””์—์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์ž˜ ๋ชป ๋˜์—ˆ๋Š”์ง€ ์ง€์‹œํ•˜๋Š” ์นœ์ ˆํ•˜๊ณ  ๋ช…๋ฃŒํ•œ ์—๋Ÿฌ๋ฅผ ๋ฐ˜ํ™˜ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
* ๋งค๊ฐœ๋ณ€์ˆ˜ `item`์— ํฌํ•จ๋œ ์ˆ˜์‹  ๋ฐ์ดํ„ฐ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
* ํ•จ์ˆ˜ ๋‚ด์—์„œ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ `Item` ํƒ€์ž…์œผ๋กœ ์„ ์–ธํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋ชจ๋“  ์–ดํŠธ๋ฆฌ๋ทฐํŠธ์™€ ๊ทธ์— ๋Œ€ํ•œ ํƒ€์ž…์— ๋Œ€ํ•œ ํŽธ์ง‘๊ธฐ ์ง€์›(์™„์„ฑ ๋“ฑ)์„ ๋˜ํ•œ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
* ์—ฌ๋Ÿฌ๋ถ„์˜ ๋ชจ๋ธ์„ ์œ„ํ•œ <a href="https://json-schema.org" class="external-link" target="_blank">JSON ์Šคํ‚ค๋งˆ</a> ์ •์˜๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ๋ถ„์˜ ํ”„๋กœ์ ํŠธ์— ์ ํ•ฉํ•˜๋‹ค๋ฉด ์—ฌ๋Ÿฌ๋ถ„์ด ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ๊ณณ ์–ด๋””์—์„œ๋‚˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
* ์ด๋Ÿฌํ•œ ์Šคํ‚ค๋งˆ๋Š”, ์ƒ์„ฑ๋œ OpenAPI ์Šคํ‚ค๋งˆ ์ผ๋ถ€๊ฐ€ ๋  ๊ฒƒ์ด๋ฉฐ, ์ž๋™ ๋ฌธ์„œํ™” <abbr title="์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค">UI</abbr>์— ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
## ์ž๋™ ๋ฌธ์„œํ™”
๋ชจ๋ธ์˜ JSON ์Šคํ‚ค๋งˆ๋Š” ์ƒ์„ฑ๋œ OpenAPI ์Šคํ‚ค๋งˆ์— ํฌํ•จ๋˜๋ฉฐ ๋Œ€ํ™”ํ˜• API ๋ฌธ์„œ์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค:
<img src="/img/tutorial/body/image01.png">
์ด๋ฅผ ํ•„์š”๋กœ ํ•˜๋Š” ๊ฐ๊ฐ์˜ *๊ฒฝ๋กœ ์ž‘๋™*๋‚ด๋ถ€์˜ API ๋ฌธ์„œ์—๋„ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค:
<img src="/img/tutorial/body/image02.png">
## ํŽธ์ง‘๊ธฐ ์ง€์›
ํŽธ์ง‘๊ธฐ์—์„œ, ํ•จ์ˆ˜ ๋‚ด์—์„œ ํƒ€์ž… ํžŒํŠธ์™€ ์™„์„ฑ์„ ์–ด๋””์„œ๋‚˜ (๋งŒ์•ฝ Pydantic model ๋Œ€์‹ ์— `dict`์„ ๋ฐ›์„ ๊ฒฝ์šฐ ๋‚˜ํƒ€๋‚˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค) ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
<img src="/img/tutorial/body/image03.png">
์ž˜๋ชป๋œ ํƒ€์ž… ์—ฐ์‚ฐ์— ๋Œ€ํ•œ ์—๋Ÿฌ ํ™•์ธ๋„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
<img src="/img/tutorial/body/image04.png">
๋‹จ์ˆœํ•œ ์šฐ์—ฐ์ด ์•„๋‹™๋‹ˆ๋‹ค. ํ”„๋ ˆ์ž„์›Œํฌ ์ „์ฒด๊ฐ€ ์ด๋Ÿฌํ•œ ๋””์ž์ธ์„ ์ค‘์‹ฌ์œผ๋กœ ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
๊ทธ ์–ด๋–ค ์‹คํ–‰ ์ „์—, ๋ชจ๋“  ํŽธ์ง‘๊ธฐ์—์„œ ์ž‘๋™ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ณด์žฅํ•˜๊ธฐ ์œ„ํ•ด ์„ค๊ณ„ ๋‹จ๊ณ„์—์„œ ํ˜น๋…ํ•˜๊ฒŒ ํ…Œ์ŠคํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
์ด๋ฅผ ์ง€์›ํ•˜๊ธฐ ์œ„ํ•ด Pydantic ์ž์ฒด์—์„œ ๋ช‡๋ช‡ ๋ณ€๊ฒฝ์ ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
์ด์ „ ์Šคํฌ๋ฆฐ์ƒท์€ <a href="https://code.visualstudio.com" class="external-link" target="_blank">Visual Studio Code</a>๋ฅผ ์ฐ์€ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ ๋˜‘๊ฐ™์€ ํŽธ์ง‘๊ธฐ ์ง€์›์„ <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">PyCharm</a>์—์„œ ๋ฐ›์„ ์ˆ˜ ์žˆ๊ฑฐ๋‚˜, ๋Œ€๋ถ€๋ถ„์˜ ๋‹ค๋ฅธ ํŽธ์ง‘๊ธฐ์—์„œ๋„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
<img src="/img/tutorial/body/image05.png">
!!! ํŒ
๋งŒ์•ฝ <a href="https://www.jetbrains.com/pycharm/" class="external-link" target="_blank">PyCharm</a>๋ฅผ ํŽธ์ง‘๊ธฐ๋กœ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด, <a href="https://github.com/koxudaxi/pydantic-pycharm-plugin/" class="external-link" target="_blank">Pydantic PyCharm Plugin</a>์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋‹ค์Œ ์‚ฌํ•ญ์„ ํฌํ•จํ•ด Pydantic ๋ชจ๋ธ์— ๋Œ€ํ•œ ํŽธ์ง‘๊ธฐ ์ง€์›์„ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค:
* ์ž๋™ ์™„์„ฑ
* ํƒ€์ž… ํ™•์ธ
* ๋ฆฌํŒฉํ† ๋ง
* ๊ฒ€์ƒ‰
* ์ ๊ฒ€
## ๋ชจ๋ธ ์‚ฌ์šฉํ•˜๊ธฐ
ํ•จ์ˆ˜ ์•ˆ์—์„œ ๋ชจ๋ธ ๊ฐ์ฒด์˜ ๋ชจ๋“  ์–ดํŠธ๋ฆฌ๋ทฐํŠธ์— ์ง์ ‘ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค:
=== "Python 3.10+"
```Python hl_lines="19"
{!> ../../../docs_src/body/tutorial002_py310.py!}
```
=== "Python 3.8+"
```Python hl_lines="21"
{!> ../../../docs_src/body/tutorial002.py!}
```
## ์š”์ฒญ ๋ณธ๋ฌธ + ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜
๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ์š”์ฒญ ๋ณธ๋ฌธ์„ ๋™์‹œ์— ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
**FastAPI**๋Š” ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ์ผ์น˜ํ•˜๋Š” ํ•จ์ˆ˜ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ **๊ฒฝ๋กœ์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค**๋Š” ๊ฒƒ์„ ์ธ์ง€ํ•˜๋ฉฐ, Pydantic ๋ชจ๋ธ๋กœ ์„ ์–ธ๋œ ๊ทธ ํ•จ์ˆ˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” **์š”์ฒญ ๋ณธ๋ฌธ์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค**๋Š” ๊ฒƒ์„ ์ธ์ง€ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
=== "Python 3.10+"
```Python hl_lines="15-16"
{!> ../../../docs_src/body/tutorial003_py310.py!}
```
=== "Python 3.8+"
```Python hl_lines="17-18"
{!> ../../../docs_src/body/tutorial003.py!}
```
## ์š”์ฒญ ๋ณธ๋ฌธ + ๊ฒฝ๋กœ + ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜
**๋ณธ๋ฌธ**, **๊ฒฝ๋กœ** ๊ทธ๋ฆฌ๊ณ  **์ฟผ๋ฆฌ** ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชจ๋‘ ๋™์‹œ์— ์„ ์–ธํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
**FastAPI**๋Š” ๊ฐ๊ฐ์„ ์ธ์ง€ํ•˜๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ์˜ณ๋ฐ”๋ฅธ ์œ„์น˜์— ๊ฐ€์ ธ์˜ฌ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
=== "Python 3.10+"
```Python hl_lines="16"
{!> ../../../docs_src/body/tutorial004_py310.py!}
```
=== "Python 3.8+"
```Python hl_lines="18"
{!> ../../../docs_src/body/tutorial004.py!}
```
ํ•จ์ˆ˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๋‹ค์Œ์„ ๋”ฐ๋ผ์„œ ์ธ์ง€ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค:
* ๋งŒ์•ฝ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ **๊ฒฝ๋กœ**์—๋„ ์„ ์–ธ๋˜์–ด ์žˆ๋‹ค๋ฉด, ์ด๋Š” ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
* ๋งŒ์•ฝ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ (`int`, `float`, `str`, `bool` ๋“ฑ๊ณผ ๊ฐ™์€) **์œ ์ผํ•œ ํƒ€์ž…**์œผ๋กœ ๋˜์–ด์žˆ์œผ๋ฉด, **์ฟผ๋ฆฌ** ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ํ•ด์„๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
* ๋งŒ์•ฝ ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ **Pydantic ๋ชจ๋ธ** ํƒ€์ž…์œผ๋กœ ์„ ์–ธ๋˜์–ด ์žˆ์œผ๋ฉด, ์š”์ฒญ **๋ณธ๋ฌธ**์œผ๋กœ ํ•ด์„๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
!!! ์ฐธ๊ณ 
FastAPI๋Š” `q`์˜ ๊ฐ’์ด ํ•„์š”์—†์Œ์„ ์•Œ๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ๊ฐ’์ด `= None`์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
`Union[str, None]`์— ์žˆ๋Š” `Union`์€ FastAPI์— ์˜ํ•ด ์‚ฌ์šฉ๋œ ๊ฒƒ์ด ์•„๋‹ˆ์ง€๋งŒ, ํŽธ์ง‘๊ธฐ๋กœ ํ•˜์—ฌ๊ธˆ ๋” ๋‚˜์€ ์ง€์›๊ณผ ์—๋Ÿฌ ํƒ์ง€๋ฅผ ์ง€์›ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
## Pydantic์—†์ด
๋งŒ์•ฝ Pydantic ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์ง€ ์•Š๋‹ค๋ฉด, **Body** ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. [Body - ๋‹ค์ค‘ ๋งค๊ฐœ๋ณ€์ˆ˜: ๋ณธ๋ฌธ์— ์žˆ๋Š” ์œ ์ผํ•œ ๊ฐ’](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank} ๋ฌธ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.
Loadingโ€ฆ
Cancel
Save