@digi-frontend/dgate-api-documentation 4.1.6 → 4.1.9
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 +242 -133
- 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 +243 -134
- 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,49 @@ 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
|
+
const target = el.firstElementChild ?? el;
|
|
686
|
+
setIsOverflowing(target.scrollWidth > target.clientWidth);
|
|
687
|
+
}, []);
|
|
688
|
+
useEffect(() => {
|
|
689
|
+
checkOverflow();
|
|
690
|
+
const el = ref.current;
|
|
691
|
+
if (!el) return;
|
|
692
|
+
const ro = new ResizeObserver(checkOverflow);
|
|
693
|
+
ro.observe(el);
|
|
694
|
+
return () => ro.disconnect();
|
|
695
|
+
}, [
|
|
696
|
+
checkOverflow,
|
|
697
|
+
children,
|
|
698
|
+
title
|
|
699
|
+
]);
|
|
700
|
+
const content = /* @__PURE__ */ jsx("span", {
|
|
701
|
+
ref,
|
|
702
|
+
className,
|
|
703
|
+
style: {
|
|
704
|
+
display: "block",
|
|
705
|
+
overflow: "hidden",
|
|
706
|
+
textOverflow: "ellipsis",
|
|
707
|
+
whiteSpace: "nowrap",
|
|
708
|
+
...style
|
|
709
|
+
},
|
|
710
|
+
children
|
|
711
|
+
});
|
|
712
|
+
if (!isOverflowing) return content;
|
|
713
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
714
|
+
title,
|
|
715
|
+
placement,
|
|
716
|
+
children: content
|
|
717
|
+
});
|
|
718
|
+
};
|
|
719
|
+
//#endregion
|
|
678
720
|
//#region src/view/helper/sidebar.components.tsx
|
|
679
|
-
const { Text: Text$2 } = Typography;
|
|
680
721
|
const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
|
|
681
722
|
const methodStyle = (isSelected ? darkerMethodColors$1 : methodColors$1)[method];
|
|
682
723
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -689,9 +730,9 @@ const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
|
|
|
689
730
|
border: "none"
|
|
690
731
|
},
|
|
691
732
|
children: method
|
|
692
|
-
}), /* @__PURE__ */ jsx(
|
|
733
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
734
|
+
title,
|
|
693
735
|
className: cx("endpoint-text"),
|
|
694
|
-
ellipsis: { tooltip: title },
|
|
695
736
|
style: { flex: 1 },
|
|
696
737
|
children: title
|
|
697
738
|
})]
|
|
@@ -710,14 +751,14 @@ const convertToRenderableTreeData$1 = (treeDataStructure, selectedEndpoint, cx)
|
|
|
710
751
|
});
|
|
711
752
|
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
|
|
712
753
|
const isHighlighted = isApiSectionHighlighted(node.key, selectedEndpoint);
|
|
713
|
-
title = /* @__PURE__ */ jsx(
|
|
754
|
+
title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
755
|
+
title: typeof node.title === "string" ? node.title : "API Name",
|
|
714
756
|
className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
|
|
715
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
|
|
716
757
|
children: node.title
|
|
717
758
|
});
|
|
718
|
-
} else title = /* @__PURE__ */ jsx(
|
|
759
|
+
} else title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
760
|
+
title: typeof node.title === "string" ? node.title : "",
|
|
719
761
|
className: cx("tag-title"),
|
|
720
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
|
|
721
762
|
children: node.title
|
|
722
763
|
});
|
|
723
764
|
return {
|
|
@@ -1232,7 +1273,7 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1232
1273
|
borderRadius: token.borderRadiusSM,
|
|
1233
1274
|
border: `1px solid ${token.colorBorderSecondary}`,
|
|
1234
1275
|
minWidth: "6.25rem",
|
|
1235
|
-
maxWidth: "
|
|
1276
|
+
maxWidth: "100%",
|
|
1236
1277
|
svg: { path: { fill: "#4D75D9" } }
|
|
1237
1278
|
},
|
|
1238
1279
|
[scope("list-title")]: {
|
|
@@ -1245,6 +1286,9 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1245
1286
|
fontFamily: token.fontFamily,
|
|
1246
1287
|
cursor: "pointer",
|
|
1247
1288
|
transition: "color 0.2s ease-in",
|
|
1289
|
+
overflow: "hidden",
|
|
1290
|
+
textOverflow: "ellipsis",
|
|
1291
|
+
whiteSpace: "nowrap",
|
|
1248
1292
|
"&:hover": {
|
|
1249
1293
|
color: `${token.colorPrimary} !important`,
|
|
1250
1294
|
textDecoration: "underline"
|
|
@@ -1306,15 +1350,6 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1306
1350
|
const handleOpenEndPointView = () => {
|
|
1307
1351
|
selectNodeByKey(api.id);
|
|
1308
1352
|
};
|
|
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
1353
|
const MethodChip = ({ method }) => {
|
|
1319
1354
|
const methodStyle = methodColors$1[method];
|
|
1320
1355
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1341,11 +1376,16 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1341
1376
|
className: cx("list-container"),
|
|
1342
1377
|
children: [/* @__PURE__ */ jsxs(Flex, {
|
|
1343
1378
|
gap: token.marginSM,
|
|
1379
|
+
style: { minWidth: 0 },
|
|
1344
1380
|
children: [/* @__PURE__ */ jsx(MethodChip, { method: api.method }), /* @__PURE__ */ jsx(Title, {
|
|
1345
1381
|
className: cx("list-title"),
|
|
1346
1382
|
level: 4,
|
|
1347
1383
|
onClick: handleOpenEndPointView,
|
|
1348
|
-
children: /* @__PURE__ */ jsx(
|
|
1384
|
+
children: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
1385
|
+
title: api?.summary || "Endpoint Name",
|
|
1386
|
+
placement: "bottomLeft",
|
|
1387
|
+
children: api?.summary || "Endpoint Name"
|
|
1388
|
+
})
|
|
1349
1389
|
})]
|
|
1350
1390
|
}), /* @__PURE__ */ jsx(Button, {
|
|
1351
1391
|
className: cx("list-see-details"),
|
|
@@ -1376,7 +1416,11 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1376
1416
|
/* @__PURE__ */ jsx(Title, {
|
|
1377
1417
|
className: cx("grid-title"),
|
|
1378
1418
|
level: 4,
|
|
1379
|
-
children: /* @__PURE__ */ jsx(
|
|
1419
|
+
children: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
1420
|
+
title: api?.summary || "Endpoint Name",
|
|
1421
|
+
placement: "bottomLeft",
|
|
1422
|
+
children: api?.summary || "Endpoint Name"
|
|
1423
|
+
})
|
|
1380
1424
|
}),
|
|
1381
1425
|
/* @__PURE__ */ jsxs("div", {
|
|
1382
1426
|
className: cx("grid-content"),
|
|
@@ -1513,16 +1557,19 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
|
|
|
1513
1557
|
return wrapSSR(/* @__PURE__ */ jsxs("div", {
|
|
1514
1558
|
className: cx("root"),
|
|
1515
1559
|
children: [
|
|
1516
|
-
/* @__PURE__ */ jsx(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1560
|
+
/* @__PURE__ */ jsx(OverflowTooltip, {
|
|
1561
|
+
title: api.title,
|
|
1562
|
+
children: /* @__PURE__ */ jsx(Typography.Title, {
|
|
1563
|
+
level: 4,
|
|
1564
|
+
className: cx("title"),
|
|
1565
|
+
ellipsis: true,
|
|
1566
|
+
style: {
|
|
1567
|
+
margin: 0,
|
|
1568
|
+
fontSize: 20,
|
|
1569
|
+
fontWeight: 600
|
|
1570
|
+
},
|
|
1571
|
+
children: api.title
|
|
1572
|
+
})
|
|
1526
1573
|
}),
|
|
1527
1574
|
/* @__PURE__ */ jsxs("div", {
|
|
1528
1575
|
className: cx("meta-bar"),
|
|
@@ -1703,6 +1750,36 @@ const APIsRenderer = ({ apis, withTitle, tagName, haveUnderLine, contextPath, vi
|
|
|
1703
1750
|
}, `${tagName}_renderer_${contextPath}`);
|
|
1704
1751
|
};
|
|
1705
1752
|
//#endregion
|
|
1753
|
+
//#region src/utils/generateExampleFromSchema.ts
|
|
1754
|
+
function generateExampleFromSchema(schema) {
|
|
1755
|
+
if (!schema) return null;
|
|
1756
|
+
if (schema.example !== void 0) return schema.example;
|
|
1757
|
+
if (schema.examples !== void 0) return Array.isArray(schema.examples) ? schema.examples[0] : schema.examples;
|
|
1758
|
+
if (schema.properties) {
|
|
1759
|
+
const result = {};
|
|
1760
|
+
for (const [key, prop] of Object.entries(schema.properties)) result[key] = generateExampleFromSchema(prop);
|
|
1761
|
+
return result;
|
|
1762
|
+
}
|
|
1763
|
+
if (schema.type === "array" && schema.items) return [generateExampleFromSchema(schema.items)];
|
|
1764
|
+
if (schema.enum && schema.enum.length > 0) return schema.enum[0];
|
|
1765
|
+
switch (schema.type) {
|
|
1766
|
+
case "string": return "string";
|
|
1767
|
+
case "integer":
|
|
1768
|
+
case "number": return 0;
|
|
1769
|
+
case "boolean": return false;
|
|
1770
|
+
case "array": return [];
|
|
1771
|
+
case "object": return {};
|
|
1772
|
+
default: return null;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function hasAnyExample(schema) {
|
|
1776
|
+
if (!schema) return false;
|
|
1777
|
+
if (schema.example !== void 0 || schema.examples !== void 0) return true;
|
|
1778
|
+
if (schema.properties) return Object.values(schema.properties).some(hasAnyExample);
|
|
1779
|
+
if (schema.type === "array" && schema.items) return hasAnyExample(schema.items);
|
|
1780
|
+
return false;
|
|
1781
|
+
}
|
|
1782
|
+
//#endregion
|
|
1706
1783
|
//#region src/utils/index.ts
|
|
1707
1784
|
const handleStatusColor = (code) => {
|
|
1708
1785
|
if (code >= 200 && code < 300) return "green";
|
|
@@ -1757,7 +1834,7 @@ const buildRequestData$1 = (params, colors) => [...params].sort((a, b) => a.requ
|
|
|
1757
1834
|
})
|
|
1758
1835
|
] }),
|
|
1759
1836
|
desc: p.description || "--",
|
|
1760
|
-
enum: p.schema?.enum ? p.schema.enum.map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1837
|
+
enum: p.schema?.enum ?? p.schema?.items?.enum ? (p.schema?.enum ?? p.schema?.items?.enum).map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1761
1838
|
};
|
|
1762
1839
|
});
|
|
1763
1840
|
const buildHeaderData$1 = (headers, colors) => {
|
|
@@ -1786,7 +1863,7 @@ const buildHeaderData$1 = (headers, colors) => {
|
|
|
1786
1863
|
})
|
|
1787
1864
|
] }, idx),
|
|
1788
1865
|
desc: header.description || "--",
|
|
1789
|
-
enum: header.schema?.enum ? header.schema.enum.map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1866
|
+
enum: header.schema?.enum ?? header.schema?.items?.enum ? (header.schema?.enum ?? header.schema?.items?.enum).map((e) => /* @__PURE__ */ jsx(Tag, { children: e }, e)) : "--"
|
|
1790
1867
|
};
|
|
1791
1868
|
});
|
|
1792
1869
|
};
|
|
@@ -2221,15 +2298,17 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
|
|
|
2221
2298
|
className: cx("mobileBottomRow"),
|
|
2222
2299
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
2223
2300
|
className: cx("title-section"),
|
|
2224
|
-
children: [/* @__PURE__ */ jsx(
|
|
2301
|
+
children: [/* @__PURE__ */ jsx(OverflowTooltip, {
|
|
2225
2302
|
title: apiName,
|
|
2226
2303
|
children: /* @__PURE__ */ jsx(Title$2, {
|
|
2227
2304
|
level: 3,
|
|
2228
|
-
ellipsis: true,
|
|
2229
2305
|
style: {
|
|
2230
2306
|
margin: 0,
|
|
2231
2307
|
fontWeight: 600,
|
|
2232
|
-
color: token.colorTextHeading
|
|
2308
|
+
color: token.colorTextHeading,
|
|
2309
|
+
whiteSpace: "nowrap",
|
|
2310
|
+
overflow: "hidden",
|
|
2311
|
+
textOverflow: "ellipsis"
|
|
2233
2312
|
},
|
|
2234
2313
|
children: apiName
|
|
2235
2314
|
})
|
|
@@ -2259,7 +2338,7 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
|
|
|
2259
2338
|
children: [
|
|
2260
2339
|
/* @__PURE__ */ jsx("div", {
|
|
2261
2340
|
className: cx("title-section"),
|
|
2262
|
-
children: /* @__PURE__ */ jsx(
|
|
2341
|
+
children: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
2263
2342
|
title: `${apiName} API Documentation`,
|
|
2264
2343
|
children: /* @__PURE__ */ jsxs(Title$2, {
|
|
2265
2344
|
level: 3,
|
|
@@ -4138,7 +4217,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
4138
4217
|
backgroundColor: methodColor?.bg ?? "transparent"
|
|
4139
4218
|
},
|
|
4140
4219
|
children: ep.method
|
|
4141
|
-
}), /* @__PURE__ */ jsx(
|
|
4220
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
4142
4221
|
title: ep.path,
|
|
4143
4222
|
children: /* @__PURE__ */ jsx(Title, {
|
|
4144
4223
|
level: 4,
|
|
@@ -5347,7 +5426,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
5347
5426
|
backgroundColor: isExpanded ? methodColor?.color : "transparent"
|
|
5348
5427
|
},
|
|
5349
5428
|
children: ep.method
|
|
5350
|
-
}), /* @__PURE__ */ jsx(
|
|
5429
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
5351
5430
|
title: ep.path,
|
|
5352
5431
|
children: /* @__PURE__ */ jsx("span", {
|
|
5353
5432
|
className: cx("endpoint-path"),
|
|
@@ -5453,14 +5532,24 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
5453
5532
|
const selectedCode = selectedStatusCodes[ep.id] ?? (Object.keys(ep.responses ?? {}).includes("200") ? "200" : Object.keys(ep.responses ?? {})[0]);
|
|
5454
5533
|
const responseContent = ep.responses?.[selectedCode]?.content;
|
|
5455
5534
|
if (!responseContent) return null;
|
|
5456
|
-
const
|
|
5535
|
+
const contentEntry = Object.values(responseContent)[0];
|
|
5536
|
+
if (!contentEntry) return null;
|
|
5537
|
+
const schema = contentEntry.schema;
|
|
5457
5538
|
if (!schema) return null;
|
|
5539
|
+
let displayData;
|
|
5540
|
+
if (contentEntry.example !== void 0) displayData = contentEntry.example;
|
|
5541
|
+
else if (contentEntry.examples !== void 0) {
|
|
5542
|
+
const firstKey = Object.keys(contentEntry.examples)[0];
|
|
5543
|
+
const firstExample = contentEntry.examples[firstKey];
|
|
5544
|
+
displayData = firstExample?.value ?? firstExample;
|
|
5545
|
+
} else if (hasAnyExample(schema)) displayData = generateExampleFromSchema(schema);
|
|
5546
|
+
else displayData = schema;
|
|
5458
5547
|
return /* @__PURE__ */ jsx("div", {
|
|
5459
5548
|
className: cx("code-panel"),
|
|
5460
5549
|
style: { marginTop: token.marginSM },
|
|
5461
5550
|
children: /* @__PURE__ */ jsx("code", {
|
|
5462
5551
|
className: cx("code-area"),
|
|
5463
|
-
children: JSON.stringify(
|
|
5552
|
+
children: JSON.stringify(displayData, null, 2)
|
|
5464
5553
|
})
|
|
5465
5554
|
});
|
|
5466
5555
|
})()
|
|
@@ -7148,7 +7237,6 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag,
|
|
|
7148
7237
|
alignItems: "center",
|
|
7149
7238
|
position: "relative",
|
|
7150
7239
|
paddingTop: 20,
|
|
7151
|
-
paddingBottom: 8,
|
|
7152
7240
|
paddingLeft: 24,
|
|
7153
7241
|
paddingRight: 24,
|
|
7154
7242
|
width: "100%"
|
|
@@ -7809,53 +7897,50 @@ const buildTreeDataStructure = (data) => {
|
|
|
7809
7897
|
if (!data) return [];
|
|
7810
7898
|
return data.map((api) => {
|
|
7811
7899
|
const tagEntries = Object.entries(api.tags);
|
|
7812
|
-
const
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
key: endpoint.id,
|
|
7817
|
-
isLeaf: true,
|
|
7900
|
+
const hasOnlyDefaultTag = tagEntries.length === 1 && tagEntries[0][0] === "default";
|
|
7901
|
+
return {
|
|
7902
|
+
title: api.title,
|
|
7903
|
+
key: api.id,
|
|
7818
7904
|
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,
|
|
7905
|
+
data: api,
|
|
7906
|
+
children: hasOnlyDefaultTag ? tagEntries[0][1].map((endpoint) => ({
|
|
7907
|
+
title: endpoint.summary,
|
|
7908
|
+
key: endpoint.id,
|
|
7909
|
+
isLeaf: true,
|
|
7832
7910
|
selectable: true,
|
|
7911
|
+
method: endpoint.method,
|
|
7833
7912
|
data: {
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7913
|
+
endpoint,
|
|
7914
|
+
api,
|
|
7915
|
+
tagName: "default",
|
|
7916
|
+
parentApiId: api.id
|
|
7917
|
+
}
|
|
7918
|
+
})) : tagEntries.map(([tag, endpoints]) => {
|
|
7919
|
+
const tagId = `tag-${api.id}-${tag.replace(/\s+/g, "-").toLowerCase()}`;
|
|
7920
|
+
return {
|
|
7921
|
+
title: tag,
|
|
7922
|
+
key: tagId,
|
|
7841
7923
|
selectable: true,
|
|
7842
|
-
method: endpoint.method,
|
|
7843
7924
|
data: {
|
|
7844
|
-
endpoint,
|
|
7845
|
-
api,
|
|
7846
7925
|
tagName: tag,
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7926
|
+
apiData: api
|
|
7927
|
+
},
|
|
7928
|
+
children: endpoints.map((endpoint) => ({
|
|
7929
|
+
title: endpoint.summary,
|
|
7930
|
+
key: endpoint.id,
|
|
7931
|
+
isLeaf: true,
|
|
7932
|
+
selectable: true,
|
|
7933
|
+
method: endpoint.method,
|
|
7934
|
+
data: {
|
|
7935
|
+
endpoint,
|
|
7936
|
+
api,
|
|
7937
|
+
tagName: tag,
|
|
7938
|
+
parentApiId: api.id,
|
|
7939
|
+
tagId
|
|
7940
|
+
}
|
|
7941
|
+
}))
|
|
7942
|
+
};
|
|
7943
|
+
})
|
|
7859
7944
|
};
|
|
7860
7945
|
});
|
|
7861
7946
|
};
|
|
@@ -7991,7 +8076,6 @@ const getSidebarStyles = (token, scope) => ({
|
|
|
7991
8076
|
});
|
|
7992
8077
|
//#endregion
|
|
7993
8078
|
//#region src/view/console/helper/sidebar.components.tsx
|
|
7994
|
-
const { Text: Text$1 } = Typography;
|
|
7995
8079
|
const EndpointItem = ({ method, title, cx, isSelected = false }) => {
|
|
7996
8080
|
const methodStyle = (isSelected ? darkerMethodColors : sidebarMethodColors)[method];
|
|
7997
8081
|
const isPost = method?.toUpperCase() === "POST";
|
|
@@ -8006,9 +8090,9 @@ const EndpointItem = ({ method, title, cx, isSelected = false }) => {
|
|
|
8006
8090
|
...isPost ? { borderRadius: 4 } : {}
|
|
8007
8091
|
},
|
|
8008
8092
|
children: method
|
|
8009
|
-
}), /* @__PURE__ */ jsx(
|
|
8093
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8094
|
+
title,
|
|
8010
8095
|
className: cx("endpoint-text"),
|
|
8011
|
-
ellipsis: { tooltip: title },
|
|
8012
8096
|
style: { flex: 1 },
|
|
8013
8097
|
children: title
|
|
8014
8098
|
})]
|
|
@@ -8025,14 +8109,14 @@ const convertToRenderableTreeData = (treeDataStructure, selectedEndpoint, cx) =>
|
|
|
8025
8109
|
cx,
|
|
8026
8110
|
isSelected
|
|
8027
8111
|
});
|
|
8028
|
-
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) title = /* @__PURE__ */ jsx(
|
|
8112
|
+
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8113
|
+
title: typeof node.title === "string" ? node.title : "API Name",
|
|
8029
8114
|
className: cx("api-title"),
|
|
8030
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
|
|
8031
8115
|
children: node.title
|
|
8032
8116
|
});
|
|
8033
|
-
else title = /* @__PURE__ */ jsx(
|
|
8117
|
+
else title = /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8118
|
+
title: typeof node.title === "string" ? node.title : "",
|
|
8034
8119
|
className: cx("tag-title"),
|
|
8035
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
|
|
8036
8120
|
children: node.title
|
|
8037
8121
|
});
|
|
8038
8122
|
return {
|
|
@@ -8323,7 +8407,7 @@ const buildRequestData = (params, token) => [...params].sort((a, b) => a.require
|
|
|
8323
8407
|
children: p.description || "--"
|
|
8324
8408
|
})
|
|
8325
8409
|
}),
|
|
8326
|
-
enum: p.schema?.enum ? renderEnumTags(p.schema.enum, token) : "--"
|
|
8410
|
+
enum: p.schema?.enum ?? p.schema?.items?.enum ? renderEnumTags(p.schema?.enum ?? p.schema?.items?.enum, token) : "--"
|
|
8327
8411
|
};
|
|
8328
8412
|
});
|
|
8329
8413
|
const buildHeaderData = (headers, token) => {
|
|
@@ -8373,7 +8457,7 @@ const buildHeaderData = (headers, token) => {
|
|
|
8373
8457
|
]
|
|
8374
8458
|
}, idx),
|
|
8375
8459
|
desc: header.description || "--",
|
|
8376
|
-
enum: header.schema?.enum ? renderEnumTags(header.schema.enum, token) : "--"
|
|
8460
|
+
enum: header.schema?.enum ?? header.schema?.items?.enum ? renderEnumTags(header.schema?.enum ?? header.schema?.items?.enum, token) : "--"
|
|
8377
8461
|
};
|
|
8378
8462
|
});
|
|
8379
8463
|
};
|
|
@@ -8515,18 +8599,10 @@ const EndpointPage = () => {
|
|
|
8515
8599
|
children: /* @__PURE__ */ jsx("span", { children: selectedEndpoint?.tagName || "default" })
|
|
8516
8600
|
})
|
|
8517
8601
|
},
|
|
8518
|
-
{ title: /* @__PURE__ */ jsx(
|
|
8602
|
+
{ title: /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8519
8603
|
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
|
-
})
|
|
8604
|
+
style: { maxWidth: "300px" },
|
|
8605
|
+
children: /* @__PURE__ */ jsx("span", { children: selectedEndpoint?.summary || "Endpoint Name" })
|
|
8530
8606
|
}) }
|
|
8531
8607
|
] })]
|
|
8532
8608
|
}),
|
|
@@ -8549,16 +8625,9 @@ const EndpointPage = () => {
|
|
|
8549
8625
|
flexShrink: 0
|
|
8550
8626
|
},
|
|
8551
8627
|
children: selectedEndpoint?.method
|
|
8552
|
-
}), /* @__PURE__ */ jsx(
|
|
8628
|
+
}), /* @__PURE__ */ jsx(OverflowTooltip, {
|
|
8553
8629
|
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
|
-
})
|
|
8630
|
+
children: /* @__PURE__ */ jsx("span", { children: selectedEndpoint?.summary?.replace(selectedEndpoint?.method, "") ?? "--" })
|
|
8562
8631
|
})]
|
|
8563
8632
|
}),
|
|
8564
8633
|
/* @__PURE__ */ jsx(Paragraph, {
|
|
@@ -8765,19 +8834,12 @@ function CodeboxSidebar$1() {
|
|
|
8765
8834
|
} }), code]
|
|
8766
8835
|
})
|
|
8767
8836
|
})), [statusCodeOptions]);
|
|
8768
|
-
const [curlTooltip, setCurlTooltip] = useState("Copy Request");
|
|
8769
8837
|
const curlCommand = (() => {
|
|
8770
8838
|
if (!selectedEndpoint || !Array.isArray(selectedApi?.curl)) return "";
|
|
8771
8839
|
return selectedApi.curl.find((c) => c.path === selectedEndpoint.path && c.method?.toUpperCase() === selectedEndpoint.method.toUpperCase())?.curlCommand ?? "";
|
|
8772
8840
|
})();
|
|
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
|
-
})();
|
|
8841
|
+
const curlDisplayLines = curlCommand.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
8842
|
+
const [curlTooltip, setCurlTooltip] = useState("Copy Request");
|
|
8781
8843
|
const { token: antdToken, theme: themeConfig } = theme.useToken();
|
|
8782
8844
|
const isDark = themeConfig.id == 1;
|
|
8783
8845
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8923,7 +8985,7 @@ function CodeboxSidebar$1() {
|
|
|
8923
8985
|
})]
|
|
8924
8986
|
}), /* @__PURE__ */ jsx("div", {
|
|
8925
8987
|
className: cx("curl-list"),
|
|
8926
|
-
children:
|
|
8988
|
+
children: curlDisplayLines.map((line, i) => /* @__PURE__ */ jsx("div", {
|
|
8927
8989
|
className: cx("curl-line"),
|
|
8928
8990
|
children: line
|
|
8929
8991
|
}, i))
|
|
@@ -8948,7 +9010,20 @@ function CodeboxSidebar$1() {
|
|
|
8948
9010
|
open: httpStatusOptions.length === 1 ? false : void 0,
|
|
8949
9011
|
suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
|
|
8950
9012
|
})]
|
|
8951
|
-
}),
|
|
9013
|
+
}), (() => {
|
|
9014
|
+
const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
|
|
9015
|
+
const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
|
|
9016
|
+
let displayData;
|
|
9017
|
+
if (contentEntry?.example !== void 0) displayData = contentEntry.example;
|
|
9018
|
+
else if (contentEntry?.examples !== void 0) {
|
|
9019
|
+
const firstKey = Object.keys(contentEntry.examples)[0];
|
|
9020
|
+
const firstExample = contentEntry.examples[firstKey];
|
|
9021
|
+
displayData = firstExample?.value ?? firstExample;
|
|
9022
|
+
} else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
|
|
9023
|
+
else if (contentEntry?.schema) displayData = contentEntry.schema;
|
|
9024
|
+
else displayData = responseObj;
|
|
9025
|
+
return /* @__PURE__ */ jsx(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
|
|
9026
|
+
})()]
|
|
8952
9027
|
})]
|
|
8953
9028
|
});
|
|
8954
9029
|
}
|
|
@@ -9002,7 +9077,15 @@ const transformOpenApiToDocs = (api) => {
|
|
|
9002
9077
|
};
|
|
9003
9078
|
if (entry.requestBody?.content) {
|
|
9004
9079
|
const resolvedContent = {};
|
|
9005
|
-
for (const [contentType, contentValue] of Object.entries(entry.requestBody.content))
|
|
9080
|
+
for (const [contentType, contentValue] of Object.entries(entry.requestBody.content)) {
|
|
9081
|
+
const resolvedSchema = resolveSchema(contentValue.schema, api.components) ?? contentValue.schema;
|
|
9082
|
+
const resolvedExample = contentValue.example !== void 0 ? contentValue.example : resolvedSchema.example;
|
|
9083
|
+
resolvedContent[contentType] = {
|
|
9084
|
+
schema: resolvedSchema,
|
|
9085
|
+
...resolvedExample !== void 0 && { example: resolvedExample },
|
|
9086
|
+
...contentValue.examples !== void 0 && { examples: contentValue.examples }
|
|
9087
|
+
};
|
|
9088
|
+
}
|
|
9006
9089
|
entry.requestBody = {
|
|
9007
9090
|
...entry.requestBody,
|
|
9008
9091
|
content: resolvedContent
|
|
@@ -9012,7 +9095,15 @@ const transformOpenApiToDocs = (api) => {
|
|
|
9012
9095
|
const resolvedResponses = {};
|
|
9013
9096
|
for (const [code, responseValue] of Object.entries(entry.responses)) if (responseValue.content) {
|
|
9014
9097
|
const resolvedContent = {};
|
|
9015
|
-
for (const [contentType, contentValue] of Object.entries(responseValue.content))
|
|
9098
|
+
for (const [contentType, contentValue] of Object.entries(responseValue.content)) {
|
|
9099
|
+
const resolvedSchema = resolveSchema(contentValue.schema, api.components) ?? contentValue.schema;
|
|
9100
|
+
const resolvedExample = contentValue.example !== void 0 ? contentValue.example : resolvedSchema.example;
|
|
9101
|
+
resolvedContent[contentType] = {
|
|
9102
|
+
schema: resolvedSchema,
|
|
9103
|
+
...resolvedExample !== void 0 && { example: resolvedExample },
|
|
9104
|
+
...contentValue.examples !== void 0 && { examples: contentValue.examples }
|
|
9105
|
+
};
|
|
9106
|
+
}
|
|
9016
9107
|
resolvedResponses[code] = {
|
|
9017
9108
|
...responseValue,
|
|
9018
9109
|
content: resolvedContent
|
|
@@ -9195,7 +9286,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9195
9286
|
alignItems: "center",
|
|
9196
9287
|
position: "relative",
|
|
9197
9288
|
paddingTop: 20,
|
|
9198
|
-
paddingBottom: 8,
|
|
9199
9289
|
paddingLeft: 24,
|
|
9200
9290
|
paddingRight: 24,
|
|
9201
9291
|
width: "100%"
|
|
@@ -9302,7 +9392,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9302
9392
|
type: schema?.type ?? "string",
|
|
9303
9393
|
required: Boolean(p.required ?? false),
|
|
9304
9394
|
description: p.description != null ? String(p.description) : void 0,
|
|
9305
|
-
enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
|
|
9395
|
+
enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
|
|
9306
9396
|
...schema?.items && { items: { type: schema.items.type ?? "string" } }
|
|
9307
9397
|
};
|
|
9308
9398
|
});
|
|
@@ -9333,7 +9423,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9333
9423
|
type: schema?.type ?? "string",
|
|
9334
9424
|
required: Boolean(p.required ?? false),
|
|
9335
9425
|
description: p.description != null ? String(p.description) : void 0,
|
|
9336
|
-
enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
|
|
9426
|
+
enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
|
|
9337
9427
|
...schema?.items && { items: { type: schema.items.type ?? "string" } }
|
|
9338
9428
|
};
|
|
9339
9429
|
});
|
|
@@ -9372,7 +9462,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9372
9462
|
Object.entries(methods).forEach(([method, operation]) => {
|
|
9373
9463
|
const responses = operation.responses;
|
|
9374
9464
|
if (!responses) return;
|
|
9375
|
-
const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.
|
|
9465
|
+
const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.example;
|
|
9376
9466
|
const epId = pathMethodToId[`${path}||${method}`];
|
|
9377
9467
|
if (epId && schema) result[epId] = schema;
|
|
9378
9468
|
});
|
|
@@ -9605,8 +9695,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9605
9695
|
...param.description && { description: param.description },
|
|
9606
9696
|
schema: {
|
|
9607
9697
|
type: param.type,
|
|
9608
|
-
...param.enum && param.enum.length > 0
|
|
9609
|
-
|
|
9698
|
+
...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
|
|
9699
|
+
type: param.items?.type ?? "string",
|
|
9700
|
+
enum: param.enum
|
|
9701
|
+
} } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
|
|
9702
|
+
...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
|
|
9610
9703
|
}
|
|
9611
9704
|
}));
|
|
9612
9705
|
else delete methodObj.parameters;
|
|
@@ -9623,8 +9716,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9623
9716
|
...param.description && { description: param.description },
|
|
9624
9717
|
schema: {
|
|
9625
9718
|
type: param.type,
|
|
9626
|
-
...param.enum && param.enum.length > 0
|
|
9627
|
-
|
|
9719
|
+
...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
|
|
9720
|
+
type: param.items?.type ?? "string",
|
|
9721
|
+
enum: param.enum
|
|
9722
|
+
} } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
|
|
9723
|
+
...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
|
|
9628
9724
|
}
|
|
9629
9725
|
}));
|
|
9630
9726
|
else delete methodObj["x-response-params"];
|
|
@@ -9656,7 +9752,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9656
9752
|
const statusCode = "200" in responses ? "200" : Object.keys(responses)[0];
|
|
9657
9753
|
if (!responses[statusCode]) return;
|
|
9658
9754
|
if (!responses[statusCode].content) responses[statusCode].content = {};
|
|
9659
|
-
responses[statusCode].content["application/json"] = { schema };
|
|
9755
|
+
responses[statusCode].content["application/json"] = { example: schema };
|
|
9660
9756
|
});
|
|
9661
9757
|
try {
|
|
9662
9758
|
await onSave?.(cloned);
|
|
@@ -10665,7 +10761,20 @@ function CodeboxSidebar() {
|
|
|
10665
10761
|
open: httpStatusOptions.length === 1 ? false : void 0,
|
|
10666
10762
|
suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
|
|
10667
10763
|
})]
|
|
10668
|
-
}),
|
|
10764
|
+
}), (() => {
|
|
10765
|
+
const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
|
|
10766
|
+
const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
|
|
10767
|
+
let displayData;
|
|
10768
|
+
if (contentEntry?.example !== void 0) displayData = contentEntry.example;
|
|
10769
|
+
else if (contentEntry?.examples !== void 0) {
|
|
10770
|
+
const firstKey = Object.keys(contentEntry.examples)[0];
|
|
10771
|
+
const firstExample = contentEntry.examples[firstKey];
|
|
10772
|
+
displayData = firstExample?.value ?? firstExample;
|
|
10773
|
+
} else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
|
|
10774
|
+
else if (contentEntry?.schema) displayData = contentEntry.schema;
|
|
10775
|
+
else displayData = responseObj;
|
|
10776
|
+
return /* @__PURE__ */ jsx(Codebox, { code: JSON.stringify(displayData, null, 2) || "" });
|
|
10777
|
+
})()]
|
|
10669
10778
|
})]
|
|
10670
10779
|
});
|
|
10671
10780
|
}
|