@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.cjs
CHANGED
|
@@ -704,8 +704,49 @@ 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
|
+
const target = el.firstElementChild ?? el;
|
|
715
|
+
setIsOverflowing(target.scrollWidth > target.clientWidth);
|
|
716
|
+
}, []);
|
|
717
|
+
(0, react.useEffect)(() => {
|
|
718
|
+
checkOverflow();
|
|
719
|
+
const el = ref.current;
|
|
720
|
+
if (!el) return;
|
|
721
|
+
const ro = new ResizeObserver(checkOverflow);
|
|
722
|
+
ro.observe(el);
|
|
723
|
+
return () => ro.disconnect();
|
|
724
|
+
}, [
|
|
725
|
+
checkOverflow,
|
|
726
|
+
children,
|
|
727
|
+
title
|
|
728
|
+
]);
|
|
729
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
730
|
+
ref,
|
|
731
|
+
className,
|
|
732
|
+
style: {
|
|
733
|
+
display: "block",
|
|
734
|
+
overflow: "hidden",
|
|
735
|
+
textOverflow: "ellipsis",
|
|
736
|
+
whiteSpace: "nowrap",
|
|
737
|
+
...style
|
|
738
|
+
},
|
|
739
|
+
children
|
|
740
|
+
});
|
|
741
|
+
if (!isOverflowing) return content;
|
|
742
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tooltip, {
|
|
743
|
+
title,
|
|
744
|
+
placement,
|
|
745
|
+
children: content
|
|
746
|
+
});
|
|
747
|
+
};
|
|
748
|
+
//#endregion
|
|
707
749
|
//#region src/view/helper/sidebar.components.tsx
|
|
708
|
-
const { Text: Text$6 } = antd.Typography;
|
|
709
750
|
const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
|
|
710
751
|
const methodStyle = (isSelected ? darkerMethodColors$1 : methodColors$1)[method];
|
|
711
752
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -718,9 +759,9 @@ const EndpointItem$1 = ({ method, title, cx, isSelected = false }) => {
|
|
|
718
759
|
border: "none"
|
|
719
760
|
},
|
|
720
761
|
children: method
|
|
721
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
762
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
763
|
+
title,
|
|
722
764
|
className: cx("endpoint-text"),
|
|
723
|
-
ellipsis: { tooltip: title },
|
|
724
765
|
style: { flex: 1 },
|
|
725
766
|
children: title
|
|
726
767
|
})]
|
|
@@ -739,14 +780,14 @@ const convertToRenderableTreeData$1 = (treeDataStructure, selectedEndpoint, cx)
|
|
|
739
780
|
});
|
|
740
781
|
} else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
|
|
741
782
|
const isHighlighted = isApiSectionHighlighted(node.key, selectedEndpoint);
|
|
742
|
-
title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
783
|
+
title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
784
|
+
title: typeof node.title === "string" ? node.title : "API Name",
|
|
743
785
|
className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
|
|
744
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
|
|
745
786
|
children: node.title
|
|
746
787
|
});
|
|
747
|
-
} else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
788
|
+
} else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
789
|
+
title: typeof node.title === "string" ? node.title : "",
|
|
748
790
|
className: cx("tag-title"),
|
|
749
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
|
|
750
791
|
children: node.title
|
|
751
792
|
});
|
|
752
793
|
return {
|
|
@@ -1261,7 +1302,7 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1261
1302
|
borderRadius: token.borderRadiusSM,
|
|
1262
1303
|
border: `1px solid ${token.colorBorderSecondary}`,
|
|
1263
1304
|
minWidth: "6.25rem",
|
|
1264
|
-
maxWidth: "
|
|
1305
|
+
maxWidth: "100%",
|
|
1265
1306
|
svg: { path: { fill: "#4D75D9" } }
|
|
1266
1307
|
},
|
|
1267
1308
|
[scope("list-title")]: {
|
|
@@ -1274,6 +1315,9 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1274
1315
|
fontFamily: token.fontFamily,
|
|
1275
1316
|
cursor: "pointer",
|
|
1276
1317
|
transition: "color 0.2s ease-in",
|
|
1318
|
+
overflow: "hidden",
|
|
1319
|
+
textOverflow: "ellipsis",
|
|
1320
|
+
whiteSpace: "nowrap",
|
|
1277
1321
|
"&:hover": {
|
|
1278
1322
|
color: `${token.colorPrimary} !important`,
|
|
1279
1323
|
textDecoration: "underline"
|
|
@@ -1335,15 +1379,6 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1335
1379
|
const handleOpenEndPointView = () => {
|
|
1336
1380
|
selectNodeByKey(api.id);
|
|
1337
1381
|
};
|
|
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
1382
|
const MethodChip = ({ method }) => {
|
|
1348
1383
|
const methodStyle = methodColors$1[method];
|
|
1349
1384
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1370,11 +1405,16 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1370
1405
|
className: cx("list-container"),
|
|
1371
1406
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Flex, {
|
|
1372
1407
|
gap: token.marginSM,
|
|
1408
|
+
style: { minWidth: 0 },
|
|
1373
1409
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MethodChip, { method: api.method }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd_es_typography_Title_js.default, {
|
|
1374
1410
|
className: cx("list-title"),
|
|
1375
1411
|
level: 4,
|
|
1376
1412
|
onClick: handleOpenEndPointView,
|
|
1377
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1413
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
1414
|
+
title: api?.summary || "Endpoint Name",
|
|
1415
|
+
placement: "bottomLeft",
|
|
1416
|
+
children: api?.summary || "Endpoint Name"
|
|
1417
|
+
})
|
|
1378
1418
|
})]
|
|
1379
1419
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
|
|
1380
1420
|
className: cx("list-see-details"),
|
|
@@ -1405,7 +1445,11 @@ const ApiCard = ({ api, viewStyle }) => {
|
|
|
1405
1445
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd_es_typography_Title_js.default, {
|
|
1406
1446
|
className: cx("grid-title"),
|
|
1407
1447
|
level: 4,
|
|
1408
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1448
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
1449
|
+
title: api?.summary || "Endpoint Name",
|
|
1450
|
+
placement: "bottomLeft",
|
|
1451
|
+
children: api?.summary || "Endpoint Name"
|
|
1452
|
+
})
|
|
1409
1453
|
}),
|
|
1410
1454
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1411
1455
|
className: cx("grid-content"),
|
|
@@ -1542,16 +1586,19 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
|
|
|
1542
1586
|
return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1543
1587
|
className: cx("root"),
|
|
1544
1588
|
children: [
|
|
1545
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1589
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
1590
|
+
title: api.title,
|
|
1591
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Typography.Title, {
|
|
1592
|
+
level: 4,
|
|
1593
|
+
className: cx("title"),
|
|
1594
|
+
ellipsis: true,
|
|
1595
|
+
style: {
|
|
1596
|
+
margin: 0,
|
|
1597
|
+
fontSize: 20,
|
|
1598
|
+
fontWeight: 600
|
|
1599
|
+
},
|
|
1600
|
+
children: api.title
|
|
1601
|
+
})
|
|
1555
1602
|
}),
|
|
1556
1603
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1557
1604
|
className: cx("meta-bar"),
|
|
@@ -1732,6 +1779,36 @@ const APIsRenderer = ({ apis, withTitle, tagName, haveUnderLine, contextPath, vi
|
|
|
1732
1779
|
}, `${tagName}_renderer_${contextPath}`);
|
|
1733
1780
|
};
|
|
1734
1781
|
//#endregion
|
|
1782
|
+
//#region src/utils/generateExampleFromSchema.ts
|
|
1783
|
+
function generateExampleFromSchema(schema) {
|
|
1784
|
+
if (!schema) return null;
|
|
1785
|
+
if (schema.example !== void 0) return schema.example;
|
|
1786
|
+
if (schema.examples !== void 0) return Array.isArray(schema.examples) ? schema.examples[0] : schema.examples;
|
|
1787
|
+
if (schema.properties) {
|
|
1788
|
+
const result = {};
|
|
1789
|
+
for (const [key, prop] of Object.entries(schema.properties)) result[key] = generateExampleFromSchema(prop);
|
|
1790
|
+
return result;
|
|
1791
|
+
}
|
|
1792
|
+
if (schema.type === "array" && schema.items) return [generateExampleFromSchema(schema.items)];
|
|
1793
|
+
if (schema.enum && schema.enum.length > 0) return schema.enum[0];
|
|
1794
|
+
switch (schema.type) {
|
|
1795
|
+
case "string": return "string";
|
|
1796
|
+
case "integer":
|
|
1797
|
+
case "number": return 0;
|
|
1798
|
+
case "boolean": return false;
|
|
1799
|
+
case "array": return [];
|
|
1800
|
+
case "object": return {};
|
|
1801
|
+
default: return null;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
function hasAnyExample(schema) {
|
|
1805
|
+
if (!schema) return false;
|
|
1806
|
+
if (schema.example !== void 0 || schema.examples !== void 0) return true;
|
|
1807
|
+
if (schema.properties) return Object.values(schema.properties).some(hasAnyExample);
|
|
1808
|
+
if (schema.type === "array" && schema.items) return hasAnyExample(schema.items);
|
|
1809
|
+
return false;
|
|
1810
|
+
}
|
|
1811
|
+
//#endregion
|
|
1735
1812
|
//#region src/utils/index.ts
|
|
1736
1813
|
const handleStatusColor = (code) => {
|
|
1737
1814
|
if (code >= 200 && code < 300) return "green";
|
|
@@ -1786,7 +1863,7 @@ const buildRequestData$1 = (params, colors) => [...params].sort((a, b) => a.requ
|
|
|
1786
1863
|
})
|
|
1787
1864
|
] }),
|
|
1788
1865
|
desc: p.description || "--",
|
|
1789
|
-
enum: p.schema?.enum ? p.schema.enum.map((e) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, { children: e }, e)) : "--"
|
|
1866
|
+
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
1867
|
};
|
|
1791
1868
|
});
|
|
1792
1869
|
const buildHeaderData$1 = (headers, colors) => {
|
|
@@ -1815,7 +1892,7 @@ const buildHeaderData$1 = (headers, colors) => {
|
|
|
1815
1892
|
})
|
|
1816
1893
|
] }, idx),
|
|
1817
1894
|
desc: header.description || "--",
|
|
1818
|
-
enum: header.schema?.enum ? header.schema.enum.map((e) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, { children: e }, e)) : "--"
|
|
1895
|
+
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
1896
|
};
|
|
1820
1897
|
});
|
|
1821
1898
|
};
|
|
@@ -2250,15 +2327,17 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
|
|
|
2250
2327
|
className: cx("mobileBottomRow"),
|
|
2251
2328
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2252
2329
|
className: cx("title-section"),
|
|
2253
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2330
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
2254
2331
|
title: apiName,
|
|
2255
2332
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Title$6, {
|
|
2256
2333
|
level: 3,
|
|
2257
|
-
ellipsis: true,
|
|
2258
2334
|
style: {
|
|
2259
2335
|
margin: 0,
|
|
2260
2336
|
fontWeight: 600,
|
|
2261
|
-
color: token.colorTextHeading
|
|
2337
|
+
color: token.colorTextHeading,
|
|
2338
|
+
whiteSpace: "nowrap",
|
|
2339
|
+
overflow: "hidden",
|
|
2340
|
+
textOverflow: "ellipsis"
|
|
2262
2341
|
},
|
|
2263
2342
|
children: apiName
|
|
2264
2343
|
})
|
|
@@ -2288,7 +2367,7 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
|
|
|
2288
2367
|
children: [
|
|
2289
2368
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2290
2369
|
className: cx("title-section"),
|
|
2291
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2370
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
2292
2371
|
title: `${apiName} API Documentation`,
|
|
2293
2372
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Title$6, {
|
|
2294
2373
|
level: 3,
|
|
@@ -4167,7 +4246,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
4167
4246
|
backgroundColor: methodColor?.bg ?? "transparent"
|
|
4168
4247
|
},
|
|
4169
4248
|
children: ep.method
|
|
4170
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4249
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
4171
4250
|
title: ep.path,
|
|
4172
4251
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd_es_typography_Title_js.default, {
|
|
4173
4252
|
level: 4,
|
|
@@ -5376,7 +5455,7 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
5376
5455
|
backgroundColor: isExpanded ? methodColor?.color : "transparent"
|
|
5377
5456
|
},
|
|
5378
5457
|
children: ep.method
|
|
5379
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
5458
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
5380
5459
|
title: ep.path,
|
|
5381
5460
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
5382
5461
|
className: cx("endpoint-path"),
|
|
@@ -5482,14 +5561,24 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
|
|
|
5482
5561
|
const selectedCode = selectedStatusCodes[ep.id] ?? (Object.keys(ep.responses ?? {}).includes("200") ? "200" : Object.keys(ep.responses ?? {})[0]);
|
|
5483
5562
|
const responseContent = ep.responses?.[selectedCode]?.content;
|
|
5484
5563
|
if (!responseContent) return null;
|
|
5485
|
-
const
|
|
5564
|
+
const contentEntry = Object.values(responseContent)[0];
|
|
5565
|
+
if (!contentEntry) return null;
|
|
5566
|
+
const schema = contentEntry.schema;
|
|
5486
5567
|
if (!schema) return null;
|
|
5568
|
+
let displayData;
|
|
5569
|
+
if (contentEntry.example !== void 0) displayData = contentEntry.example;
|
|
5570
|
+
else if (contentEntry.examples !== void 0) {
|
|
5571
|
+
const firstKey = Object.keys(contentEntry.examples)[0];
|
|
5572
|
+
const firstExample = contentEntry.examples[firstKey];
|
|
5573
|
+
displayData = firstExample?.value ?? firstExample;
|
|
5574
|
+
} else if (hasAnyExample(schema)) displayData = generateExampleFromSchema(schema);
|
|
5575
|
+
else displayData = schema;
|
|
5487
5576
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5488
5577
|
className: cx("code-panel"),
|
|
5489
5578
|
style: { marginTop: token.marginSM },
|
|
5490
5579
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
5491
5580
|
className: cx("code-area"),
|
|
5492
|
-
children: JSON.stringify(
|
|
5581
|
+
children: JSON.stringify(displayData, null, 2)
|
|
5493
5582
|
})
|
|
5494
5583
|
});
|
|
5495
5584
|
})()
|
|
@@ -7177,7 +7266,6 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag,
|
|
|
7177
7266
|
alignItems: "center",
|
|
7178
7267
|
position: "relative",
|
|
7179
7268
|
paddingTop: 20,
|
|
7180
|
-
paddingBottom: 8,
|
|
7181
7269
|
paddingLeft: 24,
|
|
7182
7270
|
paddingRight: 24,
|
|
7183
7271
|
width: "100%"
|
|
@@ -7838,53 +7926,50 @@ const buildTreeDataStructure = (data) => {
|
|
|
7838
7926
|
if (!data) return [];
|
|
7839
7927
|
return data.map((api) => {
|
|
7840
7928
|
const tagEntries = Object.entries(api.tags);
|
|
7841
|
-
const
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
key: endpoint.id,
|
|
7846
|
-
isLeaf: true,
|
|
7929
|
+
const hasOnlyDefaultTag = tagEntries.length === 1 && tagEntries[0][0] === "default";
|
|
7930
|
+
return {
|
|
7931
|
+
title: api.title,
|
|
7932
|
+
key: api.id,
|
|
7847
7933
|
selectable: true,
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
endpoint,
|
|
7851
|
-
|
|
7852
|
-
|
|
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,
|
|
7934
|
+
data: api,
|
|
7935
|
+
children: hasOnlyDefaultTag ? tagEntries[0][1].map((endpoint) => ({
|
|
7936
|
+
title: endpoint.summary,
|
|
7937
|
+
key: endpoint.id,
|
|
7938
|
+
isLeaf: true,
|
|
7861
7939
|
selectable: true,
|
|
7940
|
+
method: endpoint.method,
|
|
7862
7941
|
data: {
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7942
|
+
endpoint,
|
|
7943
|
+
api,
|
|
7944
|
+
tagName: "default",
|
|
7945
|
+
parentApiId: api.id
|
|
7946
|
+
}
|
|
7947
|
+
})) : tagEntries.map(([tag, endpoints]) => {
|
|
7948
|
+
const tagId = `tag-${api.id}-${tag.replace(/\s+/g, "-").toLowerCase()}`;
|
|
7949
|
+
return {
|
|
7950
|
+
title: tag,
|
|
7951
|
+
key: tagId,
|
|
7870
7952
|
selectable: true,
|
|
7871
|
-
method: endpoint.method,
|
|
7872
7953
|
data: {
|
|
7873
|
-
endpoint,
|
|
7874
|
-
api,
|
|
7875
7954
|
tagName: tag,
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7955
|
+
apiData: api
|
|
7956
|
+
},
|
|
7957
|
+
children: endpoints.map((endpoint) => ({
|
|
7958
|
+
title: endpoint.summary,
|
|
7959
|
+
key: endpoint.id,
|
|
7960
|
+
isLeaf: true,
|
|
7961
|
+
selectable: true,
|
|
7962
|
+
method: endpoint.method,
|
|
7963
|
+
data: {
|
|
7964
|
+
endpoint,
|
|
7965
|
+
api,
|
|
7966
|
+
tagName: tag,
|
|
7967
|
+
parentApiId: api.id,
|
|
7968
|
+
tagId
|
|
7969
|
+
}
|
|
7970
|
+
}))
|
|
7971
|
+
};
|
|
7972
|
+
})
|
|
7888
7973
|
};
|
|
7889
7974
|
});
|
|
7890
7975
|
};
|
|
@@ -8020,7 +8105,6 @@ const getSidebarStyles = (token, scope) => ({
|
|
|
8020
8105
|
});
|
|
8021
8106
|
//#endregion
|
|
8022
8107
|
//#region src/view/console/helper/sidebar.components.tsx
|
|
8023
|
-
const { Text: Text$2 } = antd.Typography;
|
|
8024
8108
|
const EndpointItem = ({ method, title, cx, isSelected = false }) => {
|
|
8025
8109
|
const methodStyle = (isSelected ? darkerMethodColors : sidebarMethodColors)[method];
|
|
8026
8110
|
const isPost = method?.toUpperCase() === "POST";
|
|
@@ -8035,9 +8119,9 @@ const EndpointItem = ({ method, title, cx, isSelected = false }) => {
|
|
|
8035
8119
|
...isPost ? { borderRadius: 4 } : {}
|
|
8036
8120
|
},
|
|
8037
8121
|
children: method
|
|
8038
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
8122
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
8123
|
+
title,
|
|
8039
8124
|
className: cx("endpoint-text"),
|
|
8040
|
-
ellipsis: { tooltip: title },
|
|
8041
8125
|
style: { flex: 1 },
|
|
8042
8126
|
children: title
|
|
8043
8127
|
})]
|
|
@@ -8054,14 +8138,14 @@ const convertToRenderableTreeData = (treeDataStructure, selectedEndpoint, cx) =>
|
|
|
8054
8138
|
cx,
|
|
8055
8139
|
isSelected
|
|
8056
8140
|
});
|
|
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)(
|
|
8141
|
+
} 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, {
|
|
8142
|
+
title: typeof node.title === "string" ? node.title : "API Name",
|
|
8058
8143
|
className: cx("api-title"),
|
|
8059
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "API Name" },
|
|
8060
8144
|
children: node.title
|
|
8061
8145
|
});
|
|
8062
|
-
else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
8146
|
+
else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
8147
|
+
title: typeof node.title === "string" ? node.title : "",
|
|
8063
8148
|
className: cx("tag-title"),
|
|
8064
|
-
ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
|
|
8065
8149
|
children: node.title
|
|
8066
8150
|
});
|
|
8067
8151
|
return {
|
|
@@ -8352,7 +8436,7 @@ const buildRequestData = (params, token) => [...params].sort((a, b) => a.require
|
|
|
8352
8436
|
children: p.description || "--"
|
|
8353
8437
|
})
|
|
8354
8438
|
}),
|
|
8355
|
-
enum: p.schema?.enum ? renderEnumTags(p.schema.enum, token) : "--"
|
|
8439
|
+
enum: p.schema?.enum ?? p.schema?.items?.enum ? renderEnumTags(p.schema?.enum ?? p.schema?.items?.enum, token) : "--"
|
|
8356
8440
|
};
|
|
8357
8441
|
});
|
|
8358
8442
|
const buildHeaderData = (headers, token) => {
|
|
@@ -8402,7 +8486,7 @@ const buildHeaderData = (headers, token) => {
|
|
|
8402
8486
|
]
|
|
8403
8487
|
}, idx),
|
|
8404
8488
|
desc: header.description || "--",
|
|
8405
|
-
enum: header.schema?.enum ? renderEnumTags(header.schema.enum, token) : "--"
|
|
8489
|
+
enum: header.schema?.enum ?? header.schema?.items?.enum ? renderEnumTags(header.schema?.enum ?? header.schema?.items?.enum, token) : "--"
|
|
8406
8490
|
};
|
|
8407
8491
|
});
|
|
8408
8492
|
};
|
|
@@ -8544,18 +8628,10 @@ const EndpointPage = () => {
|
|
|
8544
8628
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectedEndpoint?.tagName || "default" })
|
|
8545
8629
|
})
|
|
8546
8630
|
},
|
|
8547
|
-
{ title: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
8631
|
+
{ title: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
8548
8632
|
title: selectedEndpoint?.summary || "Endpoint Name",
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
overflow: "hidden",
|
|
8552
|
-
textOverflow: "ellipsis",
|
|
8553
|
-
whiteSpace: "nowrap",
|
|
8554
|
-
display: "block",
|
|
8555
|
-
maxWidth: "300px"
|
|
8556
|
-
},
|
|
8557
|
-
children: selectedEndpoint?.summary || "Endpoint Name"
|
|
8558
|
-
})
|
|
8633
|
+
style: { maxWidth: "300px" },
|
|
8634
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectedEndpoint?.summary || "Endpoint Name" })
|
|
8559
8635
|
}) }
|
|
8560
8636
|
] })]
|
|
8561
8637
|
}),
|
|
@@ -8578,16 +8654,9 @@ const EndpointPage = () => {
|
|
|
8578
8654
|
flexShrink: 0
|
|
8579
8655
|
},
|
|
8580
8656
|
children: selectedEndpoint?.method
|
|
8581
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
8657
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OverflowTooltip, {
|
|
8582
8658
|
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
|
-
})
|
|
8659
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectedEndpoint?.summary?.replace(selectedEndpoint?.method, "") ?? "--" })
|
|
8591
8660
|
})]
|
|
8592
8661
|
}),
|
|
8593
8662
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Paragraph, {
|
|
@@ -8794,19 +8863,12 @@ function CodeboxSidebar$1() {
|
|
|
8794
8863
|
} }), code]
|
|
8795
8864
|
})
|
|
8796
8865
|
})), [statusCodeOptions]);
|
|
8797
|
-
const [curlTooltip, setCurlTooltip] = (0, react$1.useState)("Copy Request");
|
|
8798
8866
|
const curlCommand = (() => {
|
|
8799
8867
|
if (!selectedEndpoint || !Array.isArray(selectedApi?.curl)) return "";
|
|
8800
8868
|
return selectedApi.curl.find((c) => c.path === selectedEndpoint.path && c.method?.toUpperCase() === selectedEndpoint.method.toUpperCase())?.curlCommand ?? "";
|
|
8801
8869
|
})();
|
|
8802
|
-
const
|
|
8803
|
-
|
|
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
|
-
})();
|
|
8870
|
+
const curlDisplayLines = curlCommand.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
8871
|
+
const [curlTooltip, setCurlTooltip] = (0, react$1.useState)("Copy Request");
|
|
8810
8872
|
const { token: antdToken, theme: themeConfig } = antd.theme.useToken();
|
|
8811
8873
|
const isDark = themeConfig.id == 1;
|
|
8812
8874
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8952,7 +9014,7 @@ function CodeboxSidebar$1() {
|
|
|
8952
9014
|
})]
|
|
8953
9015
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
8954
9016
|
className: cx("curl-list"),
|
|
8955
|
-
children:
|
|
9017
|
+
children: curlDisplayLines.map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
8956
9018
|
className: cx("curl-line"),
|
|
8957
9019
|
children: line
|
|
8958
9020
|
}, i))
|
|
@@ -8977,7 +9039,20 @@ function CodeboxSidebar$1() {
|
|
|
8977
9039
|
open: httpStatusOptions.length === 1 ? false : void 0,
|
|
8978
9040
|
suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
|
|
8979
9041
|
})]
|
|
8980
|
-
}),
|
|
9042
|
+
}), (() => {
|
|
9043
|
+
const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
|
|
9044
|
+
const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
|
|
9045
|
+
let displayData;
|
|
9046
|
+
if (contentEntry?.example !== void 0) displayData = contentEntry.example;
|
|
9047
|
+
else if (contentEntry?.examples !== void 0) {
|
|
9048
|
+
const firstKey = Object.keys(contentEntry.examples)[0];
|
|
9049
|
+
const firstExample = contentEntry.examples[firstKey];
|
|
9050
|
+
displayData = firstExample?.value ?? firstExample;
|
|
9051
|
+
} else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
|
|
9052
|
+
else if (contentEntry?.schema) displayData = contentEntry.schema;
|
|
9053
|
+
else displayData = responseObj;
|
|
9054
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
|
|
9055
|
+
})()]
|
|
8981
9056
|
})]
|
|
8982
9057
|
});
|
|
8983
9058
|
}
|
|
@@ -9031,7 +9106,15 @@ const transformOpenApiToDocs = (api) => {
|
|
|
9031
9106
|
};
|
|
9032
9107
|
if (entry.requestBody?.content) {
|
|
9033
9108
|
const resolvedContent = {};
|
|
9034
|
-
for (const [contentType, contentValue] of Object.entries(entry.requestBody.content))
|
|
9109
|
+
for (const [contentType, contentValue] of Object.entries(entry.requestBody.content)) {
|
|
9110
|
+
const resolvedSchema = resolveSchema(contentValue.schema, api.components) ?? contentValue.schema;
|
|
9111
|
+
const resolvedExample = contentValue.example !== void 0 ? contentValue.example : resolvedSchema.example;
|
|
9112
|
+
resolvedContent[contentType] = {
|
|
9113
|
+
schema: resolvedSchema,
|
|
9114
|
+
...resolvedExample !== void 0 && { example: resolvedExample },
|
|
9115
|
+
...contentValue.examples !== void 0 && { examples: contentValue.examples }
|
|
9116
|
+
};
|
|
9117
|
+
}
|
|
9035
9118
|
entry.requestBody = {
|
|
9036
9119
|
...entry.requestBody,
|
|
9037
9120
|
content: resolvedContent
|
|
@@ -9041,7 +9124,15 @@ const transformOpenApiToDocs = (api) => {
|
|
|
9041
9124
|
const resolvedResponses = {};
|
|
9042
9125
|
for (const [code, responseValue] of Object.entries(entry.responses)) if (responseValue.content) {
|
|
9043
9126
|
const resolvedContent = {};
|
|
9044
|
-
for (const [contentType, contentValue] of Object.entries(responseValue.content))
|
|
9127
|
+
for (const [contentType, contentValue] of Object.entries(responseValue.content)) {
|
|
9128
|
+
const resolvedSchema = resolveSchema(contentValue.schema, api.components) ?? contentValue.schema;
|
|
9129
|
+
const resolvedExample = contentValue.example !== void 0 ? contentValue.example : resolvedSchema.example;
|
|
9130
|
+
resolvedContent[contentType] = {
|
|
9131
|
+
schema: resolvedSchema,
|
|
9132
|
+
...resolvedExample !== void 0 && { example: resolvedExample },
|
|
9133
|
+
...contentValue.examples !== void 0 && { examples: contentValue.examples }
|
|
9134
|
+
};
|
|
9135
|
+
}
|
|
9045
9136
|
resolvedResponses[code] = {
|
|
9046
9137
|
...responseValue,
|
|
9047
9138
|
content: resolvedContent
|
|
@@ -9224,7 +9315,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9224
9315
|
alignItems: "center",
|
|
9225
9316
|
position: "relative",
|
|
9226
9317
|
paddingTop: 20,
|
|
9227
|
-
paddingBottom: 8,
|
|
9228
9318
|
paddingLeft: 24,
|
|
9229
9319
|
paddingRight: 24,
|
|
9230
9320
|
width: "100%"
|
|
@@ -9331,7 +9421,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9331
9421
|
type: schema?.type ?? "string",
|
|
9332
9422
|
required: Boolean(p.required ?? false),
|
|
9333
9423
|
description: p.description != null ? String(p.description) : void 0,
|
|
9334
|
-
enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
|
|
9424
|
+
enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
|
|
9335
9425
|
...schema?.items && { items: { type: schema.items.type ?? "string" } }
|
|
9336
9426
|
};
|
|
9337
9427
|
});
|
|
@@ -9362,7 +9452,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9362
9452
|
type: schema?.type ?? "string",
|
|
9363
9453
|
required: Boolean(p.required ?? false),
|
|
9364
9454
|
description: p.description != null ? String(p.description) : void 0,
|
|
9365
|
-
enum: Array.isArray(schema?.enum) ? schema.enum : void 0,
|
|
9455
|
+
enum: Array.isArray(schema?.enum) ? schema.enum : Array.isArray(schema?.items?.enum) ? schema.items.enum : void 0,
|
|
9366
9456
|
...schema?.items && { items: { type: schema.items.type ?? "string" } }
|
|
9367
9457
|
};
|
|
9368
9458
|
});
|
|
@@ -9401,7 +9491,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9401
9491
|
Object.entries(methods).forEach(([method, operation]) => {
|
|
9402
9492
|
const responses = operation.responses;
|
|
9403
9493
|
if (!responses) return;
|
|
9404
|
-
const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.
|
|
9494
|
+
const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.example;
|
|
9405
9495
|
const epId = pathMethodToId[`${path}||${method}`];
|
|
9406
9496
|
if (epId && schema) result[epId] = schema;
|
|
9407
9497
|
});
|
|
@@ -9634,8 +9724,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9634
9724
|
...param.description && { description: param.description },
|
|
9635
9725
|
schema: {
|
|
9636
9726
|
type: param.type,
|
|
9637
|
-
...param.enum && param.enum.length > 0
|
|
9638
|
-
|
|
9727
|
+
...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
|
|
9728
|
+
type: param.items?.type ?? "string",
|
|
9729
|
+
enum: param.enum
|
|
9730
|
+
} } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
|
|
9731
|
+
...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
|
|
9639
9732
|
}
|
|
9640
9733
|
}));
|
|
9641
9734
|
else delete methodObj.parameters;
|
|
@@ -9652,8 +9745,11 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9652
9745
|
...param.description && { description: param.description },
|
|
9653
9746
|
schema: {
|
|
9654
9747
|
type: param.type,
|
|
9655
|
-
...param.enum && param.enum.length > 0
|
|
9656
|
-
|
|
9748
|
+
...param.type === "array" && param.enum && param.enum.length > 0 ? { items: {
|
|
9749
|
+
type: param.items?.type ?? "string",
|
|
9750
|
+
enum: param.enum
|
|
9751
|
+
} } : param.enum && param.enum.length > 0 ? { enum: param.enum } : {},
|
|
9752
|
+
...param.type === "array" && param.items && !param.enum?.length ? { items: param.items } : {}
|
|
9657
9753
|
}
|
|
9658
9754
|
}));
|
|
9659
9755
|
else delete methodObj["x-response-params"];
|
|
@@ -9685,7 +9781,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9685
9781
|
const statusCode = "200" in responses ? "200" : Object.keys(responses)[0];
|
|
9686
9782
|
if (!responses[statusCode]) return;
|
|
9687
9783
|
if (!responses[statusCode].content) responses[statusCode].content = {};
|
|
9688
|
-
responses[statusCode].content["application/json"] = { schema };
|
|
9784
|
+
responses[statusCode].content["application/json"] = { example: schema };
|
|
9689
9785
|
});
|
|
9690
9786
|
try {
|
|
9691
9787
|
await onSave?.(cloned);
|
|
@@ -10694,7 +10790,20 @@ function CodeboxSidebar() {
|
|
|
10694
10790
|
open: httpStatusOptions.length === 1 ? false : void 0,
|
|
10695
10791
|
suffixIcon: httpStatusOptions.length > 1 ? void 0 : false
|
|
10696
10792
|
})]
|
|
10697
|
-
}),
|
|
10793
|
+
}), (() => {
|
|
10794
|
+
const responseObj = selectedEndpoint?.responses?.[selectedStatusCode];
|
|
10795
|
+
const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
|
|
10796
|
+
let displayData;
|
|
10797
|
+
if (contentEntry?.example !== void 0) displayData = contentEntry.example;
|
|
10798
|
+
else if (contentEntry?.examples !== void 0) {
|
|
10799
|
+
const firstKey = Object.keys(contentEntry.examples)[0];
|
|
10800
|
+
const firstExample = contentEntry.examples[firstKey];
|
|
10801
|
+
displayData = firstExample?.value ?? firstExample;
|
|
10802
|
+
} else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
|
|
10803
|
+
else if (contentEntry?.schema) displayData = contentEntry.schema;
|
|
10804
|
+
else displayData = responseObj;
|
|
10805
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox, { code: JSON.stringify(displayData, null, 2) || "" });
|
|
10806
|
+
})()]
|
|
10698
10807
|
})]
|
|
10699
10808
|
});
|
|
10700
10809
|
}
|