@digi-frontend/dgate-api-documentation 4.1.6 → 4.1.8

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/index.cjs CHANGED
@@ -704,8 +704,48 @@ const getSidebarStyles$1 = (token, scope) => ({
704
704
  }
705
705
  });
706
706
  //#endregion
707
+ //#region src/utils/OverflowTooltip.tsx
708
+ const OverflowTooltip = ({ title, children, className, style, placement }) => {
709
+ const ref = (0, react.useRef)(null);
710
+ const [isOverflowing, setIsOverflowing] = (0, react.useState)(false);
711
+ const checkOverflow = (0, react.useCallback)(() => {
712
+ const el = ref.current;
713
+ if (!el) return;
714
+ setIsOverflowing(el.scrollWidth > el.clientWidth);
715
+ }, []);
716
+ (0, react.useEffect)(() => {
717
+ checkOverflow();
718
+ const el = ref.current;
719
+ if (!el) return;
720
+ const ro = new ResizeObserver(checkOverflow);
721
+ ro.observe(el);
722
+ return () => ro.disconnect();
723
+ }, [
724
+ checkOverflow,
725
+ children,
726
+ title
727
+ ]);
728
+ const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
729
+ ref,
730
+ className,
731
+ style: {
732
+ display: "block",
733
+ overflow: "hidden",
734
+ textOverflow: "ellipsis",
735
+ whiteSpace: "nowrap",
736
+ ...style
737
+ },
738
+ children
739
+ });
740
+ if (!isOverflowing) return content;
741
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
742
+ title,
743
+ placement,
744
+ children: content
745
+ });
746
+ };
747
+ //#endregion
707
748
  //#region src/view/helper/sidebar.components.tsx
708
- const { Text: Text$6 } = antd.Typography;
709
749
  const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
710
750
  const methodStyle = (isSelected ? darkerMethodColors$1 : methodColors$1)[method];
711
751
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -718,9 +758,9 @@ const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
718
758
  border: "none"
719
759
  },
720
760
  children: method
721
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$6, {
761
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
762
+ title,
722
763
  className: cx("endpoint-text"),
723
- ellipsis: { tooltip: title },
724
764
  style: { flex: 1 },
725
765
  children: title
726
766
  })]
@@ -739,14 +779,14 @@ const convertToRenderableTreeData$1 = (treeDataStructure, selectedEndpoint, cx)
739
779
  });
740
780
  } else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
741
781
  const isHighlighted = isApiSectionHighlighted(node.key, selectedEndpoint);
742
- title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$6, {
782
+ title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
783
+ title: typeof node.title === "string" ? node.title : "API Name",
743
784
  className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
744
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
745
785
  children: node.title
746
786
  });
747
- } else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$6, {
787
+ } else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
788
+ title: typeof node.title === "string" ? node.title : "",
748
789
  className: cx("tag-title"),
749
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
750
790
  children: node.title
751
791
  });
752
792
  return {
@@ -1335,15 +1375,6 @@ const ApiCard = ({ api, viewStyle }) => {
1335
1375
  const handleOpenEndPointView = () => {
1336
1376
  selectNodeByKey(api.id);
1337
1377
  };
1338
- const TooltippedText = ({ text }) => {
1339
- const limitation = viewStyle == "grid" ? 15 : 36;
1340
- if (text.length < limitation) return text;
1341
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Tooltip, {
1342
- title: text,
1343
- placement: "bottomLeft",
1344
- children: [text.substring(0, limitation), "..."]
1345
- });
1346
- };
1347
1378
  const MethodChip = ({ method }) => {
1348
1379
  const methodStyle = methodColors$1[method];
1349
1380
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -1374,7 +1405,11 @@ const ApiCard = ({ api, viewStyle }) => {
1374
1405
  className: cx("list-title"),
1375
1406
  level: 4,
1376
1407
  onClick: handleOpenEndPointView,
1377
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltippedText, { text: api?.summary || "Endpoint Name" })
1408
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
1409
+ title: api?.summary || "Endpoint Name",
1410
+ placement: "bottomLeft",
1411
+ children: api?.summary || "Endpoint Name"
1412
+ })
1378
1413
  })]
1379
1414
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
1380
1415
  className: cx("list-see-details"),
