mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 01:28:37 +00:00
fix(plugins): guard legacy zod schemas without toJSONSchema
This commit is contained in:
committed by
Peter Steinberger
parent
dd145f1346
commit
9f4764cd41
17
src/channels/plugins/config-schema.test.ts
Normal file
17
src/channels/plugins/config-schema.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
import { buildChannelConfigSchema } from "./config-schema.js";
|
||||
|
||||
describe("buildChannelConfigSchema", () => {
|
||||
it("builds json schema when toJSONSchema is available", () => {
|
||||
const schema = z.object({ enabled: z.boolean().default(true) });
|
||||
const result = buildChannelConfigSchema(schema);
|
||||
expect(result.schema).toMatchObject({ type: "object" });
|
||||
});
|
||||
|
||||
it("falls back when toJSONSchema is missing (zod v3 plugin compatibility)", () => {
|
||||
const legacySchema = {} as unknown as Parameters<typeof buildChannelConfigSchema>[0];
|
||||
const result = buildChannelConfigSchema(legacySchema);
|
||||
expect(result.schema).toEqual({ type: "object", additionalProperties: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user