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