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

- **ID:** `python/fastapi-depends-invalid-parameter`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

错误使用`Depends()`，如传递非可调用对象或在响应模型中使用，导致FastAPI抛出错误。

## 版本兼容性

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

## 解决方案

1. **** (100% 成功率)
   ```
   Use `Depends()` correctly: `def endpoint(dep: SomeClass = Depends())` or `def endpoint(dep: SomeClass = Depends(get_dep))`.
   ```
2. **** (95% 成功率)
   ```
   Ensure the dependency function is callable and has correct signature.
   ```

## 无效尝试

- **** — Using `Depends` as a type hint without parentheses, e.g., `def endpoint(dep: Depends):` fails because Depends is a class, not a type. (90% 失败率)
- **** — Putting `Depends` in a Pydantic model field doesn't work; it's only for route parameters. (95% 失败率)
