From e4e1e9abb9f226e8519e0adbf11e4957d791a4ec Mon Sep 17 00:00:00 2001 From: abearxiong Date: Wed, 18 Feb 2026 10:00:26 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E8=87=B30.0.76=EF=BC=8C=E5=B9=B6=E5=9C=A8=20route.ts?= =?UTF-8?q?=20=E4=B8=AD=E6=B7=BB=E5=8A=A0=20extractArgs=20=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +-- src/route.ts | 16 +++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 13bdf55..252bcbb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package", "name": "@kevisual/router", - "version": "0.0.75", + "version": "0.0.76", "description": "", "type": "module", "main": "./dist/router.js", @@ -21,7 +21,6 @@ "keywords": [], "author": "abearxiong", "license": "MIT", - "packageManager": "pnpm@10.30.0", "devDependencies": { "@kevisual/code-builder": "^0.0.6", "@kevisual/context": "^0.0.6", diff --git a/src/route.ts b/src/route.ts index c70d6ba..0877ec1 100644 --- a/src/route.ts +++ b/src/route.ts @@ -245,14 +245,20 @@ export class Route { + if (args && typeof args === 'object' && typeof args.shape === 'object') { + return args.shape as z.ZodRawShape; + } + return args || {}; +}; + export const toJSONSchema = (route: RouteInfo) => { const pickValues = pick(route, pickValue as any); if (pickValues?.metadata?.args) { - const args = pickValues.metadata.args; - if (args && typeof args === 'object' && args.toJSONSchema && typeof args.toJSONSchema === 'function') { - pickValues.metadata.args = args.toJSONSchema(); - return pickValues; - } + let args = pickValues.metadata.args; + // 如果 args 本身是一个 zod object schema,先提取 shape + args = extractArgs(args); + const keys = Object.keys(args); const newArgs: { [key: string]: any } = {}; for (let key of keys) {