zod-nest 3.5.0 → 3.7.0
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/README.md +2 -2
- package/dist/index.d.mts +36 -27
- package/dist/index.d.ts +36 -27
- package/dist/index.js +205 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +205 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -624,6 +624,9 @@ var extractDescriptionFields = /* @__PURE__ */ chunkEV5I5HGT_js.__name((desc) =>
|
|
|
624
624
|
const out = {
|
|
625
625
|
description: desc.description
|
|
626
626
|
};
|
|
627
|
+
if (desc.summary !== void 0) {
|
|
628
|
+
out.summary = desc.summary;
|
|
629
|
+
}
|
|
627
630
|
if (desc.headers !== void 0) {
|
|
628
631
|
out.headers = desc.headers;
|
|
629
632
|
}
|
|
@@ -1100,35 +1103,45 @@ var HTTP_METHODS = [
|
|
|
1100
1103
|
];
|
|
1101
1104
|
var ADDITIONAL_OPERATIONS_KEY = "additionalOperations";
|
|
1102
1105
|
var isRecord = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object", "isRecord");
|
|
1103
|
-
var
|
|
1104
|
-
const
|
|
1106
|
+
var operationEntriesOfPathItem = /* @__PURE__ */ chunkEV5I5HGT_js.__name((pathItem) => {
|
|
1107
|
+
const entries = [];
|
|
1105
1108
|
for (const method of HTTP_METHODS) {
|
|
1106
1109
|
const operation = pathItem[method];
|
|
1107
1110
|
if (isRecord(operation)) {
|
|
1108
|
-
|
|
1111
|
+
entries.push({
|
|
1112
|
+
method,
|
|
1113
|
+
operation
|
|
1114
|
+
});
|
|
1109
1115
|
}
|
|
1110
1116
|
}
|
|
1111
1117
|
const additional = pathItem[ADDITIONAL_OPERATIONS_KEY];
|
|
1112
1118
|
if (isRecord(additional)) {
|
|
1113
|
-
for (const operation of Object.
|
|
1119
|
+
for (const [method, operation] of Object.entries(additional)) {
|
|
1114
1120
|
if (isRecord(operation)) {
|
|
1115
|
-
|
|
1121
|
+
entries.push({
|
|
1122
|
+
method,
|
|
1123
|
+
operation
|
|
1124
|
+
});
|
|
1116
1125
|
}
|
|
1117
1126
|
}
|
|
1118
1127
|
}
|
|
1119
|
-
return
|
|
1120
|
-
}, "
|
|
1128
|
+
return entries;
|
|
1129
|
+
}, "operationEntriesOfPathItem");
|
|
1130
|
+
var operationsOfPathItem = /* @__PURE__ */ chunkEV5I5HGT_js.__name((pathItem) => operationEntriesOfPathItem(pathItem).map((entry) => entry.operation), "operationsOfPathItem");
|
|
1121
1131
|
var forEachOperation = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, fn) => {
|
|
1122
1132
|
const paths = doc.paths;
|
|
1123
1133
|
if (!isRecord(paths)) {
|
|
1124
1134
|
return;
|
|
1125
1135
|
}
|
|
1126
|
-
for (const pathItem of Object.
|
|
1136
|
+
for (const [path, pathItem] of Object.entries(paths)) {
|
|
1127
1137
|
if (!isRecord(pathItem)) {
|
|
1128
1138
|
continue;
|
|
1129
1139
|
}
|
|
1130
|
-
for (const operation of
|
|
1131
|
-
fn(operation
|
|
1140
|
+
for (const { method, operation } of operationEntriesOfPathItem(pathItem)) {
|
|
1141
|
+
fn(operation, {
|
|
1142
|
+
path,
|
|
1143
|
+
method
|
|
1144
|
+
});
|
|
1132
1145
|
}
|
|
1133
1146
|
}
|
|
1134
1147
|
}, "forEachOperation");
|
|
@@ -1417,35 +1430,104 @@ var hintFor = /* @__PURE__ */ chunkEV5I5HGT_js.__name((ref, collected) => {
|
|
|
1417
1430
|
return "no DTO with this id was registered \u2014 check for a meta.id typo or a DTO used without createZodDto";
|
|
1418
1431
|
}, "hintFor");
|
|
1419
1432
|
|
|
1420
|
-
// src/document/
|
|
1433
|
+
// src/document/querystring-param.ts
|
|
1434
|
+
var QUERYSTRING_MEDIA_TYPE = "application/x-www-form-urlencoded";
|
|
1421
1435
|
var isPlainRecord3 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isPlainRecord");
|
|
1436
|
+
var buildQuerystringParam = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
1437
|
+
const { dtoId, body } = params;
|
|
1438
|
+
const required = isPlainRecord3(body) && Array.isArray(body.required) && body.required.length > 0;
|
|
1439
|
+
return {
|
|
1440
|
+
name: dtoId,
|
|
1441
|
+
in: "querystring",
|
|
1442
|
+
required,
|
|
1443
|
+
content: {
|
|
1444
|
+
[QUERYSTRING_MEDIA_TYPE]: {
|
|
1445
|
+
schema: {
|
|
1446
|
+
$ref: `${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}${dtoId}`
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
}, "buildQuerystringParam");
|
|
1452
|
+
var hasQueryConflict = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
1453
|
+
const { parameters, pathItemParameters, candidateCount } = params;
|
|
1454
|
+
if (candidateCount > 1) {
|
|
1455
|
+
return true;
|
|
1456
|
+
}
|
|
1457
|
+
return containsQueryParam(parameters) || containsQueryParam(pathItemParameters);
|
|
1458
|
+
}, "hasQueryConflict");
|
|
1459
|
+
var conflictingQueryNames = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters, pathItemParameters) => [
|
|
1460
|
+
...queryNamesOf(parameters),
|
|
1461
|
+
...queryNamesOf(pathItemParameters)
|
|
1462
|
+
], "conflictingQueryNames");
|
|
1463
|
+
var containsQueryParam = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters) => Array.isArray(parameters) && parameters.some(isPlainQueryParam), "containsQueryParam");
|
|
1464
|
+
var queryNamesOf = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters) => {
|
|
1465
|
+
if (!Array.isArray(parameters)) {
|
|
1466
|
+
return [];
|
|
1467
|
+
}
|
|
1468
|
+
const names = [];
|
|
1469
|
+
for (const param of parameters) {
|
|
1470
|
+
if (!isPlainQueryParam(param)) {
|
|
1471
|
+
continue;
|
|
1472
|
+
}
|
|
1473
|
+
names.push(typeof param.name === "string" ? param.name : "<unnamed>");
|
|
1474
|
+
}
|
|
1475
|
+
return names;
|
|
1476
|
+
}, "queryNamesOf");
|
|
1477
|
+
var isPlainQueryParam = /* @__PURE__ */ chunkEV5I5HGT_js.__name((param) => isPlainRecord3(param) && param.in === "query" && param.__zodNestDto !== true, "isPlainQueryParam");
|
|
1478
|
+
|
|
1479
|
+
// src/document/expand-param-markers.ts
|
|
1480
|
+
var isPlainRecord4 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isPlainRecord");
|
|
1422
1481
|
var expandParamMarkers = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
1423
|
-
const { doc, inputSchemas, outputSchemas } = params;
|
|
1424
|
-
const
|
|
1482
|
+
const { doc, inputSchemas, outputSchemas, queryParamStyle } = params;
|
|
1483
|
+
const emitThirtyTwo = params.emitThirtyTwo ?? false;
|
|
1425
1484
|
const schemas = doc.components?.schemas;
|
|
1426
1485
|
const componentIds = schemas !== null && typeof schemas === "object" ? new Set(Object.keys(schemas)) : /* @__PURE__ */ new Set();
|
|
1486
|
+
if (queryParamStyle !== void 0 && emitThirtyTwo) {
|
|
1487
|
+
warnDeprecatedQueryParamStyle();
|
|
1488
|
+
}
|
|
1489
|
+
const context = {
|
|
1490
|
+
inputSchemas,
|
|
1491
|
+
outputSchemas,
|
|
1492
|
+
queryParamStyle,
|
|
1493
|
+
emitThirtyTwo,
|
|
1494
|
+
componentIds
|
|
1495
|
+
};
|
|
1427
1496
|
let expandedAny = false;
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
return;
|
|
1497
|
+
for (const [path, pathItem] of Object.entries(doc.paths ?? {})) {
|
|
1498
|
+
if (!isPlainRecord4(pathItem)) {
|
|
1499
|
+
continue;
|
|
1432
1500
|
}
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1501
|
+
for (const { method, operation } of operationEntriesOfPathItem(pathItem)) {
|
|
1502
|
+
const parameters = operation.parameters;
|
|
1503
|
+
if (!Array.isArray(parameters)) {
|
|
1504
|
+
continue;
|
|
1505
|
+
}
|
|
1506
|
+
const next = expandParameterList(parameters, context, {
|
|
1507
|
+
path,
|
|
1508
|
+
method,
|
|
1509
|
+
pathItemParameters: pathItem.parameters
|
|
1510
|
+
});
|
|
1511
|
+
if (next !== parameters) {
|
|
1512
|
+
operation.parameters = next;
|
|
1513
|
+
expandedAny = true;
|
|
1514
|
+
}
|
|
1442
1515
|
}
|
|
1443
|
-
}
|
|
1516
|
+
}
|
|
1444
1517
|
if (expandedAny) {
|
|
1445
1518
|
pruneOrphanObjectSchema(doc);
|
|
1446
1519
|
}
|
|
1447
1520
|
}, "expandParamMarkers");
|
|
1448
|
-
var expandParameterList = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters, context) => {
|
|
1521
|
+
var expandParameterList = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters, context, scope) => {
|
|
1522
|
+
const candidateCount = countCollapseCandidates(parameters, context);
|
|
1523
|
+
const collapseBlocked = context.emitThirtyTwo && candidateCount > 0 && hasQueryConflict({
|
|
1524
|
+
parameters,
|
|
1525
|
+
pathItemParameters: scope.pathItemParameters,
|
|
1526
|
+
candidateCount
|
|
1527
|
+
});
|
|
1528
|
+
if (collapseBlocked) {
|
|
1529
|
+
warnQuerystringDegraded(scope, parameters, candidateCount);
|
|
1530
|
+
}
|
|
1449
1531
|
let result;
|
|
1450
1532
|
for (let i = 0; i < parameters.length; i++) {
|
|
1451
1533
|
const param = parameters[i];
|
|
@@ -1459,21 +1541,51 @@ var expandParameterList = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters, c
|
|
|
1459
1541
|
}
|
|
1460
1542
|
const map = marker.io === "output" ? context.outputSchemas : context.inputSchemas;
|
|
1461
1543
|
const body = map.get(marker.dtoId);
|
|
1462
|
-
result.push(...resolveMarker(marker, body, context));
|
|
1544
|
+
result.push(...resolveMarker(marker, body, context, collapseBlocked));
|
|
1463
1545
|
}
|
|
1464
1546
|
return result ?? parameters;
|
|
1465
1547
|
}, "expandParameterList");
|
|
1466
|
-
var
|
|
1467
|
-
|
|
1468
|
-
if (marker.
|
|
1548
|
+
var wouldCollapse = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, context) => marker.in === "query" && prefersCollapse(marker, context) && context.componentIds.has(marker.dtoId), "wouldCollapse");
|
|
1549
|
+
var prefersCollapse = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, context) => {
|
|
1550
|
+
if (marker.ref !== void 0) {
|
|
1551
|
+
return marker.ref;
|
|
1552
|
+
}
|
|
1553
|
+
if (context.queryParamStyle !== void 0) {
|
|
1554
|
+
return context.queryParamStyle === "ref";
|
|
1555
|
+
}
|
|
1556
|
+
return context.emitThirtyTwo;
|
|
1557
|
+
}, "prefersCollapse");
|
|
1558
|
+
var countCollapseCandidates = /* @__PURE__ */ chunkEV5I5HGT_js.__name((parameters, context) => {
|
|
1559
|
+
let count = 0;
|
|
1560
|
+
for (const param of parameters) {
|
|
1561
|
+
const marker = readMarker2(param);
|
|
1562
|
+
if (marker !== void 0 && wouldCollapse(marker, context)) {
|
|
1563
|
+
count += 1;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
return count;
|
|
1567
|
+
}, "countCollapseCandidates");
|
|
1568
|
+
var resolveMarker = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, body, context, collapseBlocked) => {
|
|
1569
|
+
if (marker.ref !== void 0 && context.emitThirtyTwo) {
|
|
1570
|
+
warnDeprecatedRefOption(marker.dtoId);
|
|
1571
|
+
}
|
|
1572
|
+
if (collapseBlocked || !wouldCollapse(marker, context)) {
|
|
1573
|
+
return expandOne(marker, body);
|
|
1574
|
+
}
|
|
1575
|
+
if (context.emitThirtyTwo) {
|
|
1469
1576
|
return [
|
|
1470
|
-
|
|
1577
|
+
buildQuerystringParam({
|
|
1578
|
+
dtoId: marker.dtoId,
|
|
1579
|
+
body
|
|
1580
|
+
})
|
|
1471
1581
|
];
|
|
1472
1582
|
}
|
|
1473
|
-
return
|
|
1583
|
+
return [
|
|
1584
|
+
buildRefQueryParam(marker, body)
|
|
1585
|
+
];
|
|
1474
1586
|
}, "resolveMarker");
|
|
1475
1587
|
var buildRefQueryParam = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, body) => {
|
|
1476
|
-
const required =
|
|
1588
|
+
const required = isPlainRecord4(body) && Array.isArray(body.required) && body.required.length > 0;
|
|
1477
1589
|
return {
|
|
1478
1590
|
name: marker.dtoId,
|
|
1479
1591
|
in: "query",
|
|
@@ -1486,7 +1598,7 @@ var buildRefQueryParam = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, body)
|
|
|
1486
1598
|
};
|
|
1487
1599
|
}, "buildRefQueryParam");
|
|
1488
1600
|
var readMarker2 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => {
|
|
1489
|
-
if (!
|
|
1601
|
+
if (!isPlainRecord4(value)) {
|
|
1490
1602
|
return void 0;
|
|
1491
1603
|
}
|
|
1492
1604
|
if (value.__zodNestDto !== true) {
|
|
@@ -1507,7 +1619,7 @@ var readMarker2 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => {
|
|
|
1507
1619
|
return value;
|
|
1508
1620
|
}, "readMarker");
|
|
1509
1621
|
var expandOne = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, body) => {
|
|
1510
|
-
if (!
|
|
1622
|
+
if (!isPlainRecord4(body) || !isPlainRecord4(body.properties)) {
|
|
1511
1623
|
throw new ZodNestDocumentError("UNEXPANDABLE_PARAM_DTO", `Cannot expand \`@${capitalize(marker.in)}() x: ${marker.dtoId}\` \u2014 the DTO's schema is not an object with \`properties\`. Non-body parameter DTOs must be object schemas; arrays, unions, primitives, etc. cannot be split into individual parameters. Use \`@Body()\` for non-object DTOs, or restructure the schema as an object whose fields become the params.`, {
|
|
1512
1624
|
dtoId: marker.dtoId,
|
|
1513
1625
|
in: marker.in,
|
|
@@ -1518,7 +1630,7 @@ var expandOne = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, body) => {
|
|
|
1518
1630
|
const requiredSet = collectRequired(body.required);
|
|
1519
1631
|
const out = [];
|
|
1520
1632
|
for (const [propName, propSchemaRaw] of Object.entries(properties)) {
|
|
1521
|
-
if (!
|
|
1633
|
+
if (!isPlainRecord4(propSchemaRaw)) {
|
|
1522
1634
|
continue;
|
|
1523
1635
|
}
|
|
1524
1636
|
out.push(buildParameter(marker, propName, propSchemaRaw, requiredSet.has(propName)));
|
|
@@ -1551,6 +1663,22 @@ var buildParameter = /* @__PURE__ */ chunkEV5I5HGT_js.__name((marker, name, sche
|
|
|
1551
1663
|
};
|
|
1552
1664
|
}, "buildParameter");
|
|
1553
1665
|
var capitalize = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value.charAt(0).toUpperCase() + value.slice(1), "capitalize");
|
|
1666
|
+
var warnQuerystringDegraded = /* @__PURE__ */ chunkEV5I5HGT_js.__name((scope, parameters, candidateCount) => {
|
|
1667
|
+
console.warn(`[zod-nest] Expanded the query DTO on \`${scope.method.toUpperCase()} ${scope.path}\` per-property instead of emitting \`in: 'querystring'\`: ${degradeReason(scope, parameters, candidateCount)} The expanded form is spec-valid, so the document still ships.`);
|
|
1668
|
+
}, "warnQuerystringDegraded");
|
|
1669
|
+
var degradeReason = /* @__PURE__ */ chunkEV5I5HGT_js.__name((scope, parameters, candidateCount) => {
|
|
1670
|
+
if (candidateCount > 1) {
|
|
1671
|
+
return `OpenAPI 3.2 allows at most one \`querystring\` parameter per operation, and this one has ${candidateCount} query DTOs.`;
|
|
1672
|
+
}
|
|
1673
|
+
const names = conflictingQueryNames(parameters, scope.pathItemParameters);
|
|
1674
|
+
return `OpenAPI 3.2 forbids a \`querystring\` parameter alongside \`in: 'query'\` parameters (${names.map((name) => `\`${name}\``).join(", ")}).`;
|
|
1675
|
+
}, "degradeReason");
|
|
1676
|
+
var warnDeprecatedQueryParamStyle = /* @__PURE__ */ chunkEV5I5HGT_js.__name(() => {
|
|
1677
|
+
console.warn("[zod-nest] `queryParamStyle` is deprecated and will be removed in the next major: OpenAPI 3.2 emits `in: 'querystring'` for named query DTOs by default, which is what this option approximated. Drop it to take the default.");
|
|
1678
|
+
}, "warnDeprecatedQueryParamStyle");
|
|
1679
|
+
var warnDeprecatedRefOption = /* @__PURE__ */ chunkEV5I5HGT_js.__name((dtoId) => {
|
|
1680
|
+
console.warn(`[zod-nest] \`@ZodQuery({ ref })\` on \`${dtoId}\` is deprecated and will be removed in the next major: OpenAPI 3.2 emits \`in: 'querystring'\` for named query DTOs by default. Drop the option to take the default.`);
|
|
1681
|
+
}, "warnDeprecatedRefOption");
|
|
1554
1682
|
var pruneOrphanObjectSchema = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc) => {
|
|
1555
1683
|
const schemas = doc.components?.schemas;
|
|
1556
1684
|
if (schemas === void 0 || !Object.prototype.hasOwnProperty.call(schemas, "Object")) {
|
|
@@ -1622,7 +1750,7 @@ var inlineAnonymousBodies = /* @__PURE__ */ chunkEV5I5HGT_js.__name(({ doc, regi
|
|
|
1622
1750
|
`${anonId}${OUTPUT_SUFFIX}`
|
|
1623
1751
|
]) {
|
|
1624
1752
|
const body = schemas[key];
|
|
1625
|
-
if (
|
|
1753
|
+
if (isPlainRecord5(body)) {
|
|
1626
1754
|
bodyByRef.set(`${chunkJ2MGUXBB_js.COMPONENTS_SCHEMAS_PREFIX}${key}`, body);
|
|
1627
1755
|
}
|
|
1628
1756
|
}
|
|
@@ -1648,7 +1776,7 @@ var refsWithin = /* @__PURE__ */ chunkEV5I5HGT_js.__name((schemas, bodyByRef) =>
|
|
|
1648
1776
|
});
|
|
1649
1777
|
return found;
|
|
1650
1778
|
}, "refsWithin");
|
|
1651
|
-
var
|
|
1779
|
+
var isPlainRecord5 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isPlainRecord");
|
|
1652
1780
|
var inlineRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, bodyByRef) => {
|
|
1653
1781
|
if (Array.isArray(node)) {
|
|
1654
1782
|
for (const item of node) {
|
|
@@ -1656,7 +1784,7 @@ var inlineRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, bodyByRef) => {
|
|
|
1656
1784
|
}
|
|
1657
1785
|
return;
|
|
1658
1786
|
}
|
|
1659
|
-
if (!
|
|
1787
|
+
if (!isPlainRecord5(node)) {
|
|
1660
1788
|
return;
|
|
1661
1789
|
}
|
|
1662
1790
|
const ref = node.$ref;
|
|
@@ -1888,7 +2016,7 @@ var applyRefTitles = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc) => {
|
|
|
1888
2016
|
}
|
|
1889
2017
|
const titleById = /* @__PURE__ */ new Map();
|
|
1890
2018
|
for (const [id, body] of Object.entries(schemas)) {
|
|
1891
|
-
if (
|
|
2019
|
+
if (isPlainRecord6(body) && typeof body.title === "string" && body.title !== "") {
|
|
1892
2020
|
titleById.set(id, body.title);
|
|
1893
2021
|
}
|
|
1894
2022
|
}
|
|
@@ -1898,7 +2026,7 @@ var applyRefTitles = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc) => {
|
|
|
1898
2026
|
addRefTitles(doc.paths, titleById);
|
|
1899
2027
|
addRefTitles(schemas, titleById);
|
|
1900
2028
|
}, "applyRefTitles");
|
|
1901
|
-
var
|
|
2029
|
+
var isPlainRecord6 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isPlainRecord");
|
|
1902
2030
|
var addRefTitles = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, titleById) => {
|
|
1903
2031
|
if (Array.isArray(node)) {
|
|
1904
2032
|
for (const item of node) {
|
|
@@ -1906,7 +2034,7 @@ var addRefTitles = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, titleById) =>
|
|
|
1906
2034
|
}
|
|
1907
2035
|
return;
|
|
1908
2036
|
}
|
|
1909
|
-
if (!
|
|
2037
|
+
if (!isPlainRecord6(node)) {
|
|
1910
2038
|
return;
|
|
1911
2039
|
}
|
|
1912
2040
|
const ref = node.$ref;
|
|
@@ -1921,6 +2049,30 @@ var addRefTitles = /* @__PURE__ */ chunkEV5I5HGT_js.__name((node, titleById) =>
|
|
|
1921
2049
|
}
|
|
1922
2050
|
}, "addRefTitles");
|
|
1923
2051
|
|
|
2052
|
+
// src/document/response-summary.ts
|
|
2053
|
+
var isRecord4 = /* @__PURE__ */ chunkEV5I5HGT_js.__name((value) => value !== null && typeof value === "object", "isRecord");
|
|
2054
|
+
var applyResponseSummary = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts) => {
|
|
2055
|
+
if (opts.emit) {
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
forEachOperation(doc, (operation, { path, method }) => {
|
|
2059
|
+
const responses = operation.responses;
|
|
2060
|
+
if (!isRecord4(responses)) {
|
|
2061
|
+
return;
|
|
2062
|
+
}
|
|
2063
|
+
for (const [status, response] of Object.entries(responses)) {
|
|
2064
|
+
if (!isRecord4(response) || response.summary === void 0) {
|
|
2065
|
+
continue;
|
|
2066
|
+
}
|
|
2067
|
+
delete response.summary;
|
|
2068
|
+
warnDropped(method, path, status);
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
}, "applyResponseSummary");
|
|
2072
|
+
var warnDropped = /* @__PURE__ */ chunkEV5I5HGT_js.__name((method, path, status) => {
|
|
2073
|
+
console.warn(`[zod-nest] Dropped \`summary\` from \`${method.toUpperCase()} ${path}\` response \`${status}\`: OpenAPI 3.1 has no Response Object \`summary\` field. Declare 3.2 via \`DocumentBuilder.setOpenAPIVersion('3.2.0')\` to emit it.`);
|
|
2074
|
+
}, "warnDropped");
|
|
2075
|
+
|
|
1924
2076
|
// src/document/rewrite-refs.ts
|
|
1925
2077
|
var rewriteRefs = /* @__PURE__ */ chunkEV5I5HGT_js.__name((params) => {
|
|
1926
2078
|
const { doc, renames, divergentOutputIds } = params;
|
|
@@ -2030,6 +2182,8 @@ var withForcedExposure = /* @__PURE__ */ chunkEV5I5HGT_js.__name((collected, reg
|
|
|
2030
2182
|
}, "withForcedExposure");
|
|
2031
2183
|
var applyZodNest = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts = {}) => {
|
|
2032
2184
|
const registry = opts.registry ?? chunkJ2MGUXBB_js.defaultRegistry;
|
|
2185
|
+
const openApiVersion = resolveOpenApiVersion(doc);
|
|
2186
|
+
const emitThirtyTwo = openApiVersion.startsWith("3.2.");
|
|
2033
2187
|
const collected = collectUsage(doc, registry);
|
|
2034
2188
|
const exposed = withForcedExposure(collected, registry);
|
|
2035
2189
|
const { inputSchemas, outputSchemas } = bulkEmit({
|
|
@@ -2049,7 +2203,8 @@ var applyZodNest = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts = {}) => {
|
|
|
2049
2203
|
doc,
|
|
2050
2204
|
inputSchemas,
|
|
2051
2205
|
outputSchemas,
|
|
2052
|
-
queryParamStyle: opts.queryParamStyle
|
|
2206
|
+
queryParamStyle: opts.queryParamStyle,
|
|
2207
|
+
emitThirtyTwo
|
|
2053
2208
|
});
|
|
2054
2209
|
rewriteRefs({
|
|
2055
2210
|
doc,
|
|
@@ -2068,12 +2223,14 @@ var applyZodNest = /* @__PURE__ */ chunkEV5I5HGT_js.__name((doc, opts = {}) => {
|
|
|
2068
2223
|
doc,
|
|
2069
2224
|
collected: extended
|
|
2070
2225
|
});
|
|
2071
|
-
|
|
2072
|
-
if (openApiVersion.startsWith("3.2.")) {
|
|
2226
|
+
if (emitThirtyTwo) {
|
|
2073
2227
|
relocateExtensionOperations(doc);
|
|
2074
2228
|
}
|
|
2075
2229
|
applyItemSchema(doc, {
|
|
2076
|
-
emit:
|
|
2230
|
+
emit: emitThirtyTwo
|
|
2231
|
+
});
|
|
2232
|
+
applyResponseSummary(doc, {
|
|
2233
|
+
emit: emitThirtyTwo
|
|
2077
2234
|
});
|
|
2078
2235
|
doc.openapi = openApiVersion;
|
|
2079
2236
|
return doc;
|