@digi-frontend/dgate-api-documentation 4.2.0 → 4.2.3

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
@@ -2959,7 +2959,6 @@ const AddParameterDrawer = ({ open, onClose, onAdd, onEdit, mode = "add", initia
2959
2959
  alignItems: "center",
2960
2960
  position: "relative",
2961
2961
  paddingTop: 20,
2962
- paddingBottom: 5,
2963
2962
  paddingLeft: 24,
2964
2963
  paddingRight: 24,
2965
2964
  width: "100%"
@@ -3468,11 +3467,15 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
3468
3467
  }));
3469
3468
  });
3470
3469
  openResponsePanels.forEach((epId) => {
3471
- const val = responseBodySchemas?.[epId];
3472
- const json = val ? JSON.stringify(val, null, 2) : "";
3470
+ const statusCodes = responseBodySchemas?.[epId];
3471
+ if (!statusCodes) return;
3472
+ const allStatusCodeEntries = {};
3473
+ Object.entries(statusCodes).forEach(([code, val]) => {
3474
+ allStatusCodeEntries[code] = val ? JSON.stringify(val, null, 2) : "";
3475
+ });
3473
3476
  setEditableResponseContent((prev) => ({
3474
3477
  ...prev,
3475
- [epId]: json
3478
+ [epId]: allStatusCodeEntries
3476
3479
  }));
3477
3480
  });
3478
3481
  }, [
@@ -3498,11 +3501,15 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
3498
3501
  if (!openResponsePanels.size) return;
3499
3502
  openResponsePanels.forEach((epId) => {
3500
3503
  if (editableResponseContent[epId] !== void 0) return;
3501
- const val = responseBodySchemas?.[epId];
3502
- const json = val ? JSON.stringify(val, null, 2) : "";
3504
+ const statusCodes = responseBodySchemas?.[epId];
3505
+ if (!statusCodes) return;
3506
+ const allStatusCodeEntries = {};
3507
+ Object.entries(statusCodes).forEach(([code, val]) => {
3508
+ allStatusCodeEntries[code] = val ? JSON.stringify(val, null, 2) : "";
3509
+ });
3503
3510
  setEditableResponseContent((prev) => ({
3504
3511
  ...prev,
3505
- [epId]: json
3512
+ [epId]: allStatusCodeEntries
3506
3513
  }));
3507
3514
  });
3508
3515
  }, [openResponsePanels, responseBodySchemas]);
@@ -5255,15 +5262,19 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
5255
5262
  openResponsePanels.has(ep.id) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5256
5263
  className: cx("code-panel"),
5257
5264
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input.TextArea, {
5258
- value: editableResponseContent[ep.id] ?? "",
5265
+ value: editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? "",
5259
5266
  onChange: (e) => {
5267
+ const statusCode = selectedStatusCodes[ep.id];
5260
5268
  setEditableResponseContent((prev) => ({
5261
5269
  ...prev,
5262
- [ep.id]: e.target.value
5270
+ [ep.id]: {
5271
+ ...prev[ep.id],
5272
+ [statusCode]: e.target.value
5273
+ }
5263
5274
  }));
5264
- onResponseContentChange?.(ep.id, e.target.value);
5275
+ onResponseContentChange?.(ep.id, selectedStatusCodes[ep.id], e.target.value);
5265
5276
  },
5266
- rows: Math.max(3, (editableResponseContent[ep.id] ?? "").split("\n").length),
5277
+ rows: Math.max(3, (editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? "").split("\n").length),
5267
5278
  style: {
5268
5279
  fontFamily: "monospace",
5269
5280
  fontSize: "0.75rem",
@@ -5279,16 +5290,22 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
5279
5290
  ghost: true,
5280
5291
  size: "small",
5281
5292
  className: cx("code-btn"),
5282
- onClick: () => handleValidate(editableResponseContent[ep.id] ?? ""),
5293
+ onClick: () => handleValidate(editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? ""),
5283
5294
  children: "Validate"
5284
5295
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
5285
5296
  ghost: true,
5286
5297
  size: "small",
5287
5298
  className: cx("code-btn"),
5288
- onClick: () => handleBeautify(editableResponseContent[ep.id] ?? "", (v) => setEditableResponseContent((prev) => ({
5289
- ...prev,
5290
- [ep.id]: v
5291
- }))),
5299
+ onClick: () => handleBeautify(editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? "", (v) => {
5300
+ const statusCode = selectedStatusCodes[ep.id];
5301
+ setEditableResponseContent((prev) => ({
5302
+ ...prev,
5303
+ [ep.id]: {
5304
+ ...prev[ep.id],
5305
+ [statusCode]: v
5306
+ }
5307
+ }));
5308
+ }),
5292
5309
  children: "Beautify"
5293
5310
  })]
5294
5311
  })]
@@ -6538,15 +6555,19 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
6538
6555
  openResponsePanels.has(ep.id) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6539
6556
  className: cx("code-panel"),
