next-openapi-gen 0.10.0 → 0.10.1
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.
|
@@ -119,7 +119,6 @@ export class DrizzleZodProcessor {
|
|
|
119
119
|
? node.callee.property.name
|
|
120
120
|
: null;
|
|
121
121
|
if (methodName === "optional" ||
|
|
122
|
-
methodName === "nullable" ||
|
|
123
122
|
methodName === "nullish") {
|
|
124
123
|
return true;
|
|
125
124
|
}
|
|
@@ -291,10 +290,13 @@ export class DrizzleZodProcessor {
|
|
|
291
290
|
result.type = "integer";
|
|
292
291
|
break;
|
|
293
292
|
case "optional":
|
|
293
|
+
// Handled by isFieldOptional check, no schema modification needed
|
|
294
|
+
break;
|
|
294
295
|
case "nullable":
|
|
296
|
+
result.nullable = true;
|
|
297
|
+
break;
|
|
295
298
|
case "nullish":
|
|
296
|
-
|
|
297
|
-
// Don't modify the schema here
|
|
299
|
+
result.nullable = true;
|
|
298
300
|
break;
|
|
299
301
|
case "describe":
|
|
300
302
|
if (args.length > 0 && t.isStringLiteral(args[0])) {
|
|
@@ -347,12 +347,8 @@ export class ZodSchemaConverter {
|
|
|
347
347
|
}
|
|
348
348
|
break;
|
|
349
349
|
case "partial":
|
|
350
|
-
// All fields become optional
|
|
350
|
+
// All fields become optional (T | undefined), not nullable
|
|
351
351
|
if (schema.properties) {
|
|
352
|
-
Object.keys(schema.properties).forEach((key) => {
|
|
353
|
-
schema.properties[key].nullable = true;
|
|
354
|
-
});
|
|
355
|
-
// Remove all required
|
|
356
352
|
delete schema.required;
|
|
357
353
|
}
|
|
358
354
|
break;
|
|
@@ -390,14 +386,9 @@ export class ZodSchemaConverter {
|
|
|
390
386
|
}
|
|
391
387
|
break;
|
|
392
388
|
case "required":
|
|
393
|
-
// All fields become required
|
|
389
|
+
// All fields become required — preserve genuine nullable flags
|
|
394
390
|
if (schema.properties) {
|
|
395
|
-
|
|
396
|
-
schema.required = requiredFields;
|
|
397
|
-
// Remove nullable from fields
|
|
398
|
-
Object.keys(schema.properties).forEach((key) => {
|
|
399
|
-
delete schema.properties[key].nullable;
|
|
400
|
-
});
|
|
391
|
+
schema.required = Object.keys(schema.properties);
|
|
401
392
|
}
|
|
402
393
|
break;
|
|
403
394
|
case "extend":
|
|
@@ -418,8 +409,9 @@ export class ZodSchemaConverter {
|
|
|
418
409
|
const propSchema = this.processZodNode(prop.value);
|
|
419
410
|
if (propSchema) {
|
|
420
411
|
extensionProperties[key] = propSchema;
|
|
421
|
-
|
|
422
|
-
|
|
412
|
+
const isOptional =
|
|
413
|
+
// @ts-ignore
|
|
414
|
+
this.isOptional(prop.value) || this.hasOptionalMethod(prop.value);
|
|
423
415
|
if (!isOptional) {
|
|
424
416
|
extensionRequired.push(key);
|
|
425
417
|
}
|
|
@@ -1239,20 +1231,17 @@ export class ZodSchemaConverter {
|
|
|
1239
1231
|
// Apply the current method
|
|
1240
1232
|
switch (methodName) {
|
|
1241
1233
|
case "optional":
|
|
1242
|
-
//
|
|
1243
|
-
//
|
|
1244
|
-
if (!schema.allOf) {
|
|
1245
|
-
schema.nullable = true;
|
|
1246
|
-
}
|
|
1234
|
+
// optional means T | undefined — not in required array, no nullable flag
|
|
1235
|
+
// Required array exclusion is handled by hasOptionalMethod() in processZodObject()
|
|
1247
1236
|
break;
|
|
1248
1237
|
case "nullable":
|
|
1249
|
-
//
|
|
1238
|
+
// nullable means T | null — field stays required but can be null
|
|
1250
1239
|
if (!schema.allOf) {
|
|
1251
1240
|
schema.nullable = true;
|
|
1252
1241
|
}
|
|
1253
1242
|
break;
|
|
1254
|
-
case "nullish": //
|
|
1255
|
-
//
|
|
1243
|
+
case "nullish": // T | null | undefined
|
|
1244
|
+
// Not in required array (handled by hasOptionalMethod) AND can be null
|
|
1256
1245
|
if (!schema.allOf) {
|
|
1257
1246
|
schema.nullable = true;
|
|
1258
1247
|
}
|
|
@@ -1540,7 +1529,6 @@ export class ZodSchemaConverter {
|
|
|
1540
1529
|
if (t.isMemberExpression(node.callee) &&
|
|
1541
1530
|
t.isIdentifier(node.callee.property) &&
|
|
1542
1531
|
(node.callee.property.name === "optional" ||
|
|
1543
|
-
node.callee.property.name === "nullable" ||
|
|
1544
1532
|
node.callee.property.name === "nullish")) {
|
|
1545
1533
|
return true;
|
|
1546
1534
|
}
|
package/package.json
CHANGED