@@ -1405,7 +1440,11 @@ const ApiCard = ({ api, viewStyle }) => {
1405
1440
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd_es_typography_Title_js.default, {
1406
1441
  className: cx("grid-title"),
1407
1442
  level: 4,
1408
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltippedText, { text: api?.summary || "Endpoint Name" })
1443
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
1444
+ title: api?.summary || "Endpoint Name",
1445
+ placement: "bottomLeft",
1446
+ children: api?.summary || "Endpoint Name"
1447
+ })
1409
1448
  }),
1410
1449
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1411
1450
  className: cx("grid-content"),
@@ -1542,16 +1581,19 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
1542
1581
  return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1543
1582
  className: cx("root"),
1544
1583
  children: [
1545
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Typography.Title, {
1546
- level: 4,
1547
- className: cx("title"),
1548
- ellipsis: { tooltip: api.title },
1549
- style: {
1550
- margin: 0,
1551
- fontSize: 20,
1552
- fontWeight: 600
1553
- },
1554
- children: api.title
1584
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
1585
+ title: api.title,
1586
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Typography.Title, {
1587
+ level: 4,
1588
+ className: cx("title"),
1589
+ ellipsis: true,
1590
+ style: {
1591
+ margin: 0,
1592
+ fontSize: 20,
1593
+ fontWeight: 600
1594
+ },
1595
+ children: api.title
1596
+ })
1555
1597
  }),
1556
1598
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1557
1599
  className: cx("meta-bar"),
@@ -1732,6 +1774,36 @@ const APIsRenderer = ({ apis, withTitle, tagName, haveUnderLine, contextPath, vi
1732
1774
  }, `${tagName}_renderer_${contextPath}`);
1733
1775
  };
1734
1776
  //#endregion
1777
+ //#region src/utils/generateExampleFromSchema.ts
1778
+ function generateExampleFromSchema(schema) {
1779
+ if (!schema) return null;
1780
+ if (schema.example !== void 0) return schema.example;
1781
+ if (schema.examples !== void 0) return Array.isArray(schema.examples) ? schema.examples[0] : schema.examples;
1782
+ if (schema.properties) {
1783
+ const result = {};
1784
+ for (const [key, prop] of Object.entries(schema.properties)) result[key] = generateExampleFromSchema(prop);
1785
+ return result;
1786
+ }
1787
+ if (schema.type === "array" && schema.items) return [generateExampleFromSchema(schema.items)];
1788
+ if (schema.enum && schema.enum.length > 0) return schema.enum[0];
1789
+ switch (schema.type) {
1790
+ case "string": return "string";
1791
+ case "integer":
1792
+ case "number": return 0;
1793
+ case "boolean": return false;
1794
+ case "array": return [];
1795
+ case "object": return {};
1796
+ default: return null;
1797
+ }
1798
+ }
1799
+ function hasAnyExample(schema) {
1800
+ if (!schema) return false;
1801
+ if (schema.example !== void 0 || schema.examples !== void 0) return true;
1802
+ if (schema.properties) return Object.values(schema.properties).some(hasAnyExample);
1803
+ if (schema.type === "array" && schema.items) return hasAnyExample(schema.items);
1804
+ return false;
1805
+ }
1806
+ //#endregion
1735
1807
  //#region src/utils/index.ts
1736
1808
  const handleStatusColor = (code) => {
1737
1809
  if (code >= 200 && code < 300) return "green";
@@ -1786,7 +1858,7 @@ const buildRequestData$1 = (params, colors) => [...params].sort((a, b) => a.requ
1786
1858
  })
1787
1859
  ] }),
1788
1860
  desc: p.description || "--",
1789
- enum: p.schema?.enum ? p.schema.enum.map((e) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, { children: e }, e)) : "--"
1861
+ enum: p.schema?.enum ?? p.schema?.items?.enum ? (p.schema?.enum ?? p.schema?.items?.enum).map((e) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, { children: e }, e)) : "--"
1790
1862
  };
1791
1863
  });
1792
1864
  const buildHeaderData$1 = (headers, colors) => {
@@ -1815,7 +1887,7 @@ const buildHeaderData$1 = (headers, colors) => {
1815
1887
  })
1816
1888
  ] }, idx),
1817
1889
  desc: header.description || "--",
1818
- enum: header.schema?.enum ? header.schema.enum.map((e) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, { children: e }, e)) : "--"
1890
+ enum: header.schema?.enum ?? header.schema?.items?.enum ? (header.schema?.enum ?? header.schema?.items?.enum).map((e) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, { children: e }, e)) : "--"
1819
1891
  };