6540
6557
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input.TextArea, {
6541
- value: editableResponseContent[ep.id] ?? "",
6558
+ value: editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? "",
6542
6559
  onChange: (e) => {
6560
+ const statusCode = selectedStatusCodes[ep.id];
6543
6561
  setEditableResponseContent((prev) => ({
6544
6562
  ...prev,
6545
- [ep.id]: e.target.value
6563
+ [ep.id]: {
6564
+ ...prev[ep.id],
6565
+ [statusCode]: e.target.value
6566
+ }
6546
6567
  }));
6547
- onResponseContentChange?.(ep.id, e.target.value);
6568
+ onResponseContentChange?.(ep.id, selectedStatusCodes[ep.id], e.target.value);
6548
6569
  },
6549
- rows: Math.max(3, (editableResponseContent[ep.id] ?? "").split("\n").length),
6570
+ rows: Math.max(3, (editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? "").split("\n").length),
6550
6571
  style: {
6551
6572
  fontFamily: "monospace",
6552
6573
  fontSize: "0.75rem",
@@ -6562,16 +6583,22 @@ const EndpointsSection = ({ endpointsByTag, collapsed = false, onToggleCollapse,
6562
6583
  ghost: true,
6563
6584
  size: "small",
6564
6585
  className: cx("code-btn"),
6565
- onClick: () => handleValidate(editableResponseContent[ep.id] ?? ""),
6586
+ onClick: () => handleValidate(editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? ""),
6566
6587
  children: "Validate"
6567
6588
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
6568
6589
  ghost: true,
6569
6590
  size: "small",
6570
6591
  className: cx("code-btn"),
6571
- onClick: () => handleBeautify(editableResponseContent[ep.id] ?? "", (v) => setEditableResponseContent((prev) => ({
6572
- ...prev,
6573
- [ep.id]: v
6574
- }))),
6592
+ onClick: () => handleBeautify(editableResponseContent[ep.id]?.[selectedStatusCodes[ep.id]] ?? "", (v) => {
6593
+ const statusCode = selectedStatusCodes[ep.id];
6594
+ setEditableResponseContent((prev) => ({
6595
+ ...prev,
6596
+ [ep.id]: {
6597
+ ...prev[ep.id],
6598
+ [statusCode]: v
6599
+ }
6600
+ }));
6601
+ }),
6575
6602
  children: "Beautify"
6576
6603
  })]
6577
6604
  })]
@@ -9077,8 +9104,7 @@ function CodeboxSidebar$1() {
9077
9104
  const firstKey = Object.keys(contentEntry.examples)[0];
9078
9105
  const firstExample = contentEntry.examples[firstKey];
9079
9106
  displayData = firstExample?.value ?? firstExample;
9080
- } else if (contentEntry?.schema && hasAnyExample(contentEntry.schema)) displayData = generateExampleFromSchema(contentEntry.schema);
9081
- else if (contentEntry?.schema) displayData = contentEntry.schema;
9107
+ } else if (contentEntry?.schema) displayData = generateExampleFromSchema(contentEntry.schema);
9082
9108
  else displayData = responseObj;
9083
9109
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Codebox$1, { code: JSON.stringify(displayData, null, 2) || "" });
9084
9110
  })()]
@@ -9520,9 +9546,15 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
9520
9546
  Object.entries(methods).forEach(([method, operation]) => {
9521
9547
  const responses = operation.responses;
9522
9548
  if (!responses) return;
9523
- const schema = responses["200" in responses ? "200" : Object.keys(responses)[0]]?.content?.["application/json"]?.example;
9524
9549
  const epId = pathMethodToId[`${path}||${method}`];
9525
- if (epId && schema) result[epId] = schema;
9550
+ if (!epId) return;
9551
+ result[epId] = {};
9552
+ Object.entries(responses).forEach(([statusCode, responseValue]) => {
9553
+ const content = responseValue?.content?.["application/json"];
9554
+ if (!content) return;
9555
+ const resolved = content?.example !== void 0 ? content.example : content?.examples !== void 0 ? Object.values(content.examples)[0]?.value ?? Object.values(content.examples)[0] : content?.schema != null ? generateExampleFromSchema(content.schema) : void 0;
9556
+ if (resolved !== void 0) result[epId][statusCode] = resolved;
9557
+ });
9526
9558
  });
9527
9559
  });
9528
9560
  return result;
@@ -10169,12 +10201,15 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
10169
10201
  setBannerVisible(true);
10170
10202
  } catch {}
10171
10203
  },
10172
- onResponseContentChange: (endpointId, jsonString) => {
10204
+ onResponseContentChange: (endpointId, statusCode, jsonString) => {
10173
10205
  try {
10174
10206
  const schema = JSON.parse(jsonString);
10175
10207
  setEndpointResponseBody((prev) => ({
10176
10208
  ...prev,
10177
- [endpointId]: schema
10209
+ [endpointId]: {
10210
+ ...prev[endpointId],
10211
+ [statusCode]: schema
10212
+ }
10178
10213
  }));
10179
10214
  setBannerVisible(true);
10180
10215
  } catch {}
@@ -10330,12 +10365,15 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
10330
10365
  setBannerVisible(true);
10331
10366
  } catch {}
10332
10367
  },
10333
- onResponseContentChange: (endpointId, jsonString) => {
10368
+ onResponseContentChange: (endpointId, statusCode, jsonString) => {
10334
10369
  try {
10335
10370
  const schema = JSON.parse(jsonString);
10336
10371
  setEndpointResponseBody((prev) => ({
10337
10372
  ...prev,
10338
- [endpointId]: schema
10373
+ [endpointId]: {
10374
+ ...prev[endpointId],
10375
+ [statusCode]: schema
10376
+ }
10339
10377
  }));
10340
10378
  setBannerVisible(true);
10341
10379
  } catch {}