fix: 修正精确搜索与模糊搜索的 response_model

/search/media/{media_id} 与 /search/title 的 response_model 声明为
Response[list[TorrentInfo]],而 SearchChain.async_search_by_id 与
async_search_by_title 实际返回的是 List[Context]。

Context.to_dict() 产出 {meta_info, media_info, torrent_info} 三层结构,
与 TorrentInfo 的字段完全不相交,被 pydantic 按 response_model 序列化后
所有字段都变成 null,接口对外返回一批空壳数据。

改为与同文件 /search/last 一致的 List[_SchemaContext],
由 ResponseAPIRouter 统一包装成 Response[List[Context]]。
This commit is contained in:
sokouu87
2026-08-29 12:20:50 +08:00
parent 8f6e6ad5d0
commit 18c984c072

View File

@@ -432,7 +432,7 @@ async def search_by_id_stream(
@router.get(
"/media/{media_id}",
summary="精确搜索资源",
response_model=_SchemaResponse[list[_SchemaTorrentInfo]],
response_model=List[_SchemaContext],
)
async def search_by_id(
media_id: str,
@@ -513,7 +513,7 @@ async def search_by_title_stream(
@router.get(
"/title",
summary="模糊搜索资源",
response_model=_SchemaResponse[list[_SchemaTorrentInfo]],
response_model=List[_SchemaContext],
)
async def search_by_title(
keyword: Optional[str] = None,