1820
1892
  });
1821
1893
  };
@@ -2250,7 +2322,7 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
2250
2322
  className: cx("mobileBottomRow"),
2251
2323
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2252
2324
  className: cx("title-section"),
2253
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
2325
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
2254
2326
  title: apiName,
2255
2327
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Title$6, {
2256
2328
  level: 3,
@@ -2288,7 +2360,7 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
2288
2360
  children: [
2289
2361
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2290
2362
  className: cx("title-section"),
2291
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
2363
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
2292
2364
  title: `${apiName} API Documentation`,
2293
2365
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Title$6, {
2294
2366
  level: 3,
@@ -3393,6 +3465,27 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
3393
3465
  }));
3394
3466
  });
3395
3467
  }, [openResponsePanels, responseBodySchemas]);
3468
+ (0, react$1.useEffect)(() => {
3469
+ if (!openResponsePanels.size) return;
3470
+ openResponsePanels.forEach((epId) => {
3471
+ const code = selectedStatusCodes[epId];
3472
+ if (!code) return;
3473
+ const ep = Object.values(endpointsByTag).flat().find((e) => e.id === epId);
3474
+ if (!ep?.responses?.[code]?.content) return;
3475
+ const content = ep.responses[code].content;
3476
+ const schema = Object.values(content)[0]?.schema;
3477
+ if (!schema) return;
3478
+ const json = JSON.stringify(schema, null, 2);
3479
+ setEditableResponseContent((prev) => ({
3480
+ ...prev,
3481
+ [epId]: json
3482
+ }));
3483
+ });
3484
+ }, [
3485
+ selectedStatusCodes,
3486
+ openResponsePanels,
3487
+ endpointsByTag
3488
+ ]);
3396
3489
  const handleValidate = (content) => {
3397
3490
  try {
3398
3491
  JSON.parse(content);
@@ -4167,7 +4260,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
4167
4260
  backgroundColor: methodColor?.bg ?? "transparent"
4168
4261
  },
4169
4262
  children: ep.method
4170
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
4263
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
4171
4264
  title: ep.path,
4172
4265
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd_es_typography_Title_js.default, {
4173
4266
  level: 4,
@@ -5376,7 +5469,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
5376
5469
  backgroundColor: isExpanded ? methodColor?.color : "transparent"
5377
5470
  },
5378
5471
  children: ep.method
5379
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
5472
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
5380
5473
  title: ep.path,
5381
5474
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5382
5475
  className: cx("endpoint-path"),
@@ -5482,14 +5575,21 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
5482
5575
  const selectedCode = selectedStatusCodes[ep.id] ?? (Object.keys(ep.responses ?? {}).includes("200") ? "200" : Object.keys(ep.responses ?? {})[0]);
5483
5576
  const responseContent = ep.responses?.[selectedCode]?.content;
5484
5577
  if (!responseContent) return null;
5485
- const schema = Object.values(responseContent)[0]?.schema;
5578
+ const contentEntry = Object.values(responseContent)[0];
5579
+ if (!contentEntry) return null;
5580
+ const schema = contentEntry.schema;
5486
5581
  if (!schema) return null;
5582
+ let displayData;
5583
+ if (contentEntry.example !== void 0) displayData = contentEntry.example;
5584
+ else if (contentEntry.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
5585
+ else if (hasAnyExample(schema)) displayData = generateExampleFromSchema(schema);
5586
+ else displayData = schema;
5487
5587
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5488
5588
  className: cx("code-panel"),
5489
5589
  style: { marginTop: token.marginSM },
5490
5590
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
5491
5591
  className: cx("code-area"),
5492
- children: JSON.stringify(schema, null, 2)
5592
+ children: JSON.stringify(displayData, null, 2)
5493
5593
  })
5494
5594
  });
5495
5595
  })()
