@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 +224 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +225 -125
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
2
|
import { devtools } from "zustand/middleware";
|
|
3
3
|
import { immer } from "zustand/middleware/immer";
|
|
4
|
-
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { Alert, Breadcrumb, Button, Card, Col, Divider, Drawer, Empty, Flex, Form, Grid, Input, Menu, Modal, Pagination, Row, Select, Switch, Table, Tabs, Tag, Tooltip, Tree, Typography, message, theme } from "antd";
|
|
6
6
|
import { useStyleRegister } from "@ant-design/cssinjs";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -675,8 +675,48 @@ const getSidebarStyles$1 = (token, scope) => ({
|
|
|
675
675
|
}
|
|
676
676
|
});
|
|
677
677
|
//#endregion
|
|
678
|
+
//#region src/utils/OverflowTooltip.tsx
|
|
679
|
+
const OverflowTooltip = ({ title, children, className, style, placement }) => {
|
|
680
|
+
const ref = useRef(null);
|
|
681
|
+
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
682
|
+
const checkOverflow = useCallback(() => {
|
|
683
|
+
const el = ref.current;
|
|
684
|
+
if (!el) return;
|
|
685
|
+
setIsOverflowing(el.scrollWidth > el.clientWidth);
|
|
686
|
+
}, []);
|
|
687
|
+
useEffect(() => {
|
|
688
|
+
checkOverflow();
|
|
689
|
+
const el = ref.current;
|
|
690
|
+
if (!el) return;
|
|
691
|
+
const ro = new ResizeObserver(checkOverflow);
|
|
692
|
+
ro.observe(el);
|
|
693
|
+
return () => ro.disconnect();
|
|
694
|
+
}, [
|
|
695
|
+
checkOverflow,
|
|
696
|
+
children,
|
|
697
|
+
title
|
|
698
|
+
]);
|
|
699
|
+
const content = /* @__PURE__ */ jsx("span", {
|
|
700
|
+
ref,
|
|
701
|
+
className,
|
|
702
|
+
style: {
|
|
703
|
+
display: "block",
|
|
704
|
+
overflow: "hidden",
|
|
705
|
+
textOverflow: "ellipsis",
|
|
706
|
+
whiteSpace: "nowrap",
|
|
707
|
+
...style
|
|
708
|
+
},
|
|
709
|
+
children
|
|
710
|
+
});
|
|
711
|
+
if (!isOverflowing) return content;
|
|
712
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
713
|
+
title,
|
|
714
|
+
placement,
|
|
715
|
+
children: content
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
//#endregion
|
|
678
719
|
//#region src/view/helper/sidebar.components.tsx
|
|
679
|
-
const { Text: Text$2 } = Typography;
|
|
680
720
|
const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
|
|
681
721
|
const methodStyle = (isSelected ? darkerMethodColors$1 : methodColors$1)[method];
|
|
682
722
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -689,9 +729,9 @@ const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
|
|
|
689
729
|
border: "none"
|
|
690
730
|
},
|
|
691
731
|
children: method
|
|
692
|
-
}), /* @__PURE__ */ jsx(
|
|
732
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
733
|
+
title,
|
|
693
734
|
className: cx("endpoint-text"),
|
|
694
|
-
ellipsis: { tooltip: title },
|
|
695
735
|
style: { flex: 1 },
|
|
696
736
|
children: title
|
|
697
737
|
})]
|
|
@@ -710,14 +750,14 @@ const convertToRenderableTreeData$1 = (treeDataStructure, selectedEndpoint, cx)
|
|
|
710
750
|
});
|
|
711
751
|
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
|
|
712
752
|
const isHighlighted = isApiSectionHighlighted(node.key, selectedEndpoint);
|
|
713
|
-
title = /* @__PURE__ */ jsx(
|
|
753
|
+
title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
754
|
+
title: typeof node.title === "string" ? node.title : "API Name",
|
|
714
755
|
className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
|
|
715
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
|
|
716
756
|
children: node.title
|
|
717
757
|
});
|
|
718
|
-
} else title = /* @__PURE__ */ jsx(
|
|
758
|
+
} else title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
759
|
+
title: typeof node.title === "string" ? node.title : "",
|
|
719
760
|
className: cx("tag-title"),
|
|
720
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
|
|
721
761
|
children: node.title
|
|
722
762
|
});
|
|
723
763
|
return {
|
|
@@ -1306,15 +1346,6 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1306
1346
|
const handleOpenEndPointView = () => {
|
|
1307
1347
|
selectNodeByKey(api.id);
|
|
1308
1348
|
};
|
|
1309
|
-
const TooltippedText = ({ text }) => {
|
|
1310
|
-
const limitation = viewStyle == "grid" ? 15 : 36;
|
|
1311
|
-
if (text.length < limitation) return text;
|
|
1312
|
-
return /* @__PURE__ */ jsxs(Tooltip, {
|
|
1313
|
-
title: text,
|
|
1314
|
-
placement: "bottomLeft",
|
|
1315
|
-
children: [text.substring(0, limitation), "..."]
|
|
1316
|
-
});
|
|
1317
|
-
};
|
|
1318
1349
|
const MethodChip = ({ method }) => {
|
|
1319
1350
|
const methodStyle = methodColors$1[method];
|
|
1320
1351
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1345,7 +1376,11 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1345
1376
|
className: cx("list-title"),
|
|
1346
1377
|
level: 4,
|
|
1347
1378
|
onClick: handleOpenEndPointView,
|
|
1348
|
-
children: /* @__PURE__ */ jsx(
|
|
1379
|
+
children: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
1380
|
+
title: api?.summary || "Endpoint Name",
|
|
1381
|
+
placement: "bottomLeft",
|
|
1382
|
+
children: api?.summary || "Endpoint Name"
|
|
1383
|
+
})
|
|
1349
1384
|
})]
|
|
1350
1385
|
}), /* @__PURE__ */ jsx(Button, {
|
|
1351
1386
|
className: cx("list-see-details"),
|
|
@@ -1376,7 +1411,11 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1376
1411
|
/* @__PURE__ */ jsx(Title, {
|
|
1377
1412
|
className: cx("grid-title"),
|
|
1378
1413
|
level: 4,
|
|
1379
|
-
children: /* @__PURE__ */ jsx(
|
|
1414
|
+
children: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
1415
|
+
title: api?.summary || "Endpoint Name",
|
|
1416
|
+
placement: "bottomLeft",
|
|
1417
|
+
children: api?.summary || "Endpoint Name"
|
|
1418
|
+
})
|
|
1380
1419
|
}),
|
|
1381
1420
|
/* @__PURE__ */ jsxs("div", {
|
|
1382
1421
|
className: cx("grid-content"),
|
|
@@ -1513,16 +1552,19 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
|
|
|
1513
1552
|
return wrapSSR(/* @__PURE__ */ jsxs("div", {
|
|
1514
1553
|
className: cx("root"),
|
|
1515
1554
|
children: [
|
|
1516
|
-
/* @__PURE__ */ jsx(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1555
|
+
/* @__PURE__ */ jsx(OverflowTooltip, {
|
|
1556
|
+
title: api.title,
|
|
1557
|
+
children: /* @__PURE__ */ jsx(Typography.Title, {
|
|
1558
|
+
level: 4,
|
|
1559
|
+
className: cx("title"),
|
|
1560
|
+
ellipsis: true,
|
|
1561
|
+
style: {
|
|
1562
|
+
margin: 0,
|
|
1563
|
+
fontSize: 20,
|
|
1564
|
+
fontWeight: 600
|
|
1565
|
+
},
|
|
1566
|
+
children: api.title
|
|
1567
|
+
})
|
|
1526
1568
|
}),
|
|
1527
1569
|
/* @__PURE__ */ jsxs("div", {
|
|
1528
1570
|
className: cx("meta-bar"),
|
|
@@ -1703,6 +1745,36 @@ const APIsRenderer = ({ apis, withTitle, tagName, haveUnderLine, contextPath, vi
|
|
|
1703
1745
|
}, `${tagName}_renderer_${contextPath}`);
|
|
1704
1746
|
};
|
|
1705
1747
|
//#endregion
|
|
1748
|
+
//#region src/utils/generateExampleFromSchema.ts
|
|
1749
|
+
function generateExampleFromSchema(schema) {
|
|
1750
|
+
if (!schema) return null;
|
|
1751
|
+
if (schema.example !== void 0) return schema.example;
|
|
1752
|
+
if (schema.examples !== void 0) return Array.isArray(schema.examples) ? schema.examples[0] : schema.examples;
|
|
1753
|
+
if (schema.properties) {
|
|
1754
|
+
const result = {};
|
|
1755
|
+
for (const [key, prop] of Object.entries(schema.properties)) result[key] = generateExampleFromSchema(prop);
|
|
1756
|
+
return result;
|
|
1757
|
+
}
|
|
1758
|
+
if (schema.type === "array" && schema.items) return [generateExampleFromSchema(schema.items)];
|
|
1759
|
+
if (schema.enum && schema.enum.length > 0) return schema.enum[0];
|
|
1760
|
+
switch (schema.type) {
|
|
1761
|
+
case "string": return "string";
|
|
1762
|
+
case "integer":
|
|
1763
|
+
case "number": return 0;
|
|
1764
|
+
case "boolean": return false;
|
|
1765
|
+
case "array": return [];
|
|
1766
|
+
case "object": return {};
|
|
1767
|
+
default: return null;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
function hasAnyExample(schema) {
|
|
1771
|
+
if (!schema) return false;
|
|
1772
|
+
if (schema.example !== void 0 || schema.examples !== void 0) return true;
|
|
1773
|
+
if (schema.properties) return Object.values(schema.properties).some(hasAnyExample);
|
|
1774
|
+
if (schema.type === "array" && schema.items) return hasAnyExample(schema.items);
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
//#endregion
|
|
1706
1778
|
//#region src/utils/index.ts
|
|
1707
1779
|
const handleStatusColor = (code) => {
|
|
1708
1780
|
if (code >= 200 && code < 300) return "green";
|
|
@@ -1757,7 +1829,7 @@ const buildRequestData$1 = (params, colors) => [...params].sort((a, b) => a.requ
|
|
|
1757
1829
|
})
|
|
1758
1830
|
] }),
|
|
1759
1831
|
desc: p.description || "--",
|
|
1760
|
-
enum: p.schema?.enum ? p.schema.enum.map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1832
|
+
enum: p.schema?.enum ?? p.schema?.items?.enum ? (p.schema?.enum ?? p.schema?.items?.enum).map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1761
1833
|
};
|
|
1762
1834
|
});
|
|
1763
1835
|
const buildHeaderData$1 = (headers, colors) => {
|
|
@@ -1786,7 +1858,7 @@ const buildHeaderData$1 = (headers, colors) => {
|
|
|
1786
1858
|
})
|
|
1787
1859
|
] }, idx),
|
|
1788
1860
|
desc: header.description || "--",
|
|
1789
|
-
enum: header.schema?.enum ? header.schema.enum.map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1861
|
+
enum: header.schema?.enum ?? header.schema?.items?.enum ? (header.schema?.enum ?? header.schema?.items?.enum).map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1790
1862
|
};
|
|
1791
1863
|
});
|
|
1792
1864
|
};
|
|
@@ -2221,7 +2293,7 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
|
|
|
2221
2293
|
className: cx("mobileBottomRow"),
|
|
2222
2294
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2223
2295
|
className: cx("title-section"),
|
|
2224
|
-
children: [/* @__PURE__ */ jsx(
|
|
2296
|
+
children: [/* @__PURE__ */ jsx(OverflowTooltip, {
|
|
2225
2297
|
title: apiName,
|
|
2226
2298
|
children: /* @__PURE__ */ jsx(Title$2, {
|
|
2227
2299
|
level: 3,
|
|
@@ -2259,7 +2331,7 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
|
|
|
2259
2331
|
children: [
|
|
2260
2332
|
/* @__PURE__ */ jsx("div", {
|
|
2261
2333
|
className: cx("title-section"),
|
|
2262
|
-
children: /* @__PURE__ */ jsx(
|
|
2334
|
+
children: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
2263
2335
|
title: `${apiName} API Documentation`,
|
|
2264
2336
|
children: /* @__PURE__ */ jsxs(Title$2, {
|
|
2265
2337
|
level: 3,
|
|
@@ -3364,6 +3436,27 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
3364
3436
|
}));
|
|
3365
3437
|
});
|
|
3366
3438
|
}, [openResponsePanels, responseBodySchemas]);
|
|
3439
|
+
useEffect(() => {
|
|
3440
|
+
if (!openResponsePanels.size) return;
|
|
3441
|
+
openResponsePanels.forEach((epId) => {
|
|
3442
|
+
const code = selectedStatusCodes[epId];
|
|
3443
|
+
if (!code) return;
|
|
3444
|
+
const ep = Object.values(endpointsByTag).flat().find((e) => e.id === epId);
|
|
3445
|
+
if (!ep?.responses?.[code]?.content) return;
|
|
3446
|
+
const content = ep.responses[code].content;
|
|
3447
|
+
const schema = Object.values(content)[0]?.schema;
|
|
3448
|
+
if (!schema) return;
|
|
3449
|
+
const json = JSON.stringify(schema, null, 2);
|
|
3450
|
+
setEditableResponseContent((prev) => ({
|
|
3451
|
+
...prev,
|
|
3452
|
+
[epId]: json
|
|
3453
|
+
}));
|
|
3454
|
+
});
|
|
3455
|
+
}, [
|
|
3456
|
+
selectedStatusCodes,
|
|
3457
|
+
openResponsePanels,
|
|
3458
|
+
endpointsByTag
|
|
3459
|
+
]);
|
|
3367
3460
|
const handleValidate = (content) => {
|
|
3368
3461
|
try {
|
|
3369
3462
|
JSON.parse(content);
|
|
@@ -4138,7 +4231,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
4138
4231
|
backgroundColor: methodColor?.bg ?? "transparent"
|
|
4139
4232
|
},
|
|
4140
4233
|
children: ep.method
|
|
4141
|
-
}), /* @__PURE__ */ jsx(
|
|
4234
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
4142
4235
|
title: ep.path,
|
|
4143
4236
|
children: /* @__PURE__ */ jsx(Title, {
|
|
4144
4237
|
level: 4,
|
|
@@ -5347,7 +5440,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
5347
5440
|
backgroundColor: isExpanded ? methodColor?.color : "transparent"
|
|
5348
5441
|
},
|
|
5349
5442
|
children: ep.method
|
|
5350
|
-
}), /* @__PURE__ */ jsx(
|
|
5443
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
5351
5444
|
title: ep.path,
|
|
5352
5445
|
children: /* @__PURE__ */ jsx("span", {
|
|
5353
5446
|
className: cx("endpoint-path"),
|
|
@@ -5453,14 +5546,21 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
5453
5546
|
const selectedCode = selectedStatusCodes[ep.id] ?? (Object.keys(ep.responses ?? {}).includes("200") ? "200" : Object.keys(ep.responses ?? {})[0]);
|
|
5454
5547
|
const responseContent = ep.responses?.[selectedCode]?.content;
|
|
5455
5548
|
if (!responseContent) return null;
|
|
5456
|
-
const
|
|
5549
|
+
const contentEntry = Object.values(responseContent)[0];
|
|
5550
|
+
if (!contentEntry) return null;
|
|
5551
|
+
const schema = contentEntry.schema;
|
|
5457
5552
|
if (!schema) return null;
|
|
5553
|
+
let displayData;
|
|
5554
|
+
if (contentEntry.example !== void 0) displayData = contentEntry.example;
|
|
5555
|
+
else if (contentEntry.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
|
|
5556
|
+
else if (hasAnyExample(schema)) displayData = generateExampleFromSchema(schema);
|
|
5557
|
+
else displayData = schema;
|
|
5458
5558
|
return /* @__PURE__ */ jsx("div", {
|
|
5459
5559
|
className: cx("code-panel"),
|
|
5460
5560
|
style: { marginTop: token.marginSM },
|
|
5461
5561
|
children: /* @__PURE__ */ jsx("code", {
|
|
5462
5562
|
className: cx("code-area"),
|
|
5463
|
-
children: JSON.stringify(
|
|
5563
|
+
children: JSON.stringify(displayData, null, 2)
|
|
5464
5564
|
})
|
|
5465
5565
|
});
|
|
5466
5566
|
})()
|
|
@@ -7809,53 +7909,50 @@ const buildTreeDataStructure = (data) => {
|
|
|
7809
7909
|
if (!data) return [];
|
|
7810
7910
|
return data.map((api) => {
|
|
7811
7911
|
const tagEntries = Object.entries(api.tags);
|
|
7812
|
-
const
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
key: endpoint.id,
|
|
7817
|
-
isLeaf: true,
|
|
7912
|
+
const hasOnlyDefaultTag = tagEntries.length === 1 && tagEntries[0][0] === "default";
|
|
7913
|
+
return {
|
|
7914
|
+
title: api.title,
|
|
7915
|
+
key: api.id,
|
|
7818
7916
|
selectable: true,
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
endpoint,
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
parentApiId: api.id
|
|
7825
|
-
}
|
|
7826
|
-
})) : [];
|
|
7827
|
-
const tagNodes = nonDefaultTags.map(([tag, endpoints]) => {
|
|
7828
|
-
const tagId = `tag-${api.id}-${tag.replace(/\s+/g, "-").toLowerCase()}`;
|
|
7829
|
-
return {
|
|
7830
|
-
title: tag,
|
|
7831
|
-
key: tagId,
|
|
7917
|
+
data: api,
|
|
7918
|
+
children: hasOnlyDefaultTag ? tagEntries[0][1].map((endpoint) => ({
|
|
7919
|
+
title: endpoint.summary,
|
|
7920
|
+
key: endpoint.id,
|
|
7921
|
+
isLeaf: true,
|
|
7832
7922
|
selectable: true,
|
|
7923
|
+
method: endpoint.method,
|
|
7833
7924
|
data: {
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7925
|
+
endpoint,
|
|
7926
|
+
api,
|
|
7927
|
+
tagName: "default",
|
|
7928
|
+
parentApiId: api.id
|
|
7929
|
+
}
|
|
7930
|
+
})) : tagEntries.map(([tag, endpoints]) => {
|
|
7931
|
+
const tagId = `tag-${api.id}-${tag.replace(/\s+/g, "-").toLowerCase()}`;
|
|
7932
|
+
return {
|
|
7933
|
+
title: tag,
|
|
7934
|
+
key: tagId,
|
|
7841
7935
|
selectable: true,
|
|
7842
|
-
method: endpoint.method,
|
|
7843
7936
|
data: {
|
|
7844
|
-
endpoint,
|
|
7845
|
-
api,
|
|
7846
7937
|
tagName: tag,
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7938
|
+
apiData: api
|
|
7939
|
+
},
|
|
7940
|
+
children: endpoints.map((endpoint) => ({
|
|
7941
|
+
title: endpoint.summary,
|
|
7942
|
+
key: endpoint.id,
|
|
7943
|
+
isLeaf: true,
|
|
7944
|
+
selectable: true,
|
|
7945
|
+
method: endpoint.method,
|
|
7946
|
+
data: {
|
|
7947
|
+
endpoint,
|
|
7948
|
+
api,
|
|
7949
|
+
tagName: tag,
|
|
7950
|
+
parentApiId: api.id,
|
|
7951
|
+
tagId
|
|
7952
|
+
}
|
|
7953
|
+
}))
|
|
7954
|
+
};
|
|
7955
|
+
})
|
|
7859
7956
|
};
|
|
7860
7957
|
});
|
|
7861
7958
|
};
|
|
@@ -7991,7 +8088,6 @@ const getSidebarStyles = (token, scope) => ({
|
|
|
7991
8088
|
});
|
|
7992
8089
|
//#endregion
|
|
7993
8090
|
//#region src/view/console/helper/sidebar.components.tsx
|
|
7994
|
-
const { Text: Text$1 } = Typography;
|
|
7995
8091
|
const EndpointItem = ({ method, title, cx, isSelected = false }) => {
|
|
7996
8092
|
const methodStyle = (isSelected ? darkerMethodColors : sidebarMethodColors)[method];
|
|
7997
8093
|
const isPost = method?.toUpperCase() === "POST";
|
|
@@ -8006,9 +8102,9 @@ const EndpointItem = ({ method, title, cx, isSelected = false }) => {
|
|
|
8006
8102
|
...isPost ? { borderRadius: 4 } : {}
|
|
8007
8103
|
},
|
|
8008
8104
|
children: method
|
|
8009
|
-
}), /* @__PURE__ */ jsx(
|
|
8105
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8106
|
+
title,
|
|
8010
8107
|
className: cx("endpoint-text"),
|
|
8011
|
-
ellipsis: { tooltip: title },
|
|
8012
8108
|
style: { flex: 1 },
|
|
8013
8109
|
children: title
|
|
8014
8110
|
})]
|
|
@@ -8025,14 +8121,14 @@ const convertToRenderableTreeData = (treeDataStructure, selectedEndpoint, cx) =>
|
|
|
8025
8121
|
cx,
|
|
8026
8122
|
isSelected
|
|
8027
8123
|
});
|
|
8028
|
-
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) title = /* @__PURE__ */ jsx(
|
|
8124
|
+
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8125
|
+
title: typeof node.title === "string" ? node.title : "API Name",
|
|
8029
8126
|
className: cx("api-title"),
|
|
8030
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
|
|
8031
8127
|
children: node.title
|
|
8032
8128
|
});
|
|
8033
|
-
else title = /* @__PURE__ */ jsx(
|
|
8129
|
+
else title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8130
|
+
title: typeof node.title === "string" ? node.title : "",
|
|
8034
8131
|
className: cx("tag-title"),
|
|
8035
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
|
|
8036
8132
|
children: node.title
|
|
8037
8133
|
});
|
|
8038
8134
|
return {
|
|
@@ -8323,7 +8419,7 @@ const buildRequestData = (params, token) => [...params].sort((a, b) => a.require
|
|
|
8323
8419
|
children: p.description || "--"
|
|
8324
8420
|
})
|
|
8325
8421
|
}),
|
|
8326
|
-
enum: p.schema?.enum ? renderEnumTags(p.schema.enum, token) : "--"
|
|
8422
|
+
enum: p.schema?.enum ?? p.schema?.items?.enum ? renderEnumTags(p.schema?.enum ?? p.schema?.items?.enum, token) : "--"
|
|
8327
8423
|
};
|
|
8328
8424
|
});
|
|
8329
8425
|
const buildHeaderData = (headers, token) => {
|
|
@@ -8373,7 +8469,7 @@ const buildHeaderData = (headers, token) => {
|
|
|
8373
8469
|
]
|
|
8374
8470
|
}, idx),
|
|
8375
8471
|
desc: header.description || "--",
|
|
8376
|
-
enum: header.schema?.enum ? renderEnumTags(header.schema.enum, token) : "--"
|
|
8472
|
+
enum: header.schema?.enum ?? header.schema?.items?.enum ? renderEnumTags(header.schema?.enum ?? header.schema?.items?.enum, token) : "--"
|
|
8377
8473
|
};
|
|
8378
8474
|
});
|
|
8379
8475
|
};
|
|
@@ -8515,18 +8611,10 @@ const EndpointPage = () => {
|
|
|
8515
8611
|
children: /* @__PURE__ */ jsx("span", { children: selectedEndpoint?.tagName || "default" })
|
|
8516
8612
|
})
|
|
8517
8613
|
},
|
|
8518
|
-
{ title: /* @__PURE__ */ jsx(
|
|
8614
|
+
{ title: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8519
8615
|
title: selectedEndpoint?.summary || "Endpoint Name",
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
overflow: "hidden",
|
|
8523
|
-
textOverflow: "ellipsis",
|
|
8524
|
-
whiteSpace: "nowrap",
|
|
8525
|
-
display: "block",
|
|
8526
|
-
maxWidth: "300px"
|
|
8527
|
-
},
|
|
8528
|
-
children: selectedEndpoint?.summary || "Endpoint Name"
|
|
8529
|
-
})
|
|
8616
|
+
style: { maxWidth: "300px" },
|
|
8617
|
+
children: /* @__PURE__ */ jsx("span", { children: selectedEndpoint?.summary || "Endpoint Name" })
|
|
8530
8618
|
}) }
|
|
8531
8619
|
] })]
|
|
8532
8620
|
}),
|
|
@@ -8549,16 +8637,9 @@ const EndpointPage = () => {
|
|
|
8549
8637
|
flexShrink: 0
|
|
8550
8638
|
},
|
|
8551
8639
|
children: selectedEndpoint?.method
|
|
8552
|
-
}), /* @__PURE__ */ jsx(
|
|
8640
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8553
8641
|
title: selectedEndpoint?.summary ?? "--",
|
|
8554
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
8555
|
-
style: {
|
|
8556
|
-
overflow: "hidden",
|
|
8557
|
-
textOverflow: "ellipsis",
|
|
8558
|
-
whiteSpace: "nowrap"
|
|
8559
|
-
},
|
|
8560
|
-
children: selectedEndpoint?.summary?.replace(selectedEndpoint?.method, "") ?? "--"
|
|
8561
|
-
})
|
|
8642
|
+
children: /* @__PURE__ */ jsx("span", { children: selectedEndpoint?.summary?.replace(selectedEndpoint?.method, "") ?? "--" })
|
|
8562
8643
|
})]
|
|
8563
8644
|
}),
|
|
8564
8645
|
/* @__PURE__ */ jsx(Paragraph, {
|
|
@@ -8765,19 +8846,12 @@ function CodeboxSidebar$1() {
|
|
|
8765
8846
|
} }), code]
|
|
8766
8847
|
})
|
|
8767
8848
|
})), [statusCodeOptions]);
|
|
8768
|
-
const [curlTooltip, setCurlTooltip] = useState("Copy Request");
|
|
8769
8849
|
const curlCommand = (() => {
|
|
8770
8850
|
if (!selectedEndpoint || !Array.isArray(selectedApi?.curl)) return "";
|
|
8771
8851
|
return selectedApi.curl.find((c) => c.path === selectedEndpoint.path && c.method?.toUpperCase() === selectedEndpoint.method.toUpperCase())?.curlCommand ?? "";
|
|
8772
8852
|
})();
|
|
8773
|
-
const
|
|
8774
|
-
|
|
8775
|
-
const params = selectedEndpoint.parameters ?? [];
|
|
8776
|
-
const serverUrl = selectedApi?.servers?.[0]?.url ?? "";
|
|
8777
|
-
const resolvedPath = params.filter((p) => p.in === "path").reduce((acc, p) => acc.replace(`{${p.name}}`, "sample-value"), selectedEndpoint.path);
|
|
8778
|
-
const queryParams = params.filter((p) => p.in === "query");
|
|
8779
|
-
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'`)];
|
|
8780
|
-
})();
|
|
8853
|
+
const curlDisplayLines = curlCommand.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
8854
|
+
const [curlTooltip, setCurlTooltip] = useState("Copy Request");
|
|
8781
8855
|
const { token: antdToken, theme: themeConfig } = theme.useToken();
|
|
8782
8856
|
const isDark = themeConfig.id == 1;
|
|
8783
8857
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8923,7 +8997,7 @@ function CodeboxSidebar$1() {
|
|
|
8923
8997
|
})]
|
|
8924
8998
|
}), /* @__PURE__ */ jsx("div", {
|
|
8925
8999
|
className: cx("curl-list"),
|
|
8926
|
-
children:
|
|
9000
|
+
children: curlDisplayLines.map((line, i) => /* @__PURE__ */ jsx("div", {
|
|
8927
9001
|
className: cx("curl-line"),
|
|
8928
9002
|
children: line
|
|
8929
9003
|
}, i))
|
|
@@ -8948,7 +9022,17 @@ function CodeboxSidebar$1() {
|
|
|
8948
9022
|
open: httpStatusOptions.length === 1 ? false : void 0,
|
|
8949
9023
|
suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
|
|
8950
9024
|
})]
|
|
8951
|
-
}),
|
|
9025
|
+
}), (() => {
|
|
9026
|
+
const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
|
|
9027
|
+
const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
|
|
9028
|
+
let displayData;
|
|
9029
|
+
if (contentEntry?.example !== void 0) displayData = contentEntry.example;
|
|
9030
|
+
else if (contentEntry?.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
|
|
9031
|
+
else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
|
|
9032
|
+
else if (contentEntry?.schema) displayData = contentEntry.schema;
|
|
9033
|
+
else displayData = responseObj;
|
|
9034
|
+
return /* @__PURE__ */ jsx(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
|
|
9035
|
+
})()]
|
|
8952
9036
|
})]
|
|
8953
9037
|
});
|
|
8954
9038
|
}
|
|
@@ -9302,7 +9386,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9302
9386
|
type: schema?.type ?? "string",
|
|
9303
9387
|
required: Boolean(p.required ?? false),
|
|
9304
9388
|
description: p.description != null ? String(p.description) : void 0,
|
|
9305
|
-
enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
|
|
9389
|
+
enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
|
|
9306
9390
|
...schema?.items && { items: { type: schema.items.type ?? "string" } }
|
|
9307
9391
|
};
|
|
9308
9392
|
});
|
|
@@ -9333,7 +9417,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9333
9417
|
type: schema?.type ?? "string",
|
|
9334
9418
|
required: Boolean(p.required ?? false),
|
|
9335
9419
|
description: p.description != null ? String(p.description) : void 0,
|
|
9336
|
-
enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
|
|
9420
|
+
enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
|
|
9337
9421
|
...schema?.items && { items: { type: schema.items.type ?? "string" } }
|
|
9338
9422
|
};
|
|
9339
9423
|
});
|
|
@@ -9605,8 +9689,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9605
9689
|
...param.description && { description: param.description },
|
|
9606
9690
|
schema: {
|
|
9607
9691
|
type: param.type,
|
|
9608
|
-
...param.enum && param.enum.length > 0
|
|
9609
|
-
|
|
9692
|
+
...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
|
|
9693
|
+
type: param.items?.type ?? "string",
|
|
9694
|
+
enum: param.enum
|
|
9695
|
+
} } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
|
|
9696
|
+
...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
|
|
9610
9697
|
}
|
|
9611
9698
|
}));
|
|
9612
9699
|
else delete methodObj.parameters;
|
|
@@ -9623,8 +9710,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9623
9710
|
...param.description && { description: param.description },
|
|
9624
9711
|
schema: {
|
|
9625
9712
|
type: param.type,
|
|
9626
|
-
...param.enum && param.enum.length > 0
|
|
9627
|
-
|
|
9713
|
+
...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
|
|
9714
|
+
type: param.items?.type ?? "string",
|
|
9715
|
+
enum: param.enum
|
|
9716
|
+
} } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
|
|
9717
|
+
...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
|
|
9628
9718
|
}
|
|
9629
9719
|
}));
|
|
9630
9720
|
else delete methodObj["x-response-params"];
|
|
@@ -10665,7 +10755,17 @@ function CodeboxSidebar() {
|
|
|
10665
10755
|
open: httpStatusOptions.length === 1 ? false : void 0,
|
|
10666
10756
|
suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
|
|
10667
10757
|
})]
|
|
10668
|
-
}),
|
|
10758
|
+
}), (() => {
|
|
10759
|
+
const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
|
|
10760
|
+
const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
|
|
10761
|
+
let displayData;
|
|
10762
|
+
if (contentEntry?.example !== void 0) displayData = contentEntry.example;
|
|
10763
|
+
else if (contentEntry?.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
|
|
10764
|
+
else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
|
|
10765
|
+
else if (contentEntry?.schema) displayData = contentEntry.schema;
|
|
10766
|
+
else displayData = responseObj;
|
|
10767
|
+
return /* @__PURE__ */ jsx(Codebox, { code: JSON.stringify(displayData, null, 2) || "" });
|
|
10768
|
+
})()]
|
|
10669
10769
|
})]
|
|
10670
10770
|
});
|
|
10671
10771
|
}
|