mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-05 22:26:41 -04:00
📝 Update Request Body's tutorial002 to deal with tax=0 case (#13230)
Co-authored-by: svlandeg <svlandeg@github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ app = FastAPI()
|
||||
@app.post("/items/")
|
||||
async def create_item(item: Item):
|
||||
item_dict = item.dict()
|
||||
if item.tax:
|
||||
if item.tax is not None:
|
||||
price_with_tax = item.price + item.tax
|
||||
item_dict.update({"price_with_tax": price_with_tax})
|
||||
return item_dict
|
||||
|
||||
@@ -15,7 +15,7 @@ app = FastAPI()
|
||||
@app.post("/items/")
|
||||
async def create_item(item: Item):
|
||||
item_dict = item.dict()
|
||||
if item.tax:
|
||||
if item.tax is not None:
|
||||
price_with_tax = item.price + item.tax
|
||||
item_dict.update({"price_with_tax": price_with_tax})
|
||||
return item_dict
|
||||
|
||||
Reference in New Issue
Block a user