@@ -7838,53 +7938,50 @@ const buildTreeDataStructure = (data) => {
7838
7938
  if (!data) return [];
7839
7939
  return data.map((api) => {
7840
7940
  const tagEntries = Object.entries(api.tags);
7841
- const defaultTag = tagEntries.find(([tag]) => tag.toLowerCase() === "default");
7842
- const nonDefaultTags = tagEntries.filter(([tag]) => tag.toLowerCase() !== "default");
7843
- const defaultEndpoints = defaultTag ? defaultTag[1].map((endpoint) => ({
7844
- title: endpoint.summary,
7845
- key: endpoint.id,
7846
- isLeaf: true,
7941
+ const hasOnlyDefaultTag = tagEntries.length === 1 && tagEntries[0][0] === "default";
7942
+ return {
7943
+ title: api.title,
7944
+ key: api.id,
7847
7945
  selectable: true,
7848
- method: endpoint.method,
7849
- data: {
7850
- endpoint,
7851
- api,
7852
- tagName: "default",
7853
- parentApiId: api.id
7854
- }
7855
- })) : [];
7856
- const tagNodes = nonDefaultTags.map(([tag, endpoints]) => {
7857
- const tagId = `tag-${api.id}-${tag.replace(/\s+/g, "-").toLowerCase()}`;
7858
- return {
7859
- title: tag,
7860
- key: tagId,
7946
+ data: api,
7947
+ children: hasOnlyDefaultTag ? tagEntries[0][1].map((endpoint) => ({
7948
+ title: endpoint.summary,
7949
+ key: endpoint.id,
7950
+ isLeaf: true,
7861
7951
  selectable: true,
7952
+ method: endpoint.method,
7862
7953
  data: {
7863
- tagName: tag,
7864
- apiData: api
7865
- },
7866
- children: endpoints.map((endpoint) => ({
7867
- title: endpoint.summary,
7868
- key: endpoint.id,
7869
- isLeaf: true,
7954
+ endpoint,
7955
+ api,
7956
+ tagName: "default",
7957
+ parentApiId: api.id
7958
+ }
7959
+ })) : tagEntries.map(([tag, endpoints]) => {
7960
+ const tagId = `tag-${api.id}-${tag.replace(/\s+/g, "-").toLowerCase()}`;
7961
+ return {
7962
+ title: tag,
7963
+ key: tagId,
7870
7964
  selectable: true,
7871
- method: endpoint.method,
7872
7965
  data: {
7873
- endpoint,
7874
- api,
7875
7966
  tagName: tag,
7876
- parentApiId: api.id,
7877
- tagId
7878
- }
7879
- }))
7880
- };
7881
- });
7882
- return {
7883
- title: api.title,
7884
- key: api.id,
7885
- selectable: true,
7886
- data: api,
7887
- children: [...tagNodes, ...defaultEndpoints]
7967
+ apiData: api
7968
+ },
7969
+ children: endpoints.map((endpoint) => ({
7970
+ title: endpoint.summary,
7971
+ key: endpoint.id,
7972
+ isLeaf: true,
7973
+ selectable: true,
7974
+ method: endpoint.method,
7975
+ data: {
7976
+ endpoint,
7977
+ api,
7978
+ tagName: tag,
7979
+ parentApiId: api.id,
7980
+ tagId
7981
+ }
7982
+ }))
7983
+ };
7984
+ })
7888
7985
  };
7889
7986
  });
7890
7987
  };
@@ -8020,7 +8117,6 @@ const getSidebarStyles = (token, scope) => ({
8020
8117
  });
8021
8118
  //#endregion
8022
8119
  //#region src/view/console/helper/sidebar.components.tsx
8023
- const { Text: Text$2 } = antd.Typography;
8024
8120
  const EndpointItem = ({ method, title, cx, isSelected = false }) => {
8025
8121
  const methodStyle = (isSelected ? darkerMethodColors : sidebarMethodColors)[method];
8026
8122
  const isPost = method?.toUpperCase() === "POST";
@@ -8035,9 +8131,9 @@ const EndpointItem = ({ method, title, cx, isSelected = false }) => {
8035
8131
  ...isPost ? { borderRadius: 4 } : {}
8036
8132
  },
8037
8133
  children: method
8038
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$2, {
8134
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
8135
+ title,
8039
8136
  className: cx("endpoint-text"),
8040
- ellipsis: { tooltip: title },
8041
8137
  style: { flex: 1 },
8042
8138
  children: title
8043
8139
  })]
@@ -8054,14 +8150,14 @@ const convertToRenderableTreeData = (treeDataStructure, selectedEndpoint, cx) =>
8054
8150
  cx,
8055
8151
  isSelected
8056
8152
  });
8057
- } else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$2, {
8153
+ } else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
8154
+ title: typeof node.title === "string" ? node.title : "API Name",
8058
8155
  className: cx("api-title"),
8059
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
8060
8156
  children: node.title
8061
8157
  });
