# fastapi.exceptions.FastAPIError: 响应字段参数无效！提示：请检查<class 'models.User'>是否为有效的Pydantic字段类型

- **ID:** `python/fastapi-route-name-conflict-openapi`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

将非Pydantic类作为response_model传递，或在v2下使用了Pydantic v1的BaseModel。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   class UserOut(BaseModel):\n    id: int\n    name: str
   ```
2. **** (85% 成功率)
   ```
   class M(BaseModel):\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n    obj: MyClass
   ```

## 无效尝试

- **** — Removes OpenAPI schema; clients lose type info. (70% 失败率)
- **** — Pydantic v2 uses __get_pydantic_core_schema__; v1 hook ignored. (80% 失败率)
