MCPcopy
hub / github.com/fastapi/fastapi / update_item

Function update_item

docs_src/body_updates/tutorial002_py310.py:29–35  ·  view source on GitHub ↗
(item_id: str, item: Item)

Source from the content-addressed store, hash-verified

27
28@app.patch("/items/{item_id}")
29async def update_item(item_id: str, item: Item) -> Item:
30 stored_item_data = items[item_id]
31 stored_item_model = Item(**stored_item_data)
32 update_data = item.model_dump(exclude_unset=True)
33 updated_item = stored_item_model.model_copy(update=update_data)
34 items[item_id] = jsonable_encoder(updated_item)
35 return updated_item

Callers

nothing calls this directly

Calls 2

jsonable_encoderFunction · 0.90
ItemClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…