zod-openapi 3.0.0 → 3.1.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.
@@ -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, documentOptions, type, name) => {
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,80 @@ 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
+ documentOptions,
1498
+ type,
1499
+ key
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
+ documentOptions
1544
+ );
1515
1545
  }
1516
1546
  return param;
1517
1547
  })) ?? [];
1518
- const createParametersObject = (parameters, requestParams, components, subpath) => {
1548
+ const createParametersObject = (parameters, requestParams, components, subpath, documentOptions) => {
1519
1549
  const manualParameters = createManualParameters(
1520
1550
  parameters,
1521
1551
  components,
1522
- subpath
1552
+ subpath,
1553
+ documentOptions
1554
+ );
1555
+ const createdParams = createRequestParams(
1556
+ requestParams,
1557
+ components,
1558
+ subpath,
1559
+ documentOptions
1523
1560
  );
1524
- const createdParams = createRequestParams(requestParams, components, subpath);
1525
1561
  const combinedParameters = [
1526
1562
  ...manualParameters,
1527
1563
  ...createdParams
@@ -1549,19 +1585,19 @@ const getZodObject = (schema, type) => {
1549
1585
  throw new Error("failed to find ZodObject in schema");
1550
1586
  };
1551
1587
  const isISpecificationExtension = (key) => key.startsWith("x-");
1552
- const createResponseHeaders = (responseHeaders, components) => {
1588
+ const createResponseHeaders = (responseHeaders, components, documentOptions) => {
1553
1589
  if (!responseHeaders) {
1554
1590
  return void 0;
1555
1591
  }
1556
1592
  if (isAnyZodType(responseHeaders)) {
1557
1593
  return Object.entries(responseHeaders.shape).reduce((acc, [key, zodSchema]) => {
1558
- acc[key] = createHeaderOrRef(zodSchema, components);
1594
+ acc[key] = createHeaderOrRef(zodSchema, components, documentOptions);
1559
1595
  return acc;
1560
1596
  }, {});
1561
1597
  }
1562
1598
  return responseHeaders;
1563
1599
  };
1564
- const createHeaderOrRef = (schema, components) => {
1600
+ const createHeaderOrRef = (schema, components, documentOptions) => {
1565
1601
  var _a, _b, _c;
1566
1602
  const component = components.headers.get(schema);
1567
1603
  if (component && component.type === "complete") {
@@ -1569,7 +1605,7 @@ const createHeaderOrRef = (schema, components) => {
1569
1605
  $ref: createComponentHeaderRef(component.ref)
1570
1606
  };
1571
1607
  }
1572
- const baseHeader = createBaseHeader(schema, components);
1608
+ const baseHeader = createBaseHeader(schema, components, documentOptions);
1573
1609
  if ("$ref" in baseHeader) {
1574
1610
  throw new Error("Unexpected Error: received a reference object");
1575
1611
  }
@@ -1586,14 +1622,15 @@ const createHeaderOrRef = (schema, components) => {
1586
1622
  }
1587
1623
  return baseHeader;
1588
1624
  };
1589
- const createBaseHeader = (schema, components) => {
1625
+ const createBaseHeader = (schema, components, documentOptions) => {
1590
1626
  var _a, _b;
1591
1627
  const { ref, ...rest } = ((_a = schema._def.openapi) == null ? void 0 : _a.header) ?? {};
1592
1628
  const state = {
1593
1629
  components,
1594
1630
  type: "output",
1595
1631
  path: [],
1596
- visited: /* @__PURE__ */ new Set()
1632
+ visited: /* @__PURE__ */ new Set(),
1633
+ documentOptions
1597
1634
  };
1598
1635
  const schemaObject = createSchema(schema, state, ["header"]);
1599
1636
  const required = !((_b = isOptionalSchema(schema, state)) == null ? void 0 : _b.optional);
@@ -1604,7 +1641,7 @@ const createBaseHeader = (schema, components) => {
1604
1641
  };
1605
1642
  };
1606
1643
  const createComponentHeaderRef = (ref) => `#/components/headers/${ref}`;
1607
- const createResponse = (responseObject, components, subpath) => {
1644
+ const createResponse = (responseObject, components, subpath, documentOptions) => {
1608
1645
  if ("$ref" in responseObject) {
1609
1646
  return responseObject;
1610
1647
  }
@@ -1613,15 +1650,22 @@ const createResponse = (responseObject, components, subpath) => {
1613
1650
  return { $ref: createComponentResponseRef(component.ref) };
1614
1651
  }
1615
1652
  const { content, headers, ref, ...rest } = responseObject;
1616
- const maybeHeaders = createResponseHeaders(headers, components);
1653
+ const maybeHeaders = createResponseHeaders(
1654
+ headers,
1655
+ components,
1656
+ documentOptions
1657
+ );
1617
1658
  const response = {
1618
1659
  ...rest,
1619
1660
  ...maybeHeaders && { headers: maybeHeaders },
1620
1661
  ...content && {
1621
- content: createContent(content, components, "output", [
1622
- ...subpath,
1623
- "content"
1624
- ])
1662
+ content: createContent(
1663
+ content,
1664
+ components,
1665
+ "output",
1666
+ [...subpath, "content"],
1667
+ documentOptions
1668
+ )
1625
1669
  }
1626
1670
  };
1627
1671
  const responseRef = ref ?? (component == null ? void 0 : component.ref);
@@ -1637,21 +1681,23 @@ const createResponse = (responseObject, components, subpath) => {
1637
1681
  }
1638
1682
  return response;
1639
1683
  };
1640
- const createResponses = (responsesObject, components, subpath) => Object.entries(responsesObject).reduce(
1684
+ const createResponses = (responsesObject, components, subpath, documentOptions) => Object.entries(responsesObject).reduce(
1641
1685
  (acc, [statusCode, responseObject]) => {
1642
1686
  if (isISpecificationExtension(statusCode)) {
1643
1687
  acc[statusCode] = responseObject;
1644
1688
  return acc;
1645
1689
  }
1646
- acc[statusCode] = createResponse(responseObject, components, [
1647
- ...subpath,
1648
- statusCode
1649
- ]);
1690
+ acc[statusCode] = createResponse(
1691
+ responseObject,
1692
+ components,
1693
+ [...subpath, statusCode],
1694
+ documentOptions
1695
+ );
1650
1696
  return acc;
1651
1697
  },
1652
1698
  {}
1653
1699
  );
1654
- const createRequestBody = (requestBodyObject, components, subpath) => {
1700
+ const createRequestBody = (requestBodyObject, components, subpath, documentOptions) => {
1655
1701
  if (!requestBodyObject) {
1656
1702
  return void 0;
1657
1703
  }
@@ -1664,10 +1710,13 @@ const createRequestBody = (requestBodyObject, components, subpath) => {
1664
1710
  const ref = requestBodyObject.ref ?? (component == null ? void 0 : component.ref);
1665
1711
  const requestBody = {
1666
1712
  ...requestBodyObject,
1667
- content: createContent(requestBodyObject.content, components, "input", [
1668
- ...subpath,
1669
- "content"
1670
- ])
1713
+ content: createContent(
1714
+ requestBodyObject.content,
1715
+ components,
1716
+ "input",
1717
+ [...subpath, "content"],
1718
+ documentOptions
1719
+ )
1671
1720
  };
1672
1721
  if (ref) {
1673
1722
  components.requestBodies.set(requestBodyObject, {
@@ -1681,28 +1730,32 @@ const createRequestBody = (requestBodyObject, components, subpath) => {
1681
1730
  }
1682
1731
  return requestBody;
1683
1732
  };
1684
- const createOperation = (operationObject, components, subpath) => {
1733
+ const createOperation = (operationObject, components, subpath, documentOptions) => {
1685
1734
  const { parameters, requestParams, requestBody, responses, ...rest } = operationObject;
1686
1735
  const maybeParameters = createParametersObject(
1687
1736
  parameters,
1688
1737
  requestParams,
1689
1738
  components,
1690
- [...subpath, "parameters"]
1739
+ [...subpath, "parameters"],
1740
+ documentOptions
1691
1741
  );
1692
1742
  const maybeRequestBody = createRequestBody(
1693
1743
  operationObject.requestBody,
1694
1744
  components,
1695
- [...subpath, "request body"]
1745
+ [...subpath, "request body"],
1746
+ documentOptions
1696
1747
  );
1697
1748
  const maybeResponses = createResponses(
1698
1749
  operationObject.responses,
1699
1750
  components,
1700
- [...subpath, "responses"]
1751
+ [...subpath, "responses"],
1752
+ documentOptions
1701
1753
  );
1702
1754
  const maybeCallbacks = createCallbacks(
1703
1755
  operationObject.callbacks,
1704
1756
  components,
1705
- [...subpath, "callbacks"]
1757
+ [...subpath, "callbacks"],
1758
+ documentOptions
1706
1759
  );
1707
1760
  return {
1708
1761
  ...rest,
@@ -1712,7 +1765,7 @@ const createOperation = (operationObject, components, subpath) => {
1712
1765
  ...maybeCallbacks && { callbacks: maybeCallbacks }
1713
1766
  };
1714
1767
  };
1715
- const createPathItem = (pathObject, components, path) => Object.entries(pathObject).reduce(
1768
+ const createPathItem = (pathObject, components, path, documentOptions) => Object.entries(pathObject).reduce(
1716
1769
  (acc, [key, value]) => {
1717
1770
  if (!value) {
1718
1771
  return acc;
@@ -1721,7 +1774,8 @@ const createPathItem = (pathObject, components, path) => Object.entries(pathObje
1721
1774
  acc[key] = createOperation(
1722
1775
  value,
1723
1776
  components,
1724
- [...path, key]
1777
+ [...path, key],
1778
+ documentOptions
1725
1779
  );
1726
1780
  return acc;
1727
1781
  }
@@ -1730,7 +1784,7 @@ const createPathItem = (pathObject, components, path) => Object.entries(pathObje
1730
1784
  },
1731
1785
  {}
1732
1786
  );
1733
- const createPaths = (pathsObject, components) => {
1787
+ const createPaths = (pathsObject, components, documentOptions) => {
1734
1788
  if (!pathsObject) {
1735
1789
  return void 0;
1736
1790
  }
@@ -1740,13 +1794,18 @@ const createPaths = (pathsObject, components) => {
1740
1794
  acc[path] = pathItemObject;
1741
1795
  return acc;
1742
1796
  }
1743
- acc[path] = createPathItem(pathItemObject, components, [path]);
1797
+ acc[path] = createPathItem(
1798
+ pathItemObject,
1799
+ components,
1800
+ [path],
1801
+ documentOptions
1802
+ );
1744
1803
  return acc;
1745
1804
  },
1746
1805
  {}
1747
1806
  );
1748
1807
  };
1749
- const createCallback = (callbackObject, components, subpath) => {
1808
+ const createCallback = (callbackObject, components, subpath, documentOptions) => {
1750
1809
  const { ref, ...callbacks } = callbackObject;
1751
1810
  const callback = Object.entries(
1752
1811
  callbacks
@@ -1755,10 +1814,13 @@ const createCallback = (callbackObject, components, subpath) => {
1755
1814
  acc[callbackName] = pathItemObject;
1756
1815
  return acc;
1757
1816
  }
1758
- acc[callbackName] = createPathItem(pathItemObject, components, [
1759
- ...subpath,
1760
- callbackName
1761
- ]);
1817
+ acc[callbackName] = createPathItem(
1818
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1819
+ pathItemObject,
1820
+ components,
1821
+ [...subpath, callbackName],
1822
+ documentOptions
1823
+ );
1762
1824
  return acc;
1763
1825
  }, {});
1764
1826
  if (ref) {
@@ -1773,7 +1835,7 @@ const createCallback = (callbackObject, components, subpath) => {
1773
1835
  }
1774
1836
  return callback;
1775
1837
  };
1776
- const createCallbacks = (callbacksObject, components, subpath) => {
1838
+ const createCallbacks = (callbacksObject, components, subpath, documentOptions) => {
1777
1839
  if (!callbacksObject) {
1778
1840
  return void 0;
1779
1841
  }
@@ -1783,10 +1845,13 @@ const createCallbacks = (callbacksObject, components, subpath) => {
1783
1845
  acc[callbackName] = callbackObject;
1784
1846
  return acc;
1785
1847
  }
1786
- acc[callbackName] = createCallback(callbackObject, components, [
1787
- ...subpath,
1788
- callbackName
1789
- ]);
1848
+ acc[callbackName] = createCallback(
1849
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1850
+ callbackObject,
1851
+ components,
1852
+ [...subpath, callbackName],
1853
+ documentOptions
1854
+ );
1790
1855
  return acc;
1791
1856
  },
1792
1857
  {}
@@ -1935,16 +2000,34 @@ const createComponentSchemaRef = (schemaRef) => `#/components/schemas/${schemaRe
1935
2000
  const createComponentResponseRef = (responseRef) => `#/components/responses/${responseRef}`;
1936
2001
  const createComponentRequestBodyRef = (requestBodyRef) => `#/components/requestBodies/${requestBodyRef}`;
1937
2002
  const createComponentCallbackRef = (callbackRef) => `#/components/callbacks/${callbackRef}`;
1938
- const createComponents = (componentsObject, components) => {
1939
- const combinedSchemas = createSchemaComponents(componentsObject, components);
2003
+ const createComponents = (componentsObject, components, documentOptions) => {
2004
+ const combinedSchemas = createSchemaComponents(
2005
+ componentsObject,
2006
+ components,
2007
+ documentOptions
2008
+ );
1940
2009
  const combinedParameters = createParamComponents(
1941
2010
  componentsObject,
1942
- components
2011
+ components,
2012
+ documentOptions
2013
+ );
2014
+ const combinedHeaders = createHeaderComponents(
2015
+ componentsObject,
2016
+ components,
2017
+ documentOptions
2018
+ );
2019
+ const combinedResponses = createResponseComponents(
2020
+ components,
2021
+ documentOptions
2022
+ );
2023
+ const combinedRequestBodies = createRequestBodiesComponents(
2024
+ components,
2025
+ documentOptions
2026
+ );
2027
+ const combinedCallbacks = createCallbackComponents(
2028
+ components,
2029
+ documentOptions
1943
2030
  );
1944
- const combinedHeaders = createHeaderComponents(componentsObject, components);
1945
- const combinedResponses = createResponseComponents(components);
1946
- const combinedRequestBodies = createRequestBodiesComponents(components);
1947
- const combinedCallbacks = createCallbackComponents(components);
1948
2031
  const { schemas, parameters, headers, responses, requestBodies, ...rest } = componentsObject;
1949
2032
  const finalComponents = {
1950
2033
  ...rest,
@@ -1957,7 +2040,7 @@ const createComponents = (componentsObject, components) => {
1957
2040
  };
1958
2041
  return Object.keys(finalComponents).length ? finalComponents : void 0;
1959
2042
  };
1960
- const createSchemaComponents = (componentsObject, components) => {
2043
+ const createSchemaComponents = (componentsObject, components, documentOptions) => {
1961
2044
  Array.from(components.schemas).forEach(([schema, { type }], index) => {
1962
2045
  var _a;
1963
2046
  if (type === "manual") {
@@ -1965,7 +2048,8 @@ const createSchemaComponents = (componentsObject, components) => {
1965
2048
  components,
1966
2049
  type: ((_a = schema._def.openapi) == null ? void 0 : _a.refType) ?? "output",
1967
2050
  path: [],
1968
- visited: /* @__PURE__ */ new Set()
2051
+ visited: /* @__PURE__ */ new Set(),
2052
+ documentOptions
1969
2053
  };
1970
2054
  createSchema(schema, state, [`component schema index ${index}`]);
1971
2055
  }
@@ -1996,13 +2080,14 @@ const createSchemaComponents = (componentsObject, components) => {
1996
2080
  }, customComponents);
1997
2081
  return Object.keys(finalComponents).length ? finalComponents : void 0;
1998
2082
  };
1999
- const createParamComponents = (componentsObject, components) => {
2083
+ const createParamComponents = (componentsObject, components, documentOptions) => {
2000
2084
  Array.from(components.parameters).forEach(([schema, component], index) => {
2001
2085
  if (component.type === "manual") {
2002
2086
  createParamOrRef(
2003
2087
  schema,
2004
2088
  components,
2005
2089
  [`component parameter index ${index}`],
2090
+ documentOptions,
2006
2091
  component.in,
2007
2092
  component.ref
2008
2093
  );
@@ -2033,10 +2118,10 @@ const createParamComponents = (componentsObject, components) => {
2033
2118
  }, customComponents);
2034
2119
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2035
2120
  };
2036
- const createHeaderComponents = (componentsObject, components) => {
2121
+ const createHeaderComponents = (componentsObject, components, documentOptions) => {
2037
2122
  Array.from(components.headers).forEach(([schema, component]) => {
2038
2123
  if (component.type === "manual") {
2039
- createHeaderOrRef(schema, components);
2124
+ createHeaderOrRef(schema, components, documentOptions);
2040
2125
  }
2041
2126
  });
2042
2127
  const headers = componentsObject.headers ?? {};
@@ -2060,10 +2145,15 @@ const createHeaderComponents = (componentsObject, components) => {
2060
2145
  }, customComponents);
2061
2146
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2062
2147
  };
2063
- const createResponseComponents = (components) => {
2148
+ const createResponseComponents = (components, documentOptions) => {
2064
2149
  Array.from(components.responses).forEach(([schema, component], index) => {
2065
2150
  if (component.type === "manual") {
2066
- createResponse(schema, components, [`component response index ${index}`]);
2151
+ createResponse(
2152
+ schema,
2153
+ components,
2154
+ [`component response index ${index}`],
2155
+ documentOptions
2156
+ );
2067
2157
  }
2068
2158
  });
2069
2159
  const finalComponents = Array.from(components.responses).reduce((acc, [_zodType, component]) => {
@@ -2077,12 +2167,15 @@ const createResponseComponents = (components) => {
2077
2167
  }, {});
2078
2168
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2079
2169
  };
2080
- const createRequestBodiesComponents = (components) => {
2170
+ const createRequestBodiesComponents = (components, documentOptions) => {
2081
2171
  Array.from(components.requestBodies).forEach(([schema, component], index) => {
2082
2172
  if (component.type === "manual") {
2083
- createRequestBody(schema, components, [
2084
- `component request body ${index}`
2085
- ]);
2173
+ createRequestBody(
2174
+ schema,
2175
+ components,
2176
+ [`component request body ${index}`],
2177
+ documentOptions
2178
+ );
2086
2179
  }
2087
2180
  });
2088
2181
  const finalComponents = Array.from(components.requestBodies).reduce((acc, [_zodType, component]) => {
@@ -2096,10 +2189,15 @@ const createRequestBodiesComponents = (components) => {
2096
2189
  }, {});
2097
2190
  return Object.keys(finalComponents).length ? finalComponents : void 0;
2098
2191
  };
2099
- const createCallbackComponents = (components) => {
2192
+ const createCallbackComponents = (components, documentOptions) => {
2100
2193
  Array.from(components.callbacks).forEach(([schema, component], index) => {
2101
2194
  if (component.type === "manual") {
2102
- createCallback(schema, components, [`component callback ${index}`]);
2195
+ createCallback(
2196
+ schema,
2197
+ components,
2198
+ [`component callback ${index}`],
2199
+ documentOptions
2200
+ );
2103
2201
  }
2104
2202
  });
2105
2203
  const finalComponents = Array.from(components.callbacks).reduce((acc, [_zodType, component]) => {
@@ -2117,4 +2215,6 @@ exports.createComponents = createComponents;
2117
2215
  exports.createMediaTypeSchema = createMediaTypeSchema;
2118
2216
  exports.createParamOrRef = createParamOrRef;
2119
2217
  exports.createPaths = createPaths;
2218
+ exports.createSchema = createSchema;
2219
+ exports.createSchemaComponents = createSchemaComponents;
2120
2220
  exports.getDefaultComponents = getDefaultComponents;