8062
- else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text$2, {
8158
+ else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
8159
+ title: typeof node.title === "string" ? node.title : "",
8063
8160
  className: cx("tag-title"),
8064
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
8065
8161
  children: node.title
8066
8162
  });
8067
8163
  return {
@@ -8352,7 +8448,7 @@ const buildRequestData = (params, token) => [...params].sort((a, b) => a.require
8352
8448
  children: p.description || "--"
8353
8449
  })
8354
8450
  }),
8355
- enum: p.schema?.enum ? renderEnumTags(p.schema.enum, token) : "--"
8451
+ enum: p.schema?.enum ?? p.schema?.items?.enum ? renderEnumTags(p.schema?.enum ?? p.schema?.items?.enum, token) : "--"
8356
8452
  };
8357
8453
  });
8358
8454
  const buildHeaderData = (headers, token) => {
@@ -8402,7 +8498,7 @@ const buildHeaderData = (headers, token) => {
8402
8498
  ]
8403
8499
  }, idx),
8404
8500
  desc: header.description || "--",
8405
- enum: header.schema?.enum ? renderEnumTags(header.schema.enum, token) : "--"
8501
+ enum: header.schema?.enum ?? header.schema?.items?.enum ? renderEnumTags(header.schema?.enum ?? header.schema?.items?.enum, token) : "--"
8406
8502
  };
8407
8503
  });
8408
8504
  };
@@ -8544,18 +8640,10 @@ const EndpointPage = () => {
8544
8640
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectedEndpoint?.tagName || "default" })
8545
8641
  })
8546
8642
  },
8547
- { title: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
8643
+ { title: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
8548
8644
  title: selectedEndpoint?.summary || "Endpoint Name",
8549
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
8550
- style: {
8551
- overflow: "hidden",
8552
- textOverflow: "ellipsis",
8553
- whiteSpace: "nowrap",
8554
- display: "block",
8555
- maxWidth: "300px"
8556
- },
8557
- children: selectedEndpoint?.summary || "Endpoint Name"
8558
- })
8645
+ style: { maxWidth: "300px" },
8646
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectedEndpoint?.summary || "Endpoint Name" })
8559
8647
  }) }
8560
8648
  ] })]
8561
8649
  }),
@@ -8578,16 +8666,9 @@ const EndpointPage = () => {
8578
8666
  flexShrink: 0
8579
8667
  },
8580
8668
  children: selectedEndpoint?.method
8581
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
8669
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
8582
8670
  title: selectedEndpoint?.summary ?? "--",
8583
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
8584
- style: {
8585
- overflow: "hidden",
8586
- textOverflow: "ellipsis",
8587
- whiteSpace: "nowrap"
8588
- },
8589
- children: selectedEndpoint?.summary?.replace(selectedEndpoint?.method, "") ?? "--"
8590
- })
8671
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectedEndpoint?.summary?.replace(selectedEndpoint?.method, "") ?? "--" })
8591
8672
  })]
8592
8673
  }),
8593
8674
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Paragraph, {
@@ -8794,19 +8875,12 @@ function CodeboxSidebar$1() {
8794
8875
  } }), code]
8795
8876
  })
8796
8877
  })), [statusCodeOptions]);
8797
- const [curlTooltip, setCurlTooltip] = (0, react$1.useState)("Copy Request");
8798
8878
  const curlCommand = (() => {
8799
8879
  if (!selectedEndpoint || !Array.isArray(selectedApi?.curl)) return "";
8800
8880
  return selectedApi.curl.find((c) => c.path === selectedEndpoint.path && c.method?.toUpperCase() === selectedEndpoint.method.toUpperCase())?.curlCommand ?? "";
8801
8881
  })();
8802
- const curlLines = (() => {
8803
- if (!selectedEndpoint) return [];
8804
- const params = selectedEndpoint.parameters ?? [];
8805
- const serverUrl = selectedApi?.servers?.[0]?.url ?? "";
8806
- const resolvedPath = params.filter((p) => p.in === "path").reduce((acc, p) => acc.replace(`{${p.name}}`, "sample-value"), selectedEndpoint.path);
8807
- const queryParams = params.filter((p) => p.in === "query");
8808
- return [`curl --location '${serverUrl}${resolvedPath}${queryParams.length > 0 ? "?" + queryParams.map((p) => `${p.name}=sample-value`).join("&") : ""}'`, ...params.filter((p) => p.in === "header").map((p) => `--header '${p.name}: sample-value'`)];
8809
- })();
8882
+ const curlDisplayLines = curlCommand.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
8883
+ const [curlTooltip, setCurlTooltip] = (0, react$1.useState)("Copy Request");
8810
8884
  const { token: antdToken, theme: themeConfig } = antd.theme.useToken();
