chore: bump @kevisual/router to version 0.0.80, update QueryApi to handle optional fields in metadata args, and enhance JSON Schema conversion
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { optional } from 'zod';
|
||||
import { createQueryApi } from '../src/query-api.ts';
|
||||
|
||||
// ============ 示例 1: 基础 JSON Schema 推断 ============
|
||||
@@ -9,7 +10,8 @@ const api1 = {
|
||||
"metadata": {
|
||||
"args": {
|
||||
"userId": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"optional": true
|
||||
},
|
||||
"includeProfile": {
|
||||
"type": "boolean"
|
||||
@@ -53,7 +55,8 @@ const api2 = {
|
||||
"domain": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"optional": true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +66,7 @@ const api2 = {
|
||||
|
||||
const queryApi2 = createQueryApi({ api: api2 });
|
||||
|
||||
// ✅ 类型推断正常工作 - data 参数被推断为 { id: string, domain: string }
|
||||
// ✅ 类型推断正常工作 - data 参数被推断为 { id?: string, domain?: string }(没有required字段,所有字段可选)
|
||||
queryApi2.app_domain_manager.get({
|
||||
data: {
|
||||
id: '123',
|
||||
@@ -208,7 +211,8 @@ const api5 = {
|
||||
"type": "string",
|
||||
"enum": ["active", "inactive"] as const
|
||||
}
|
||||
}
|
||||
},
|
||||
// optional: true, // 单个 data 参数是可选的
|
||||
// 没有 required 字段,所以所有字段都是可选的
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user