@signe/schema-to-zod 1.4.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -10
- package/tests/validate.spec.ts +2 -3
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -162,16 +162,6 @@ function convertPropertyToZod(
|
|
|
162
162
|
key: string,
|
|
163
163
|
parentSchema: JSONSchema7
|
|
164
164
|
): ZodType<unknown> {
|
|
165
|
-
if (schema.$ref) {
|
|
166
|
-
return z.array(
|
|
167
|
-
z.object({
|
|
168
|
-
value: z.object({
|
|
169
|
-
id: z.string()
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
165
|
if (schema.type === 'object') {
|
|
176
166
|
return z.object(jsonSchemaToZod(schema));
|
|
177
167
|
}
|
package/tests/validate.spec.ts
CHANGED
|
@@ -188,6 +188,7 @@ describe('jsonSchemaToZod', () => {
|
|
|
188
188
|
type: 'object',
|
|
189
189
|
properties: {
|
|
190
190
|
categories: {
|
|
191
|
+
type: 'string',
|
|
191
192
|
$ref: '#/definitions/CategoryList'
|
|
192
193
|
}
|
|
193
194
|
}
|
|
@@ -196,9 +197,7 @@ describe('jsonSchemaToZod', () => {
|
|
|
196
197
|
const zodSchema = z.object(jsonSchemaToZod(schema))
|
|
197
198
|
|
|
198
199
|
expect(zodSchema.safeParse({
|
|
199
|
-
categories:
|
|
200
|
-
{ value: { id: '123' } }
|
|
201
|
-
]
|
|
200
|
+
categories: '123'
|
|
202
201
|
}).success).toBeTruthy()
|
|
203
202
|
|
|
204
203
|
expect(zodSchema.safeParse({
|