@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.mjs CHANGED
@@ -682,7 +682,8 @@ const OverflowTooltip = ({ title, children, className, style, placement }) => {
682
682
  const checkOverflow = useCallback(() => {
683
683
  const el = ref.current;
684
684
  if (!el) return;
685
- setIsOverflowing(el.scrollWidth > el.clientWidth);
685
+ const target = el.firstElementChild ?? el;
686
+ setIsOverflowing(target.scrollWidth > target.clientWidth);
686
687
  }, []);
687
688
  useEffect(() => {
688
689
  checkOverflow();
@@ -1272,7 +1273,7 @@ const ApiCard = ({ api, viewStyle }) => {
1272
1273
  borderRadius: token.borderRadiusSM,
1273
1274
  border: `1px solid ${token.colorBorderSecondary}`,
1274
1275
  minWidth: "6.25rem",
1275
- maxWidth: "fit-content",
1276
+ maxWidth: "100%",
1276
1277
  svg: { path: { fill: "#4D75D9" } }
1277
1278
  },
1278
1279
  [scope("list-title")]: {
@@ -1285,6 +1286,9 @@ const ApiCard = ({ api, viewStyle }) => {
1285
1286
  fontFamily: token.fontFamily,
1286
1287
  cursor: "pointer",
1287
1288
  transition: "color 0.2s ease-in",
1289
+ overflow: "hidden",
1290
+ textOverflow: "ellipsis",
1291
+ whiteSpace: "nowrap",
1288
1292
  "&:hover": {
1289
1293
  color: `${token.colorPrimary} !important`,
1290
1294
  textDecoration: "underline"
@@ -1372,6 +1376,7 @@ const ApiCard = ({ api, viewStyle }) => {
1372
1376
  className: cx("list-container"),
1373
1377
  children: [/* @__PURE__ */ jsxs(Flex, {
1374
1378
  gap: token.marginSM,
1379
+ style: { minWidth: 0 },
1375
1380
  children: [/* @__PURE__ */ jsx(MethodChip, { method: api.method }), /* @__PURE__ */ jsx(Title, {
1376
1381
  className: cx("list-title"),
1377
1382
  level: 4,
@@ -2297,11 +2302,13 @@ const ApiDocumentationBar = ({ apiName, mode, onModeChange, onReset, onSave, has
2297
2302
  title: apiName,
2298
2303
  children: /* @__PURE__ */ jsx(Title$2, {
2299
2304
  level: 3,
2300
- ellipsis: true,
2301
2305
  style: {
2302
2306
  margin: 0,
2303
2307
  fontWeight: 600,
2304
- color: token.colorTextHeading
2308
+ color: token.colorTextHeading,
2309
+ whiteSpace: "nowrap",
2310
+ overflow: "hidden",
2311
+ textOverflow: "ellipsis"
2305
2312
  },
2306
2313
  children: apiName
2307
2314
  })
@@ -3436,27 +3443,6 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
3436
3443
  }));
3437
3444
  });
3438
3445
  }, [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
- ]);
3460
3446
  const handleValidate = (content) => {
3461
3447
  try {
3462
3448
  JSON.parse(content);
@@ -5552,8 +5538,11 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
5552
5538
  if (!schema) return null;
5553
5539
  let displayData;
5554
5540
  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);
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);
5557
5546
  else displayData = schema;
5558
5547
  return /* @__PURE__ */ jsx("div", {
5559
5548
  className: cx("code-panel"),
@@ -7248,7 +7237,6 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag,
7248
7237
  alignItems: "center",
7249
7238
  position: "relative",
7250
7239
  paddingTop: 20,
7251
- paddingBottom: 8,
7252
7240
  paddingLeft: 24,
7253
7241
  paddingRight: 24,
7254
7242
  width: "100%"
@@ -9027,8 +9015,11 @@ function CodeboxSidebar$1() {
9027
9015
  const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
9028
9016
  let displayData;
9029
9017
  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);
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);
9032
9023
  else if (contentEntry?.schema) displayData = contentEntry.schema;
9033
9024
  else displayData = responseObj;
9034
9025
  return /* @__PURE__ */ jsx(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
@@ -9086,7 +9077,15 @@ const transformOpenApiToDocs = (api) => {
9086
9077
  };
9087
9078
  if (entry.requestBody?.content) {
9088
9079
  const resolvedContent = {};
9089
- for (const [contentType, contentValue] of Object.entries(entry.requestBody.content)) resolvedContent[contentType] = { schema: resolveSchema(contentValue.schema, api.components) ?? contentValue.schema };
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
+ }
9090
9089
  entry.requestBody = {
9091
9090
  ...entry.requestBody,
9092
9091
  content: resolvedContent
@@ -9096,7 +9095,15 @@ const transformOpenApiToDocs = (api) => {
9096
9095
  const resolvedResponses = {};
9097
9096
  for (const [code, responseValue] of Object.entries(entry.responses)) if (responseValue.content) {
9098
9097
  const resolvedContent = {};
9099
- for (const [contentType, contentValue] of Object.entries(responseValue.content)) resolvedContent[contentType] = { schema: resolveSchema(contentValue.schema, api.components) ?? contentValue.schema };
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
+ }
9100
9107
  resolvedResponses[code] = {
9101
9108
  ...responseValue,
9102
9109
  content: resolvedContent
@@ -9279,7 +9286,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9279
9286
  alignItems: "center",
9280
9287
  position: "relative",
9281
9288
  paddingTop: 20,
9282
- paddingBottom: 8,
9283
9289
  paddingLeft: 24,
9284
9290
  paddingRight: 24,
9285
9291
  width: "100%"
@@ -9456,7 +9462,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9456
9462
  Object.entries(methods).forEach(([method, operation]) => {
9457
9463
  const responses = operation.responses;
9458
9464
  if (!responses) return;
9459
- const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.schema;
9465
+ const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.example;
9460
9466
  const epId = pathMethodToId[`${path}||${method}`];
9461
9467
  if (epId && schema) result[epId] = schema;
9462
9468
  });
@@ -9746,7 +9752,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9746
9752
  const statusCode = "200" in responses ? "200" : Object.keys(responses)[0];
9747
9753
  if (!responses[statusCode]) return;
9748
9754
  if (!responses[statusCode].content) responses[statusCode].content = {};
9749
- responses[statusCode].content["application/json"] = { schema };
9755
+ responses[statusCode].content["application/json"] = { example: schema };
9750
9756
  });
9751
9757
  try {
9752
9758
  await onSave?.(cloned);
@@ -10760,8 +10766,11 @@ function CodeboxSidebar() {
10760
10766
  const contentEntry = responseObj?.content ? Object.values(responseObj.content)[0] : void 0;
10761
10767
  let displayData;
10762
10768
  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);
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);
10765
10774
  else if (contentEntry?.schema) displayData = contentEntry.schema;
10766
10775
  else displayData = responseObj;
10767
10776
  return /* @__PURE__ */ jsx(Codebox, { code: JSON.stringify(displayData, null, 2) || "" });