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

- **ID:** `python/fastapi-query-param-missing-annotation`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在响应模型中定义没有类型注解或无效注解的字段（如`items = []`未指定`List[Item]`），FastAPI在生成响应模式时会失败。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Define the response model with proper type hints: `from typing import List; class ResponseModel(BaseModel): items: List[Item]`
   ```
2. **** (90% 成功率)
   ```
   Use `response_model=List[Item]` in the route decorator instead of a custom model.
   ```

## 无效尝试

- **** — Adding a default value like `items: list = []` still fails if the list type is not specified; FastAPI needs `List[SomeModel]`. (80% 失败率)
- **** — Using `items: Any` works but loses validation and may not be what you want. (70% 失败率)
