@clarify-labs/renderer 0.11.3 → 0.11.5
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/output/{ClarifyShell-D25PYLE0.cjs → ClarifyShell-BbD82nrc.cjs} +50 -22
- package/output/ClarifyShell-BbD82nrc.cjs.map +1 -0
- package/output/{ClarifyShell-4hlqrEgp.js → ClarifyShell-BwqLbTI-.js} +50 -22
- package/output/ClarifyShell-BwqLbTI-.js.map +1 -0
- package/output/{MermaidViewer-kbSVqJ_z.cjs → MermaidViewer-CO1rhB6A.cjs} +2 -2
- package/output/{MermaidViewer-kbSVqJ_z.cjs.map → MermaidViewer-CO1rhB6A.cjs.map} +1 -1
- package/output/{MermaidViewer-D4h-WEak.js → MermaidViewer-D1wiX_T9.js} +2 -2
- package/output/{MermaidViewer-D4h-WEak.js.map → MermaidViewer-D1wiX_T9.js.map} +1 -1
- package/output/{OpenApiOperation-HhSjad7q.cjs → OpenApiOperation-C77uiDjW.cjs} +271 -88
- package/output/OpenApiOperation-C77uiDjW.cjs.map +1 -0
- package/output/{OpenApiOperation-BcJYHwft.js → OpenApiOperation-CbdKZMO1.js} +270 -87
- package/output/OpenApiOperation-CbdKZMO1.js.map +1 -0
- package/output/{PageActions-Bnz5Bybt.js → PageActions-DviEypf6.js} +43 -45
- package/output/PageActions-DviEypf6.js.map +1 -0
- package/output/{PageActions-GVAsO16x.cjs → PageActions-ob2OJusG.cjs} +46 -48
- package/output/PageActions-ob2OJusG.cjs.map +1 -0
- package/output/{SearchDialog-DL5Y_bQ0.js → SearchDialog-89JAjQMh.js} +3 -3
- package/output/{SearchDialog-DL5Y_bQ0.js.map → SearchDialog-89JAjQMh.js.map} +1 -1
- package/output/{SearchDialog-CFMl0YAZ.cjs → SearchDialog-CTiUIKeo.cjs} +3 -3
- package/output/{SearchDialog-CFMl0YAZ.cjs.map → SearchDialog-CTiUIKeo.cjs.map} +1 -1
- package/output/app/AppShell.d.ts +1 -0
- package/output/app/ContentDiagnostic.d.ts +1 -1
- package/output/app/PageActions.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/core/i18n.d.ts +2 -1
- package/output/{i18n-sJUQQLRZ.js → i18n-Cff810G_.js} +11 -3
- package/output/i18n-Cff810G_.js.map +1 -0
- package/output/{i18n-R08i532P.cjs → i18n-Cjfk1N7i.cjs} +11 -3
- package/output/i18n-Cjfk1N7i.cjs.map +1 -0
- package/output/index.cjs +30 -30
- package/output/index.cjs.map +1 -1
- package/output/index.js +30 -30
- package/output/index.js.map +1 -1
- package/output/openapi/components/ExamplePanels.d.ts +3 -1
- package/output/openapi/components/OpenApiDocumentSection.d.ts +1 -0
- package/output/openapi/components/OpenApiRequest.d.ts +1 -0
- package/output/openapi/components/SchemaProperties.d.ts +8 -0
- package/output/openapi/components/SchemaSearch.d.ts +20 -0
- package/output/openapi/components/useOpenApiRequestState.d.ts +1 -1
- package/output/openapi/entry.d.ts +4 -3
- package/output/openapi/lib/helpers.d.ts +3 -0
- package/output/openapi/lib/utils.d.ts +1 -0
- package/output/preview.cjs +4 -4
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +4 -4
- package/output/preview.js.map +1 -1
- package/output/{render-BuWbLXJW.cjs → render-BhVJVa1q.cjs} +2 -2
- package/output/{render-BuWbLXJW.cjs.map → render-BhVJVa1q.cjs.map} +1 -1
- package/output/{render-tWo_ruCT.js → render-PDmRKKJm.js} +2 -2
- package/output/{render-tWo_ruCT.js.map → render-PDmRKKJm.js.map} +1 -1
- package/output/renderer.css +67 -28
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/package.json +1 -1
- package/output/ClarifyShell-4hlqrEgp.js.map +0 -1
- package/output/ClarifyShell-D25PYLE0.cjs.map +0 -1
- package/output/OpenApiOperation-BcJYHwft.js.map +0 -1
- package/output/OpenApiOperation-HhSjad7q.cjs.map +0 -1
- package/output/PageActions-Bnz5Bybt.js.map +0 -1
- package/output/PageActions-GVAsO16x.cjs.map +0 -1
- package/output/i18n-R08i532P.cjs.map +0 -1
- package/output/i18n-sJUQQLRZ.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
|
|
2
|
-
const require_i18n = require("./i18n-
|
|
3
|
-
const require_PageActions = require("./PageActions-
|
|
2
|
+
const require_i18n = require("./i18n-Cjfk1N7i.cjs");
|
|
3
|
+
const require_PageActions = require("./PageActions-ob2OJusG.cjs");
|
|
4
4
|
const require_remark = require("./remark-DTLbG8PK.cjs");
|
|
5
5
|
let clsx = require("clsx");
|
|
6
6
|
clsx = require_rolldown_runtime.__toESM(clsx, 1);
|
|
@@ -245,7 +245,7 @@ function Card(arg0) {
|
|
|
245
245
|
}
|
|
246
246
|
//#endregion
|
|
247
247
|
//#region source/components/Mermaid.tsx
|
|
248
|
-
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-
|
|
248
|
+
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-CO1rhB6A.cjs")));
|
|
249
249
|
var mermaidModulePromise;
|
|
250
250
|
async function loadMermaid() {
|
|
251
251
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -488,10 +488,14 @@ function CodeGroupHeader(arg0) {
|
|
|
488
488
|
}
|
|
489
489
|
function CodeGroupPanels(arg0) {
|
|
490
490
|
const { children, ...props } = arg0;
|
|
491
|
-
if (react.Children.count(children) > 1) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanels, { children: react.Children.map(children, (child) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanel, {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
491
|
+
if (react.Children.count(children) > 1) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanels, { children: react.Children.map(children, (child) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanel, {
|
|
492
|
+
static: true,
|
|
493
|
+
className: "hidden data-selected:block",
|
|
494
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodePanel, {
|
|
495
|
+
...props,
|
|
496
|
+
children: child
|
|
497
|
+
})
|
|
498
|
+
})) });
|
|
495
499
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodePanel, {
|
|
496
500
|
...props,
|
|
497
501
|
children
|
|
@@ -1044,7 +1048,8 @@ function Tabs(arg0) {
|
|
|
1044
1048
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanels, {
|
|
1045
1049
|
className: panelsClassName ?? "mt-5",
|
|
1046
1050
|
children: resolvedItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanel, {
|
|
1047
|
-
|
|
1051
|
+
static: true,
|
|
1052
|
+
className: ({ selected }) => (0, clsx.default)("focus:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", !selected && "hidden"),
|
|
1048
1053
|
children: item.panel
|
|
1049
1054
|
}, item.id))
|
|
1050
1055
|
})]
|
|
@@ -1257,12 +1262,15 @@ var primitives_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
1257
1262
|
});
|
|
1258
1263
|
function wrapper(arg0) {
|
|
1259
1264
|
const { children } = arg0;
|
|
1260
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1261
|
-
className: "clarify-mdx-page flex h-full min-w-0 flex-col pt-14 pb-10",
|
|
1262
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1265
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1266
|
+
className: "clarify-mdx-page relative flex h-full min-w-0 flex-col pt-14 pb-10",
|
|
1267
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1268
|
+
className: "clarify-page-actions mb-4 flex justify-end sm:absolute sm:top-14 sm:right-0 sm:mb-0",
|
|
1269
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.PageActions, {})
|
|
1270
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Prose, {
|
|
1263
1271
|
className: "flex-auto",
|
|
1264
1272
|
children
|
|
1265
|
-
})
|
|
1273
|
+
})]
|
|
1266
1274
|
});
|
|
1267
1275
|
}
|
|
1268
1276
|
function table(arg0) {
|
|
@@ -1284,13 +1292,10 @@ function a(arg0) {
|
|
|
1284
1292
|
}
|
|
1285
1293
|
function h1(arg0) {
|
|
1286
1294
|
const { children, className, ...props } = arg0;
|
|
1287
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1288
|
-
className: "clarify-page-title
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
...props,
|
|
1292
|
-
children
|
|
1293
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.PageTitleActions, {})]
|
|
1295
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
1296
|
+
className: (0, clsx.default)("clarify-page-title min-w-0 flex-1", className),
|
|
1297
|
+
...props,
|
|
1298
|
+
children
|
|
1294
1299
|
});
|
|
1295
1300
|
}
|
|
1296
1301
|
var code = Code;
|
|
@@ -1475,6 +1480,57 @@ function resolveRequestSchema(spec, schema) {
|
|
|
1475
1480
|
delete ownSchema.allOf;
|
|
1476
1481
|
return mergeAllOfSchemas(spec, [...allOf, ownSchema]);
|
|
1477
1482
|
}
|
|
1483
|
+
function fuzzyMatch(value, query) {
|
|
1484
|
+
const candidate = value.toLocaleLowerCase();
|
|
1485
|
+
const needle = query.trim().toLocaleLowerCase();
|
|
1486
|
+
let candidateIndex = 0;
|
|
1487
|
+
for (const character of needle) {
|
|
1488
|
+
candidateIndex = candidate.indexOf(character, candidateIndex);
|
|
1489
|
+
if (candidateIndex === -1) return false;
|
|
1490
|
+
candidateIndex += 1;
|
|
1491
|
+
}
|
|
1492
|
+
return true;
|
|
1493
|
+
}
|
|
1494
|
+
var noExampleMatch = Symbol("no-example-match");
|
|
1495
|
+
function getSchemaSearchText(name, schema) {
|
|
1496
|
+
if (!isRecord$1(schema)) return name;
|
|
1497
|
+
return [
|
|
1498
|
+
name,
|
|
1499
|
+
schema.type,
|
|
1500
|
+
schema.description,
|
|
1501
|
+
schema.pattern,
|
|
1502
|
+
schema.const,
|
|
1503
|
+
schema.default,
|
|
1504
|
+
schema.minimum,
|
|
1505
|
+
schema.maximum,
|
|
1506
|
+
schema.additionalProperties
|
|
1507
|
+
].filter((value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean").join(" ");
|
|
1508
|
+
}
|
|
1509
|
+
function filterExampleValue(spec, schema, value, query) {
|
|
1510
|
+
const resolved = resolveRequestSchema(spec, schema);
|
|
1511
|
+
if (Array.isArray(value)) {
|
|
1512
|
+
const itemSchema = isRecord$1(resolved) ? resolved.items : void 0;
|
|
1513
|
+
const items = value.map((item) => filterExampleValue(spec, itemSchema, item, query)).filter((item) => item !== noExampleMatch);
|
|
1514
|
+
return items.length > 0 ? items : noExampleMatch;
|
|
1515
|
+
}
|
|
1516
|
+
if (isRecord$1(value)) {
|
|
1517
|
+
const properties = isRecord$1(resolved) && isRecord$1(resolved.properties) ? resolved.properties : {};
|
|
1518
|
+
const filtered = Object.entries(value).flatMap(([name, propertyValue]) => {
|
|
1519
|
+
const propertySchema = properties[name] ?? (isRecord$1(resolved) && isRecord$1(resolved.additionalProperties) ? resolved.additionalProperties : void 0);
|
|
1520
|
+
if (fuzzyMatch(getSchemaSearchText(name, resolveRequestSchema(spec, propertySchema)), query)) return [[name, propertyValue]];
|
|
1521
|
+
const child = filterExampleValue(spec, propertySchema, propertyValue, query);
|
|
1522
|
+
return child === noExampleMatch ? [] : [[name, child]];
|
|
1523
|
+
});
|
|
1524
|
+
return filtered.length > 0 ? Object.fromEntries(filtered) : noExampleMatch;
|
|
1525
|
+
}
|
|
1526
|
+
return fuzzyMatch(getSchemaSearchText("", resolved), query) ? value : noExampleMatch;
|
|
1527
|
+
}
|
|
1528
|
+
function filterExampleBySchema(spec, schema, value, query) {
|
|
1529
|
+
if (!query.trim()) return value;
|
|
1530
|
+
const filtered = filterExampleValue(spec, schema, value, query);
|
|
1531
|
+
if (filtered !== noExampleMatch) return filtered;
|
|
1532
|
+
return Array.isArray(value) ? [] : isRecord$1(value) ? {} : value;
|
|
1533
|
+
}
|
|
1478
1534
|
function getPathItem$1(spec, path) {
|
|
1479
1535
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1480
1536
|
}
|
|
@@ -1685,9 +1741,6 @@ function normalizeOpenApiOperationSectionId(operation, method, path, source) {
|
|
|
1685
1741
|
if (typeof sectionId !== "string" || !sectionId) operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION] = createOpenApiOperationSectionId(operation, method, path, source);
|
|
1686
1742
|
return operation;
|
|
1687
1743
|
}
|
|
1688
|
-
function isOpenAPIHttpMethod(method) {
|
|
1689
|
-
return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
|
|
1690
|
-
}
|
|
1691
1744
|
function isRecord(value) {
|
|
1692
1745
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1693
1746
|
}
|
|
@@ -1723,19 +1776,9 @@ function listOperationsFromPathItems(items, source, spec) {
|
|
|
1723
1776
|
}
|
|
1724
1777
|
return operations;
|
|
1725
1778
|
}
|
|
1726
|
-
function
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
const sources = source ? [source] : ["path", "webhook"];
|
|
1730
|
-
for (const currentSource of sources) {
|
|
1731
|
-
const operation = (currentSource === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path))?.[normalizedMethod];
|
|
1732
|
-
if (isRecord(operation)) return {
|
|
1733
|
-
path,
|
|
1734
|
-
method: normalizedMethod,
|
|
1735
|
-
operation: normalizeOpenApiOperationSectionId(operation, normalizedMethod, path, currentSource),
|
|
1736
|
-
source: currentSource
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1779
|
+
function getOpenApiOperationEntryById(spec, operationId) {
|
|
1780
|
+
const matches = listOpenApiOperations(spec).filter(({ operation }) => operation.operationId === operationId);
|
|
1781
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
1739
1782
|
}
|
|
1740
1783
|
function listOpenApiOperations(spec) {
|
|
1741
1784
|
const paths = spec.paths ?? {};
|
|
@@ -2522,8 +2565,11 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2522
2565
|
function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
|
|
2523
2566
|
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
|
|
2524
2567
|
}
|
|
2568
|
+
function isStructuredMediaType(mediaType) {
|
|
2569
|
+
return mediaType.includes("json") || mediaType.includes("yaml") || mediaType.includes("yml");
|
|
2570
|
+
}
|
|
2525
2571
|
function useRequestExamplesState(arg0) {
|
|
2526
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2572
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey, query = "" } = arg0;
|
|
2527
2573
|
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
2528
2574
|
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2529
2575
|
const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
|
|
@@ -2531,6 +2577,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2531
2577
|
const [selectedClientKey, setSelectedClientKey] = (0, react.useState)("curl");
|
|
2532
2578
|
const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
|
|
2533
2579
|
const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
|
|
2580
|
+
const requestExample = selectedContent && isStructuredMediaType(selectedContent.mediaType) ? filterExampleBySchema(spec, selectedContent.value.schema, selectedExample?.value, query) : selectedExample?.value;
|
|
2534
2581
|
const codeOptions = buildRequestCodeExamples({
|
|
2535
2582
|
spec,
|
|
2536
2583
|
path,
|
|
@@ -2540,7 +2587,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2540
2587
|
...selectedContent,
|
|
2541
2588
|
value: {
|
|
2542
2589
|
...selectedContent.value,
|
|
2543
|
-
example:
|
|
2590
|
+
example: requestExample,
|
|
2544
2591
|
examples: void 0
|
|
2545
2592
|
}
|
|
2546
2593
|
} : void 0,
|
|
@@ -2575,7 +2622,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2575
2622
|
};
|
|
2576
2623
|
}
|
|
2577
2624
|
function RequestExamplesPanel(arg0) {
|
|
2578
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2625
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey, query } = arg0;
|
|
2579
2626
|
const t = require_i18n.useBuiltInText();
|
|
2580
2627
|
const state = useRequestExamplesState({
|
|
2581
2628
|
spec,
|
|
@@ -2590,7 +2637,8 @@ function RequestExamplesPanel(arg0) {
|
|
|
2590
2637
|
auth,
|
|
2591
2638
|
operationSource,
|
|
2592
2639
|
sharedExampleKey,
|
|
2593
|
-
onSelectExampleKey
|
|
2640
|
+
onSelectExampleKey,
|
|
2641
|
+
query
|
|
2594
2642
|
});
|
|
2595
2643
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
2596
2644
|
title: t("openapi.request"),
|
|
@@ -2615,11 +2663,12 @@ function RequestExamplesPanel(arg0) {
|
|
|
2615
2663
|
function firstExampleKeyForResponseContent(content, spec) {
|
|
2616
2664
|
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2617
2665
|
}
|
|
2618
|
-
function getResponseExampleBody(content, example) {
|
|
2619
|
-
|
|
2666
|
+
function getResponseExampleBody(content, example, spec, query = "") {
|
|
2667
|
+
if (!content) return "";
|
|
2668
|
+
return stringifyExample(spec && isStructuredMediaType(content.mediaType) ? filterExampleBySchema(spec, content.value.schema, example?.value, query) : example?.value);
|
|
2620
2669
|
}
|
|
2621
2670
|
function useResponseExamplesState(arg0) {
|
|
2622
|
-
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2671
|
+
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus, query = "" } = arg0;
|
|
2623
2672
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2624
2673
|
if (left.status === "default") return -1;
|
|
2625
2674
|
if (right.status === "default") return 1;
|
|
@@ -2654,7 +2703,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2654
2703
|
selectedContent,
|
|
2655
2704
|
examples,
|
|
2656
2705
|
selectedExample,
|
|
2657
|
-
responseBody: getResponseExampleBody(selectedContent, selectedExample),
|
|
2706
|
+
responseBody: getResponseExampleBody(selectedContent, selectedExample, spec, query),
|
|
2658
2707
|
onSelectStatus: (value) => {
|
|
2659
2708
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2660
2709
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2683,7 +2732,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2683
2732
|
};
|
|
2684
2733
|
}
|
|
2685
2734
|
function ResponseExamplesPanel(arg0) {
|
|
2686
|
-
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2735
|
+
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus, query } = arg0;
|
|
2687
2736
|
const t = require_i18n.useBuiltInText();
|
|
2688
2737
|
const state = useResponseExamplesState({
|
|
2689
2738
|
operation,
|
|
@@ -2691,7 +2740,8 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2691
2740
|
sharedExampleKey,
|
|
2692
2741
|
onSelectExampleKey,
|
|
2693
2742
|
selectedStatus,
|
|
2694
|
-
onSelectStatus
|
|
2743
|
+
onSelectStatus,
|
|
2744
|
+
query
|
|
2695
2745
|
});
|
|
2696
2746
|
if (!state.selectedContent || !state.responseBody) return null;
|
|
2697
2747
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
@@ -2713,7 +2763,7 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2713
2763
|
//#endregion
|
|
2714
2764
|
//#region source/openapi/components/OpenApiDocumentSection.tsx
|
|
2715
2765
|
function OpenApiDocumentSection(props) {
|
|
2716
|
-
const { title, children, className, bodyClassName, level = 3 } = props;
|
|
2766
|
+
const { title, children, action, className, bodyClassName, level = 3 } = props;
|
|
2717
2767
|
const heading = level === 3 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2718
2768
|
className: "!m-0 text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2719
2769
|
children: title
|
|
@@ -2723,7 +2773,10 @@ function OpenApiDocumentSection(props) {
|
|
|
2723
2773
|
});
|
|
2724
2774
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2725
2775
|
className: (0, clsx.default)("clarify-openapi-document-section", className),
|
|
2726
|
-
children: [
|
|
2776
|
+
children: [action ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2777
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
2778
|
+
children: [heading, action]
|
|
2779
|
+
}) : heading, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2727
2780
|
className: (0, clsx.default)("mt-2", bodyClassName),
|
|
2728
2781
|
children
|
|
2729
2782
|
})]
|
|
@@ -3006,7 +3059,7 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
3006
3059
|
function EnumValueNode(arg0) {
|
|
3007
3060
|
const { node } = arg0;
|
|
3008
3061
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
3009
|
-
className: "clarify-schema-node m-0 p-0",
|
|
3062
|
+
className: (0, clsx.default)("clarify-schema-node m-0 p-0", node.visible === false && "hidden"),
|
|
3010
3063
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3011
3064
|
className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
|
|
3012
3065
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3032,10 +3085,11 @@ function EnumValueNode(arg0) {
|
|
|
3032
3085
|
});
|
|
3033
3086
|
}
|
|
3034
3087
|
function SchemaNode(arg0) {
|
|
3035
|
-
const { node, depth = 0, defaultExpanded } = arg0;
|
|
3088
|
+
const { node, depth = 0, defaultExpanded, forceExpanded = false } = arg0;
|
|
3036
3089
|
const t = require_i18n.useBuiltInText();
|
|
3037
|
-
const [
|
|
3090
|
+
const [locallyExpanded, setLocallyExpanded] = (0, react.useState)(defaultExpanded ?? depth < 1);
|
|
3038
3091
|
const hasChildren = node.children.length > 0;
|
|
3092
|
+
const expanded = forceExpanded || locallyExpanded;
|
|
3039
3093
|
if (node.kind === "enum") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnumValueNode, {
|
|
3040
3094
|
node,
|
|
3041
3095
|
depth
|
|
@@ -3070,25 +3124,29 @@ function SchemaNode(arg0) {
|
|
|
3070
3124
|
children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-4 w-4" })
|
|
3071
3125
|
}) : null] });
|
|
3072
3126
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
3073
|
-
className: "clarify-schema-node m-0 p-0",
|
|
3127
|
+
className: (0, clsx.default)("clarify-schema-node m-0 p-0", node.visible === false && "hidden"),
|
|
3074
3128
|
children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3075
3129
|
type: "button",
|
|
3076
3130
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
3077
3131
|
"aria-expanded": expanded,
|
|
3078
|
-
onClick: () =>
|
|
3132
|
+
onClick: () => setLocallyExpanded((value) => !value),
|
|
3079
3133
|
className: (0, clsx.default)(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)"),
|
|
3080
3134
|
children: content
|
|
3081
3135
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3082
3136
|
className: rowClassName,
|
|
3083
3137
|
children: content
|
|
3084
|
-
}), hasChildren
|
|
3085
|
-
|
|
3086
|
-
|
|
3138
|
+
}), hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3139
|
+
className: (0, clsx.default)(!expanded && "hidden"),
|
|
3140
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, {
|
|
3141
|
+
nodes: node.children,
|
|
3142
|
+
depth: depth + 1,
|
|
3143
|
+
forceExpanded
|
|
3144
|
+
})
|
|
3087
3145
|
}) : null]
|
|
3088
3146
|
});
|
|
3089
3147
|
}
|
|
3090
3148
|
function SchemaTree(arg0) {
|
|
3091
|
-
const { nodes, depth = 0 } = arg0;
|
|
3149
|
+
const { nodes, depth = 0, forceExpanded = false } = arg0;
|
|
3092
3150
|
if (nodes.length === 0) return null;
|
|
3093
3151
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
3094
3152
|
role: "list",
|
|
@@ -3096,19 +3154,52 @@ function SchemaTree(arg0) {
|
|
|
3096
3154
|
children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
|
|
3097
3155
|
node,
|
|
3098
3156
|
depth,
|
|
3099
|
-
defaultExpanded: node.defaultExpanded
|
|
3157
|
+
defaultExpanded: node.defaultExpanded,
|
|
3158
|
+
forceExpanded
|
|
3100
3159
|
}, node.key))
|
|
3101
3160
|
});
|
|
3102
3161
|
}
|
|
3162
|
+
function markSchemaNodesVisibility(nodes, query) {
|
|
3163
|
+
if (!query) return nodes.map((node) => ({
|
|
3164
|
+
...node,
|
|
3165
|
+
visible: true,
|
|
3166
|
+
children: markSchemaNodesVisibility(node.children, query)
|
|
3167
|
+
}));
|
|
3168
|
+
return nodes.map((node) => {
|
|
3169
|
+
const children = markSchemaNodesVisibility(node.children, query);
|
|
3170
|
+
const searchableText = getSchemaSearchText(node.name, {
|
|
3171
|
+
type: node.type,
|
|
3172
|
+
description: node.description,
|
|
3173
|
+
pattern: node.details
|
|
3174
|
+
});
|
|
3175
|
+
return {
|
|
3176
|
+
...node,
|
|
3177
|
+
visible: fuzzyMatch(searchableText, query) || children.some((child) => child.visible),
|
|
3178
|
+
children
|
|
3179
|
+
};
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3103
3182
|
function SchemaProperties(arg0) {
|
|
3104
|
-
const { title, schema, spec, defaultExpanded } = arg0;
|
|
3183
|
+
const { title, schema, spec, defaultExpanded, query = "", emptyText } = arg0;
|
|
3184
|
+
const t = require_i18n.useBuiltInText();
|
|
3105
3185
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
3106
3186
|
if (!root || root.children.length === 0) return null;
|
|
3107
|
-
|
|
3187
|
+
const normalizedQuery = query.trim();
|
|
3188
|
+
const nodes = markSchemaNodesVisibility(root.children, normalizedQuery);
|
|
3189
|
+
const hasQuery = Boolean(normalizedQuery);
|
|
3190
|
+
const hasVisibleNodes = nodes.some((node) => node.visible);
|
|
3191
|
+
const resolvedEmptyText = emptyText ?? t("openapi.noBodyProperties");
|
|
3192
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(OpenApiDocumentSection, {
|
|
3108
3193
|
title,
|
|
3109
3194
|
level: 4,
|
|
3110
3195
|
bodyClassName: "clarify-schema-properties not-prose",
|
|
3111
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, {
|
|
3196
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, {
|
|
3197
|
+
nodes,
|
|
3198
|
+
forceExpanded: hasQuery
|
|
3199
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3200
|
+
className: (0, clsx.default)("m-0 py-2 text-sm/5 text-(--clarify-ui-text-soft)", hasVisibleNodes && "hidden"),
|
|
3201
|
+
children: resolvedEmptyText
|
|
3202
|
+
})]
|
|
3112
3203
|
});
|
|
3113
3204
|
}
|
|
3114
3205
|
function ParameterList(arg0) {
|
|
@@ -3132,7 +3223,7 @@ function ParameterList(arg0) {
|
|
|
3132
3223
|
});
|
|
3133
3224
|
}
|
|
3134
3225
|
function ResponseList(arg0) {
|
|
3135
|
-
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
3226
|
+
const { title, operation, spec, selectedStatus, onSelectStatus, query = "", search } = arg0;
|
|
3136
3227
|
const t = require_i18n.useBuiltInText();
|
|
3137
3228
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
3138
3229
|
if (left.status === "default") return -1;
|
|
@@ -3173,7 +3264,9 @@ function ResponseList(arg0) {
|
|
|
3173
3264
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
|
|
3174
3265
|
title: t("openapi.responseBodyProperties"),
|
|
3175
3266
|
schema: responseSchema,
|
|
3176
|
-
spec
|
|
3267
|
+
spec,
|
|
3268
|
+
query,
|
|
3269
|
+
emptyText: t("openapi.noResponseBodyProperties")
|
|
3177
3270
|
})
|
|
3178
3271
|
}) : null
|
|
3179
3272
|
]
|
|
@@ -3181,18 +3274,20 @@ function ResponseList(arg0) {
|
|
|
3181
3274
|
};
|
|
3182
3275
|
if (orderedResponses.length === 1) {
|
|
3183
3276
|
const [{ status, response }] = orderedResponses;
|
|
3184
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3277
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(OpenApiDocumentSection, {
|
|
3185
3278
|
title: title ?? t("openapi.responses"),
|
|
3186
|
-
|
|
3279
|
+
action: search?.action,
|
|
3280
|
+
children: [search?.open ? search.input : null, renderResponsePanel({
|
|
3187
3281
|
status,
|
|
3188
3282
|
response
|
|
3189
|
-
})
|
|
3283
|
+
})]
|
|
3190
3284
|
});
|
|
3191
3285
|
}
|
|
3192
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3286
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(OpenApiDocumentSection, {
|
|
3193
3287
|
title: title ?? t("openapi.responses"),
|
|
3288
|
+
action: search?.action,
|
|
3194
3289
|
bodyClassName: "not-prose",
|
|
3195
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
3290
|
+
children: [search?.open ? search.input : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
3196
3291
|
selectedIndex,
|
|
3197
3292
|
onChange: (index) => {
|
|
3198
3293
|
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
@@ -3207,15 +3302,71 @@ function ResponseList(arg0) {
|
|
|
3207
3302
|
})),
|
|
3208
3303
|
spacingClassName: "m-0",
|
|
3209
3304
|
panelsClassName: "mt-2"
|
|
3305
|
+
})]
|
|
3306
|
+
});
|
|
3307
|
+
}
|
|
3308
|
+
//#endregion
|
|
3309
|
+
//#region source/openapi/components/SchemaSearch.tsx
|
|
3310
|
+
function useSchemaSearch() {
|
|
3311
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
3312
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
3313
|
+
return {
|
|
3314
|
+
open,
|
|
3315
|
+
query,
|
|
3316
|
+
onChange: (event) => setQuery(event.target.value),
|
|
3317
|
+
toggle: () => {
|
|
3318
|
+
setOpen((current) => {
|
|
3319
|
+
if (current) setQuery("");
|
|
3320
|
+
return !current;
|
|
3321
|
+
});
|
|
3322
|
+
}
|
|
3323
|
+
};
|
|
3324
|
+
}
|
|
3325
|
+
function SchemaSearchButton(arg0) {
|
|
3326
|
+
const { label, open, onClick } = arg0;
|
|
3327
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3328
|
+
type: "button",
|
|
3329
|
+
"aria-label": label,
|
|
3330
|
+
"aria-pressed": open,
|
|
3331
|
+
onClick,
|
|
3332
|
+
className: (0, clsx.default)("flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-(--clarify-theme-tokens-radius-md) transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", open ? "bg-(--clarify-ui-hover-background) text-(--clarify-theme-tokens-colors-primary)" : "text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)"),
|
|
3333
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
|
|
3334
|
+
className: "size-4",
|
|
3335
|
+
"aria-hidden": "true"
|
|
3210
3336
|
})
|
|
3211
3337
|
});
|
|
3212
3338
|
}
|
|
3339
|
+
function SchemaSearchInput(arg0) {
|
|
3340
|
+
const { label, value, onChange } = arg0;
|
|
3341
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3342
|
+
className: "not-prose mb-3 flex h-9 items-center gap-2 rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-3 transition focus-within:border-(--clarify-theme-tokens-colors-primary) focus-within:ring-2 focus-within:ring-(--clarify-theme-tokens-colors-primary)/15",
|
|
3343
|
+
children: [
|
|
3344
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
|
|
3345
|
+
className: "size-4 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3346
|
+
"aria-hidden": "true"
|
|
3347
|
+
}),
|
|
3348
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3349
|
+
className: "sr-only",
|
|
3350
|
+
children: label
|
|
3351
|
+
}),
|
|
3352
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3353
|
+
type: "search",
|
|
3354
|
+
value,
|
|
3355
|
+
onChange,
|
|
3356
|
+
placeholder: label,
|
|
3357
|
+
autoFocus: true,
|
|
3358
|
+
className: "min-w-0 flex-1 bg-transparent text-sm text-(--clarify-theme-tokens-colors-foreground) outline-none placeholder:text-(--clarify-ui-text-faint)"
|
|
3359
|
+
})
|
|
3360
|
+
]
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3213
3363
|
//#endregion
|
|
3214
3364
|
//#region source/openapi/components/EndpointSections.tsx
|
|
3215
3365
|
function EndpointRequest(arg0) {
|
|
3216
3366
|
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, authOptions, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
3217
3367
|
const t = require_i18n.useBuiltInText();
|
|
3218
3368
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
3369
|
+
const requestBodySearch = useSchemaSearch();
|
|
3219
3370
|
const renderDescription = () => {
|
|
3220
3371
|
if (!description) return null;
|
|
3221
3372
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: description });
|
|
@@ -3225,11 +3376,20 @@ function EndpointRequest(arg0) {
|
|
|
3225
3376
|
className: "text-sm/5 text-(--clarify-ui-text-soft)",
|
|
3226
3377
|
children: t("openapi.requestBodyEmpty")
|
|
3227
3378
|
});
|
|
3228
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3379
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3380
|
+
requestBodySearch.open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchInput, {
|
|
3381
|
+
label: t("openapi.searchBodyProperties"),
|
|
3382
|
+
value: requestBodySearch.query,
|
|
3383
|
+
onChange: requestBodySearch.onChange
|
|
3384
|
+
}) : null,
|
|
3385
|
+
typeof requestBody?.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
|
|
3386
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
|
|
3387
|
+
title: t("openapi.bodyProperties"),
|
|
3388
|
+
schema: requestSchema,
|
|
3389
|
+
spec,
|
|
3390
|
+
query: requestBodySearch.query
|
|
3391
|
+
})
|
|
3392
|
+
] });
|
|
3233
3393
|
};
|
|
3234
3394
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderDescription(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
3235
3395
|
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
@@ -3251,6 +3411,11 @@ function EndpointRequest(arg0) {
|
|
|
3251
3411
|
}),
|
|
3252
3412
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocumentSection, {
|
|
3253
3413
|
title: t("openapi.requestBody"),
|
|
3414
|
+
action: hasRequestBody ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchButton, {
|
|
3415
|
+
label: t("openapi.searchBodyProperties"),
|
|
3416
|
+
open: requestBodySearch.open,
|
|
3417
|
+
onClick: requestBodySearch.toggle
|
|
3418
|
+
}) : null,
|
|
3254
3419
|
children: renderRequestBody()
|
|
3255
3420
|
})
|
|
3256
3421
|
]
|
|
@@ -3271,7 +3436,8 @@ function EndpointRequest(arg0) {
|
|
|
3271
3436
|
auth,
|
|
3272
3437
|
operationSource,
|
|
3273
3438
|
sharedExampleKey,
|
|
3274
|
-
onSelectExampleKey
|
|
3439
|
+
onSelectExampleKey,
|
|
3440
|
+
query: requestBodySearch.query
|
|
3275
3441
|
})
|
|
3276
3442
|
})
|
|
3277
3443
|
})]
|
|
@@ -3282,6 +3448,7 @@ function EndpointResponse(arg0) {
|
|
|
3282
3448
|
const t = require_i18n.useBuiltInText();
|
|
3283
3449
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
3284
3450
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
3451
|
+
const responseBodySearch = useSchemaSearch();
|
|
3285
3452
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3286
3453
|
className: "mt-10 pt-6",
|
|
3287
3454
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
@@ -3293,7 +3460,21 @@ function EndpointResponse(arg0) {
|
|
|
3293
3460
|
operation,
|
|
3294
3461
|
spec,
|
|
3295
3462
|
selectedStatus,
|
|
3296
|
-
onSelectStatus
|
|
3463
|
+
onSelectStatus,
|
|
3464
|
+
query: responseBodySearch.query,
|
|
3465
|
+
search: {
|
|
3466
|
+
open: responseBodySearch.open,
|
|
3467
|
+
action: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchButton, {
|
|
3468
|
+
label: t("openapi.searchResponseBodyProperties"),
|
|
3469
|
+
open: responseBodySearch.open,
|
|
3470
|
+
onClick: responseBodySearch.toggle
|
|
3471
|
+
}),
|
|
3472
|
+
input: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchInput, {
|
|
3473
|
+
label: t("openapi.searchResponseBodyProperties"),
|
|
3474
|
+
value: responseBodySearch.query,
|
|
3475
|
+
onChange: responseBodySearch.onChange
|
|
3476
|
+
})
|
|
3477
|
+
}
|
|
3297
3478
|
})
|
|
3298
3479
|
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
|
|
3299
3480
|
sticky: true,
|
|
@@ -3306,7 +3487,8 @@ function EndpointResponse(arg0) {
|
|
|
3306
3487
|
sharedExampleKey,
|
|
3307
3488
|
onSelectExampleKey,
|
|
3308
3489
|
selectedStatus,
|
|
3309
|
-
onSelectStatus
|
|
3490
|
+
onSelectStatus,
|
|
3491
|
+
query: responseBodySearch.query
|
|
3310
3492
|
})
|
|
3311
3493
|
})
|
|
3312
3494
|
})]
|
|
@@ -4569,7 +4751,7 @@ function requestBodyForExample(spec, content, exampleKey) {
|
|
|
4569
4751
|
const example = getExampleEntries(content, spec).find((entry) => !entry.generated && entry.key === exampleKey);
|
|
4570
4752
|
return example ? stringifyExample(example.value) : initialRequestBody(spec, content);
|
|
4571
4753
|
}
|
|
4572
|
-
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4754
|
+
function useOpenApiRequestTarget(spec, path, operation, operationSource, requestExample = "") {
|
|
4573
4755
|
const servers = getServers(spec, operation, path, operationSource);
|
|
4574
4756
|
const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
|
|
4575
4757
|
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
@@ -4584,7 +4766,7 @@ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
|
4584
4766
|
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4585
4767
|
const [mediaType, setMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
|
|
4586
4768
|
const selectedContent = requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0];
|
|
4587
|
-
const [body, setBody] = (0, react.useState)(
|
|
4769
|
+
const [body, setBody] = (0, react.useState)(requestBodyForExample(spec, selectedContent?.value, requestExample));
|
|
4588
4770
|
const [bodyFiles, setBodyFiles] = (0, react.useState)({});
|
|
4589
4771
|
function selectServer(value) {
|
|
4590
4772
|
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
@@ -4746,12 +4928,12 @@ function parameterGroupLabel(location, t) {
|
|
|
4746
4928
|
return t("openapi.queryParameters");
|
|
4747
4929
|
}
|
|
4748
4930
|
function OpenApiRequestWorkbench(arg0) {
|
|
4749
|
-
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4931
|
+
const { spec, path, method, operation, operationSource = "path", requestExample, compact = false, onClose } = arg0;
|
|
4750
4932
|
const t = require_i18n.useBuiltInText();
|
|
4751
4933
|
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4752
|
-
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, selectedContent, body, setBody, bodyFiles, setBodyFile, applyBodyExample, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
|
|
4934
|
+
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, selectedContent, body, setBody, bodyFiles, setBodyFile, applyBodyExample, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource, requestExample);
|
|
4753
4935
|
const requestExamples = getRequestExampleEntries(parameters, selectedContent?.value);
|
|
4754
|
-
const [selectedRequestExampleKey, setSelectedRequestExampleKey] = (0, react.useState)(requestExamples[0]?.key ?? "");
|
|
4936
|
+
const [selectedRequestExampleKey, setSelectedRequestExampleKey] = (0, react.useState)(requestExample ?? requestExamples[0]?.key ?? "");
|
|
4755
4937
|
const currentRequestExampleKey = requestExamples.some((example) => example.key === selectedRequestExampleKey) ? selectedRequestExampleKey : requestExamples[0]?.key ?? "";
|
|
4756
4938
|
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter), currentRequestExampleKey);
|
|
4757
4939
|
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue, applyParameterExample } = parameterState;
|
|
@@ -4766,6 +4948,7 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4766
4948
|
})).filter((group) => group.parameters.length > 0);
|
|
4767
4949
|
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4768
4950
|
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4951
|
+
const showResponse = compact || Boolean(exchange || error);
|
|
4769
4952
|
function applyRequestExample(exampleKey) {
|
|
4770
4953
|
setSelectedRequestExampleKey(exampleKey);
|
|
4771
4954
|
applyParameterExample(exampleKey);
|
|
@@ -4977,9 +5160,9 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4977
5160
|
});
|
|
4978
5161
|
}
|
|
4979
5162
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4980
|
-
className: (0, clsx.default)("clarify-
|
|
5163
|
+
className: (0, clsx.default)("clarify-openapi-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-ui-accent-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_10%,transparent)] [--clarify-ui-accent-border:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_22%,transparent)] [--clarify-ui-accent-text:var(--clarify-theme-tokens-colors-foreground)] [--clarify-ui-active-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_12%,transparent)] [--clarify-ui-subtle-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_5%,transparent)]", compact ? "h-full" : "my-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border)"),
|
|
4981
5164
|
children: [renderHeader(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4982
|
-
className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
|
|
5165
|
+
className: (0, clsx.default)("grid min-h-0 flex-1 gap-0 px-0", showResponse && "lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]"),
|
|
4983
5166
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4984
5167
|
className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
|
|
4985
5168
|
children: [
|
|
@@ -5016,13 +5199,13 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
5016
5199
|
})
|
|
5017
5200
|
}) : null
|
|
5018
5201
|
]
|
|
5019
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5202
|
+
}), showResponse ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5020
5203
|
className: "h-full min-h-0 min-w-0 overflow-hidden border-t border-(--clarify-theme-tokens-colors-border) lg:border-t-0 lg:border-l",
|
|
5021
5204
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiResponseViewer, {
|
|
5022
5205
|
exchange,
|
|
5023
5206
|
error
|
|
5024
5207
|
})
|
|
5025
|
-
})]
|
|
5208
|
+
}) : null]
|
|
5026
5209
|
})]
|
|
5027
5210
|
});
|
|
5028
5211
|
}
|
|
@@ -5036,7 +5219,7 @@ function OpenApiRequestDialog(arg0) {
|
|
|
5036
5219
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5037
5220
|
className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
|
|
5038
5221
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.DialogPanel, {
|
|
5039
|
-
className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-lg border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
|
|
5222
|
+
className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
|
|
5040
5223
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogTitle, {
|
|
5041
5224
|
className: "sr-only",
|
|
5042
5225
|
children: t("openapi.tryRequest")
|
|
@@ -5566,10 +5749,10 @@ Object.defineProperty(exports, "getMediaTypeEntries", {
|
|
|
5566
5749
|
return getMediaTypeEntries;
|
|
5567
5750
|
}
|
|
5568
5751
|
});
|
|
5569
|
-
Object.defineProperty(exports, "
|
|
5752
|
+
Object.defineProperty(exports, "getOpenApiOperationEntryById", {
|
|
5570
5753
|
enumerable: true,
|
|
5571
5754
|
get: function() {
|
|
5572
|
-
return
|
|
5755
|
+
return getOpenApiOperationEntryById;
|
|
5573
5756
|
}
|
|
5574
5757
|
});
|
|
5575
5758
|
Object.defineProperty(exports, "getRequestBody", {
|
|
@@ -5603,4 +5786,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
5603
5786
|
}
|
|
5604
5787
|
});
|
|
5605
5788
|
|
|
5606
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5789
|
+
//# sourceMappingURL=OpenApiOperation-C77uiDjW.cjs.map
|