@clarify-labs/renderer 0.11.2 → 0.11.4
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-Cn48irqj.cjs → ClarifyShell-Cvb7Nk3A.cjs} +3 -3
- package/output/{ClarifyShell-Cn48irqj.cjs.map → ClarifyShell-Cvb7Nk3A.cjs.map} +1 -1
- package/output/{ClarifyShell-D_HluctW.js → ClarifyShell-gzlibEm8.js} +3 -3
- package/output/{ClarifyShell-D_HluctW.js.map → ClarifyShell-gzlibEm8.js.map} +1 -1
- package/output/{MermaidViewer-EZjolX08.cjs → MermaidViewer-CPuTNujY.cjs} +2 -2
- package/output/{MermaidViewer-EZjolX08.cjs.map → MermaidViewer-CPuTNujY.cjs.map} +1 -1
- package/output/{MermaidViewer-Dby0ylNr.js → MermaidViewer-EVuBmrzA.js} +2 -2
- package/output/{MermaidViewer-Dby0ylNr.js.map → MermaidViewer-EVuBmrzA.js.map} +1 -1
- package/output/{OpenApiOperation-Cr8TxLjl.js → OpenApiOperation-Ddax6Pen.js} +401 -189
- package/output/OpenApiOperation-Ddax6Pen.js.map +1 -0
- package/output/{OpenApiOperation-bdALspAY.cjs → OpenApiOperation-QqYCuqve.cjs} +401 -189
- package/output/OpenApiOperation-QqYCuqve.cjs.map +1 -0
- package/output/{PageActions-BLzCasvB.js → PageActions-BBRz0tJ4.js} +46 -29
- package/output/{PageActions-BLzCasvB.js.map → PageActions-BBRz0tJ4.js.map} +1 -1
- package/output/{PageActions-Bw9SAHLl.cjs → PageActions-ypH6U0Vc.cjs} +49 -32
- package/output/{PageActions-Bw9SAHLl.cjs.map → PageActions-ypH6U0Vc.cjs.map} +1 -1
- package/output/{SearchDialog-j_4Y9WY_.cjs → SearchDialog-DCGBhNnW.cjs} +3 -3
- package/output/{SearchDialog-j_4Y9WY_.cjs.map → SearchDialog-DCGBhNnW.cjs.map} +1 -1
- package/output/{SearchDialog-DWYp1c6c.js → SearchDialog-Df6jknma.js} +3 -3
- package/output/{SearchDialog-DWYp1c6c.js.map → SearchDialog-Df6jknma.js.map} +1 -1
- package/output/app/PageActions.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/Tabs.d.ts +3 -0
- package/output/core/i18n.d.ts +2 -1
- package/output/{i18n-L1XX-y6M.cjs → i18n-Ds-f-qlT.cjs} +17 -1
- package/output/i18n-Ds-f-qlT.cjs.map +1 -0
- package/output/{i18n-DjRcGSuU.js → i18n-LXAq0RIC.js} +17 -1
- package/output/i18n-LXAq0RIC.js.map +1 -0
- package/output/index.cjs +15 -17
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +1 -2
- package/output/index.js +16 -17
- package/output/index.js.map +1 -1
- package/output/mdx/components.d.ts +2 -2
- package/output/mdx/primitives.d.ts +2 -0
- package/output/openapi/components/ExamplePanels.d.ts +3 -1
- package/output/openapi/components/OpenApiAuthDocumentation.d.ts +1 -1
- package/output/openapi/components/OpenApiDocumentSection.d.ts +11 -0
- package/output/openapi/components/SchemaProperties.d.ts +8 -0
- package/output/openapi/components/SchemaSearch.d.ts +20 -0
- package/output/openapi/lib/helpers.d.ts +3 -0
- package/output/preview.cjs +3 -3
- package/output/preview.js +3 -3
- package/output/{render-hq20DPxe.cjs → render-BQkaRYoY.cjs} +2 -2
- package/output/{render-hq20DPxe.cjs.map → render-BQkaRYoY.cjs.map} +1 -1
- package/output/{render-CYQmEacg.js → render-C2rZuVLy.js} +2 -2
- package/output/{render-CYQmEacg.js.map → render-C2rZuVLy.js.map} +1 -1
- package/output/renderer.css +75 -29
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/package.json +1 -1
- package/output/OpenApiOperation-Cr8TxLjl.js.map +0 -1
- package/output/OpenApiOperation-bdALspAY.cjs.map +0 -1
- package/output/i18n-DjRcGSuU.js.map +0 -1
- package/output/i18n-L1XX-y6M.cjs.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-Ds-f-qlT.cjs");
|
|
3
|
+
const require_PageActions = require("./PageActions-ypH6U0Vc.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-CPuTNujY.cjs")));
|
|
249
249
|
var mermaidModulePromise;
|
|
250
250
|
async function loadMermaid() {
|
|
251
251
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -1006,7 +1006,7 @@ function TabItem(_props) {
|
|
|
1006
1006
|
return null;
|
|
1007
1007
|
}
|
|
1008
1008
|
function Tabs(arg0) {
|
|
1009
|
-
const { items, children, defaultValue, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
|
|
1009
|
+
const { items, children, defaultValue, selectedIndex, onChange, className, spacingClassName = "my-6", listClassName, panelsClassName, actions, variant = "content" } = arg0;
|
|
1010
1010
|
const childItems = react.Children.toArray(children).filter((child) => (0, react.isValidElement)(child) && child.type === TabItem).map((child, index) => ({
|
|
1011
1011
|
id: child.props.value ?? `tab-${index}`,
|
|
1012
1012
|
label: child.props.title,
|
|
@@ -1023,23 +1023,26 @@ function Tabs(arg0) {
|
|
|
1023
1023
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.TabGroup, {
|
|
1024
1024
|
selectedIndex: resolvedIndex,
|
|
1025
1025
|
onChange: handleChange,
|
|
1026
|
-
className: (0, clsx.default)("clarify-tabs
|
|
1027
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1028
|
-
className: (0, clsx.default)("flex max-w-full items-stretch
|
|
1029
|
-
children: resolvedItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Tab, {
|
|
1030
|
-
className: ({ selected }) => (0, clsx.default)("
|
|
1026
|
+
className: (0, clsx.default)("clarify-tabs", spacingClassName, className),
|
|
1027
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.TabList, {
|
|
1028
|
+
className: (0, clsx.default)("flex max-w-full items-stretch overflow-x-auto border-b", variant === "content" ? "gap-1 border-(--clarify-theme-tokens-colors-border)" : "h-10 gap-0 border-(--clarify-code-border) px-3", listClassName),
|
|
1029
|
+
children: [resolvedItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Tab, {
|
|
1030
|
+
className: ({ selected }) => (0, clsx.default)("relative inline-flex shrink-0 items-center px-2.5 transition focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)", variant === "content" ? "clarify-content-tab clarify-ui-tab my-1 h-9 rounded-(--clarify-theme-tokens-radius-md)" : "text-2xs font-semibold", selected && (variant === "content" ? "clarify-ui-tab-active" : "text-(--clarify-code-text)"), variant === "code" && !selected && "text-(--clarify-code-muted)"),
|
|
1031
1031
|
children: ({ selected }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.label }), selected ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.span, {
|
|
1032
1032
|
layoutId: indicatorLayoutId,
|
|
1033
|
-
className: "absolute inset-x-2.5
|
|
1033
|
+
className: (0, clsx.default)("absolute inset-x-2.5 h-0.5 bg-(--clarify-ui-tab-indicator)", variant === "content" ? "-bottom-1 rounded-full" : "-bottom-px"),
|
|
1034
1034
|
transition: {
|
|
1035
1035
|
type: "tween",
|
|
1036
1036
|
duration: .16,
|
|
1037
1037
|
ease: "easeOut"
|
|
1038
1038
|
}
|
|
1039
1039
|
}) : null] })
|
|
1040
|
-
}, item.id))
|
|
1040
|
+
}, item.id)), actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1041
|
+
className: "sticky right-0 ml-auto flex shrink-0 items-center bg-(--clarify-code-background)",
|
|
1042
|
+
children: actions
|
|
1043
|
+
}) : null]
|
|
1041
1044
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanels, {
|
|
1042
|
-
className:
|
|
1045
|
+
className: panelsClassName ?? "mt-5",
|
|
1043
1046
|
children: resolvedItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanel, {
|
|
1044
1047
|
className: "focus:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
1045
1048
|
children: item.panel
|
|
@@ -1254,12 +1257,15 @@ var primitives_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
1254
1257
|
});
|
|
1255
1258
|
function wrapper(arg0) {
|
|
1256
1259
|
const { children } = arg0;
|
|
1257
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1258
|
-
className: "clarify-mdx-page flex h-full min-w-0 flex-col pt-14 pb-10",
|
|
1259
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1260
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
|
|
1261
|
+
className: "clarify-mdx-page relative flex h-full min-w-0 flex-col pt-14 pb-10",
|
|
1262
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1263
|
+
className: "clarify-page-actions mb-4 flex justify-end sm:absolute sm:top-14 sm:right-0 sm:mb-0",
|
|
1264
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.PageActions, {})
|
|
1265
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Prose, {
|
|
1260
1266
|
className: "flex-auto",
|
|
1261
1267
|
children
|
|
1262
|
-
})
|
|
1268
|
+
})]
|
|
1263
1269
|
});
|
|
1264
1270
|
}
|
|
1265
1271
|
function table(arg0) {
|
|
@@ -1281,13 +1287,10 @@ function a(arg0) {
|
|
|
1281
1287
|
}
|
|
1282
1288
|
function h1(arg0) {
|
|
1283
1289
|
const { children, className, ...props } = arg0;
|
|
1284
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1285
|
-
className: "clarify-page-title
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
...props,
|
|
1289
|
-
children
|
|
1290
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.PageTitleActions, {})]
|
|
1290
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
1291
|
+
className: (0, clsx.default)("clarify-page-title min-w-0 flex-1", className),
|
|
1292
|
+
...props,
|
|
1293
|
+
children
|
|
1291
1294
|
});
|
|
1292
1295
|
}
|
|
1293
1296
|
var code = Code;
|
|
@@ -1330,9 +1333,9 @@ function Col(arg0) {
|
|
|
1330
1333
|
});
|
|
1331
1334
|
}
|
|
1332
1335
|
function Properties(arg0) {
|
|
1333
|
-
const { children } = arg0;
|
|
1336
|
+
const { children, className, spacingClassName = "my-6" } = arg0;
|
|
1334
1337
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1335
|
-
className: "clarify-properties
|
|
1338
|
+
className: (0, clsx.default)("clarify-properties", spacingClassName, className),
|
|
1336
1339
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
1337
1340
|
role: "list",
|
|
1338
1341
|
className: "m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border) p-0",
|
|
@@ -1472,6 +1475,57 @@ function resolveRequestSchema(spec, schema) {
|
|
|
1472
1475
|
delete ownSchema.allOf;
|
|
1473
1476
|
return mergeAllOfSchemas(spec, [...allOf, ownSchema]);
|
|
1474
1477
|
}
|
|
1478
|
+
function fuzzyMatch(value, query) {
|
|
1479
|
+
const candidate = value.toLocaleLowerCase();
|
|
1480
|
+
const needle = query.trim().toLocaleLowerCase();
|
|
1481
|
+
let candidateIndex = 0;
|
|
1482
|
+
for (const character of needle) {
|
|
1483
|
+
candidateIndex = candidate.indexOf(character, candidateIndex);
|
|
1484
|
+
if (candidateIndex === -1) return false;
|
|
1485
|
+
candidateIndex += 1;
|
|
1486
|
+
}
|
|
1487
|
+
return true;
|
|
1488
|
+
}
|
|
1489
|
+
var noExampleMatch = Symbol("no-example-match");
|
|
1490
|
+
function getSchemaSearchText(name, schema) {
|
|
1491
|
+
if (!isRecord$1(schema)) return name;
|
|
1492
|
+
return [
|
|
1493
|
+
name,
|
|
1494
|
+
schema.type,
|
|
1495
|
+
schema.description,
|
|
1496
|
+
schema.pattern,
|
|
1497
|
+
schema.const,
|
|
1498
|
+
schema.default,
|
|
1499
|
+
schema.minimum,
|
|
1500
|
+
schema.maximum,
|
|
1501
|
+
schema.additionalProperties
|
|
1502
|
+
].filter((value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean").join(" ");
|
|
1503
|
+
}
|
|
1504
|
+
function filterExampleValue(spec, schema, value, query) {
|
|
1505
|
+
const resolved = resolveRequestSchema(spec, schema);
|
|
1506
|
+
if (Array.isArray(value)) {
|
|
1507
|
+
const itemSchema = isRecord$1(resolved) ? resolved.items : void 0;
|
|
1508
|
+
const items = value.map((item) => filterExampleValue(spec, itemSchema, item, query)).filter((item) => item !== noExampleMatch);
|
|
1509
|
+
return items.length > 0 ? items : noExampleMatch;
|
|
1510
|
+
}
|
|
1511
|
+
if (isRecord$1(value)) {
|
|
1512
|
+
const properties = isRecord$1(resolved) && isRecord$1(resolved.properties) ? resolved.properties : {};
|
|
1513
|
+
const filtered = Object.entries(value).flatMap(([name, propertyValue]) => {
|
|
1514
|
+
const propertySchema = properties[name] ?? (isRecord$1(resolved) && isRecord$1(resolved.additionalProperties) ? resolved.additionalProperties : void 0);
|
|
1515
|
+
if (fuzzyMatch(getSchemaSearchText(name, resolveRequestSchema(spec, propertySchema)), query)) return [[name, propertyValue]];
|
|
1516
|
+
const child = filterExampleValue(spec, propertySchema, propertyValue, query);
|
|
1517
|
+
return child === noExampleMatch ? [] : [[name, child]];
|
|
1518
|
+
});
|
|
1519
|
+
return filtered.length > 0 ? Object.fromEntries(filtered) : noExampleMatch;
|
|
1520
|
+
}
|
|
1521
|
+
return fuzzyMatch(getSchemaSearchText("", resolved), query) ? value : noExampleMatch;
|
|
1522
|
+
}
|
|
1523
|
+
function filterExampleBySchema(spec, schema, value, query) {
|
|
1524
|
+
if (!query.trim()) return value;
|
|
1525
|
+
const filtered = filterExampleValue(spec, schema, value, query);
|
|
1526
|
+
if (filtered !== noExampleMatch) return filtered;
|
|
1527
|
+
return Array.isArray(value) ? [] : isRecord$1(value) ? {} : value;
|
|
1528
|
+
}
|
|
1475
1529
|
function getPathItem$1(spec, path) {
|
|
1476
1530
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1477
1531
|
}
|
|
@@ -2519,8 +2573,11 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2519
2573
|
function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
|
|
2520
2574
|
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
|
|
2521
2575
|
}
|
|
2576
|
+
function isStructuredMediaType(mediaType) {
|
|
2577
|
+
return mediaType.includes("json") || mediaType.includes("yaml") || mediaType.includes("yml");
|
|
2578
|
+
}
|
|
2522
2579
|
function useRequestExamplesState(arg0) {
|
|
2523
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2580
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey, query = "" } = arg0;
|
|
2524
2581
|
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
2525
2582
|
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2526
2583
|
const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
|
|
@@ -2528,6 +2585,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2528
2585
|
const [selectedClientKey, setSelectedClientKey] = (0, react.useState)("curl");
|
|
2529
2586
|
const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
|
|
2530
2587
|
const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
|
|
2588
|
+
const requestExample = selectedContent && isStructuredMediaType(selectedContent.mediaType) ? filterExampleBySchema(spec, selectedContent.value.schema, selectedExample?.value, query) : selectedExample?.value;
|
|
2531
2589
|
const codeOptions = buildRequestCodeExamples({
|
|
2532
2590
|
spec,
|
|
2533
2591
|
path,
|
|
@@ -2537,7 +2595,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2537
2595
|
...selectedContent,
|
|
2538
2596
|
value: {
|
|
2539
2597
|
...selectedContent.value,
|
|
2540
|
-
example:
|
|
2598
|
+
example: requestExample,
|
|
2541
2599
|
examples: void 0
|
|
2542
2600
|
}
|
|
2543
2601
|
} : void 0,
|
|
@@ -2572,7 +2630,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2572
2630
|
};
|
|
2573
2631
|
}
|
|
2574
2632
|
function RequestExamplesPanel(arg0) {
|
|
2575
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2633
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey, query } = arg0;
|
|
2576
2634
|
const t = require_i18n.useBuiltInText();
|
|
2577
2635
|
const state = useRequestExamplesState({
|
|
2578
2636
|
spec,
|
|
@@ -2587,7 +2645,8 @@ function RequestExamplesPanel(arg0) {
|
|
|
2587
2645
|
auth,
|
|
2588
2646
|
operationSource,
|
|
2589
2647
|
sharedExampleKey,
|
|
2590
|
-
onSelectExampleKey
|
|
2648
|
+
onSelectExampleKey,
|
|
2649
|
+
query
|
|
2591
2650
|
});
|
|
2592
2651
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
2593
2652
|
title: t("openapi.request"),
|
|
@@ -2612,11 +2671,12 @@ function RequestExamplesPanel(arg0) {
|
|
|
2612
2671
|
function firstExampleKeyForResponseContent(content, spec) {
|
|
2613
2672
|
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2614
2673
|
}
|
|
2615
|
-
function getResponseExampleBody(content, example) {
|
|
2616
|
-
|
|
2674
|
+
function getResponseExampleBody(content, example, spec, query = "") {
|
|
2675
|
+
if (!content) return "";
|
|
2676
|
+
return stringifyExample(spec && isStructuredMediaType(content.mediaType) ? filterExampleBySchema(spec, content.value.schema, example?.value, query) : example?.value);
|
|
2617
2677
|
}
|
|
2618
2678
|
function useResponseExamplesState(arg0) {
|
|
2619
|
-
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2679
|
+
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus, query = "" } = arg0;
|
|
2620
2680
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2621
2681
|
if (left.status === "default") return -1;
|
|
2622
2682
|
if (right.status === "default") return 1;
|
|
@@ -2651,7 +2711,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2651
2711
|
selectedContent,
|
|
2652
2712
|
examples,
|
|
2653
2713
|
selectedExample,
|
|
2654
|
-
responseBody: getResponseExampleBody(selectedContent, selectedExample),
|
|
2714
|
+
responseBody: getResponseExampleBody(selectedContent, selectedExample, spec, query),
|
|
2655
2715
|
onSelectStatus: (value) => {
|
|
2656
2716
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2657
2717
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2680,7 +2740,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2680
2740
|
};
|
|
2681
2741
|
}
|
|
2682
2742
|
function ResponseExamplesPanel(arg0) {
|
|
2683
|
-
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2743
|
+
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus, query } = arg0;
|
|
2684
2744
|
const t = require_i18n.useBuiltInText();
|
|
2685
2745
|
const state = useResponseExamplesState({
|
|
2686
2746
|
operation,
|
|
@@ -2688,7 +2748,8 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2688
2748
|
sharedExampleKey,
|
|
2689
2749
|
onSelectExampleKey,
|
|
2690
2750
|
selectedStatus,
|
|
2691
|
-
onSelectStatus
|
|
2751
|
+
onSelectStatus,
|
|
2752
|
+
query
|
|
2692
2753
|
});
|
|
2693
2754
|
if (!state.selectedContent || !state.responseBody) return null;
|
|
2694
2755
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
@@ -2708,6 +2769,28 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2708
2769
|
});
|
|
2709
2770
|
}
|
|
2710
2771
|
//#endregion
|
|
2772
|
+
//#region source/openapi/components/OpenApiDocumentSection.tsx
|
|
2773
|
+
function OpenApiDocumentSection(props) {
|
|
2774
|
+
const { title, children, action, className, bodyClassName, level = 3 } = props;
|
|
2775
|
+
const heading = level === 3 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2776
|
+
className: "!m-0 text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2777
|
+
children: title
|
|
2778
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
|
2779
|
+
className: "!m-0 text-xs/5 font-semibold text-(--clarify-ui-text-soft)",
|
|
2780
|
+
children: title
|
|
2781
|
+
});
|
|
2782
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2783
|
+
className: (0, clsx.default)("clarify-openapi-document-section", className),
|
|
2784
|
+
children: [action ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2785
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
2786
|
+
children: [heading, action]
|
|
2787
|
+
}) : heading, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2788
|
+
className: (0, clsx.default)("mt-2", bodyClassName),
|
|
2789
|
+
children
|
|
2790
|
+
})]
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
//#endregion
|
|
2711
2794
|
//#region source/openapi/components/OpenApiAuthDocumentation.tsx
|
|
2712
2795
|
function authSchemeType(option, apiKeyLabel) {
|
|
2713
2796
|
const { scheme } = option;
|
|
@@ -2717,73 +2800,73 @@ function authSchemeType(option, apiKeyLabel) {
|
|
|
2717
2800
|
if (scheme.type === "openIdConnect") return "OPENID CONNECT";
|
|
2718
2801
|
return scheme.type?.toUpperCase() || "AUTH";
|
|
2719
2802
|
}
|
|
2720
|
-
function OpenApiAuthDocumentation(
|
|
2803
|
+
function OpenApiAuthDocumentation(props) {
|
|
2804
|
+
const { options } = props;
|
|
2721
2805
|
const t = require_i18n.useBuiltInText();
|
|
2722
2806
|
if (options.length === 0) return null;
|
|
2723
|
-
|
|
2724
|
-
className: "
|
|
2725
|
-
children:
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
})
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
})] });
|
|
2807
|
+
const renderOption = (option) => option.schemes.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2808
|
+
className: "border-b border-(--clarify-theme-tokens-colors-border) pt-2 pb-4 text-sm/6 font-medium text-(--clarify-theme-tokens-colors-foreground)",
|
|
2809
|
+
children: t("openapi.authNoAuth")
|
|
2810
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2811
|
+
className: "divide-y divide-(--clarify-theme-tokens-colors-border) border-b border-(--clarify-theme-tokens-colors-border)",
|
|
2812
|
+
children: option.schemes.map((schemeOption, schemeIndex) => {
|
|
2813
|
+
const { scheme } = schemeOption;
|
|
2814
|
+
const details = [
|
|
2815
|
+
scheme.type === "apiKey" && scheme.in && scheme.name ? t("openapi.authLocation", {
|
|
2816
|
+
in: scheme.in,
|
|
2817
|
+
name: scheme.name
|
|
2818
|
+
}) : void 0,
|
|
2819
|
+
scheme.type === "http" && scheme.bearerFormat ? t("openapi.authBearerFormat", { format: scheme.bearerFormat }) : void 0,
|
|
2820
|
+
scheme.type === "openIdConnect" ? scheme.openIdConnectUrl : void 0,
|
|
2821
|
+
schemeOption.scopes.length > 0 ? t("openapi.authScopes", { scopes: schemeOption.scopes.join(", ") }) : void 0
|
|
2822
|
+
].filter((value) => Boolean(value));
|
|
2823
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [schemeIndex > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2824
|
+
className: "relative h-0",
|
|
2825
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2826
|
+
className: "absolute top-0 left-4 -translate-y-1/2 bg-(--clarify-theme-tokens-colors-background) px-1.5 text-2xs font-semibold text-(--clarify-ui-text-faint)",
|
|
2827
|
+
children: t("openapi.authAnd")
|
|
2828
|
+
})
|
|
2829
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2830
|
+
className: "py-4 first:pt-2",
|
|
2831
|
+
children: [
|
|
2832
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2833
|
+
className: "flex flex-wrap items-center gap-2",
|
|
2834
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2835
|
+
className: "font-mono text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2836
|
+
children: schemeOption.name
|
|
2837
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2838
|
+
className: "rounded bg-(--clarify-ui-subtle-background) px-1.5 py-0.5 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
2839
|
+
children: authSchemeType(schemeOption, t("openapi.authApiKey"))
|
|
2840
|
+
})]
|
|
2841
|
+
}),
|
|
2842
|
+
scheme.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
2843
|
+
className: "mt-2 text-sm/6 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
|
|
2844
|
+
children: scheme.description
|
|
2845
|
+
}) : null,
|
|
2846
|
+
details.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2847
|
+
className: "mt-2 flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
2848
|
+
children: details.map((detail) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2849
|
+
className: "min-w-0 break-all font-mono",
|
|
2850
|
+
children: detail
|
|
2851
|
+
}, detail))
|
|
2852
|
+
}) : null
|
|
2853
|
+
]
|
|
2854
|
+
})] }, schemeOption.name);
|
|
2855
|
+
})
|
|
2856
|
+
});
|
|
2857
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocumentSection, {
|
|
2858
|
+
title: t("openapi.authentication"),
|
|
2859
|
+
bodyClassName: "not-prose",
|
|
2860
|
+
children: options.length === 1 ? renderOption(options[0]) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
2861
|
+
items: options.map((option) => ({
|
|
2862
|
+
id: option.key,
|
|
2863
|
+
label: option.label || t("openapi.none"),
|
|
2864
|
+
panel: renderOption(option)
|
|
2865
|
+
})),
|
|
2866
|
+
spacingClassName: "m-0",
|
|
2867
|
+
panelsClassName: "mt-2"
|
|
2868
|
+
})
|
|
2869
|
+
});
|
|
2787
2870
|
}
|
|
2788
2871
|
//#endregion
|
|
2789
2872
|
//#region source/openapi/components/SchemaProperties.tsx
|
|
@@ -3010,10 +3093,11 @@ function EnumValueNode(arg0) {
|
|
|
3010
3093
|
});
|
|
3011
3094
|
}
|
|
3012
3095
|
function SchemaNode(arg0) {
|
|
3013
|
-
const { node, depth = 0, defaultExpanded } = arg0;
|
|
3096
|
+
const { node, depth = 0, defaultExpanded, forceExpanded = false } = arg0;
|
|
3014
3097
|
const t = require_i18n.useBuiltInText();
|
|
3015
|
-
const [
|
|
3098
|
+
const [locallyExpanded, setLocallyExpanded] = (0, react.useState)(defaultExpanded ?? depth < 1);
|
|
3016
3099
|
const hasChildren = node.children.length > 0;
|
|
3100
|
+
const expanded = forceExpanded || locallyExpanded;
|
|
3017
3101
|
if (node.kind === "enum") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnumValueNode, {
|
|
3018
3102
|
node,
|
|
3019
3103
|
depth
|
|
@@ -3053,7 +3137,7 @@ function SchemaNode(arg0) {
|
|
|
3053
3137
|
type: "button",
|
|
3054
3138
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
3055
3139
|
"aria-expanded": expanded,
|
|
3056
|
-
onClick: () =>
|
|
3140
|
+
onClick: () => setLocallyExpanded((value) => !value),
|
|
3057
3141
|
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)"),
|
|
3058
3142
|
children: content
|
|
3059
3143
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3061,12 +3145,13 @@ function SchemaNode(arg0) {
|
|
|
3061
3145
|
children: content
|
|
3062
3146
|
}), hasChildren && expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, {
|
|
3063
3147
|
nodes: node.children,
|
|
3064
|
-
depth: depth + 1
|
|
3148
|
+
depth: depth + 1,
|
|
3149
|
+
forceExpanded
|
|
3065
3150
|
}) : null]
|
|
3066
3151
|
});
|
|
3067
3152
|
}
|
|
3068
3153
|
function SchemaTree(arg0) {
|
|
3069
|
-
const { nodes, depth = 0 } = arg0;
|
|
3154
|
+
const { nodes, depth = 0, forceExpanded = false } = arg0;
|
|
3070
3155
|
if (nodes.length === 0) return null;
|
|
3071
3156
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
3072
3157
|
role: "list",
|
|
@@ -3074,34 +3159,68 @@ function SchemaTree(arg0) {
|
|
|
3074
3159
|
children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
|
|
3075
3160
|
node,
|
|
3076
3161
|
depth,
|
|
3077
|
-
defaultExpanded: node.defaultExpanded
|
|
3162
|
+
defaultExpanded: node.defaultExpanded,
|
|
3163
|
+
forceExpanded
|
|
3078
3164
|
}, node.key))
|
|
3079
3165
|
});
|
|
3080
3166
|
}
|
|
3167
|
+
function filterSchemaNodes(nodes, query) {
|
|
3168
|
+
if (!query.trim()) return nodes;
|
|
3169
|
+
return nodes.flatMap((node) => {
|
|
3170
|
+
const children = filterSchemaNodes(node.children, query);
|
|
3171
|
+
return fuzzyMatch(getSchemaSearchText(node.name, {
|
|
3172
|
+
type: node.type,
|
|
3173
|
+
description: node.description,
|
|
3174
|
+
pattern: node.details
|
|
3175
|
+
}), query) || children.length > 0 ? [{
|
|
3176
|
+
...node,
|
|
3177
|
+
children
|
|
3178
|
+
}] : [];
|
|
3179
|
+
});
|
|
3180
|
+
}
|
|
3081
3181
|
function SchemaProperties(arg0) {
|
|
3082
|
-
const { title, schema, spec, defaultExpanded } = arg0;
|
|
3182
|
+
const { title, schema, spec, defaultExpanded, query = "", emptyText } = arg0;
|
|
3183
|
+
const t = require_i18n.useBuiltInText();
|
|
3083
3184
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
3084
3185
|
if (!root || root.children.length === 0) return null;
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3186
|
+
const filteredNodes = filterSchemaNodes(root.children, query);
|
|
3187
|
+
const hasQuery = Boolean(query.trim());
|
|
3188
|
+
const resolvedEmptyText = emptyText ?? t("openapi.noBodyProperties");
|
|
3189
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocumentSection, {
|
|
3190
|
+
title,
|
|
3191
|
+
level: 4,
|
|
3192
|
+
bodyClassName: "clarify-schema-properties not-prose",
|
|
3193
|
+
children: filteredNodes.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, {
|
|
3194
|
+
nodes: filteredNodes,
|
|
3195
|
+
forceExpanded: hasQuery
|
|
3196
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3197
|
+
className: "m-0 py-2 text-sm/5 text-(--clarify-ui-text-soft)",
|
|
3198
|
+
children: resolvedEmptyText
|
|
3199
|
+
})
|
|
3200
|
+
});
|
|
3089
3201
|
}
|
|
3090
3202
|
function ParameterList(arg0) {
|
|
3091
3203
|
const t = require_i18n.useBuiltInText();
|
|
3092
3204
|
const { title, parameters } = arg0;
|
|
3093
3205
|
if (parameters.length === 0) return null;
|
|
3094
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
children:
|
|
3098
|
-
|
|
3099
|
-
children: parameter.
|
|
3100
|
-
|
|
3101
|
-
|
|
3206
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocumentSection, {
|
|
3207
|
+
title,
|
|
3208
|
+
bodyClassName: "not-prose",
|
|
3209
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, {
|
|
3210
|
+
spacingClassName: "m-0",
|
|
3211
|
+
children: parameters.map((parameter) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
|
|
3212
|
+
name: parameter.name ?? t("openapi.parameter"),
|
|
3213
|
+
type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
|
|
3214
|
+
children: parameter.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
3215
|
+
className: "*:first:mt-0 *:last:mb-0",
|
|
3216
|
+
children: parameter.description
|
|
3217
|
+
}) : t("openapi.operationParameter")
|
|
3218
|
+
}, `${parameter.in}-${parameter.name}`))
|
|
3219
|
+
})
|
|
3220
|
+
});
|
|
3102
3221
|
}
|
|
3103
3222
|
function ResponseList(arg0) {
|
|
3104
|
-
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
3223
|
+
const { title, operation, spec, selectedStatus, onSelectStatus, query = "", search } = arg0;
|
|
3105
3224
|
const t = require_i18n.useBuiltInText();
|
|
3106
3225
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
3107
3226
|
if (left.status === "default") return -1;
|
|
@@ -3138,11 +3257,13 @@ function ResponseList(arg0) {
|
|
|
3138
3257
|
}) : `${t("openapi.response")}.`
|
|
3139
3258
|
}),
|
|
3140
3259
|
responseSchema && spec ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3141
|
-
className: "mt-
|
|
3260
|
+
className: "mt-6",
|
|
3142
3261
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
|
|
3143
3262
|
title: t("openapi.responseBodyProperties"),
|
|
3144
3263
|
schema: responseSchema,
|
|
3145
|
-
spec
|
|
3264
|
+
spec,
|
|
3265
|
+
query,
|
|
3266
|
+
emptyText: t("openapi.noResponseBodyProperties")
|
|
3146
3267
|
})
|
|
3147
3268
|
}) : null
|
|
3148
3269
|
]
|
|
@@ -3150,27 +3271,91 @@ function ResponseList(arg0) {
|
|
|
3150
3271
|
};
|
|
3151
3272
|
if (orderedResponses.length === 1) {
|
|
3152
3273
|
const [{ status, response }] = orderedResponses;
|
|
3153
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
}
|
|
3158
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title ?? t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
3159
|
-
selectedIndex,
|
|
3160
|
-
onChange: (index) => {
|
|
3161
|
-
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
3162
|
-
},
|
|
3163
|
-
items: orderedResponses.map(({ status, response }) => ({
|
|
3164
|
-
id: status,
|
|
3165
|
-
label: status,
|
|
3166
|
-
panel: renderResponsePanel({
|
|
3274
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(OpenApiDocumentSection, {
|
|
3275
|
+
title: title ?? t("openapi.responses"),
|
|
3276
|
+
action: search?.action,
|
|
3277
|
+
children: [search?.open ? search.input : null, renderResponsePanel({
|
|
3167
3278
|
status,
|
|
3168
3279
|
response
|
|
3280
|
+
})]
|
|
3281
|
+
});
|
|
3282
|
+
}
|
|
3283
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(OpenApiDocumentSection, {
|
|
3284
|
+
title: title ?? t("openapi.responses"),
|
|
3285
|
+
action: search?.action,
|
|
3286
|
+
bodyClassName: "not-prose",
|
|
3287
|
+
children: [search?.open ? search.input : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
3288
|
+
selectedIndex,
|
|
3289
|
+
onChange: (index) => {
|
|
3290
|
+
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
3291
|
+
},
|
|
3292
|
+
items: orderedResponses.map(({ status, response }) => ({
|
|
3293
|
+
id: status,
|
|
3294
|
+
label: status,
|
|
3295
|
+
panel: renderResponsePanel({
|
|
3296
|
+
status,
|
|
3297
|
+
response
|
|
3298
|
+
})
|
|
3299
|
+
})),
|
|
3300
|
+
spacingClassName: "m-0",
|
|
3301
|
+
panelsClassName: "mt-2"
|
|
3302
|
+
})]
|
|
3303
|
+
});
|
|
3304
|
+
}
|
|
3305
|
+
//#endregion
|
|
3306
|
+
//#region source/openapi/components/SchemaSearch.tsx
|
|
3307
|
+
function useSchemaSearch() {
|
|
3308
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
3309
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
3310
|
+
return {
|
|
3311
|
+
open,
|
|
3312
|
+
query,
|
|
3313
|
+
onChange: (event) => setQuery(event.target.value),
|
|
3314
|
+
toggle: () => {
|
|
3315
|
+
setOpen((current) => {
|
|
3316
|
+
if (current) setQuery("");
|
|
3317
|
+
return !current;
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
function SchemaSearchButton(arg0) {
|
|
3323
|
+
const { label, open, onClick } = arg0;
|
|
3324
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3325
|
+
type: "button",
|
|
3326
|
+
"aria-label": label,
|
|
3327
|
+
"aria-pressed": open,
|
|
3328
|
+
onClick,
|
|
3329
|
+
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)"),
|
|
3330
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
|
|
3331
|
+
className: "size-4",
|
|
3332
|
+
"aria-hidden": "true"
|
|
3333
|
+
})
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
function SchemaSearchInput(arg0) {
|
|
3337
|
+
const { label, value, onChange } = arg0;
|
|
3338
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3339
|
+
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",
|
|
3340
|
+
children: [
|
|
3341
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
|
|
3342
|
+
className: "size-4 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3343
|
+
"aria-hidden": "true"
|
|
3344
|
+
}),
|
|
3345
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3346
|
+
className: "sr-only",
|
|
3347
|
+
children: label
|
|
3348
|
+
}),
|
|
3349
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3350
|
+
type: "search",
|
|
3351
|
+
value,
|
|
3352
|
+
onChange,
|
|
3353
|
+
placeholder: label,
|
|
3354
|
+
autoFocus: true,
|
|
3355
|
+
className: "min-w-0 flex-1 bg-transparent text-sm text-(--clarify-theme-tokens-colors-foreground) outline-none placeholder:text-(--clarify-ui-text-faint)"
|
|
3169
3356
|
})
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
panelsClassName: "mt-5"
|
|
3173
|
-
})] });
|
|
3357
|
+
]
|
|
3358
|
+
});
|
|
3174
3359
|
}
|
|
3175
3360
|
//#endregion
|
|
3176
3361
|
//#region source/openapi/components/EndpointSections.tsx
|
|
@@ -3178,6 +3363,7 @@ function EndpointRequest(arg0) {
|
|
|
3178
3363
|
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, authOptions, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
3179
3364
|
const t = require_i18n.useBuiltInText();
|
|
3180
3365
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
3366
|
+
const requestBodySearch = useSchemaSearch();
|
|
3181
3367
|
const renderDescription = () => {
|
|
3182
3368
|
if (!description) return null;
|
|
3183
3369
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: description });
|
|
@@ -3187,16 +3373,25 @@ function EndpointRequest(arg0) {
|
|
|
3187
3373
|
className: "text-sm/5 text-(--clarify-ui-text-soft)",
|
|
3188
3374
|
children: t("openapi.requestBodyEmpty")
|
|
3189
3375
|
});
|
|
3190
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3376
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3377
|
+
requestBodySearch.open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchInput, {
|
|
3378
|
+
label: t("openapi.searchBodyProperties"),
|
|
3379
|
+
value: requestBodySearch.query,
|
|
3380
|
+
onChange: requestBodySearch.onChange
|
|
3381
|
+
}) : null,
|
|
3382
|
+
typeof requestBody?.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
|
|
3383
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
|
|
3384
|
+
title: t("openapi.bodyProperties"),
|
|
3385
|
+
schema: requestSchema,
|
|
3386
|
+
spec,
|
|
3387
|
+
query: requestBodySearch.query
|
|
3388
|
+
})
|
|
3389
|
+
] });
|
|
3195
3390
|
};
|
|
3196
3391
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderDescription(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
3197
3392
|
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
3198
3393
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3199
|
-
className: "w-full",
|
|
3394
|
+
className: "flex w-full flex-col gap-6",
|
|
3200
3395
|
children: [
|
|
3201
3396
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiAuthDocumentation, { options: authOptions }),
|
|
3202
3397
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
|
|
@@ -3211,7 +3406,15 @@ function EndpointRequest(arg0) {
|
|
|
3211
3406
|
title: t("openapi.headers"),
|
|
3212
3407
|
parameters: groupedParameters.header
|
|
3213
3408
|
}),
|
|
3214
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
3409
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiDocumentSection, {
|
|
3410
|
+
title: t("openapi.requestBody"),
|
|
3411
|
+
action: hasRequestBody ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchButton, {
|
|
3412
|
+
label: t("openapi.searchBodyProperties"),
|
|
3413
|
+
open: requestBodySearch.open,
|
|
3414
|
+
onClick: requestBodySearch.toggle
|
|
3415
|
+
}) : null,
|
|
3416
|
+
children: renderRequestBody()
|
|
3417
|
+
})
|
|
3215
3418
|
]
|
|
3216
3419
|
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
|
|
3217
3420
|
sticky: true,
|
|
@@ -3230,7 +3433,8 @@ function EndpointRequest(arg0) {
|
|
|
3230
3433
|
auth,
|
|
3231
3434
|
operationSource,
|
|
3232
3435
|
sharedExampleKey,
|
|
3233
|
-
onSelectExampleKey
|
|
3436
|
+
onSelectExampleKey,
|
|
3437
|
+
query: requestBodySearch.query
|
|
3234
3438
|
})
|
|
3235
3439
|
})
|
|
3236
3440
|
})]
|
|
@@ -3241,6 +3445,7 @@ function EndpointResponse(arg0) {
|
|
|
3241
3445
|
const t = require_i18n.useBuiltInText();
|
|
3242
3446
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
3243
3447
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
3448
|
+
const responseBodySearch = useSchemaSearch();
|
|
3244
3449
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3245
3450
|
className: "mt-10 pt-6",
|
|
3246
3451
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
@@ -3252,7 +3457,21 @@ function EndpointResponse(arg0) {
|
|
|
3252
3457
|
operation,
|
|
3253
3458
|
spec,
|
|
3254
3459
|
selectedStatus,
|
|
3255
|
-
onSelectStatus
|
|
3460
|
+
onSelectStatus,
|
|
3461
|
+
query: responseBodySearch.query,
|
|
3462
|
+
search: {
|
|
3463
|
+
open: responseBodySearch.open,
|
|
3464
|
+
action: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchButton, {
|
|
3465
|
+
label: t("openapi.searchResponseBodyProperties"),
|
|
3466
|
+
open: responseBodySearch.open,
|
|
3467
|
+
onClick: responseBodySearch.toggle
|
|
3468
|
+
}),
|
|
3469
|
+
input: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaSearchInput, {
|
|
3470
|
+
label: t("openapi.searchResponseBodyProperties"),
|
|
3471
|
+
value: responseBodySearch.query,
|
|
3472
|
+
onChange: responseBodySearch.onChange
|
|
3473
|
+
})
|
|
3474
|
+
}
|
|
3256
3475
|
})
|
|
3257
3476
|
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
|
|
3258
3477
|
sticky: true,
|
|
@@ -3265,7 +3484,8 @@ function EndpointResponse(arg0) {
|
|
|
3265
3484
|
sharedExampleKey,
|
|
3266
3485
|
onSelectExampleKey,
|
|
3267
3486
|
selectedStatus,
|
|
3268
|
-
onSelectStatus
|
|
3487
|
+
onSelectStatus,
|
|
3488
|
+
query: responseBodySearch.query
|
|
3269
3489
|
})
|
|
3270
3490
|
})
|
|
3271
3491
|
})]
|
|
@@ -4291,6 +4511,7 @@ function OpenApiResponseViewer(arg0) {
|
|
|
4291
4511
|
const previewAvailable = exchange ? canPreviewResponse(exchange.contentType) : false;
|
|
4292
4512
|
const selectedBodyMode = bodyModeSelection && bodyModeSelection.exchange === exchange ? bodyModeSelection.mode : "preview";
|
|
4293
4513
|
const activeBodyMode = previewAvailable ? selectedBodyMode : "raw";
|
|
4514
|
+
const bodyModes = ["preview", "raw"].filter((mode) => mode === "raw" || previewAvailable);
|
|
4294
4515
|
function downloadBody() {
|
|
4295
4516
|
if (!exchange) return;
|
|
4296
4517
|
const url = URL.createObjectURL(exchange.blob);
|
|
@@ -4365,48 +4586,37 @@ function OpenApiResponseViewer(arg0) {
|
|
|
4365
4586
|
className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
|
|
4366
4587
|
children: exchange.contentType || t("openapi.unknownContentType")
|
|
4367
4588
|
}),
|
|
4368
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
role: "tablist",
|
|
4374
|
-
className: "flex",
|
|
4375
|
-
children: ["preview", "raw"].filter((mode) => mode === "raw" || previewAvailable).map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4376
|
-
type: "button",
|
|
4377
|
-
role: "tab",
|
|
4378
|
-
"aria-selected": activeBodyMode === mode,
|
|
4379
|
-
onClick: () => setBodyModeSelection({
|
|
4380
|
-
exchange,
|
|
4381
|
-
mode
|
|
4382
|
-
}),
|
|
4383
|
-
className: (0, clsx.default)("border-b-2 px-2.5 py-1 text-2xs font-semibold", activeBodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
|
|
4384
|
-
children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
|
|
4385
|
-
}, mode))
|
|
4386
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4387
|
-
className: "flex",
|
|
4388
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: exchange.body }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4389
|
-
type: "button",
|
|
4390
|
-
onClick: downloadBody,
|
|
4391
|
-
"aria-label": t("openapi.downloadBody"),
|
|
4392
|
-
title: t("openapi.downloadBody"),
|
|
4393
|
-
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4394
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.DownloadIcon, {
|
|
4395
|
-
className: "size-4",
|
|
4396
|
-
"aria-hidden": "true"
|
|
4397
|
-
})
|
|
4398
|
-
})]
|
|
4399
|
-
})]
|
|
4400
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4401
|
-
className: "p-4",
|
|
4402
|
-
children: activeBodyMode === "preview" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
4589
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
4590
|
+
items: bodyModes.map((mode) => ({
|
|
4591
|
+
id: mode,
|
|
4592
|
+
label: mode === "preview" ? t("openapi.preview") : t("openapi.raw"),
|
|
4593
|
+
panel: mode === "preview" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
4403
4594
|
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4404
4595
|
children: exchange.body
|
|
4405
4596
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4406
4597
|
className: "py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
4407
4598
|
children: t("openapi.responseBodyEmpty")
|
|
4408
4599
|
})
|
|
4409
|
-
})
|
|
4600
|
+
})),
|
|
4601
|
+
selectedIndex: bodyModes.indexOf(activeBodyMode),
|
|
4602
|
+
onChange: (index) => setBodyModeSelection({
|
|
4603
|
+
exchange,
|
|
4604
|
+
mode: bodyModes[index] ?? "raw"
|
|
4605
|
+
}),
|
|
4606
|
+
spacingClassName: "m-0 min-h-72",
|
|
4607
|
+
panelsClassName: "p-4",
|
|
4608
|
+
variant: "code",
|
|
4609
|
+
actions: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: exchange.body }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4610
|
+
type: "button",
|
|
4611
|
+
onClick: downloadBody,
|
|
4612
|
+
"aria-label": t("openapi.downloadBody"),
|
|
4613
|
+
title: t("openapi.downloadBody"),
|
|
4614
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4615
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.DownloadIcon, {
|
|
4616
|
+
className: "size-4",
|
|
4617
|
+
"aria-hidden": "true"
|
|
4618
|
+
})
|
|
4619
|
+
})] })
|
|
4410
4620
|
})
|
|
4411
4621
|
})
|
|
4412
4622
|
]
|
|
@@ -5169,7 +5379,8 @@ function ServerVariableControl(arg0) {
|
|
|
5169
5379
|
label: option
|
|
5170
5380
|
})),
|
|
5171
5381
|
onChange,
|
|
5172
|
-
compact
|
|
5382
|
+
compact,
|
|
5383
|
+
buttonClassName: "inline-flex min-h-8 w-full min-w-0 items-center justify-between gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-open:bg-(--clarify-ui-active-background)"
|
|
5173
5384
|
});
|
|
5174
5385
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
5175
5386
|
"aria-label": name,
|
|
@@ -5199,7 +5410,8 @@ function ServerPanel(arg0) {
|
|
|
5199
5410
|
label: getServerLabel(server, index),
|
|
5200
5411
|
description: server.description
|
|
5201
5412
|
})),
|
|
5202
|
-
onChange: onSelectServer
|
|
5413
|
+
onChange: onSelectServer,
|
|
5414
|
+
buttonClassName: "inline-flex min-h-8 w-full min-w-0 items-center justify-between gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-open:bg-(--clarify-ui-active-background)"
|
|
5203
5415
|
})]
|
|
5204
5416
|
}) : null, variableEntries.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
5205
5417
|
className: "grid gap-3 sm:grid-cols-(--clarify-openapi-variable-grid)",
|
|
@@ -5570,4 +5782,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
5570
5782
|
}
|
|
5571
5783
|
});
|
|
5572
5784
|
|
|
5573
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5785
|
+
//# sourceMappingURL=OpenApiOperation-QqYCuqve.cjs.map
|