-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPath_OperationConfiguration2.py
More file actions
36 lines (30 loc) · 1.51 KB
/
Path_OperationConfiguration2.py
File metadata and controls
36 lines (30 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 엔드포인트에서 사용할 수 있는 매개변수들
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
description: str | None = None
price: float
tax: float | None = None
tags: set[str] = set()
@app.post(
"/items/",
response_model=Item,
summary="Create an item",
#description="Create an item with all the information, name, description, price, tax and a set of unique tags" # description 1
response_description="The created item" # Response에서 나오는 description, fastAPI 기본 값은 'Successful response'
)
async def create_item(item: Item): # description 2
"""
Create an item with all the information:
- **name**: each item must have a name
- **description**: a long description
- **price**: required
- **tax**: if the item doesn't have tax, you can omit this
- **tags**: a set of unique tag strings for this item
"""
return item
@app.get("/elements/", tags=["items"], deprecated=True) # deprecated를 엔드포인트에 사용할 수 있음
async def read_elements():
return [{"item_id", "Foo"}]