Skip to content

Commit e55eea5

Browse files
authored
feat(schema): schema support helpers (#57)
* schema, zod detection for tools * server, schema specific log messages
1 parent 6634b01 commit e55eea5

15 files changed

+829
-1474
lines changed

package-lock.json

Lines changed: 4 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"@patternfly/patternfly-component-schemas": "1.2.0",
5252
"fastest-levenshtein": "1.0.16",
5353
"pid-port": "2.0.0",
54-
"zod": "3.25.76"
54+
"zod": "4.2.1"
5555
},
5656
"devDependencies": {
5757
"@cdcabrera/eslint-config-toolkit": "^0.3.0",
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, array input, failFast false 1`] = `
4+
{
5+
"$schema": "https://json-schema.org/draft/2020-12/schema",
6+
}
7+
`;
8+
9+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, array input, failFast true 1`] = `undefined`;
10+
11+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, complex schema, failFast false 1`] = `
12+
{
13+
"$schema": "https://json-schema.org/draft/2020-12/schema",
14+
"additionalProperties": {},
15+
"properties": {
16+
"age": {
17+
"type": "number",
18+
},
19+
"name": {
20+
"type": "string",
21+
},
22+
},
23+
"type": "object",
24+
}
25+
`;
26+
27+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, complex schema, failFast true 1`] = `
28+
{
29+
"$schema": "https://json-schema.org/draft/2020-12/schema",
30+
"additionalProperties": {},
31+
"properties": {
32+
"age": {
33+
"type": "number",
34+
},
35+
"name": {
36+
"type": "string",
37+
},
38+
},
39+
"type": "object",
40+
}
41+
`;
42+
43+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, complex unsupported schema attempt, failFast false 1`] = `
44+
{
45+
"$schema": "https://json-schema.org/draft/2020-12/schema",
46+
"items": {
47+
"type": "string",
48+
},
49+
"type": "array",
50+
}
51+
`;
52+
53+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, complex unsupported schema attempt, failFast true 1`] = `
54+
{
55+
"$schema": "https://json-schema.org/draft/2020-12/schema",
56+
"items": {
57+
"type": "string",
58+
},
59+
"type": "array",
60+
}
61+
`;
62+
63+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, null input with failFast false 1`] = `
64+
{
65+
"$schema": "https://json-schema.org/draft/2020-12/schema",
66+
}
67+
`;
68+
69+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, null input with failFast true 1`] = `undefined`;
70+
71+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, number input, failFast false 1`] = `
72+
{
73+
"$schema": "https://json-schema.org/draft/2020-12/schema",
74+
}
75+
`;
76+
77+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, number input, failFast true 1`] = `undefined`;
78+
79+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, object schema with additionalProperties true, failFast false 1`] = `
80+
{
81+
"$schema": "https://json-schema.org/draft/2020-12/schema",
82+
"additionalProperties": {},
83+
"properties": {},
84+
"type": "object",
85+
}
86+
`;
87+
88+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, object schema with additionalProperties true, failFast true 1`] = `
89+
{
90+
"$schema": "https://json-schema.org/draft/2020-12/schema",
91+
"additionalProperties": {},
92+
"properties": {},
93+
"type": "object",
94+
}
95+
`;
96+
97+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, simple string schema, failFast false 1`] = `
98+
{
99+
"$schema": "https://json-schema.org/draft/2020-12/schema",
100+
"type": "string",
101+
}
102+
`;
103+
104+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, simple string schema, failFast true 1`] = `
105+
{
106+
"$schema": "https://json-schema.org/draft/2020-12/schema",
107+
"type": "string",
108+
}
109+
`;
110+
111+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, string input, failFast false 1`] = `
112+
{
113+
"$schema": "https://json-schema.org/draft/2020-12/schema",
114+
}
115+
`;
116+
117+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, string input, failFast true 1`] = `undefined`;
118+
119+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, undefined input with failFast false 1`] = `
120+
{
121+
"$schema": "https://json-schema.org/draft/2020-12/schema",
122+
}
123+
`;
124+
125+
exports[`jsonSchemaToZod should convert JSON Schema to Zod, undefined input with failFast true 1`] = `undefined`;

0 commit comments

Comments
 (0)