@omnifyjp/ts 1.2.1 → 1.2.5
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.
|
@@ -90,7 +90,7 @@ export function getPropertyType(property, allSchemas) {
|
|
|
90
90
|
return property.enum;
|
|
91
91
|
}
|
|
92
92
|
if (Array.isArray(property.enum)) {
|
|
93
|
-
return property.enum.map(v => `'${v}'`).join(' | ');
|
|
93
|
+
return property.enum.map(v => `'${typeof v === 'string' ? v : v.value}'`).join(' | ');
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
return TYPE_MAP[property.type] ?? 'string';
|
|
@@ -119,7 +119,7 @@ export function propertyToTSProperties(propertyName, property, schema, allSchema
|
|
|
119
119
|
tsType = compoundField.enumRef;
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
122
|
-
tsType = col.enum.map(v => `'${v}'`).join(' | ');
|
|
122
|
+
tsType = col.enum.map(v => `'${typeof v === 'string' ? v : v.value}'`).join(' | ');
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
else {
|
package/dist/zod-generator.js
CHANGED
|
@@ -216,7 +216,7 @@ function getZodSchemaForType(propDef, _fieldName, options) {
|
|
|
216
216
|
schema = `z.nativeEnum(${propDef.enum})`;
|
|
217
217
|
}
|
|
218
218
|
else if (Array.isArray(propDef.enum)) {
|
|
219
|
-
const values = propDef.enum.map(v => `'${v}'`).join(', ');
|
|
219
|
+
const values = propDef.enum.map(v => `'${typeof v === 'string' ? v : v.value}'`).join(', ');
|
|
220
220
|
schema = `z.enum([${values}])`;
|
|
221
221
|
}
|
|
222
222
|
else {
|
|
@@ -269,7 +269,7 @@ function generateCompoundTypeSchemas(propName, schema, options) {
|
|
|
269
269
|
}
|
|
270
270
|
else if (col.type === 'Enum' && col.enum) {
|
|
271
271
|
// Inline enum
|
|
272
|
-
const values = col.enum.map(v => `'${v}'`).join(', ');
|
|
272
|
+
const values = col.enum.map(v => `'${typeof v === 'string' ? v : v.value}'`).join(', ');
|
|
273
273
|
zodSchema = `z.enum([${values}])`;
|
|
274
274
|
if (isNullable)
|
|
275
275
|
zodSchema += '.optional().nullable()';
|