zod-openapi 3.0.1 → 3.1.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.
@@ -56,12 +56,15 @@ const createBooleanSchema = (_zodBoolean) => ({
56
56
  });
57
57
  const createBrandedSchema = (zodBranded, state) => createSchemaObject(zodBranded._def.type, state, ["brand"]);
58
58
  const createCatchSchema = (zodCatch, state) => createSchemaObject(zodCatch._def.innerType, state, ["catch"]);
59
- const createDateSchema = (_zodDate) => ({
60
- type: "schema",
61
- schema: {
62
- type: "string"
63
- }
64
- });
59
+ const createDateSchema = (_zodDate, state) => {
60
+ var _a;
61
+ return {
62
+ type: "schema",
63
+ schema: ((_a = state.documentOptions) == null ? void 0 : _a.defaultDateSchema) ?? {
64
+ type: "string"
65
+ }
66
+ };
67
+ };
65
68
  const createDefaultSchema = (zodDefault, state) => {
66
69
  const schemaObject = createSchemaObject(zodDefault._def.innerType, state, [
67
70
  "default"
@@ -82,7 +85,7 @@ const createNativeEnumSchema = (zodEnum, state) => {
82
85
  const enumValues = getValidEnumValues(zodEnum._def.values);
83
86
  const { numbers, strings } = sortStringsAndNumbers(enumValues);
84
87
  if (strings.length && numbers.length) {
85
- if (satisfiesVersion(state.components.openapi, "3.1.0"))
88
+ if (satisfiesVersion(state.components.openapi, "3.1.0")) {
86
89
  return {
87
90
  type: "schema",
88
91
  schema: {
@@ -90,6 +93,7 @@ const createNativeEnumSchema = (zodEnum, state) => {
90
93
  enum: [...strings, ...numbers]
91
94
  }
92
95
  };
96
+ }
93
97
  return {
94
98
  type: "schema",
95
99
  schema: {
@@ -1129,11 +1133,11 @@ const mapPrefixItems = (items, state) => {
1129
1133
  return void 0;
1130
1134
  };
1131
1135
  const createUnionSchema = (zodUnion, state) => {
1132
- var _a;
1136
+ var _a, _b;
1133
1137
  const schemas = zodUnion.options.map(
1134
1138
  (option, index) => createSchemaObject(option, state, [`union option ${index}`])
1135
1139
  );
1136
- if ((_a = zodUnion._def.openapi) == null ? void 0 : _a.unionOneOf) {
1140
+ if (((_a = zodUnion._def.openapi) == null ? void 0 : _a.unionOneOf) ?? ((_b = state.documentOptions) == null ? void 0 : _b.unionOneOf)) {
1137
1141
  return {
1138
1142
  type: "schema",
1139
1143
  schema: {
@@ -1211,7 +1215,7 @@ const createSchemaSwitch = (zodSchema, state) => {
1211
1215
  return createTupleSchema(zodSchema, state);
1212
1216
  }
1213
1217
  if (isZodType(zodSchema, "ZodDate")) {
1214
- return createDateSchema();
1218
+ return createDateSchema(zodSchema, state);
1215
1219
  }
1216
1220
  if (isZodType(zodSchema, "ZodPipeline")) {
1217
1221
  return createPipelineSchema(zodSchema, state);
@@ -1361,7 +1365,7 @@ const createSchema = (zodSchema, state, subpath) => {
1361
1365
  }
1362
1366
  return schema.schema;
1363
1367
  };
1364
- const createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1368
+ const createMediaTypeSchema = (schemaObject, components, type, subpath, documentOptions) => {
1365
1369
  if (!schemaObject) {
1366
1370
  return void 0;
1367
1371
  }
@@ -1374,30 +1378,35 @@ const createMediaTypeSchema = (schemaObject, components, type, subpath) => {
1374
1378
  components,
1375
1379
  type,
1376
1380
  path: [],
1377
- visited: /* @__PURE__ */ new Set()
1381
+ visited: /* @__PURE__ */ new Set(),
1382
+ documentOptions
1378
1383
  },
1379
1384
  subpath
1380
1385
  );
1381
1386
  };
1382
- const createMediaTypeObject = (mediaTypeObject, components, type, subpath) => {
1387
+ const createMediaTypeObject = (mediaTypeObject, components, type, subpath, documentOptions) => {
1383
1388
  if (!mediaTypeObject) {
1384
1389
  return void 0;
1385
1390
  }
1386
1391
  return {
1387
1392
  ...mediaTypeObject,
1388
- schema: createMediaTypeSchema(mediaTypeObject.schema, components, type, [
1389
- ...subpath,
1390
- "schema"
1391
- ])
1393
+ schema: createMediaTypeSchema(
1394
+ mediaTypeObject.schema,
1395
+ components,
1396
+ type,
1397
+ [...subpath, "schema"],
1398
+ documentOptions
1399
+ )
1392
1400
  };
1393
1401
  };
1394
- const createContent = (contentObject, components, type, subpath) => Object.entries(contentObject).reduce(
1402
+ const createContent = (contentObject, components, type, subpath, documentOptions) => Object.entries(contentObject).reduce(
1395
1403
  (acc, [mediaType, zodOpenApiMediaTypeObject]) => {
1396
1404
  const mediaTypeObject = createMediaTypeObject(
1397
1405
  zodOpenApiMediaTypeObject,
1398
1406
  components,
1399
1407
  type,
1400
- [...subpath, mediaType]
1408
+ [...subpath, mediaType],
1409
+ documentOptions
1401
1410
  );
1402
1411
  if (mediaTypeObject) {
1403
1412
  acc[mediaType] = mediaTypeObject;
@@ -1407,14 +1416,15 @@ const createContent = (contentObject, components, type, subpath) => Object.entri
1407
1416
  {}
1408
1417
  );
1409
1418
  const createComponentParamRef = (ref) => `#/components/parameters/${ref}`;
1410
- const createBaseParameter = (schema, components, subpath) => {
1419
+ const createBaseParameter = (schema, components, subpath, documentOptions) => {
1411
1420
  var _a, _b, _c;
1412
1421
  const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.param) ?? {};
1413
1422
  const state = {
1414
1423
  components,
1415
1424
  type: "input",
1416
1425
  path: [],
1417
- visited: /* @__PURE__ */ new Set()
1426
+ visited: /* @__PURE__ */ new Set(),
1427
+ documentOptions
1418
1428
  };
1419
1429
  const schemaObject = createSchema(schema, state, [...subpath, "schema"]);
1420
1430
  const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
@@ -1426,7 +1436,7 @@ const createBaseParameter = (schema, components, subpath) => {
1426
1436
  ...required && { required }
1427
1437
  };
1428
1438
  };
1429
- const createParamOrRef = (zodSchema, components, subpath, type, name) => {
1439
+ const createParamOrRef = (zodSchema, components, subpath, type, name, documentOptions) => {
1430
1440
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1431
1441
  const component = components.parameters.get(zodSchema);
1432
1442
  const paramType = ((_c = (_b = (_a = zodSchema._def) == null ? void 0 : _a.openapi) == null ? void 0 : _b.param) == null ? void 0 : _c.in) ?? (component == null ? void 0 : component.in) ?? type;
@@ -1445,7 +1455,12 @@ const createParamOrRef = (zodSchema, components, subpath, type, name) => {
1445
1455
  $ref: createComponentParamRef(component.ref)
1446
1456
  };
1447
1457
  }
1448
- const baseParamOrRef = createBaseParameter(zodSchema, components, subpath);
1458
+ const baseParamOrRef = createBaseParameter(
1459
+ zodSchema,
1460
+ components,
1461
+ subpath,
1462
+ documentOptions
1463
+ );
1449
1464
  if ("$ref" in baseParamOrRef) {
1450
1465
  throw new Error("Unexpected Error: received a reference object");
1451
1466
  }
@@ -1469,59 +1484,82 @@ const createParamOrRef = (zodSchema, components, subpath, type, name) => {
1469
1484
  }
1470
1485
  return paramObject;
1471
1486
  };
1472
- const createParameters = (type, zodObjectType, components, subpath) => {
1487
+ const createParameters = (type, zodObjectType, components, subpath, documentOptions) => {
1473
1488
  if (!zodObjectType) {
1474
1489
  return [];
1475
1490
  }
1476
1491
  const zodObject = getZodObject(zodObjectType).shape;
1477
1492
  return Object.entries(zodObject).map(
1478
- ([key, zodSchema]) => createParamOrRef(zodSchema, components, [...subpath, key], type, key)
1493
+ ([key, zodSchema]) => createParamOrRef(
1494
+ zodSchema,
1495
+ components,
1496
+ [...subpath, key],
1497
+ type,
1498
+ key,
1499
+ documentOptions
1500
+ )
1479
1501
  );
1480
1502
  };
1481
- const createRequestParams = (requestParams, components, subpath) => {
1503
+ const createRequestParams = (requestParams, components, subpath, documentOptions) => {
1482
1504
  if (!requestParams) {
1483
1505
  return [];
1484
1506
  }
1485
- const pathParams = createParameters("path", requestParams.path, components, [
1486
- ...subpath,
1487
- "path"
1488
- ]);
1507
+ const pathParams = createParameters(
1508
+ "path",
1509
+ requestParams.path,
1510
+ components,
1511
+ [...subpath, "path"],
1512
+ documentOptions
1513
+ );
1489
1514
  const queryParams = createParameters(
1490
1515
  "query",
1491
1516
  requestParams.query,
1492
1517
  components,
1493
- [...subpath, "query"]
1518
+ [...subpath, "query"],
1519
+ documentOptions
1494
1520
  );
1495
1521
  const cookieParams = createParameters(
1496
1522
  "cookie",
1497
1523
  requestParams.cookie,
1498
1524
  components,
1499
- [...subpath, "cookie"]
1525
+ [...subpath, "cookie"],
1526
+ documentOptions
1500
1527
  );
1501
1528
  const headerParams = createParameters(
1502
1529
  "header",
1503
1530
  requestParams.header,
1504
1531
  components,
1505
- [...subpath, "header"]
1532
+ [...subpath, "header"],
1533
+ documentOptions
1506
1534
  );
1507
1535
  return [...pathParams, ...queryParams, ...cookieParams, ...headerParams];
1508
1536
  };
1509
- const createManualParameters = (parameters, components, subpath) => (parameters == null ? void 0 : parameters.map((param, index) => {
1537
+ const createManualParameters = (parameters, components, subpath, documentOptions) => (parameters == null ? void 0 : parameters.map((param, index) => {
1510
1538
  if (isAnyZodType(param)) {
1511
- return createParamOrRef(param, components, [
1512
- ...subpath,
1513
- `param index ${index}`
1514
- ]);
1539
+ return createParamOrRef(
1540
+ param,
1541
+ components,
1542
+ [...subpath, `param index ${index}`],
1543
+ void 0,
1544
+ void 0,
1545
+ documentOptions
1546
+ );
1515
1547
  }
1516
1548
  return param;
1517
1549
  })) ?? [];
1518
- const createParametersObject = (parameters, requestParams, components, subpath) => {
1550
+ const createParametersObject = (parameters, requestParams, components, subpath, documentOptions) => {
1519
1551
  const manualParameters = createManualParameters(
1520
1552
  parameters,
1521
1553
  components,
1522
- subpath
1554
+ subpath,
1555
+ documentOptions
1556
+ );
1557
+ const createdParams = createRequestParams(
1558
+ requestParams,
1559
+ components,
1560
+ subpath,
1561
+ documentOptions
1523
1562
  );
1524
- const createdParams = createRequestParams(requestParams, components, subpath);
1525
1563
  const combinedParameters = [
1526
1564
  ...manualParameters,
1527
1565
  ...createdParams
@@ -1549,19 +1587,19 @@ const getZodObject = (schema, type) => {
1549
1587
  throw new Error("failed to find ZodObject in schema");
1550
1588
  };
1551
1589
  const isISpecificationExtension = (key) => key.startsWith("x-");
1552
- const createResponseHeaders = (responseHeaders, components) => {
1590
+ const createResponseHeaders = (responseHeaders, components, documentOptions) => {
1553
1591
  if (!responseHeaders) {
1554
1592
  return void 0;
1555
1593
  }
1556
1594
  if (isAnyZodType(responseHeaders)) {
1557
1595
  return Object.entries(responseHeaders.shape).reduce((acc, [key, zodSchema]) => {
1558
- acc[key] = createHeaderOrRef(zodSchema, components);
1596
+ acc[key] = createHeaderOrRef(zodSchema, components, documentOptions);
1559
1597
  return acc;
1560
1598
  }, {});
1561
1599
  }
1562
1600
  return responseHeaders;
1563
1601
  };
1564
- const createHeaderOrRef = (schema, components) => {
1602
+ const createHeaderOrRef = (schema, components, documentOptions) => {
1565
1603
  var _a, _b, _c;
1566
1604
  const component = components.headers.get(schema);
1567
1605
  if (component && component.type === "complete") {
@@ -1569,7 +1607,7 @@ const createHeaderOrRef = (schema, components) => {
1569
1607
  $ref: createComponentHeaderRef(component.ref)
1570
1608
  };
1571
1609
  }
1572
- const baseHeader = createBaseHeader(schema, components);
1610
+ const baseHeader = createBaseHeader(schema, components, documentOptions);
1573
1611
  if ("$ref" in baseHeader) {
1574
1612
  throw new Error("Unexpected Error: received a reference object");
1575
1613
  }
@@ -1586,14 +1624,15 @@ const createHeaderOrRef = (schema, components) => {
1586
1624
  }
1587
1625
  return baseHeader;
1588
1626
  };
1589
- const createBaseHeader = (schema, components) => {
1627
+ const createBaseHeader = (schema, components, documentOptions) => {
1590
1628
  var _a, _b;
1591
1629
  const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.header) ?? {};
1592
1630
  const state = {
1593
1631
  components,
1594
1632
  type: "output",
1595
1633
  path: [],
1596
- visited: /* @__PURE__ */ new Set()
1634
+ visited: /* @__PURE__ */ new Set(),
1635
+ documentOptions
1597
1636
  };
1598
1637
  const schemaObject = createSchema(schema, state, ["header"]);
1599
1638
  const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
@@ -1604,7 +1643,7 @@ const createBaseHeader = (schema, components) => {
1604
1643
  };
1605
1644
  };
1606
1645
  const createComponentHeaderRef = (ref) => `#/components/headers/${ref}`;
1607
- const createResponse = (responseObject, components, subpath) => {
1646
+ const createResponse = (responseObject, components, subpath, documentOptions) => {
1608
1647
  if ("$ref" in responseObject) {
1609
1648
  return responseObject;
1610
1649
  }
@@ -1613,15 +1652,22 @@ const createResponse = (responseObject, components, subpath) => {
1613
1652
  return { $ref: createComponentResponseRef(component.ref) };
1614
1653
  }
1615
1654
  const { content, headers, ref, ...rest } = responseObject;
1616
- const maybeHeaders = createResponseHeaders(headers, components);
1655
+ const maybeHeaders = createResponseHeaders(
1656
+ headers,
1657
+ components,
1658
+ documentOptions
1659
+ );
1617
1660
  const response = {
1618
1661
  ...rest,
1619
1662
  ...maybeHeaders && { headers: maybeHeaders },
1620
1663
  ...content && {
1621
- content: createContent(content, components, "output", [
1622
- ...subpath,
1623
- "content"
1624
- ])
1664
+ content: createContent(
1665
+ content,
1666
+ components,
1667
+ "output",
1668
+ [...subpath, "content"],
1669
+ documentOptions
1670
+ )
1625
1671
  }
1626
1672
  };
1627
1673
  const responseRef = ref ?? (component == null ? void 0 : component.ref);
@@ -1637,21 +1683,23 @@ const createResponse = (responseObject, components, subpath) => {
1637
1683
  }
1638
1684
  return response;
1639
1685
  };
1640
- const createResponses = (responsesObject, components, subpath) => Object.entries(responsesObject).reduce(
1686
+ const createResponses = (responsesObject, components, subpath, documentOptions) => Object.entries(responsesObject).reduce(
1641
1687
  (acc, [statusCode, responseObject]) => {
1642
1688
  if (isISpecificationExtension(statusCode)) {
1643
1689
  acc[statusCode] = responseObject;
1644
1690
  return acc;
1645
1691
  }
1646
- acc[statusCode] = createResponse(responseObject, components, [
1647
- ...subpath,
1648
- statusCode
1649
- ]);
1692
+ acc[statusCode] = createResponse(
1693
+ responseObject,
1694
+ components,
1695
+ [...subpath, statusCode],
1696
+ documentOptions
1697
+ );
1650
1698
  return acc;
1651
1699
  },
1652
1700
  {}
1653
1701
  );
1654
- const createRequestBody = (requestBodyObject, components, subpath) => {
1702
+ const createRequestBody = (requestBodyObject, components, subpath, documentOptions) => {
1655
1703
  if (!requestBodyObject) {
1656
1704
  return void 0;
1657
1705
  }
@@ -1664,10 +1712,13 @@ const createRequestBody = (requestBodyObject, components, subpath) => {
1664
1712
  const ref = requestBodyObject.ref ?? (component == null ? void 0 : component.ref);
1665
1713
  const requestBody = {
1666
1714
  ...requestBodyObject,
1667
- content: createContent(requestBodyObject.content, components, "input", [
1668
- ...subpath,
1669
- "content"
1670
- ])
1715
+ content: createContent(
1716
+ requestBodyObject.content,
1717
+ components,
1718
+ "input",
1719
+ [...subpath, "content"],
1720
+ documentOptions
1721
+ )
1671
1722
  };
1672
1723
  if (ref) {
1673
1724
  components.requestBodies.set(requestBodyObject, {
@@ -1681,28 +1732,32 @@ const createRequestBody = (requestBodyObject, components, subpath) => {
1681
1732
  }
1682
1733
  return requestBody;
1683
1734
  };
1684
- const createOperation = (operationObject, components, subpath) => {
1735
+ const createOperation = (operationObject, components, subpath, documentOptions) => {
1685
1736
  const { parameters, requestParams, requestBody, responses, ...rest } = operationObject;
1686
1737
  const maybeParameters = createParametersObject(
1687
1738
  parameters,
1688
1739
  requestParams,
1689
1740
  components,
1690
- [...subpath, "parameters"]
1741
+ [...subpath, "parameters"],
1742
+ documentOptions
1691
1743
  );
1692
1744
  const maybeRequestBody = createRequestBody(
1693
1745
  operationObject.requestBody,
1694
1746
  components,
1695
- [...subpath, "request body"]
1747
+ [...subpath, "request body"],
1748
+ documentOptions
1696
1749
  );
1697
1750
  const maybeResponses = createResponses(
1698
1751
  operationObject.responses,
1699
1752
  components,
1700
- [...subpath, "responses"]
1753
+ [...subpath, "responses"],
1754
+ documentOptions
1701
1755
  );
1702
1756
  const maybeCallbacks = createCallbacks(
1703
1757
  operationObject.callbacks,
1704
1758
  components,
1705
- [...subpath, "callbacks"]
1759
+ [...subpath, "callbacks"],
1760
+ documentOptions
1706
1761
  );
1707
1762
  return {
1708
1763
  ...rest,
@@ -1712,7 +1767,7 @@ const createOperation = (operationObject, components, subpath) => {
1712
1767
  ...maybeCallbacks && { callbacks: maybeCallbacks }
1713
1768
  };
1714
1769
  };
1715
- const createPathItem = (pathObject, components, path) => Object.entries(pathObject).reduce(
1770
+ const createPathItem = (pathObject, components, path, documentOptions) => Object.entries(pathObject).reduce(
1716
1771
  (acc, [key, value]) => {
1717
1772
  if (!value) {
1718
1773
  return acc;
@@ -1721,7 +1776,8 @@ const createPathItem = (pathObject, components, path) => Object.entries(pathObje
1721
1776
  acc[key] = createOperation(
1722
1777
  value,
1723
1778
  components,
1724
- [...path, key]
1779
+ [...path, key],
1780
+ documentOptions
1725
1781
  );
1726
1782
  return acc;
1727
1783
  }
@@ -1730,7 +1786,7 @@ const createPathItem = (pathObject, components, path) => Object.entries(pathObje
1730
1786
  },
1731
1787
  {}
1732
1788
  );
1733
- const createPaths = (pathsObject, components) => {
1789
+ const createPaths = (pathsObject, components, documentOptions) => {
1734
1790
  if (!pathsObject) {
1735
1791
  return void 0;
1736
1792
  }
@@ -1740,13 +1796,18 @@ const createPaths = (pathsObject, components) => {
1740
1796
  acc[path] = pathItemObject;
1741
1797
  return acc;
1742
1798
  }
1743
- acc[path] = createPathItem(pathItemObject, components, [path]);
1799
+ acc[path] = createPathItem(
1800
+ pathItemObject,
1801
+ components,
1802
+ [path],
1803
+ documentOptions
1804
+ );
1744
1805
  return acc;
1745
1806
  },
1746
1807
  {}
1747
1808
  );
1748
1809
  };
1749
- const createCallback = (callbackObject, components, subpath) => {
1810
+ const createCallback = (callbackObject, components, subpath, documentOptions) => {
1750
1811
  const { ref, ...callbacks } = callbackObject;
1751
1812
  const callback = Object.entries(
1752
1813
  callbacks
@@ -1755,10 +1816,13 @@ const createCallback = (callbackObject, components, subpath) => {
1755
1816
  acc[callbackName] = pathItemObject;
1756
1817
  return acc;
1757
1818
  }
1758
- acc[callbackName] = createPathItem(pathItemObject, components, [
1759
- ...subpath,
1760
- callbackName
1761
- ]);
1819
+ acc[callbackName] = createPathItem(
1820
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1821
+ pathItemObject,
1822
+ components,
1823
+ [...subpath, callbackName],
1824
+ documentOptions
1825
+ );
1762
1826
  return acc;
1763
1827
  }, {});
1764
1828
  if (ref) {
@@ -1773,7 +1837,7 @@ const createCallback = (callbackObject, components, subpath) => {
1773
1837
  }
1774
1838
  return callback;
1775
1839
  };
1776
- const createCallbacks = (callbacksObject, components, subpath) => {
1840
+ const createCallbacks = (callbacksObject, components, subpath, documentOptions) => {
1777
1841
  if (!callbacksObject) {
1778
1842
  return void 0;
1779
1843
  }
@@ -1783,10 +1847,13 @@ const createCallbacks = (callbacksObject, components, subpath) => {
1783
1847
  acc[callbackName] = callbackObject;
1784
1848
  return acc;
1785
1849
  }
1786
- acc[callbackName] = createCallback(callbackObject, components, [
1787
- ...subpath,
1788
- callbackName
1789
- ]);
1850
+ acc[callbackName] = createCallback(
1851
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1852
+ callbackObject,
1853
+ components,
1854
+ [...subpath, callbackName],
1855
+ documentOptions
1856
+ );
1790
1857
  return acc;
1791
1858
  },
1792
1859
  {}
@@ -1935,16 +2002,34 @@ const createComponentSchemaRef = (schemaRef) => `#/components/schemas/${schemaRe
1935
2002
  const createComponentResponseRef = (responseRef) => `#/components/responses/${responseRef}`;
1936
2003
  const createComponentRequestBodyRef = (requestBodyRef) => `#/components/requestBodies/${requestBodyRef}`;
1937
2004
  const createComponentCallbackRef = (callbackRef) => `#/components/callbacks/${callbackRef}`;
1938
- const createComponents = (componentsObject, components) => {
1939
- const combinedSchemas = createSchemaComponents(componentsObject, components);
2005
+ const createComponents = (componentsObject, components, documentOptions) => {
2006
+ const combinedSchemas = createSchemaComponents(
2007
+ componentsObject,
2008
+ components,
2009
+ documentOptions
2010
+ );
1940
2011
  const combinedParameters = createParamComponents(
1941
2012
  componentsObject,
1942
- components
2013
+ components,
2014
+ documentOptions
2015
+ );
2016
+ const combinedHeaders = createHeaderComponents(
2017
+ componentsObject,
2018
+ components,
2019
+ documentOptions
2020
+ );
2021
+ const combinedResponses = createResponseComponents(
2022
+ components,
2023
+ documentOptions
2024
+ );
2025
+ const combinedRequestBodies = createRequestBodiesComponents(
2026
+ components,
2027
+ documentOptions
2028
+ );
2029
+ const combinedCallbacks = createCallbackComponents(
2030
+ components,
2031
+ documentOptions
1943
2032
  );
1944
- const combinedHeaders = createHeaderComponents(componentsObject, components);
1945
- const combinedResponses = createResponseComponents(components);
1946
- const combinedRequestBodies = createRequestBodiesComponents(components);
1947
- const combinedCallbacks = createCallbackComponents(components);
1948
2033
  const { schemas, parameters, headers, responses, requestBodies, ...rest } = componentsObject;
1949
2034
  const finalComponents = {
1950
2035
  ...rest,
@@ -1957,7 +2042,7 @@ const createComponents = (componentsObject, components) => {
1957
2042
  };
1958
2043
  return Object.keys(finalComponents).length ? finalComponents : void 0;
1959
2044
  };
1960
- const createSchemaComponents = (componentsObject, components) => {
2045
+ const createSchemaComponents = (componentsObject, components, documentOptions) => {
1961
2046
  Array.from(components.schemas).forEach(([schema, { type }], index) => {
1962
2047
  var _a;
1963
2048
  if (type === "manual") {
@@ -1965,7 +2050,8 @@ const createSchemaComponents = (componentsObject, components) => {
1965
2050
  components,
1966
2051
  type: ((_a = schema._def.openapi) == null ? void 0 : _a.refType) ?? "output",
1967
2052
  path: [],
1968
- visited: /* @__PURE__ */ new Set()
2053
+ visited: /* @__PURE__ */ new Set(),
2054
+ documentOptions
1969
2055
  };
1970
2056
  createSchema(schema, state, [`component schema index ${index}`]);
1971
2057
  }
@@ -1996,7 +2082,7 @@ const createSchemaComponents = (componentsObject, components) => {
1996
2082
  }, customComponents);
1997
2083
  return Object.keys(finalComponents).length ? finalComponents : void 0;
1998
2084
  };
1999
- const createParamComponents = (componentsObject, components) => {
2085
+ const createParamComponents = (componentsObject, components, documentOptions) => {
2000
2086
  Array.from(components.parameters).forEach(([schema, component], index) => {
2001
2087
  if (component.type === "manual") {
2002
2088
  createParamOrRef(
@@ -2004,7 +2090,8 @@ const createParamComponents = (componentsObject, components) => {
2004
2090
  components,
2005
2091
  [`component parameter index ${index}`],
2006
2092
  component.in,
2007
- component.ref
2093
+ component.ref,
2094
+ documentOptions
2008
2095
  );
2009
2096
  }
2010
2097
  });
@@ -2033,10 +2120,10 @@ const createParamComponents = (componentsObject, components) => {
2033
2120
  }, customComponents);
2034
2121
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2035
2122
  };
2036
- const createHeaderComponents = (componentsObject, components) => {
2123
+ const createHeaderComponents = (componentsObject, components, documentOptions) => {
2037
2124
  Array.from(components.headers).forEach(([schema, component]) => {
2038
2125
  if (component.type === "manual") {
2039
- createHeaderOrRef(schema, components);
2126
+ createHeaderOrRef(schema, components, documentOptions);
2040
2127
  }
2041
2128
  });
2042
2129
  const headers = componentsObject.headers ?? {};
@@ -2060,10 +2147,15 @@ const createHeaderComponents = (componentsObject, components) => {
2060
2147
  }, customComponents);
2061
2148
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2062
2149
  };
2063
- const createResponseComponents = (components) => {
2150
+ const createResponseComponents = (components, documentOptions) => {
2064
2151
  Array.from(components.responses).forEach(([schema, component], index) => {
2065
2152
  if (component.type === "manual") {
2066
- createResponse(schema, components, [`component response index ${index}`]);
2153
+ createResponse(
2154
+ schema,
2155
+ components,
2156
+ [`component response index ${index}`],
2157
+ documentOptions
2158
+ );
2067
2159
  }
2068
2160
  });
2069
2161
  const finalComponents = Array.from(components.responses).reduce((acc, [_zodType, component]) => {
@@ -2077,12 +2169,15 @@ const createResponseComponents = (components) => {
2077
2169
  }, {});
2078
2170
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2079
2171
  };
2080
- const createRequestBodiesComponents = (components) => {
2172
+ const createRequestBodiesComponents = (components, documentOptions) => {
2081
2173
  Array.from(components.requestBodies).forEach(([schema, component], index) => {
2082
2174
  if (component.type === "manual") {
2083
- createRequestBody(schema, components, [
2084
- `component request body ${index}`
2085
- ]);
2175
+ createRequestBody(
2176
+ schema,
2177
+ components,
2178
+ [`component request body ${index}`],
2179
+ documentOptions
2180
+ );
2086
2181
  }
2087
2182
  });
2088
2183
  const finalComponents = Array.from(components.requestBodies).reduce((acc, [_zodType, component]) => {
@@ -2096,10 +2191,15 @@ const createRequestBodiesComponents = (components) => {
2096
2191
  }, {});
2097
2192
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2098
2193
  };
2099
- const createCallbackComponents = (components) => {
2194
+ const createCallbackComponents = (components, documentOptions) => {
2100
2195
  Array.from(components.callbacks).forEach(([schema, component], index) => {
2101
2196
  if (component.type === "manual") {
2102
- createCallback(schema, components, [`component callback ${index}`]);
2197
+ createCallback(
2198
+ schema,
2199
+ components,
2200
+ [`component callback ${index}`],
2201
+ documentOptions
2202
+ );
2103
2203
  }
2104
2204
  });
2105
2205
  const finalComponents = Array.from(components.callbacks).reduce((acc, [_zodType, component]) => {
@@ -2117,4 +2217,6 @@ exports.createComponents = createComponents;
2117
2217
  exports.createMediaTypeSchema = createMediaTypeSchema;
2118
2218
  exports.createParamOrRef = createParamOrRef;
2119
2219
  exports.createPaths = createPaths;
2220
+ exports.createSchema = createSchema;
2221
+ exports.createSchemaComponents = createSchemaComponents;
2120
2222
  exports.getDefaultComponents = getDefaultComponents;