# FastAPI 错误：响应字段的参数无效。

- **ID:** `python/fastapi-multiple-body-parameters`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在未将多个 body 参数嵌入单个 Pydantic 模型的情况下使用它们。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   class Item(BaseModel):
    name: str
    price: float

@app.post('/item')
async def create(item: Item):
    return item
   ```
2. **** (85% 成功率)
   ```
   Use Body(embed=True) for a single param: async def create(item: str = Body(embed=True))
   ```

## 无效尝试

- **** — FastAPI expects a single body; multiple params cause confusion. (90% 失败率)
- **** — Loses validation and type safety. (70% 失败率)
