@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.js CHANGED
@@ -820,10 +820,12 @@ function isObjectComposableIntersection(node, cyclicSchemas) {
820
820
  }
821
821
  /**
822
822
  * Format a default value as a code-level literal.
823
- * Objects become `{}`, primitives become their string representation, strings are quoted.
823
+ * Arrays keep their contents, other objects become `{}`, primitives become their string
824
+ * representation, strings are quoted.
824
825
  */
825
826
  function formatDefault(value) {
826
827
  if (typeof value === "string") return stringify(value);
828
+ if (Array.isArray(value)) return JSON.stringify(value);
827
829
  if (typeof value === "object" && value !== null) return "{}";
828
830
  return String(value ?? "");
829
831
  }
@@ -838,13 +840,14 @@ function formatDefault(value) {
838
840
  */
839
841
  function defaultLiteral(node, value) {
840
842
  if (value === null) return null;
841
- if (node && ast.narrowSchema(node, "bigint")) {
843
+ const resolved = node ? syncSchemaRef(node) : void 0;
844
+ if (resolved && ast.narrowSchema(resolved, "bigint")) {
842
845
  if (typeof value === "bigint") return `BigInt(${value})`;
843
846
  if (typeof value === "number" && Number.isInteger(value)) return `BigInt(${value})`;
844
847
  return null;
845
848
  }
846
- if (node && ast.narrowSchema(node, "array")) return Array.isArray(value) ? JSON.stringify(value) : null;
847
- const enumNode = node ? ast.narrowSchema(node, "enum") : void 0;
849
+ if (resolved && ast.narrowSchema(resolved, "array")) return Array.isArray(value) ? JSON.stringify(value) : null;
850
+ const enumNode = resolved ? ast.narrowSchema(resolved, "enum") : void 0;
848
851
  if (enumNode) {
849
852
  const values = enumNode.namedEnumValues?.map((member) => member.value) ?? enumNode.enumValues ?? [];
850
853
  if (values.length) {