@composio/json-schema-to-zod 0.1.10-next.1 → 0.1.10-next.3
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.cjs +5 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -407,7 +407,11 @@ function parseObjectProperties(objectSchema, refs) {
|
|
|
407
407
|
path: [...refs.path, "properties", key]
|
|
408
408
|
});
|
|
409
409
|
const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : false;
|
|
410
|
-
|
|
410
|
+
if (!required && propJsonSchema && typeof propJsonSchema === "object" && "default" in propJsonSchema) {
|
|
411
|
+
properties[key] = propZodSchema.optional().default(propJsonSchema.default);
|
|
412
|
+
} else {
|
|
413
|
+
properties[key] = required ? propZodSchema : propZodSchema.optional();
|
|
414
|
+
}
|
|
411
415
|
}
|
|
412
416
|
return z14.object(properties);
|
|
413
417
|
}
|
package/dist/index.js
CHANGED
|
@@ -371,7 +371,11 @@ function parseObjectProperties(objectSchema, refs) {
|
|
|
371
371
|
path: [...refs.path, "properties", key]
|
|
372
372
|
});
|
|
373
373
|
const required = Array.isArray(objectSchema.required) ? objectSchema.required.includes(key) : false;
|
|
374
|
-
|
|
374
|
+
if (!required && propJsonSchema && typeof propJsonSchema === "object" && "default" in propJsonSchema) {
|
|
375
|
+
properties[key] = propZodSchema.optional().default(propJsonSchema.default);
|
|
376
|
+
} else {
|
|
377
|
+
properties[key] = required ? propZodSchema : propZodSchema.optional();
|
|
378
|
+
}
|
|
375
379
|
}
|
|
376
380
|
return z14.object(properties);
|
|
377
381
|
}
|