✨ feat(vscode): FastAPI 接口卡片的调用树带上前端调用它的地方
This commit is contained in:
1 parent
d4459e93b3
commit
29cedcb751
30 files changed
+1316
-130
No files matched your search
@@ -731,9 +731,18 @@ function routeCard(block: FunctionBlock, route: Route, env: Env): RuleCard {
|
||||
...(facts.name && { defines: range(facts.name) }),
|
||||
attributes: { [METHOD_ATTRIBUTE]: route.method },
|
||||
absorbs: [],
|
||||
...(facts.name && endpointOf(route, facts.name.text)),
|
||||
}
|
||||
}
|
||||
|
||||
/** 卡片讲的 HTTP 接口:前缀和装饰器里的路径都是字符串字面量(或不写)才算得出路径;FastAPI 默认的 operationId 是函数名接完整路径和方法。 */
|
||||
function endpointOf(route: Route, fn: string): Pick<RuleCard, 'endpoint'> {
|
||||
const parts = [route.router.prefix, route.path].map(part => part ? stringContent(part)?.text : '')
|
||||
if (parts.includes(undefined))
|
||||
return {}
|
||||
return { endpoint: { method: route.method, path: parts.join(''), operationIdPrefix: `${fn}_` } }
|
||||
}
|
||||
|
||||
/**
|
||||
* 路由器卡片:名称 / 说明 / 前缀 / 标签 / 依赖 / 默认响应(有才显示),接口表列这份文件里挂在它上面的全部接口:
|
||||
* 方法 | 路径(前缀 + 装饰器里的路径,`{参数}` 讲那个函数的参数)| 函数(⌘ + 点击跳到那张接口卡片)| 说明(docstring 第一行)。
|
||||
|
||||
Reference in new issue
Block a user