from fastapi import FastAPI app = FastAPI() @app.get("/users/{user_id}/items/{item_id}") async def read_user_item(user_id: int, item_id: str, needy: str, q: str = None, short: bool = False): item = {"item_id": item_id, "owner_id": user_id, "needy": needy} if q: item.update({"q": q}) if not short: item.update({"description": "This is an amazing item that has a long description"}) return item