@digi-frontend/dgate-api-documentation 4.1.8 → 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 CHANGED
@@ -711,7 +711,8 @@ const OverflowTooltip = ({ title, children, className, style, placement }) => {
711
711
  const checkOverflow = (0, react.useCallback)(() => {
712
712
  const el = ref.current;
713
713
  if (!el) return;
714
- setIsOverflowing(el.scrollWidth > el.clientWidth);
714
+ const target = el.firstElementChild ?? el;
715
+ setIsOverflowing(target.scrollWidth > target.clientWidth);
715
716
  }, []);
716
717
  (0, react.useEffect)(() => {
717
718
  checkOverflow();
@@ -1301,7 +1302,7 @@ const ApiCard = ({ api, viewStyle }) => {
1301
1302
  borderRadius: token.borderRadiusSM,
1302
1303
  border: `1px solid ${token.colorBorderSecondary}`,
1303
1304
  minWidth: "6.25rem",
1304
- maxWidth: "fit-content",
1305
+ maxWidth: "100%",
1305
1306
  svg: { path: { fill: "#4D75D9" } }
1306
1307
  },
1307
1308
  [scope("list-title")]: {
@@ -1314,6 +1315,9 @@ const ApiCard = ({ api, viewStyle }) => {
1314
1315
  fontFamily: token.fontFamily,
1315
1316
  cursor: "pointer",
1316
1317
  transition: "color 0.2s ease-in",
1318
+ overflow: "hidden",
1319
+ textOverflow: "ellipsis",
1320
+ whiteSpace: "nowrap",
1317
1321
  "&:hover": {
1318
1322
  color: `${token.colorPrimary} !important`,
1319
1323
  textDecoration: "underline"
@@ -1401,6 +1405,7 @@ const ApiCard = ({ api, viewStyle }) => {
1401
1405
  className: cx("list-container"),
1402
1406
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Flex, {
1403
1407
  gap: token.marginSM,
1408
+ style: { minWidth: 0 },
1404
1409
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MethodChip, { method: api.method }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd_es_typography_Title_js.default, {
1405
1410
  className: cx("list-title"),
1406
1411
  level: 4,
@@ -2326,11 +2331,13 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
2326
2331
  title: apiName,
2327
2332
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Title$6, {
2328
2333
  level: 3,
2329
- ellipsis: true,
2330
2334
  style: {
2331
2335
  margin: 0,
2332
2336
  fontWeight: 600,
2333
- color: token.colorTextHeading
2337
+ color: token.colorTextHeading,
2338
+ whiteSpace: "nowrap",
2339
+ overflow: "hidden",
2340
+ textOverflow: "ellipsis"
2334
2341
  },
2335
2342
  children: apiName
2336
2343
  })
@@ -3465,27 +3472,6 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
3465
3472
  }));
3466
3473
  });
3467
3474
  }, [openResponsePanels, responseBodySchemas]);
3468
- (0, react$1.useEffect)(() => {
3469
- if (!openResponsePanels.size) return;
3470
- openResponsePanels.forEach((epId) => {
3471
- const code = selectedStatusCodes[epId];
3472
- if (!code) return;
3473
- const ep = Object.values(endpointsByTag).flat().find((e) => e.id === epId);
3474
- if (!ep?.responses?.[code]?.content) return;
3475
- const content = ep.responses[code].content;
3476
- const schema = Object.values(content)[0]?.schema;
3477
- if (!schema) return;
3478
- const json = JSON.stringify(schema, null, 2);
3479
- setEditableResponseContent((prev) => ({
3480
- ...prev,
3481
- [epId]: json
3482
- }));
3483
- });
3484
- }, [
3485
- selectedStatusCodes,
3486
- openResponsePanels,
3487
- endpointsByTag
3488
- ]);
3489
3475
  const handleValidate = (content) => {
3490
3476
  try {
3491
3477
  JSON.parse(content);
@@ -5581,8 +5567,11 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
5581
5567
  if (!schema) return null;
5582
5568
  let displayData;
5583
5569
  if (contentEntry.example !== void 0) displayData = contentEntry.example;
5584
- else if (contentEntry.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
5585
- else if (hasAnyExample(schema)) displayData = generateExampleFromSchema(schema);
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);
5586
5575
  else displayData = schema;
5587
5576
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5588
5577
  className: cx("code-panel"),
@@ -7277,7 +7266,6 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag,
7277
7266
  alignItems: "center",
7278
7267
  position: "relative",
7279
7268
  paddingTop: 20,
7280
- paddingBottom: 8,
7281
7269
  paddingLeft: 24,
7282
7270
  paddingRight: 24,
7283
7271
  width: "100%"
@@ -9056,8 +9044,11 @@ function CodeboxSidebar$1() {
9056
9044
  const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
9057
9045
  let displayData;
9058
9046
  if (contentEntry?.example !== void 0) displayData = contentEntry.example;
9059
- else if (contentEntry?.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
9060
- else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
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);
9061
9052
  else if (contentEntry?.schema) displayData = contentEntry.schema;
9062
9053
  else displayData = responseObj;
9063
9054
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
@@ -9115,7 +9106,15 @@ const transformOpenApiToDocs = (api) => {
9115
9106
  };
9116
9107
  if (entry.requestBody?.content) {
9117
9108
  const resolvedContent = {};
9118
- for (const [contentType, contentValue] of Object.entries(entry.requestBody.content)) resolvedContent[contentType] = { schema: resolveSchema(contentValue.schema, api.components) ?? contentValue.schema };
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
+ }
9119
9118
  entry.requestBody = {
9120
9119
  ...entry.requestBody,
9121
9120
  content: resolvedContent
@@ -9125,7 +9124,15 @@ const transformOpenApiToDocs = (api) => {
9125
9124
  const resolvedResponses = {};
9126
9125
  for (const [code, responseValue] of Object.entries(entry.responses)) if (responseValue.content) {
9127
9126
  const resolvedContent = {};
9128
- for (const [contentType, contentValue] of Object.entries(responseValue.content)) resolvedContent[contentType] = { schema: resolveSchema(contentValue.schema, api.components) ?? contentValue.schema };
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
+ }
9129
9136
  resolvedResponses[code] = {
9130
9137
  ...responseValue,
9131
9138
  content: resolvedContent
@@ -9308,7 +9315,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9308
9315
  alignItems: "center",
9309
9316
  position: "relative",
9310
9317
  paddingTop: 20,
9311
- paddingBottom: 8,
9312
9318
  paddingLeft: 24,
9313
9319
  paddingRight: 24,
9314
9320
  width: "100%"
@@ -9485,7 +9491,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9485
9491
  Object.entries(methods).forEach(([method, operation]) => {
9486
9492
  const responses = operation.responses;
9487
9493
  if (!responses) return;
9488
- const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.schema;
9494
+ const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.example;
9489
9495
  const epId = pathMethodToId[`${path}||${method}`];
9490
9496
  if (epId && schema) result[epId] = schema;
9491
9497
  });
@@ -9775,7 +9781,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9775
9781
  const statusCode = "200" in responses ? "200" : Object.keys(responses)[0];
9776
9782
  if (!responses[statusCode]) return;
9777
9783
  if (!responses[statusCode].content) responses[statusCode].content = {};
9778
- responses[statusCode].content["application/json"] = { schema };
9784
+ responses[statusCode].content["application/json"] = { example: schema };
9779
9785
  });
9780
9786
  try {
9781
9787
  await onSave?.(cloned);
@@ -10789,8 +10795,11 @@ function CodeboxSidebar() {
10789
10795
  const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
10790
10796
  let displayData;
10791
10797
  if (contentEntry?.example !== void 0) displayData = contentEntry.example;
10792
- else if (contentEntry?.examples !== void 0) displayData = Array.isArray(contentEntry.examples) ? contentEntry.examples[0] : contentEntry.examples;
10793
- else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
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);
10794
10803
  else if (contentEntry?.schema) displayData = contentEntry.schema;
10795
10804
  else displayData = responseObj;
10796
10805
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox, { code: JSON.stringify(displayData, null, 2) || "" });