mirror of https://github.com/tiangolo/fastapi.git
📝 Update Request Body's `tutorial002` to deal with `tax=0` case (#13230)
Co-authored-by: svlandeg <svlandeg@github.com>
This commit is contained in:
parent
0541693bc7
commit
9667ce87a9
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue