@kubb/plugin-zod 5.1.1 → 5.1.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 CHANGED
@@ -830,10 +830,12 @@ function isObjectComposableIntersection(node, cyclicSchemas) {
830
830
  }
831
831
  /**
832
832
  * Format a default value as a code-level literal.
833
- * Objects become `{}`, primitives become their string representation, strings are quoted.
833
+ * Arrays keep their contents, other objects become `{}`, primitives become their string
834
+ * representation, strings are quoted.
834
835
  */
835
836
  function formatDefault(value) {
836
837
  if (typeof value === "string") return stringify(value);
838
+ if (Array.isArray(value)) return JSON.stringify(value);
837
839
  if (typeof value === "object" && value !== null) return "{}";
838
840
  return String(value ?? "");
839
841
  }
@@ -848,13 +850,14 @@ function formatDefault(value) {
848
850
  */
849
851
  function defaultLiteral(node, value) {
850
852
  if (value === null) return null;
851
- if (node && kubb_kit.ast.narrowSchema(node, "bigint")) {
853
+ const resolved = node ? (0, kubb_kit.syncSchemaRef)(node) : void 0;
854
+ if (resolved && kubb_kit.ast.narrowSchema(resolved, "bigint")) {
852
855
  if (typeof value === "bigint") return `BigInt(${value})`;
853
856
  if (typeof value === "number" && Number.isInteger(value)) return `BigInt(${value})`;
854
857
  return null;
855
858
  }
856
- if (node && kubb_kit.ast.narrowSchema(node, "array")) return Array.isArray(value) ? JSON.stringify(value) : null;
857
- const enumNode = node ? kubb_kit.ast.narrowSchema(node, "enum") : void 0;
859
+ if (resolved && kubb_kit.ast.narrowSchema(resolved, "array")) return Array.isArray(value) ? JSON.stringify(value) : null;
860
+ const enumNode = resolved ? kubb_kit.ast.narrowSchema(resolved, "enum") : void 0;
858
861
  if (enumNode) {
859
862
  const values = enumNode.namedEnumValues?.map((member) => member.value) ?? enumNode.enumValues ?? [];
860
863
  if (values.length) {