8811
8885
  const isDark = themeConfig.id == 1;
8812
8886
  const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
@@ -8952,7 +9026,7 @@ function CodeboxSidebar$1() {
8952
9026
  })]
8953
9027
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8954
9028
  className: cx("curl-list"),
8955
- children: curlLines.map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9029
+ children: curlDisplayLines.map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8956
9030
  className: cx("curl-line"),
8957
9031
  children: line
8958
9032
  }, i))
@@ -8977,7 +9051,17 @@ function CodeboxSidebar$1() {
8977
9051
  open: httpStatusOptions.length === 1 ? false : void 0,
8978
9052
  suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
8979
9053
  })]
8980
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox$1, { code: JSON.stringify(selectedEndpoint?.responses[selectedStatusCode], null, 2) || "" })]
9054
+ }), (() => {
9055
+ const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
9056
+ const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
9057
+ let displayData;
9058
+ if (contentEntry?.example !== void 0) displayData = contentEntry.example;
9059
+ else if (contentEntry?.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
9060
+ else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
9061
+ else if (contentEntry?.schema) displayData = contentEntry.schema;
9062
+ else displayData = responseObj;
9063
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
9064
+ })()]
8981
9065
  })]
8982
9066
  });
8983
9067
  }
@@ -9331,7 +9415,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9331
9415
  type: schema?.type ?? "string",
9332
9416
  required: Boolean(p.required ?? false),
9333
9417
  description: p.description != null ? String(p.description) : void 0,
9334
- enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
9418
+ enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
9335
9419
  ...schema?.items && { items: { type: schema.items.type ?? "string" } }
9336
9420
  };
9337
9421
  });
@@ -9362,7 +9446,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9362
9446
  type: schema?.type ?? "string",
9363
9447
  required: Boolean(p.required ?? false),
9364
9448
  description: p.description != null ? String(p.description) : void 0,
9365
- enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
9449
+ enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
9366
9450
  ...schema?.items && { items: { type: schema.items.type ?? "string" } }
9367
9451
  };
9368
9452
  });
@@ -9634,8 +9718,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9634
9718
  ...param.description && { description: param.description },
9635
9719
  schema: {
9636
9720
  type: param.type,
9637
- ...param.enum && param.enum.length > 0 && { enum: param.enum },
9638
- ...param.type === "array" && param.items && { items: param.items }
9721
+ ...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
9722
+ type: param.items?.type ?? "string",
9723
+ enum: param.enum
9724
+ } } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
9725
+ ...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
9639
9726
  }
9640
9727
  }));
9641
9728
  else delete methodObj.parameters;
@@ -9652,8 +9739,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9652
9739
  ...param.description && { description: param.description },
9653
9740
  schema: {
9654
9741
  type: param.type,
9655
- ...param.enum && param.enum.length > 0 && { enum: param.enum },
9656
- ...param.type === "array" && param.items && { items: param.items }
9742
+ ...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
9743
+ type: param.items?.type ?? "string",
9744
+ enum: param.enum
9745
+ } } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
9746
+ ...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
9657
9747
  }
9658
9748
  }));
9659
9749
  else delete methodObj["x-response-params"];
@@ -10694,7 +10784,17 @@ function CodeboxSidebar() {
10694
10784
  open: httpStatusOptions.length === 1 ? false : void 0,
10695
10785
  suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
10696
10786
  })]
10697
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox, { code: JSON.stringify(selectedEndpoint?.responses[selectedStatusCode], null, 2) || "" })]
10787
+ }), (() => {
10788
+ const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
10789
+ const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
10790
+ let displayData;
10791
+ if (contentEntry?.example !== void 0) displayData = contentEntry.example;
10792
+ else if (contentEntry?.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
10793
+ else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
10794
+ else if (contentEntry?.schema) displayData = contentEntry.schema;
10795
+ else displayData = responseObj;
10796
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox, { code: JSON.stringify(displayData, null, 2) || "" });
10797
+ })()]
10698
10798
  })]
10699
10799
  });
10700
10800
  }