mirror of https://github.com/tiangolo/fastapi.git
Merge e0391ac7b5 into 272204c0c7
This commit is contained in:
commit
cdbd9608bb
|
|
@ -14,7 +14,7 @@ app = FastAPI()
|
|||
|
||||
@app.post("/items/")
|
||||
async def create_item(item: Item):
|
||||
item_dict = item.dict()
|
||||
item_dict = item.model_dump()
|
||||
if item.tax is not None:
|
||||
price_with_tax = item.price + item.tax
|
||||
item_dict.update({"price_with_tax": price_with_tax})
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ app = FastAPI()
|
|||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(item_id: int, item: Item):
|
||||
return {"item_id": item_id, **item.dict()}
|
||||
return {"item_id": item_id, **item.model_dump()}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ app = FastAPI()
|
|||
|
||||
@app.put("/items/{item_id}")
|
||||
async def update_item(item_id: int, item: Item, q: str | None = None):
|
||||
result = {"item_id": item_id, **item.dict()}
|
||||
result = {"item_id": item_id, **item.model_dump()}
|
||||
if q:
|
||||
result.update({"q": q})
|
||||
return result
|
||||
|
|
|
|||
Loading…
Reference in New Issue