diff --git a/packages/napcat-schema/index.ts b/packages/napcat-schema/index.ts index 87ca7351..d644a506 100644 --- a/packages/napcat-schema/index.ts +++ b/packages/napcat-schema/index.ts @@ -215,6 +215,16 @@ function sanitizeSchemaForOpenAPI (schema: T): T { const next: Record = {}; for (const [key, child] of Object.entries(obj)) { + // 特殊处理 properties 容器:只遍历每个属性的 schema,避免将容器对象误判为 schema 元对象 + if (key === 'properties' && child && typeof child === 'object' && !Array.isArray(child)) { + const cleanProps: Record = {}; + for (const [propName, propSchema] of Object.entries(child as Record)) { + cleanProps[propName] = walk(propSchema); + } + next[key] = cleanProps; + continue; + } + if (key === '$id') { if (typeof child === 'string' && child.length > 0) { next['x-schema-id'] = child;