# fastapi.exceptions.RequestValidationError：字段必填

- **ID:** `python/fastapi-requestvalidationerror-field-required`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

根据 Pydantic 模型，请求体、查询参数或路径参数中缺少必填字段。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   class Item(BaseModel):
    name: str = "default"
   ```
2. **** (90% 成功率)
   ```
   Check the OpenAPI docs at /docs to verify the expected schema and send all required fields.
   ```

## 无效尝试

- **** — Optional without a default still requires the field to be present (can be None). The error persists. (70% 失败率)
- **** — This affects response validation, not request validation. (85% 失败率)
