@cerios/openapi-to-zod 1.3.1 → 1.3.2
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/cli.js +17 -16
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +17 -16
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5506,7 +5506,7 @@ function generateUnion(schemas, discriminator, isNullable2, context, options, cu
|
|
|
5506
5506
|
);
|
|
5507
5507
|
}
|
|
5508
5508
|
if (schemas.length === 1) {
|
|
5509
|
-
let singleSchema = context.generatePropertySchema(schemas[0], currentSchema);
|
|
5509
|
+
let singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false, true);
|
|
5510
5510
|
if ((options == null ? void 0 : options.passthrough) && !singleSchema.includes(".catchall(")) {
|
|
5511
5511
|
singleSchema = `${singleSchema}.catchall(z.unknown())`;
|
|
5512
5512
|
}
|
|
@@ -5522,7 +5522,7 @@ function generateUnion(schemas, discriminator, isNullable2, context, options, cu
|
|
|
5522
5522
|
console.warn(
|
|
5523
5523
|
`[openapi-to-zod] Warning: Discriminator "${discriminator}" is not required in schemas: ${discriminatorCheck.invalidSchemas.join(", ")}. Falling back to z.union() instead of z.discriminatedUnion().`
|
|
5524
5524
|
);
|
|
5525
|
-
let schemaStrings3 = resolvedSchemas.map((s) => context.generatePropertySchema(s, currentSchema));
|
|
5525
|
+
let schemaStrings3 = resolvedSchemas.map((s) => context.generatePropertySchema(s, currentSchema, false, true));
|
|
5526
5526
|
if (options == null ? void 0 : options.passthrough) {
|
|
5527
5527
|
schemaStrings3 = schemaStrings3.map((s) => s.includes(".catchall(") ? s : `${s}.catchall(z.unknown())`);
|
|
5528
5528
|
}
|
|
@@ -5530,14 +5530,14 @@ function generateUnion(schemas, discriminator, isNullable2, context, options, cu
|
|
|
5530
5530
|
const union3 = `z.union([${schemaStrings3.join(", ")}]).describe("${fallbackDescription}")`;
|
|
5531
5531
|
return wrapNullable(union3, isNullable2);
|
|
5532
5532
|
}
|
|
5533
|
-
let schemaStrings2 = resolvedSchemas.map((s) => context.generatePropertySchema(s, currentSchema));
|
|
5533
|
+
let schemaStrings2 = resolvedSchemas.map((s) => context.generatePropertySchema(s, currentSchema, false, true));
|
|
5534
5534
|
if (options == null ? void 0 : options.passthrough) {
|
|
5535
5535
|
schemaStrings2 = schemaStrings2.map((s) => s.includes(".catchall(") ? s : `${s}.catchall(z.unknown())`);
|
|
5536
5536
|
}
|
|
5537
5537
|
const union2 = `z.discriminatedUnion("${discriminator}", [${schemaStrings2.join(", ")}])`;
|
|
5538
5538
|
return wrapNullable(union2, isNullable2);
|
|
5539
5539
|
}
|
|
5540
|
-
let schemaStrings = schemas.map((s) => context.generatePropertySchema(s, currentSchema));
|
|
5540
|
+
let schemaStrings = schemas.map((s) => context.generatePropertySchema(s, currentSchema, false, true));
|
|
5541
5541
|
if (options == null ? void 0 : options.passthrough) {
|
|
5542
5542
|
schemaStrings = schemaStrings.map((s) => s.includes(".catchall(") ? s : `${s}.catchall(z.unknown())`);
|
|
5543
5543
|
}
|
|
@@ -5597,9 +5597,9 @@ function detectConflictingProperties(schemas, context) {
|
|
|
5597
5597
|
}
|
|
5598
5598
|
return conflicts;
|
|
5599
5599
|
}
|
|
5600
|
-
function generateAllOf(schemas, isNullable2, context, currentSchema
|
|
5600
|
+
function generateAllOf(schemas, isNullable2, context, currentSchema) {
|
|
5601
5601
|
if (schemas.length === 1) {
|
|
5602
|
-
const singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false,
|
|
5602
|
+
const singleSchema = context.generatePropertySchema(schemas[0], currentSchema, false, true);
|
|
5603
5603
|
return wrapNullable(singleSchema, isNullable2);
|
|
5604
5604
|
}
|
|
5605
5605
|
const conflicts = detectConflictingProperties(schemas, context);
|
|
@@ -5613,23 +5613,23 @@ function generateAllOf(schemas, isNullable2, context, currentSchema, explicitNul
|
|
|
5613
5613
|
const allObjects = schemas.every((s) => s.type === "object" || s.properties || s.$ref || s.allOf);
|
|
5614
5614
|
let result;
|
|
5615
5615
|
if (allObjects) {
|
|
5616
|
-
let merged = context.generatePropertySchema(schemas[0], currentSchema, false);
|
|
5616
|
+
let merged = context.generatePropertySchema(schemas[0], currentSchema, false, true);
|
|
5617
5617
|
for (let i = 1; i < schemas.length; i++) {
|
|
5618
5618
|
const schema = schemas[i];
|
|
5619
5619
|
if (schema.$ref) {
|
|
5620
|
-
const refSchema = context.generatePropertySchema(schema, currentSchema, false);
|
|
5620
|
+
const refSchema = context.generatePropertySchema(schema, currentSchema, false, true);
|
|
5621
5621
|
merged = `${merged}.extend(${refSchema}.shape)`;
|
|
5622
5622
|
} else if (context.generateInlineObjectShape && (schema.properties || schema.type === "object")) {
|
|
5623
5623
|
const inlineShape = context.generateInlineObjectShape(schema, currentSchema);
|
|
5624
5624
|
merged = `${merged}.extend(${inlineShape})`;
|
|
5625
5625
|
} else {
|
|
5626
|
-
const schemaString = context.generatePropertySchema(schema, currentSchema, false);
|
|
5626
|
+
const schemaString = context.generatePropertySchema(schema, currentSchema, false, true);
|
|
5627
5627
|
merged = `${merged}.extend(${schemaString}.shape)`;
|
|
5628
5628
|
}
|
|
5629
5629
|
}
|
|
5630
5630
|
result = merged;
|
|
5631
5631
|
} else {
|
|
5632
|
-
const schemaStrings = schemas.map((s) => context.generatePropertySchema(s, currentSchema, false));
|
|
5632
|
+
const schemaStrings = schemas.map((s) => context.generatePropertySchema(s, currentSchema, false, true));
|
|
5633
5633
|
let merged = schemaStrings[0];
|
|
5634
5634
|
for (let i = 1; i < schemaStrings.length; i++) {
|
|
5635
5635
|
merged = `${merged}.and(${schemaStrings[i]})`;
|
|
@@ -6496,17 +6496,16 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6496
6496
|
return wrapNullable(zodUnion, nullable);
|
|
6497
6497
|
}
|
|
6498
6498
|
if (schema.allOf) {
|
|
6499
|
-
const
|
|
6499
|
+
const compositionNullable = isNullable(schema, false);
|
|
6500
6500
|
let composition = generateAllOf(
|
|
6501
6501
|
schema.allOf,
|
|
6502
|
-
|
|
6502
|
+
compositionNullable,
|
|
6503
6503
|
{
|
|
6504
6504
|
generatePropertySchema: this.generatePropertySchema.bind(this),
|
|
6505
6505
|
generateInlineObjectShape: this.generateInlineObjectShape.bind(this),
|
|
6506
6506
|
resolveSchemaRef: this.resolveSchemaRef.bind(this)
|
|
6507
6507
|
},
|
|
6508
|
-
currentSchema
|
|
6509
|
-
explicitNullableFalse
|
|
6508
|
+
currentSchema
|
|
6510
6509
|
);
|
|
6511
6510
|
if (schema.unevaluatedProperties !== void 0) {
|
|
6512
6511
|
composition = this.applyUnevaluatedProperties(composition, schema);
|
|
@@ -6514,11 +6513,12 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6514
6513
|
return composition;
|
|
6515
6514
|
}
|
|
6516
6515
|
if (schema.oneOf) {
|
|
6516
|
+
const compositionNullable = isNullable(schema, false);
|
|
6517
6517
|
const needsPassthrough = schema.unevaluatedProperties !== void 0;
|
|
6518
6518
|
let composition = generateUnion(
|
|
6519
6519
|
schema.oneOf,
|
|
6520
6520
|
(_b = schema.discriminator) == null ? void 0 : _b.propertyName,
|
|
6521
|
-
|
|
6521
|
+
compositionNullable,
|
|
6522
6522
|
{
|
|
6523
6523
|
generatePropertySchema: this.generatePropertySchema.bind(this),
|
|
6524
6524
|
resolveDiscriminatorMapping: this.resolveDiscriminatorMapping.bind(this),
|
|
@@ -6536,11 +6536,12 @@ var _PropertyGenerator = class _PropertyGenerator {
|
|
|
6536
6536
|
return composition;
|
|
6537
6537
|
}
|
|
6538
6538
|
if (schema.anyOf) {
|
|
6539
|
+
const compositionNullable = isNullable(schema, false);
|
|
6539
6540
|
const needsPassthrough = schema.unevaluatedProperties !== void 0;
|
|
6540
6541
|
let composition = generateUnion(
|
|
6541
6542
|
schema.anyOf,
|
|
6542
6543
|
(_d = schema.discriminator) == null ? void 0 : _d.propertyName,
|
|
6543
|
-
|
|
6544
|
+
compositionNullable,
|
|
6544
6545
|
{
|
|
6545
6546
|
generatePropertySchema: this.generatePropertySchema.bind(this),
|
|
6546
6547
|
resolveDiscriminatorMapping: this.resolveDiscriminatorMapping.bind(this),
|