We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
You can continue the conversation there. Go to discussion →
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from typing import Union from fastapi import Body, FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: Union[str, None] = None price: float tax: Union[float, None] = None class User(BaseModel): username: str full_name: Union[str, None] = None @app.put("/items/{item_id}") async def update_item( *, item_id: int, item: Item, user: User, importance: int = Body(gt=0), q: Union[str, None] = None ): results = {"item_id": item_id, "item": item, "user": user, "importance": importance} if q: results.update({"q": q}) return results
教程-用户指南 中的 请求体-多个参数 中的 多个请求体参数和查询参数 中的示例代码出现错误 https://fastapi.tiangolo.com/zh/tutorial/body-multiple-params/#_3
Body参数缺少一个位置参数,即TypeError: Body() missing 1 required positional argument: 'default'
个人建议改为 Body(..., gt=0),
Windows
No response
无
3.7
The text was updated successfully, but these errors were encountered:
Hi @liufei1997 Maybe you need to update the version of fastapi to 0.78.0. See #4911 (comment)
Sorry, something went wrong.
No branches or pull requests
First Check
Commit to Help
Example Code
Description
教程-用户指南 中的 请求体-多个参数 中的 多个请求体参数和查询参数 中的示例代码出现错误
https://fastapi.tiangolo.com/zh/tutorial/body-multiple-params/#_3
Body参数缺少一个位置参数,即TypeError: Body() missing 1 required positional argument: 'default'
个人建议改为 Body(..., gt=0),
Operating System
Windows
Operating System Details
No response
FastAPI Version
无
Python Version
3.7
Additional Context
No response
The text was updated successfully, but these errors were encountered: