@clarify-labs/renderer 0.10.3 → 0.11.1
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-UsefuuLS.cjs → ClarifyShell-C2XnkFQ6.cjs} +119 -100
- package/output/ClarifyShell-C2XnkFQ6.cjs.map +1 -0
- package/output/{ClarifyShell-Cq5Af46F.js → ClarifyShell-CwRtof1h.js} +119 -100
- package/output/ClarifyShell-CwRtof1h.js.map +1 -0
- package/output/{MermaidViewer-Db7qsyVk.cjs → MermaidViewer-CTvMCE19.cjs} +2 -2
- package/output/{MermaidViewer-Db7qsyVk.cjs.map → MermaidViewer-CTvMCE19.cjs.map} +1 -1
- package/output/{MermaidViewer-Bc9H25yK.js → MermaidViewer-CwkiQ2gO.js} +2 -2
- package/output/{MermaidViewer-Bc9H25yK.js.map → MermaidViewer-CwkiQ2gO.js.map} +1 -1
- package/output/{OpenApiOperation-BZWeCbvy.js → OpenApiOperation-CFo6_otd.js} +1964 -292
- package/output/OpenApiOperation-CFo6_otd.js.map +1 -0
- package/output/{OpenApiOperation-DbZjxIuj.cjs → OpenApiOperation-D1WNrj5X.cjs} +1967 -289
- package/output/OpenApiOperation-D1WNrj5X.cjs.map +1 -0
- package/output/{PageActions-BQeEmXbT.js → PageActions-3eo05fb_.js} +60 -19
- package/output/PageActions-3eo05fb_.js.map +1 -0
- package/output/{PageActions-Dg1l9KB1.cjs → PageActions-Lp_NeIKr.cjs} +59 -18
- package/output/PageActions-Lp_NeIKr.cjs.map +1 -0
- package/output/{SearchDialog-B67VA0Ut.js → SearchDialog-BvCBIFqs.js} +3 -3
- package/output/{SearchDialog-B67VA0Ut.js.map → SearchDialog-BvCBIFqs.js.map} +1 -1
- package/output/{SearchDialog-DjKvqN7p.cjs → SearchDialog-CM9DrE2Y.cjs} +3 -3
- package/output/{SearchDialog-DjKvqN7p.cjs.map → SearchDialog-CM9DrE2Y.cjs.map} +1 -1
- package/output/app/PageFooter.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/Tooltip.d.ts +1 -0
- package/output/core/i18n.d.ts +1 -1
- package/output/core/types.d.ts +37 -19
- package/output/{i18n-Bqth9d6Q.js → i18n-BxXpRSFX.js} +106 -2
- package/output/i18n-BxXpRSFX.js.map +1 -0
- package/output/{i18n-C-fReCj-.cjs → i18n-DsjZ51U1.cjs} +106 -2
- package/output/i18n-DsjZ51U1.cjs.map +1 -0
- package/output/index.cjs +26 -5
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +3 -3
- package/output/index.js +26 -6
- package/output/index.js.map +1 -1
- package/output/mdx/components.d.ts +2 -1
- package/output/openapi/components/EndpointMethodBadge.d.ts +6 -0
- package/output/openapi/components/EndpointSections.d.ts +2 -2
- package/output/openapi/components/ExamplePanels.d.ts +2 -2
- package/output/openapi/components/InlineListbox.d.ts +14 -0
- package/output/openapi/components/OpenApiAuthPanel.d.ts +12 -0
- package/output/openapi/components/OpenApiOperation.d.ts +1 -9
- package/output/openapi/components/OpenApiOperation.state.d.ts +4 -2
- package/output/openapi/components/OpenApiRequest.d.ts +18 -0
- package/output/openapi/components/OpenApiRequestBodyEditor.d.ts +14 -0
- package/output/openapi/components/OpenApiRequestFields.d.ts +25 -0
- package/output/openapi/components/OpenApiResponseViewer.d.ts +14 -0
- package/output/openapi/components/SendRequestButton.d.ts +9 -0
- package/output/openapi/components/helpers.d.ts +6 -1
- package/output/openapi/components/useOpenApiRequestState.d.ts +48 -0
- package/output/openapi/entry.d.ts +2 -0
- package/output/openapi/index.d.ts +2 -2
- package/output/openapi/lib/api-exchange-code.d.ts +8 -0
- package/output/openapi/lib/api-exchange.d.ts +30 -0
- package/output/openapi/lib/api-request.d.ts +25 -0
- package/output/openapi/lib/helpers.d.ts +8 -0
- package/output/openapi/lib/request-code.d.ts +2 -2
- package/output/openapi/lib/request-parameters.d.ts +5 -0
- package/output/openapi/store.d.ts +10 -0
- package/output/openapi/types.d.ts +6 -0
- package/output/preview.cjs +46 -40
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +46 -40
- package/output/preview.js.map +1 -1
- package/output/{render-Dc9wxg_r.cjs → render-CKG4X-me.cjs} +2 -2
- package/output/{render-Dc9wxg_r.cjs.map → render-CKG4X-me.cjs.map} +1 -1
- package/output/{render-aS-w4fK4.js → render-vlp3hwW3.js} +2 -2
- package/output/{render-aS-w4fK4.js.map → render-vlp3hwW3.js.map} +1 -1
- package/output/renderer.css +630 -152
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/output/theme/ThemeEditor.d.ts +8 -4
- package/output/theme/variables.d.ts +8 -4
- package/package.json +2 -1
- package/output/ClarifyShell-Cq5Af46F.js.map +0 -1
- package/output/ClarifyShell-UsefuuLS.cjs.map +0 -1
- package/output/OpenApiOperation-BZWeCbvy.js.map +0 -1
- package/output/OpenApiOperation-DbZjxIuj.cjs.map +0 -1
- package/output/PageActions-BQeEmXbT.js.map +0 -1
- package/output/PageActions-Dg1l9KB1.cjs.map +0 -1
- package/output/core/index.d.ts +0 -3
- package/output/i18n-Bqth9d6Q.js.map +0 -1
- package/output/i18n-C-fReCj-.cjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-
|
|
2
|
-
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-
|
|
1
|
+
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-BxXpRSFX.js";
|
|
2
|
+
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-3eo05fb_.js";
|
|
3
3
|
import { t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { Children, Suspense, cloneElement, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
6
|
import { Link } from "react-router-dom";
|
|
7
|
-
import { Dialog, DialogBackdrop, DialogPanel, Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
8
|
-
import { AlertTriangle, ArrowRight, ArrowUpRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, File, Folder, FolderOpen, Info, Lightbulb, LinkIcon,
|
|
7
|
+
import { Dialog, DialogBackdrop, DialogPanel, DialogTitle, Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
8
|
+
import { AlertTriangle, ArrowRight, ArrowUpRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleAlertIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, DownloadIcon, EraserIcon, File, FileX2Icon, Folder, FolderOpen, Info, InfoIcon, Lightbulb, LinkIcon, LoaderCircleIcon, Maximize2, PackageIcon, RotateCcwIcon, SearchIcon, SendIcon, ServerIcon, X, XCircle, XIcon } from "lucide-react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { motion, useInView } from "framer-motion";
|
|
11
11
|
import { create } from "zustand";
|
|
@@ -14,6 +14,7 @@ import rehypeRaw from "rehype-raw";
|
|
|
14
14
|
import { slug } from "github-slugger";
|
|
15
15
|
import { codeToTokens, createCssVariablesTheme } from "shiki";
|
|
16
16
|
import { snippetz } from "@scalar/snippetz";
|
|
17
|
+
import { parse, stringify } from "yaml";
|
|
17
18
|
//#region \0rolldown/runtime.js
|
|
18
19
|
var __defProp = Object.defineProperty;
|
|
19
20
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -252,7 +253,7 @@ function Card(arg0) {
|
|
|
252
253
|
}
|
|
253
254
|
//#endregion
|
|
254
255
|
//#region source/components/Mermaid.tsx
|
|
255
|
-
var MermaidViewer = lazy(() => import("./MermaidViewer-
|
|
256
|
+
var MermaidViewer = lazy(() => import("./MermaidViewer-CwkiQ2gO.js"));
|
|
256
257
|
var mermaidModulePromise;
|
|
257
258
|
async function loadMermaid() {
|
|
258
259
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -399,7 +400,7 @@ function getCodePanelTitle(node, fallbackTitle) {
|
|
|
399
400
|
fallbackTitle
|
|
400
401
|
});
|
|
401
402
|
}
|
|
402
|
-
function CopyButton(arg0) {
|
|
403
|
+
function CopyButton$1(arg0) {
|
|
403
404
|
const { code } = arg0;
|
|
404
405
|
const t = useBuiltInText();
|
|
405
406
|
const [copyCount, setCopyCount] = useState(0);
|
|
@@ -460,7 +461,7 @@ function CodePanel(arg0) {
|
|
|
460
461
|
children: [/* @__PURE__ */ jsx("pre", {
|
|
461
462
|
className: "clarify-code-pre overflow-x-auto p-4 text-xs text-(--clarify-code-text)",
|
|
462
463
|
children
|
|
463
|
-
}), /* @__PURE__ */ jsx(CopyButton, { code: copyText })]
|
|
464
|
+
}), /* @__PURE__ */ jsx(CopyButton$1, { code: copyText })]
|
|
464
465
|
})]
|
|
465
466
|
});
|
|
466
467
|
}
|
|
@@ -1057,28 +1058,61 @@ function Tabs(arg0) {
|
|
|
1057
1058
|
//#endregion
|
|
1058
1059
|
//#region source/components/Tooltip.tsx
|
|
1059
1060
|
function Tooltip(arg0) {
|
|
1060
|
-
const { content, children, side = "top", className, ...props } = arg0;
|
|
1061
|
+
const { content, children, side = "top", className, triggerClassName, ...props } = arg0;
|
|
1061
1062
|
const contentId = useId();
|
|
1062
1063
|
const [open, setOpen] = useState(false);
|
|
1064
|
+
const triggerRef = useRef(null);
|
|
1065
|
+
const tooltipRef = useRef(null);
|
|
1066
|
+
const [position, setPosition] = useState();
|
|
1067
|
+
useEffect(() => {
|
|
1068
|
+
if (!open) return;
|
|
1069
|
+
function updatePosition() {
|
|
1070
|
+
const bounds = triggerRef.current?.getBoundingClientRect();
|
|
1071
|
+
if (!bounds) return;
|
|
1072
|
+
setPosition({
|
|
1073
|
+
left: bounds.left + bounds.width / 2,
|
|
1074
|
+
top: side === "top" ? bounds.top - 8 : bounds.bottom + 8
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
updatePosition();
|
|
1078
|
+
window.addEventListener("resize", updatePosition);
|
|
1079
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
1080
|
+
return () => {
|
|
1081
|
+
window.removeEventListener("resize", updatePosition);
|
|
1082
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
1083
|
+
};
|
|
1084
|
+
}, [open, side]);
|
|
1085
|
+
useEffect(() => {
|
|
1086
|
+
const tooltip = tooltipRef.current;
|
|
1087
|
+
if (!tooltip || typeof tooltip.showPopover !== "function") return;
|
|
1088
|
+
if (open) tooltip.showPopover();
|
|
1089
|
+
else if (tooltip.matches(":popover-open")) tooltip.hidePopover();
|
|
1090
|
+
}, [open]);
|
|
1063
1091
|
return /* @__PURE__ */ jsxs("span", {
|
|
1064
|
-
className: clsx("clarify-tooltip group
|
|
1092
|
+
className: clsx("clarify-tooltip group inline-flex align-baseline", className),
|
|
1065
1093
|
onMouseEnter: () => setOpen(true),
|
|
1066
1094
|
onMouseLeave: () => setOpen(false),
|
|
1067
1095
|
...props,
|
|
1068
|
-
children: [/* @__PURE__ */ jsx("
|
|
1069
|
-
|
|
1096
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1097
|
+
type: "button",
|
|
1098
|
+
ref: triggerRef,
|
|
1070
1099
|
"aria-describedby": contentId,
|
|
1071
|
-
|
|
1100
|
+
"aria-expanded": open,
|
|
1101
|
+
className: clsx("cursor-help appearance-none rounded-sm border-0 border-b border-dotted border-current bg-transparent p-0 font-inherit text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", triggerClassName),
|
|
1072
1102
|
onFocus: () => setOpen(true),
|
|
1073
1103
|
onBlur: () => setOpen(false),
|
|
1104
|
+
onClick: () => setOpen(true),
|
|
1074
1105
|
onKeyDown: (event) => {
|
|
1075
1106
|
if (event.key === "Escape") setOpen(false);
|
|
1076
1107
|
},
|
|
1077
1108
|
children
|
|
1078
1109
|
}), /* @__PURE__ */ jsx("span", {
|
|
1110
|
+
ref: tooltipRef,
|
|
1079
1111
|
id: contentId,
|
|
1080
1112
|
role: "tooltip",
|
|
1081
|
-
|
|
1113
|
+
popover: "manual",
|
|
1114
|
+
style: position,
|
|
1115
|
+
className: clsx("pointer-events-none fixed right-auto bottom-auto z-60 m-0 w-max max-w-64 -translate-x-1/2 rounded-md border-0 bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", side === "top" && "-translate-y-full", open && position ? "visible opacity-100" : "invisible opacity-0"),
|
|
1082
1116
|
children: content
|
|
1083
1117
|
})]
|
|
1084
1118
|
});
|
|
@@ -1421,6 +1455,31 @@ function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
|
|
|
1421
1455
|
seen.add(schema.$ref);
|
|
1422
1456
|
return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
|
|
1423
1457
|
}
|
|
1458
|
+
function mergeAllOfSchemas(spec, schemas) {
|
|
1459
|
+
const merged = {};
|
|
1460
|
+
const properties = {};
|
|
1461
|
+
const required = /* @__PURE__ */ new Set();
|
|
1462
|
+
for (const schema of schemas) {
|
|
1463
|
+
const resolved = resolveRequestSchema(spec, schema);
|
|
1464
|
+
if (!isRecord$1(resolved)) continue;
|
|
1465
|
+
Object.assign(merged, resolved);
|
|
1466
|
+
if (isRecord$1(resolved.properties)) Object.assign(properties, resolved.properties);
|
|
1467
|
+
if (Array.isArray(resolved.required)) resolved.required.forEach((name) => required.add(String(name)));
|
|
1468
|
+
}
|
|
1469
|
+
if (Object.keys(properties).length > 0) merged.properties = properties;
|
|
1470
|
+
if (required.size > 0) merged.required = [...required];
|
|
1471
|
+
delete merged.allOf;
|
|
1472
|
+
return merged;
|
|
1473
|
+
}
|
|
1474
|
+
function resolveRequestSchema(spec, schema) {
|
|
1475
|
+
const resolved = resolveSchema(spec, schema);
|
|
1476
|
+
if (!isRecord$1(resolved)) return resolved;
|
|
1477
|
+
const ownSchema = { ...resolved };
|
|
1478
|
+
const allOf = Array.isArray(ownSchema.allOf) ? ownSchema.allOf : [];
|
|
1479
|
+
if (allOf.length === 0) return ownSchema;
|
|
1480
|
+
delete ownSchema.allOf;
|
|
1481
|
+
return mergeAllOfSchemas(spec, [...allOf, ownSchema]);
|
|
1482
|
+
}
|
|
1424
1483
|
function getPathItem$1(spec, path) {
|
|
1425
1484
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1426
1485
|
}
|
|
@@ -1440,6 +1499,7 @@ function resolveObjectRef(spec, value) {
|
|
|
1440
1499
|
}
|
|
1441
1500
|
function schemaHasType(schema, type) {
|
|
1442
1501
|
if (!isRecord$1(schema)) return false;
|
|
1502
|
+
if (type === "null" && schema.nullable === true) return true;
|
|
1443
1503
|
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
1444
1504
|
}
|
|
1445
1505
|
function getOperationParameters(spec, path, operation, source = "path") {
|
|
@@ -1509,7 +1569,7 @@ function getExampleEntries(mediaType, spec) {
|
|
|
1509
1569
|
title: "Example",
|
|
1510
1570
|
value: mediaType.example
|
|
1511
1571
|
}];
|
|
1512
|
-
const generated = schemaToExample(spec ?
|
|
1572
|
+
const generated = schemaToExample(spec ? resolveRequestSchema(spec, mediaType.schema) : mediaType.schema);
|
|
1513
1573
|
return typeof generated === "undefined" ? [] : [{
|
|
1514
1574
|
key: "schema",
|
|
1515
1575
|
title: "schema",
|
|
@@ -1517,6 +1577,34 @@ function getExampleEntries(mediaType, spec) {
|
|
|
1517
1577
|
generated: true
|
|
1518
1578
|
}];
|
|
1519
1579
|
}
|
|
1580
|
+
function getParameterExampleEntries(parameter) {
|
|
1581
|
+
if (isRecord$1(parameter.examples)) {
|
|
1582
|
+
const examples = [];
|
|
1583
|
+
for (const [key, example] of Object.entries(parameter.examples)) {
|
|
1584
|
+
const value = getExampleValue(example);
|
|
1585
|
+
if (typeof value === "undefined") continue;
|
|
1586
|
+
const { title, summary } = getExampleTitle(key, example);
|
|
1587
|
+
examples.push({
|
|
1588
|
+
key,
|
|
1589
|
+
title,
|
|
1590
|
+
summary,
|
|
1591
|
+
value
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
if (examples.length > 0) return examples;
|
|
1595
|
+
}
|
|
1596
|
+
return typeof parameter.example === "undefined" ? [] : [{
|
|
1597
|
+
key: "default",
|
|
1598
|
+
title: "Example",
|
|
1599
|
+
value: parameter.example
|
|
1600
|
+
}];
|
|
1601
|
+
}
|
|
1602
|
+
function getRequestExampleEntries(parameters, mediaType) {
|
|
1603
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1604
|
+
for (const example of getExampleEntries(mediaType).filter((entry) => !entry.generated)) entries.set(example.key, example);
|
|
1605
|
+
for (const parameter of parameters) for (const example of getParameterExampleEntries(parameter)) if (!entries.has(example.key)) entries.set(example.key, example);
|
|
1606
|
+
return [...entries.values()];
|
|
1607
|
+
}
|
|
1520
1608
|
function getContentExample(mediaType) {
|
|
1521
1609
|
return getExampleEntries(mediaType)[0]?.value;
|
|
1522
1610
|
}
|
|
@@ -1530,7 +1618,8 @@ function schemaToType(schema) {
|
|
|
1530
1618
|
if (Array.isArray(schema.allOf)) return schema.allOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" & ");
|
|
1531
1619
|
if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
|
|
1532
1620
|
const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
|
|
1533
|
-
|
|
1621
|
+
const nullableType = schema.nullable === true && type !== "null" ? [type, "null"].filter(Boolean).join(" | ") : type;
|
|
1622
|
+
return typeof nullableType === "string" ? [nullableType, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
1534
1623
|
}
|
|
1535
1624
|
function schemaToExample(schema, depth = 0) {
|
|
1536
1625
|
if (!isRecord$1(schema) || depth > 3) return void 0;
|
|
@@ -1538,10 +1627,12 @@ function schemaToExample(schema, depth = 0) {
|
|
|
1538
1627
|
if (typeof schema.default !== "undefined") return schema.default;
|
|
1539
1628
|
if (Array.isArray(schema.enum)) return schema.enum[0];
|
|
1540
1629
|
if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
|
|
1630
|
+
const variant = Array.isArray(schema.oneOf) ? schema.oneOf[0] : Array.isArray(schema.anyOf) ? schema.anyOf[0] : void 0;
|
|
1631
|
+
if (typeof variant !== "undefined") return schemaToExample(variant, depth + 1);
|
|
1541
1632
|
if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
|
|
1542
1633
|
if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
|
|
1543
1634
|
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
1544
|
-
return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1635
|
+
return Object.fromEntries(Object.entries(properties).filter(([, propertySchema]) => !isRecord$1(propertySchema) || propertySchema.readOnly !== true).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1545
1636
|
}
|
|
1546
1637
|
return exampleForType(schemaToType(schema));
|
|
1547
1638
|
}
|
|
@@ -1657,6 +1748,23 @@ function listOpenApiOperations(spec) {
|
|
|
1657
1748
|
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1658
1749
|
}
|
|
1659
1750
|
//#endregion
|
|
1751
|
+
//#region source/openapi/components/EndpointMethodBadge.tsx
|
|
1752
|
+
var endpointMethodStyleVars = {
|
|
1753
|
+
GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
|
|
1754
|
+
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
1755
|
+
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
1756
|
+
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
1757
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
1758
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
1759
|
+
};
|
|
1760
|
+
function EndpointMethodBadge(arg0) {
|
|
1761
|
+
const { method } = arg0;
|
|
1762
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1763
|
+
className: clsx("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
|
|
1764
|
+
children: method
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
//#endregion
|
|
1660
1768
|
//#region source/components/HighlightedCode.tsx
|
|
1661
1769
|
var cssVariablesTheme = createCssVariablesTheme();
|
|
1662
1770
|
function HighlightedCode(arg0) {
|
|
@@ -1714,6 +1822,15 @@ var snippetControlCharacters = [
|
|
|
1714
1822
|
}
|
|
1715
1823
|
];
|
|
1716
1824
|
var snippetGenerator = snippetz();
|
|
1825
|
+
function getAuthPlaceholder(name) {
|
|
1826
|
+
return `YOUR_${name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").toUpperCase() || "CREDENTIAL"}`;
|
|
1827
|
+
}
|
|
1828
|
+
function redactAuth(auth = []) {
|
|
1829
|
+
return auth.map((input) => ({
|
|
1830
|
+
...input,
|
|
1831
|
+
value: getAuthPlaceholder(input.name)
|
|
1832
|
+
}));
|
|
1833
|
+
}
|
|
1717
1834
|
function protectSnippetControlCharacters(value) {
|
|
1718
1835
|
if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
|
|
1719
1836
|
if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
|
|
@@ -1732,7 +1849,7 @@ function getDefaultServer(spec) {
|
|
|
1732
1849
|
function getDefaultWebhookServer() {
|
|
1733
1850
|
return { url: "https://webhook.example.com" };
|
|
1734
1851
|
}
|
|
1735
|
-
function expandServerUrl(server, serverVariables = {}) {
|
|
1852
|
+
function expandServerUrl$1(server, serverVariables = {}) {
|
|
1736
1853
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1737
1854
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
1738
1855
|
return serverVariables[name] ?? fallback;
|
|
@@ -1740,23 +1857,23 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1740
1857
|
}
|
|
1741
1858
|
function buildOperationUrl(input) {
|
|
1742
1859
|
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1743
|
-
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1860
|
+
return joinPath(expandServerUrl$1(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1744
1861
|
}
|
|
1745
|
-
function getQueryString(parameters, auth) {
|
|
1862
|
+
function getQueryString(parameters, auth = []) {
|
|
1746
1863
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
1747
1864
|
name: parameter.name,
|
|
1748
1865
|
value: encodeUrlPlaceholders(`{${parameter.name}}`)
|
|
1749
1866
|
}));
|
|
1750
|
-
if (
|
|
1751
|
-
name:
|
|
1752
|
-
value:
|
|
1867
|
+
for (const input of auth) if (input.scheme.type === "apiKey" && input.scheme.in === "query" && input.scheme.name) queryString.push({
|
|
1868
|
+
name: input.scheme.name,
|
|
1869
|
+
value: input.value
|
|
1753
1870
|
});
|
|
1754
1871
|
return queryString;
|
|
1755
1872
|
}
|
|
1756
|
-
function isFormMediaType(mediaType) {
|
|
1873
|
+
function isFormMediaType$1(mediaType) {
|
|
1757
1874
|
return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
|
|
1758
1875
|
}
|
|
1759
|
-
function isBinarySchema(schema) {
|
|
1876
|
+
function isBinarySchema$1(schema) {
|
|
1760
1877
|
return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
|
|
1761
1878
|
}
|
|
1762
1879
|
function getSchemaProperties(schema) {
|
|
@@ -1764,7 +1881,7 @@ function getSchemaProperties(schema) {
|
|
|
1764
1881
|
}
|
|
1765
1882
|
function getFieldValue(name, value, schema) {
|
|
1766
1883
|
if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
|
|
1767
|
-
if (isBinarySchema(schema)) return `@${name}`;
|
|
1884
|
+
if (isBinarySchema$1(schema)) return `@${name}`;
|
|
1768
1885
|
}
|
|
1769
1886
|
function getFormParams(value, requestContent) {
|
|
1770
1887
|
const properties = getSchemaProperties(requestContent.value.schema);
|
|
@@ -1786,7 +1903,7 @@ function getBodySize(requestBody) {
|
|
|
1786
1903
|
function getRequestBody(requestContent) {
|
|
1787
1904
|
const value = getContentExample(requestContent?.value);
|
|
1788
1905
|
if (!requestContent || typeof value === "undefined") return void 0;
|
|
1789
|
-
if (isFormMediaType(requestContent.mediaType)) {
|
|
1906
|
+
if (isFormMediaType$1(requestContent.mediaType)) {
|
|
1790
1907
|
const params = getFormParams(value, requestContent);
|
|
1791
1908
|
return params.length > 0 ? { params } : void 0;
|
|
1792
1909
|
}
|
|
@@ -1797,15 +1914,14 @@ function getAuthorizationValue(auth) {
|
|
|
1797
1914
|
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
|
|
1798
1915
|
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
1799
1916
|
}
|
|
1800
|
-
function
|
|
1801
|
-
if (!auth) return {};
|
|
1917
|
+
function getAuthHeader(auth) {
|
|
1802
1918
|
if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
|
|
1803
1919
|
const authorization = getAuthorizationValue(auth);
|
|
1804
1920
|
return authorization ? { Authorization: authorization } : {};
|
|
1805
1921
|
}
|
|
1806
|
-
function getRequestHeaders(requestContent, auth) {
|
|
1922
|
+
function getRequestHeaders(requestContent, auth = []) {
|
|
1807
1923
|
return {
|
|
1808
|
-
...
|
|
1924
|
+
...Object.assign({}, ...auth.map(getAuthHeader)),
|
|
1809
1925
|
Accept: "application/json",
|
|
1810
1926
|
...requestContent ? { "Content-Type": requestContent.mediaType } : {}
|
|
1811
1927
|
};
|
|
@@ -2123,6 +2239,10 @@ var requestSnippetOptions = [
|
|
|
2123
2239
|
}
|
|
2124
2240
|
];
|
|
2125
2241
|
function buildRequestCodeExamples(input) {
|
|
2242
|
+
const redactedInput = {
|
|
2243
|
+
...input,
|
|
2244
|
+
auth: redactAuth(input.auth)
|
|
2245
|
+
};
|
|
2126
2246
|
return requestSnippetOptions.map((option) => ({
|
|
2127
2247
|
key: `${option.languageKey}:${option.client}`,
|
|
2128
2248
|
title: option.title,
|
|
@@ -2130,7 +2250,7 @@ function buildRequestCodeExamples(input) {
|
|
|
2130
2250
|
languageKey: option.languageKey,
|
|
2131
2251
|
clientKey: option.client,
|
|
2132
2252
|
clientTitle: option.clientTitle,
|
|
2133
|
-
code: buildSnippet(
|
|
2253
|
+
code: buildSnippet(redactedInput, option)
|
|
2134
2254
|
}));
|
|
2135
2255
|
}
|
|
2136
2256
|
//#endregion
|
|
@@ -2152,7 +2272,7 @@ function SelectControl(arg0) {
|
|
|
2152
2272
|
className: wrapperClassName,
|
|
2153
2273
|
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
2154
2274
|
"aria-label": label,
|
|
2155
|
-
className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-
|
|
2275
|
+
className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-code-border) bg-(--clarify-code-control-background) px-2.5 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:border-(--clarify-code-border) hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-(--clarify-code-border) data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
|
|
2156
2276
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
2157
2277
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
2158
2278
|
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
@@ -2168,10 +2288,10 @@ function SelectControl(arg0) {
|
|
|
2168
2288
|
})]
|
|
2169
2289
|
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
2170
2290
|
anchor: "bottom end",
|
|
2171
|
-
className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-
|
|
2291
|
+
className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-code-surface) p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-(--clarify-code-border) [--anchor-gap:--spacing(1)] focus:outline-none",
|
|
2172
2292
|
children: normalizedOptions.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
|
|
2173
2293
|
value: option.value,
|
|
2174
|
-
className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-
|
|
2294
|
+
className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-control-text) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:bg-(--clarify-code-accent-background) data-selected:text-(--clarify-code-accent-text)",
|
|
2175
2295
|
children: [/* @__PURE__ */ jsx("span", { children: option.label }), /* @__PURE__ */ jsx(CheckIcon, {
|
|
2176
2296
|
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
2177
2297
|
"aria-hidden": "true"
|
|
@@ -2285,12 +2405,17 @@ function getSecurityRequirements(spec, operation) {
|
|
|
2285
2405
|
}
|
|
2286
2406
|
function getAuthOptions(spec, operation) {
|
|
2287
2407
|
const schemes = getSecuritySchemes(spec);
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
scheme
|
|
2293
|
-
|
|
2408
|
+
return getSecurityRequirements(spec, operation).map((requirement, index) => {
|
|
2409
|
+
const requirementSchemes = Object.keys(requirement).map((name) => ({
|
|
2410
|
+
name,
|
|
2411
|
+
scheme: schemes[name]
|
|
2412
|
+
})).filter((option) => Boolean(option.scheme));
|
|
2413
|
+
return {
|
|
2414
|
+
key: `requirement:${index}`,
|
|
2415
|
+
label: requirementSchemes.map((option) => option.name).join(" + "),
|
|
2416
|
+
schemes: requirementSchemes
|
|
2417
|
+
};
|
|
2418
|
+
});
|
|
2294
2419
|
}
|
|
2295
2420
|
function authPlaceholder(auth) {
|
|
2296
2421
|
if (!auth) return "";
|
|
@@ -2323,7 +2448,7 @@ function getClientOptions(codeOptions, languageKey) {
|
|
|
2323
2448
|
function ApiExampleCodeGroup(arg0) {
|
|
2324
2449
|
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, metaInToolbar = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2325
2450
|
const t = useBuiltInText();
|
|
2326
|
-
const metaClassName = comfortableMeta ? "flex min-h-
|
|
2451
|
+
const metaClassName = comfortableMeta ? "flex min-h-10 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5 py-2" : "flex h-9 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5";
|
|
2327
2452
|
const meta = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2328
2453
|
tag ? /* @__PURE__ */ jsx(ExampleMetaValue, {
|
|
2329
2454
|
label: t("openapi.status"),
|
|
@@ -2342,14 +2467,14 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2342
2467
|
}) : null
|
|
2343
2468
|
] });
|
|
2344
2469
|
return /* @__PURE__ */ jsx("div", {
|
|
2345
|
-
className: "clarify-openai-example my-6 overflow-hidden rounded-
|
|
2470
|
+
className: "clarify-openai-example my-6 overflow-hidden rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-background) shadow-sm",
|
|
2346
2471
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2347
2472
|
className: "not-prose",
|
|
2348
2473
|
children: [
|
|
2349
2474
|
/* @__PURE__ */ jsxs("div", {
|
|
2350
|
-
className: "clarify-openai-example-header flex min-h-
|
|
2475
|
+
className: "clarify-openai-example-header flex min-h-11 items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-3.5 py-1.5",
|
|
2351
2476
|
children: [/* @__PURE__ */ jsx("h3", {
|
|
2352
|
-
className: "mr-auto min-w-16 truncate py-1 text-
|
|
2477
|
+
className: "mr-auto min-w-16 truncate py-1 text-sm font-semibold text-(--clarify-code-text)",
|
|
2353
2478
|
children: title
|
|
2354
2479
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2355
2480
|
className: "clarify-openai-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
@@ -2786,11 +2911,11 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2786
2911
|
};
|
|
2787
2912
|
}
|
|
2788
2913
|
function EnumValueNode(arg0) {
|
|
2789
|
-
const { node
|
|
2914
|
+
const { node } = arg0;
|
|
2790
2915
|
return /* @__PURE__ */ jsx("li", {
|
|
2791
|
-
className: "clarify-schema-node m-0
|
|
2916
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2792
2917
|
children: /* @__PURE__ */ jsx("div", {
|
|
2793
|
-
className:
|
|
2918
|
+
className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
|
|
2794
2919
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2795
2920
|
className: "min-w-0 flex-1",
|
|
2796
2921
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -2824,7 +2949,7 @@ function SchemaNode(arg0) {
|
|
|
2824
2949
|
});
|
|
2825
2950
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
2826
2951
|
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
2827
|
-
const rowClassName =
|
|
2952
|
+
const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
|
|
2828
2953
|
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
2829
2954
|
className: "min-w-0 flex-1",
|
|
2830
2955
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -2852,7 +2977,7 @@ function SchemaNode(arg0) {
|
|
|
2852
2977
|
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
2853
2978
|
}) : null] });
|
|
2854
2979
|
return /* @__PURE__ */ jsxs("li", {
|
|
2855
|
-
className: "clarify-schema-node m-0
|
|
2980
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2856
2981
|
children: [hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
2857
2982
|
type: "button",
|
|
2858
2983
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
@@ -2874,7 +2999,7 @@ function SchemaTree(arg0) {
|
|
|
2874
2999
|
if (nodes.length === 0) return null;
|
|
2875
3000
|
return /* @__PURE__ */ jsx("ul", {
|
|
2876
3001
|
role: "list",
|
|
2877
|
-
className: clsx("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border)
|
|
3002
|
+
className: clsx("m-0 list-none p-0", depth === 0 ? "divide-y divide-(--clarify-theme-tokens-colors-border)" : "ml-2 border-l border-(--clarify-theme-tokens-colors-border) pl-2"),
|
|
2878
3003
|
children: nodes.map((node) => /* @__PURE__ */ jsx(SchemaNode, {
|
|
2879
3004
|
node,
|
|
2880
3005
|
depth,
|
|
@@ -2887,7 +3012,7 @@ function SchemaProperties(arg0) {
|
|
|
2887
3012
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
2888
3013
|
if (!root || root.children.length === 0) return null;
|
|
2889
3014
|
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx("div", {
|
|
2890
|
-
className: "clarify-schema-properties my-6",
|
|
3015
|
+
className: "clarify-schema-properties not-prose my-6",
|
|
2891
3016
|
children: /* @__PURE__ */ jsx(SchemaTree, { nodes: root.children })
|
|
2892
3017
|
})] });
|
|
2893
3018
|
}
|
|
@@ -2972,7 +3097,8 @@ function ResponseList(arg0) {
|
|
|
2972
3097
|
response
|
|
2973
3098
|
})
|
|
2974
3099
|
})),
|
|
2975
|
-
|
|
3100
|
+
className: "mt-4 mb-6",
|
|
3101
|
+
panelsClassName: "mt-5"
|
|
2976
3102
|
})] });
|
|
2977
3103
|
}
|
|
2978
3104
|
//#endregion
|
|
@@ -2997,7 +3123,7 @@ function EndpointRequest(arg0) {
|
|
|
2997
3123
|
})] });
|
|
2998
3124
|
};
|
|
2999
3125
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [renderDescription(), /* @__PURE__ */ jsxs(Row, {
|
|
3000
|
-
className: "relative mt-6",
|
|
3126
|
+
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
3001
3127
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsxs("div", {
|
|
3002
3128
|
className: "w-full",
|
|
3003
3129
|
children: [
|
|
@@ -3044,9 +3170,9 @@ function EndpointResponse(arg0) {
|
|
|
3044
3170
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
3045
3171
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
3046
3172
|
return /* @__PURE__ */ jsx("div", {
|
|
3047
|
-
className: "mt-6",
|
|
3173
|
+
className: "mt-10 pt-6",
|
|
3048
3174
|
children: /* @__PURE__ */ jsxs(Row, {
|
|
3049
|
-
className: "relative",
|
|
3175
|
+
className: "clarify-openapi-response-workspace relative",
|
|
3050
3176
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
|
|
3051
3177
|
className: "w-full",
|
|
3052
3178
|
children: /* @__PURE__ */ jsx(ResponseList, {
|
|
@@ -3076,49 +3202,129 @@ function EndpointResponse(arg0) {
|
|
|
3076
3202
|
}
|
|
3077
3203
|
//#endregion
|
|
3078
3204
|
//#region source/openapi/components/InlineListbox.tsx
|
|
3205
|
+
var defaultButtonClassName = "inline-flex min-w-0 items-center justify-between gap-1 border-0 bg-transparent font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-disabled:cursor-not-allowed data-open:bg-(--clarify-ui-active-background)";
|
|
3206
|
+
var optionsClassName = "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 [--anchor-gap:--spacing(1)] focus:outline-none";
|
|
3207
|
+
var optionClassName = "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-focus:text-(--clarify-ui-text-strong) data-selected:bg-(--clarify-ui-active-background) data-selected:text-(--clarify-ui-accent-text)";
|
|
3208
|
+
function OptionContent(arg0) {
|
|
3209
|
+
const { option } = arg0;
|
|
3210
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
|
|
3211
|
+
className: "min-w-0",
|
|
3212
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3213
|
+
className: "block truncate",
|
|
3214
|
+
children: option.label
|
|
3215
|
+
}), option.description ? /* @__PURE__ */ jsx("span", {
|
|
3216
|
+
className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
|
|
3217
|
+
children: option.description
|
|
3218
|
+
}) : null]
|
|
3219
|
+
}), /* @__PURE__ */ jsx(CheckIcon, {
|
|
3220
|
+
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
3221
|
+
"aria-hidden": "true"
|
|
3222
|
+
})] });
|
|
3223
|
+
}
|
|
3079
3224
|
function InlineListbox(arg0) {
|
|
3080
|
-
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className } = arg0;
|
|
3081
|
-
const selected = options.find((option) => option.value === value)
|
|
3225
|
+
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false, title } = arg0;
|
|
3226
|
+
const selected = options.find((option) => option.value === value);
|
|
3082
3227
|
return /* @__PURE__ */ jsx(Listbox, {
|
|
3083
|
-
value
|
|
3228
|
+
value,
|
|
3084
3229
|
onChange,
|
|
3230
|
+
disabled,
|
|
3085
3231
|
children: /* @__PURE__ */ jsxs("div", {
|
|
3086
|
-
className: clsx("pointer-events-auto relative inline-flex min-w-0", className),
|
|
3232
|
+
className: clsx("pointer-events-auto relative inline-flex min-w-0 w-full", className),
|
|
3087
3233
|
children: [/* @__PURE__ */ jsx(ListboxButton, {
|
|
3088
3234
|
"aria-label": label,
|
|
3089
|
-
|
|
3235
|
+
"aria-invalid": invalid || void 0,
|
|
3236
|
+
"aria-describedby": describedBy,
|
|
3237
|
+
title,
|
|
3238
|
+
className: clsx(buttonClassName ?? defaultButtonClassName, buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2 text-xs"),
|
|
3090
3239
|
children: buttonContent ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
3091
3240
|
className: "truncate",
|
|
3092
|
-
children: selected?.label ?? value
|
|
3241
|
+
children: selected?.label ?? (value || label)
|
|
3093
3242
|
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3094
3243
|
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3095
3244
|
"aria-hidden": "true"
|
|
3096
3245
|
})] })
|
|
3097
3246
|
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
3098
3247
|
anchor: "bottom start",
|
|
3099
|
-
className:
|
|
3100
|
-
children: options.map((option) => /* @__PURE__ */
|
|
3248
|
+
className: optionsClassName,
|
|
3249
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
3101
3250
|
value: option.value,
|
|
3102
|
-
className:
|
|
3103
|
-
children:
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3251
|
+
className: optionClassName,
|
|
3252
|
+
children: /* @__PURE__ */ jsx(OptionContent, { option })
|
|
3253
|
+
}, option.value))
|
|
3254
|
+
})]
|
|
3255
|
+
})
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
3258
|
+
function MultiInlineListbox(arg0) {
|
|
3259
|
+
const { label, value, options, onChange, disabled = false, invalid, describedBy } = arg0;
|
|
3260
|
+
const selectedLabel = options.filter((option) => value.includes(option.value)).map((option) => option.label).join(", ");
|
|
3261
|
+
return /* @__PURE__ */ jsx(Listbox, {
|
|
3262
|
+
value,
|
|
3263
|
+
onChange,
|
|
3264
|
+
multiple: true,
|
|
3265
|
+
disabled,
|
|
3266
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
3267
|
+
className: "pointer-events-auto relative inline-flex min-w-0 w-full",
|
|
3268
|
+
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
3269
|
+
"aria-label": label,
|
|
3270
|
+
"aria-invalid": invalid || void 0,
|
|
3271
|
+
"aria-describedby": describedBy,
|
|
3272
|
+
className: clsx(defaultButtonClassName, "min-h-8 w-full px-2 text-xs"),
|
|
3273
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3274
|
+
className: "truncate",
|
|
3275
|
+
children: selectedLabel || label
|
|
3276
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3277
|
+
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3278
|
+
"aria-hidden": "true"
|
|
3279
|
+
})]
|
|
3280
|
+
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
3281
|
+
anchor: "bottom start",
|
|
3282
|
+
className: optionsClassName,
|
|
3283
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
3284
|
+
value: option.value,
|
|
3285
|
+
className: optionClassName,
|
|
3286
|
+
children: /* @__PURE__ */ jsx(OptionContent, { option })
|
|
3116
3287
|
}, option.value))
|
|
3117
3288
|
})]
|
|
3118
3289
|
})
|
|
3119
3290
|
});
|
|
3120
3291
|
}
|
|
3121
3292
|
//#endregion
|
|
3293
|
+
//#region source/openapi/store.ts
|
|
3294
|
+
var credentialScopes = /* @__PURE__ */ new WeakMap();
|
|
3295
|
+
var emptyOpenApiCredentials = Object.freeze({});
|
|
3296
|
+
var nextCredentialScope = 0;
|
|
3297
|
+
function getOpenApiCredentialScope(spec) {
|
|
3298
|
+
const current = credentialScopes.get(spec);
|
|
3299
|
+
if (current) return current;
|
|
3300
|
+
const scope = `openapi-${nextCredentialScope += 1}`;
|
|
3301
|
+
credentialScopes.set(spec, scope);
|
|
3302
|
+
return scope;
|
|
3303
|
+
}
|
|
3304
|
+
var useOpenApiStore = create()((set) => ({
|
|
3305
|
+
credentials: {},
|
|
3306
|
+
setCredential: (scope, name, value) => set((state) => ({ credentials: {
|
|
3307
|
+
...state.credentials,
|
|
3308
|
+
[scope]: {
|
|
3309
|
+
...state.credentials[scope],
|
|
3310
|
+
[name]: value
|
|
3311
|
+
}
|
|
3312
|
+
} })),
|
|
3313
|
+
clearCredential: (scope, name) => set((state) => {
|
|
3314
|
+
const scoped = { ...state.credentials[scope] };
|
|
3315
|
+
delete scoped[name];
|
|
3316
|
+
return { credentials: {
|
|
3317
|
+
...state.credentials,
|
|
3318
|
+
[scope]: scoped
|
|
3319
|
+
} };
|
|
3320
|
+
}),
|
|
3321
|
+
clearCredentials: (scope) => set((state) => {
|
|
3322
|
+
const credentials = { ...state.credentials };
|
|
3323
|
+
delete credentials[scope];
|
|
3324
|
+
return { credentials };
|
|
3325
|
+
})
|
|
3326
|
+
}));
|
|
3327
|
+
//#endregion
|
|
3122
3328
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
3123
3329
|
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
3124
3330
|
const parameters = getOperationParameters(spec, path, operation, source);
|
|
@@ -3169,9 +3375,13 @@ function useOperationServerState(spec, operation, path, source = "path") {
|
|
|
3169
3375
|
}
|
|
3170
3376
|
function useOperationAuthState(spec, operation) {
|
|
3171
3377
|
const authOptions = getAuthOptions(spec, operation);
|
|
3172
|
-
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.
|
|
3173
|
-
const selectedAuth = authOptions.find((option) => option.
|
|
3174
|
-
const
|
|
3378
|
+
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.key ?? "");
|
|
3379
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
3380
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
3381
|
+
const authValues = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
3382
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
3383
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
3384
|
+
const clearCredentials = useOpenApiStore((state) => state.clearCredentials);
|
|
3175
3385
|
const [authOpen, setAuthOpen] = useState(false);
|
|
3176
3386
|
return {
|
|
3177
3387
|
authOptions,
|
|
@@ -3179,119 +3389,1647 @@ function useOperationAuthState(spec, operation) {
|
|
|
3179
3389
|
selectedAuth,
|
|
3180
3390
|
authValues,
|
|
3181
3391
|
authOpen,
|
|
3182
|
-
authInput: selectedAuth ? {
|
|
3183
|
-
name:
|
|
3184
|
-
scheme:
|
|
3185
|
-
value: authValues[
|
|
3186
|
-
} : void 0,
|
|
3392
|
+
authInput: selectedAuth ? selectedAuth.schemes.map((option) => ({
|
|
3393
|
+
name: option.name,
|
|
3394
|
+
scheme: option.scheme,
|
|
3395
|
+
value: authValues[option.name] ?? ""
|
|
3396
|
+
})) : void 0,
|
|
3187
3397
|
onSelectAuth: setSelectedAuthName,
|
|
3188
|
-
onChangeAuthValue: (name, value) =>
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
})),
|
|
3398
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
3399
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name),
|
|
3400
|
+
onClearAuthValues: () => clearCredentials(credentialScope),
|
|
3192
3401
|
onToggleAuth: () => setAuthOpen((current) => !current),
|
|
3193
3402
|
closeAuth: () => setAuthOpen(false)
|
|
3194
3403
|
};
|
|
3195
3404
|
}
|
|
3196
3405
|
//#endregion
|
|
3197
|
-
//#region source/openapi/
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
};
|
|
3206
|
-
function EndpointMethodBadge(arg0) {
|
|
3207
|
-
const { method } = arg0;
|
|
3208
|
-
return /* @__PURE__ */ jsx("span", {
|
|
3209
|
-
className: clsx("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
|
|
3210
|
-
children: method
|
|
3211
|
-
});
|
|
3406
|
+
//#region source/openapi/lib/api-request.ts
|
|
3407
|
+
function parseBodyObject(body) {
|
|
3408
|
+
try {
|
|
3409
|
+
const parsed = JSON.parse(body);
|
|
3410
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
3411
|
+
} catch {
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3212
3414
|
}
|
|
3213
|
-
function
|
|
3214
|
-
|
|
3415
|
+
function buildRequestBody(body, mediaType, files) {
|
|
3416
|
+
if (files[""] && !mediaType.includes("multipart/form-data")) return files[""];
|
|
3417
|
+
const values = parseBodyObject(body);
|
|
3418
|
+
if (mediaType.includes("application/x-www-form-urlencoded") && values) {
|
|
3419
|
+
const params = new URLSearchParams();
|
|
3420
|
+
Object.entries(values).forEach(([name, value]) => params.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3421
|
+
return params;
|
|
3422
|
+
}
|
|
3423
|
+
if (mediaType.includes("multipart/form-data") && values) {
|
|
3424
|
+
const form = new FormData();
|
|
3425
|
+
Object.entries(values).forEach(([name, value]) => {
|
|
3426
|
+
const file = files[name];
|
|
3427
|
+
form.append(name, file ?? (typeof value === "string" ? value : JSON.stringify(value)));
|
|
3428
|
+
});
|
|
3429
|
+
Object.entries(files).forEach(([name, file]) => {
|
|
3430
|
+
if (name && !(name in values)) form.append(name, file);
|
|
3431
|
+
});
|
|
3432
|
+
return form;
|
|
3433
|
+
}
|
|
3434
|
+
if (mediaType.includes("multipart/form-data") && Object.keys(files).length > 0) {
|
|
3435
|
+
const form = new FormData();
|
|
3436
|
+
Object.entries(files).forEach(([name, file]) => form.append(name, file));
|
|
3437
|
+
return form;
|
|
3438
|
+
}
|
|
3439
|
+
return body;
|
|
3440
|
+
}
|
|
3441
|
+
function expandServerUrl(server, variables) {
|
|
3442
|
+
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
3443
|
+
}
|
|
3444
|
+
function authorizationValue(auth) {
|
|
3445
|
+
const scheme = auth.scheme.scheme?.toLowerCase();
|
|
3446
|
+
if (auth.scheme.type === "http" && scheme === "basic") return `Basic ${auth.value}`;
|
|
3447
|
+
if (auth.scheme.type === "http" && scheme === "bearer") return `Bearer ${auth.value}`;
|
|
3448
|
+
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
3449
|
+
}
|
|
3450
|
+
function parameterKey(parameter) {
|
|
3451
|
+
return `${parameter.in ?? "query"}:${parameter.name ?? ""}`;
|
|
3452
|
+
}
|
|
3453
|
+
function parseParameterValue(value) {
|
|
3454
|
+
const trimmed = value.trim();
|
|
3455
|
+
if (!trimmed || !trimmed.startsWith("[") && !trimmed.startsWith("{")) return value;
|
|
3456
|
+
try {
|
|
3457
|
+
return JSON.parse(trimmed);
|
|
3458
|
+
} catch {
|
|
3459
|
+
return value;
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
function primitiveValue(value) {
|
|
3463
|
+
if (typeof value === "string") return value;
|
|
3464
|
+
if (value === null || typeof value === "undefined") return "";
|
|
3465
|
+
return String(value);
|
|
3466
|
+
}
|
|
3467
|
+
function serializedParameterValues(parameter, rawValue) {
|
|
3468
|
+
const value = parseParameterValue(rawValue);
|
|
3469
|
+
const style = parameter.style ?? (parameter.in === "query" || parameter.in === "cookie" ? "form" : "simple");
|
|
3470
|
+
const explode = parameter.explode ?? style === "form";
|
|
3471
|
+
if (Array.isArray(value)) {
|
|
3472
|
+
if (explode) return value.map((item) => [parameter.name ?? "", primitiveValue(item)]);
|
|
3473
|
+
const delimiter = style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",";
|
|
3474
|
+
return [[parameter.name ?? "", value.map(primitiveValue).join(delimiter)]];
|
|
3475
|
+
}
|
|
3476
|
+
if (typeof value === "object" && value !== null) {
|
|
3477
|
+
const entries = Object.entries(value);
|
|
3478
|
+
if (parameter.style === "deepObject") return entries.map(([key, item]) => [`${parameter.name}[${key}]`, primitiveValue(item)]);
|
|
3479
|
+
if (explode) return entries.map(([key, item]) => [key, primitiveValue(item)]);
|
|
3480
|
+
return [[parameter.name ?? "", entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",")]];
|
|
3481
|
+
}
|
|
3482
|
+
return [[parameter.name ?? "", primitiveValue(value)]];
|
|
3483
|
+
}
|
|
3484
|
+
function pathParameterValue(parameter, rawValue) {
|
|
3485
|
+
const value = parseParameterValue(rawValue);
|
|
3486
|
+
const style = parameter.style ?? "simple";
|
|
3487
|
+
const explode = parameter.explode ?? false;
|
|
3488
|
+
const encode = (item) => encodeURIComponent(primitiveValue(item));
|
|
3489
|
+
if (Array.isArray(value)) {
|
|
3490
|
+
if (style === "label") return `.${value.map(encode).join(explode ? "." : ",")}`;
|
|
3491
|
+
if (style === "matrix") return explode ? value.map((item) => `;${parameter.name}=${encode(item)}`).join("") : `;${parameter.name}=${value.map(encode).join(",")}`;
|
|
3492
|
+
return value.map(encode).join(",");
|
|
3493
|
+
}
|
|
3494
|
+
if (typeof value === "object" && value !== null) {
|
|
3495
|
+
const entries = Object.entries(value);
|
|
3496
|
+
if (style === "label") return explode ? `.${entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(".")}` : `.${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3497
|
+
if (style === "matrix") return explode ? entries.map(([key, item]) => `;${encode(key)}=${encode(item)}`).join("") : `;${parameter.name}=${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3498
|
+
return explode ? entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(",") : entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",");
|
|
3499
|
+
}
|
|
3500
|
+
const encoded = encode(value);
|
|
3501
|
+
if (style === "label") return `.${encoded}`;
|
|
3502
|
+
if (style === "matrix") return `;${parameter.name}=${encoded}`;
|
|
3503
|
+
return encoded;
|
|
3504
|
+
}
|
|
3505
|
+
function headerParameterValue(parameter, rawValue) {
|
|
3506
|
+
const value = parseParameterValue(rawValue);
|
|
3507
|
+
if (Array.isArray(value)) return value.map(primitiveValue).join(",");
|
|
3508
|
+
if (typeof value === "object" && value !== null) {
|
|
3509
|
+
const entries = Object.entries(value);
|
|
3510
|
+
return parameter.explode ? entries.map(([key, item]) => `${key}=${primitiveValue(item)}`).join(",") : entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",");
|
|
3511
|
+
}
|
|
3512
|
+
return primitiveValue(value);
|
|
3513
|
+
}
|
|
3514
|
+
function buildApiRequest(input) {
|
|
3515
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
3516
|
+
const query = new URLSearchParams();
|
|
3517
|
+
let path = input.path;
|
|
3518
|
+
for (const parameter of input.parameters) {
|
|
3519
|
+
if (!parameter.name) continue;
|
|
3520
|
+
const key = parameterKey(parameter);
|
|
3521
|
+
if (input.parameterEnabled?.[key] === false) continue;
|
|
3522
|
+
const value = input.parameterValues[key] ?? "";
|
|
3523
|
+
if (!value && !parameter.allowEmptyValue) continue;
|
|
3524
|
+
if (parameter.in === "path") path = path.replaceAll(`{${parameter.name}}`, pathParameterValue(parameter, value));
|
|
3525
|
+
if (parameter.in === "query") serializedParameterValues(parameter, value).forEach(([name, item]) => query.append(name, item));
|
|
3526
|
+
if (parameter.in === "header") headers.set(parameter.name, headerParameterValue(parameter, value));
|
|
3527
|
+
}
|
|
3528
|
+
for (const auth of input.auth ?? []) {
|
|
3529
|
+
if (!auth.value) continue;
|
|
3530
|
+
if (auth.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) query.set(auth.scheme.name, auth.value);
|
|
3531
|
+
else if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) headers.set(auth.scheme.name, auth.value);
|
|
3532
|
+
else {
|
|
3533
|
+
const authorization = authorizationValue(auth);
|
|
3534
|
+
if (authorization) headers.set("Authorization", authorization);
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
|
|
3538
|
+
query.forEach((value, key) => url.searchParams.append(key, value));
|
|
3539
|
+
const body = input.body?.trim() ?? "";
|
|
3540
|
+
const mediaType = input.mediaType || "application/json";
|
|
3541
|
+
const requestBody = (Boolean(body) || Object.keys(input.bodyFiles ?? {}).length > 0) && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType, input.bodyFiles ?? {}) : void 0;
|
|
3542
|
+
if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
|
|
3543
|
+
return {
|
|
3544
|
+
url: url.toString(),
|
|
3545
|
+
init: {
|
|
3546
|
+
method: input.method.toUpperCase(),
|
|
3547
|
+
headers,
|
|
3548
|
+
credentials: "include",
|
|
3549
|
+
...requestBody ? { body: requestBody } : {}
|
|
3550
|
+
}
|
|
3551
|
+
};
|
|
3552
|
+
}
|
|
3553
|
+
//#endregion
|
|
3554
|
+
//#region source/openapi/components/OpenApiAuthPanel.tsx
|
|
3555
|
+
function OpenApiAuthPanel(arg0) {
|
|
3556
|
+
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue, onClearAuthValue } = arg0;
|
|
3215
3557
|
const t = useBuiltInText();
|
|
3558
|
+
if (authOptions.length === 0) return null;
|
|
3216
3559
|
return /* @__PURE__ */ jsxs("div", {
|
|
3217
|
-
className: "
|
|
3218
|
-
children: [/* @__PURE__ */
|
|
3219
|
-
className: "min-w-0
|
|
3220
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
3221
|
-
className: "
|
|
3222
|
-
children:
|
|
3223
|
-
})
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
"
|
|
3236
|
-
|
|
3237
|
-
|
|
3560
|
+
className: "grid divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
3561
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
3562
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3563
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3564
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
3565
|
+
children: "Auth"
|
|
3566
|
+
}), /* @__PURE__ */ jsx(InlineListbox, {
|
|
3567
|
+
label: "Auth",
|
|
3568
|
+
value: selectedAuthName,
|
|
3569
|
+
options: authOptions.map((option) => ({
|
|
3570
|
+
value: option.key,
|
|
3571
|
+
label: option.label || t("openapi.none")
|
|
3572
|
+
})),
|
|
3573
|
+
onChange: onSelectAuth
|
|
3574
|
+
})]
|
|
3575
|
+
}), selectedAuth?.schemes.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
3576
|
+
className: "group grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3577
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3578
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
3579
|
+
children: authLabel(option.name, option.scheme)
|
|
3580
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3581
|
+
className: "flex min-w-0 items-center focus-within:bg-(--clarify-ui-hover-background)",
|
|
3582
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
3583
|
+
type: "password",
|
|
3584
|
+
value: authValues[option.name] ?? "",
|
|
3585
|
+
placeholder: authPlaceholder(option),
|
|
3586
|
+
onChange: (event) => onChangeAuthValue(option.name, event.target.value),
|
|
3587
|
+
autoComplete: "off",
|
|
3588
|
+
className: "h-8 min-w-0 flex-1 border-0 bg-transparent px-2 text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
|
|
3589
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3590
|
+
type: "button",
|
|
3591
|
+
onClick: () => onClearAuthValue(option.name),
|
|
3592
|
+
className: "mr-1 h-6 shrink-0 rounded-(--clarify-theme-tokens-radius-md) px-1 text-2xs font-medium text-(--clarify-ui-text-faint) opacity-0 transition-opacity hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) group-hover:opacity-100",
|
|
3593
|
+
children: t("openapi.clear")
|
|
3594
|
+
})]
|
|
3595
|
+
})]
|
|
3596
|
+
}, option.name))]
|
|
3238
3597
|
});
|
|
3239
3598
|
}
|
|
3240
|
-
|
|
3241
|
-
|
|
3599
|
+
//#endregion
|
|
3600
|
+
//#region source/openapi/components/OpenApiRequestBodyEditor.tsx
|
|
3601
|
+
function parseBodyRecord(body) {
|
|
3602
|
+
try {
|
|
3603
|
+
const value = JSON.parse(body);
|
|
3604
|
+
return isRecord$1(value) ? value : {};
|
|
3605
|
+
} catch {
|
|
3606
|
+
return {};
|
|
3607
|
+
}
|
|
3242
3608
|
}
|
|
3243
|
-
function
|
|
3244
|
-
return
|
|
3609
|
+
function isBinarySchema(schema) {
|
|
3610
|
+
return isRecord$1(schema) && schema.format === "binary";
|
|
3245
3611
|
}
|
|
3246
|
-
function
|
|
3247
|
-
|
|
3248
|
-
const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
|
|
3249
|
-
return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
|
|
3612
|
+
function isTextMediaType(mediaType) {
|
|
3613
|
+
return mediaType.startsWith("text/") || mediaType.includes("json") || mediaType.includes("xml") || mediaType.includes("yaml") || mediaType.includes("javascript") || mediaType.includes("form");
|
|
3250
3614
|
}
|
|
3251
|
-
function
|
|
3252
|
-
const
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3615
|
+
function isFormMediaType(mediaType) {
|
|
3616
|
+
const normalized = mediaType.split(";", 1)[0].trim().toLowerCase();
|
|
3617
|
+
return normalized === "application/x-www-form-urlencoded" || normalized === "multipart/form-data";
|
|
3618
|
+
}
|
|
3619
|
+
function valueFromInput(schema, value) {
|
|
3620
|
+
if (!isRecord$1(schema)) return value;
|
|
3621
|
+
if (schemaHasType(schema, "integer")) return value === "" ? "" : Number.parseInt(value, 10);
|
|
3622
|
+
if (schemaHasType(schema, "number")) return value === "" ? "" : Number(value);
|
|
3623
|
+
if (schemaHasType(schema, "boolean")) return value === "true";
|
|
3624
|
+
if (schemaHasType(schema, "array") || schemaHasType(schema, "object")) try {
|
|
3625
|
+
return JSON.parse(value);
|
|
3626
|
+
} catch {
|
|
3627
|
+
return value;
|
|
3628
|
+
}
|
|
3629
|
+
return value;
|
|
3630
|
+
}
|
|
3631
|
+
function OpenApiRequestBodyEditor(arg0) {
|
|
3632
|
+
const { spec, mediaType, content, body, files, onBodyChange, onFileChange } = arg0;
|
|
3633
|
+
const schema = resolveSchema(spec, content?.schema);
|
|
3634
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
3635
|
+
const properties = isRecord$1(schemaRecord?.properties) ? schemaRecord.properties : void 0;
|
|
3636
|
+
const required = new Set(Array.isArray(schemaRecord?.required) ? schemaRecord.required.map(String) : []);
|
|
3637
|
+
const values = parseBodyRecord(body);
|
|
3638
|
+
function updateProperty(name, propertySchema, value) {
|
|
3639
|
+
onBodyChange(JSON.stringify({
|
|
3640
|
+
...values,
|
|
3641
|
+
[name]: valueFromInput(propertySchema, value)
|
|
3642
|
+
}, null, 2));
|
|
3643
|
+
}
|
|
3644
|
+
function renderProperty(name, unresolvedSchema) {
|
|
3645
|
+
const propertySchema = resolveSchema(spec, unresolvedSchema);
|
|
3646
|
+
const propertyRecord = isRecord$1(propertySchema) ? propertySchema : void 0;
|
|
3647
|
+
const type = schemaToType(propertySchema) ?? "string";
|
|
3648
|
+
const value = values[name];
|
|
3649
|
+
const fieldId = `openapi-request-body-${name}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3650
|
+
const options = Array.isArray(propertyRecord?.enum) ? propertyRecord.enum : [];
|
|
3651
|
+
const structured = schemaHasType(propertySchema, "array") || schemaHasType(propertySchema, "object");
|
|
3652
|
+
const serializedValue = structured && typeof value !== "undefined" ? JSON.stringify(value, null, 2) : String(value ?? "");
|
|
3653
|
+
let control;
|
|
3654
|
+
if (isBinarySchema(propertySchema)) control = /* @__PURE__ */ jsx("input", {
|
|
3655
|
+
id: fieldId,
|
|
3656
|
+
"aria-label": name,
|
|
3657
|
+
type: "file",
|
|
3658
|
+
required: required.has(name),
|
|
3659
|
+
onChange: (event) => onFileChange(name, event.target.files?.[0]),
|
|
3660
|
+
className: "min-h-8 w-full px-2 py-1 text-xs text-(--clarify-theme-tokens-colors-foreground) file:mr-2 file:rounded-(--clarify-theme-tokens-radius-md) file:border file:border-(--clarify-theme-tokens-colors-border) file:bg-(--clarify-ui-subtle-background) file:px-2 file:py-1 file:text-xs file:text-(--clarify-ui-text-strong)"
|
|
3661
|
+
});
|
|
3662
|
+
else if (options.length > 0) control = /* @__PURE__ */ jsxs("select", {
|
|
3663
|
+
id: fieldId,
|
|
3664
|
+
"aria-label": name,
|
|
3665
|
+
value: serializedValue,
|
|
3666
|
+
required: required.has(name),
|
|
3667
|
+
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
3668
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)",
|
|
3669
|
+
children: [!required.has(name) ? /* @__PURE__ */ jsx("option", { value: "" }) : null, options.map((option) => /* @__PURE__ */ jsx("option", {
|
|
3670
|
+
value: String(option),
|
|
3671
|
+
children: String(option)
|
|
3672
|
+
}, String(option)))]
|
|
3673
|
+
});
|
|
3674
|
+
else if (schemaHasType(propertySchema, "boolean")) control = /* @__PURE__ */ jsx("input", {
|
|
3675
|
+
id: fieldId,
|
|
3676
|
+
"aria-label": name,
|
|
3677
|
+
type: "checkbox",
|
|
3678
|
+
checked: value === true,
|
|
3679
|
+
onChange: (event) => updateProperty(name, propertySchema, String(event.target.checked)),
|
|
3680
|
+
className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
|
|
3681
|
+
});
|
|
3682
|
+
else if (structured) control = /* @__PURE__ */ jsx("textarea", {
|
|
3683
|
+
id: fieldId,
|
|
3684
|
+
"aria-label": name,
|
|
3685
|
+
value: serializedValue,
|
|
3686
|
+
required: required.has(name),
|
|
3687
|
+
rows: 3,
|
|
3688
|
+
spellCheck: false,
|
|
3689
|
+
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
3690
|
+
className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)"
|
|
3691
|
+
});
|
|
3692
|
+
else control = /* @__PURE__ */ jsx("input", {
|
|
3693
|
+
id: fieldId,
|
|
3694
|
+
"aria-label": name,
|
|
3695
|
+
value: serializedValue,
|
|
3696
|
+
type: schemaHasType(propertySchema, "integer") || schemaHasType(propertySchema, "number") ? "number" : propertyRecord?.format === "date" ? "date" : propertyRecord?.format === "date-time" ? "datetime-local" : "text",
|
|
3697
|
+
required: required.has(name),
|
|
3698
|
+
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
3699
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)"
|
|
3700
|
+
});
|
|
3701
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3702
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",
|
|
3703
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
3704
|
+
htmlFor: fieldId,
|
|
3705
|
+
className: "flex min-h-8 min-w-0 items-center gap-1.5 border-r border-(--clarify-theme-tokens-colors-border) px-2 text-xs text-(--clarify-ui-text-strong)",
|
|
3706
|
+
children: [
|
|
3707
|
+
/* @__PURE__ */ jsx("span", {
|
|
3708
|
+
className: "truncate font-mono",
|
|
3709
|
+
children: name
|
|
3710
|
+
}),
|
|
3711
|
+
/* @__PURE__ */ jsx("span", {
|
|
3712
|
+
className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
|
|
3713
|
+
children: type
|
|
3714
|
+
}),
|
|
3715
|
+
required.has(name) ? /* @__PURE__ */ jsx("span", {
|
|
3716
|
+
className: "text-(--clarify-error-accent-text)",
|
|
3717
|
+
children: "*"
|
|
3718
|
+
}) : null
|
|
3719
|
+
]
|
|
3720
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3721
|
+
className: "flex min-w-0 items-center",
|
|
3722
|
+
children: [control, files[name] ? /* @__PURE__ */ jsx("span", {
|
|
3723
|
+
className: "sr-only",
|
|
3724
|
+
children: files[name].name
|
|
3725
|
+
}) : null]
|
|
3726
|
+
})]
|
|
3727
|
+
}, name);
|
|
3728
|
+
}
|
|
3729
|
+
if (properties && isFormMediaType(mediaType)) return /* @__PURE__ */ jsx("div", {
|
|
3730
|
+
className: "divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
3731
|
+
children: Object.entries(properties).map(([name, propertySchema]) => renderProperty(name, propertySchema))
|
|
3732
|
+
});
|
|
3733
|
+
if (isBinarySchema(schema) || !isTextMediaType(mediaType)) return /* @__PURE__ */ jsx("div", {
|
|
3734
|
+
className: "flex min-h-44 items-start p-3",
|
|
3735
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
3736
|
+
"aria-label": mediaType,
|
|
3737
|
+
type: "file",
|
|
3738
|
+
onChange: (event) => onFileChange("", event.target.files?.[0]),
|
|
3739
|
+
className: "w-full text-xs text-(--clarify-theme-tokens-colors-foreground) file:mr-2 file:rounded-(--clarify-theme-tokens-radius-md) file:border file:border-(--clarify-theme-tokens-colors-border) file:bg-(--clarify-ui-subtle-background) file:px-2 file:py-1 file:text-xs file:text-(--clarify-ui-text-strong)"
|
|
3740
|
+
})
|
|
3741
|
+
});
|
|
3742
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
3743
|
+
"aria-label": mediaType,
|
|
3744
|
+
value: body,
|
|
3745
|
+
onChange: (event) => onBodyChange(event.target.value),
|
|
3746
|
+
spellCheck: false,
|
|
3747
|
+
className: "block h-full min-h-44 w-full resize-none border-0 bg-(--clarify-code-background) p-3 font-mono text-xs/5 text-(--clarify-code-text) outline-hidden focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary)"
|
|
3259
3748
|
});
|
|
3260
|
-
return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
|
|
3261
3749
|
}
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
const
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3750
|
+
//#endregion
|
|
3751
|
+
//#region source/openapi/components/OpenApiRequestFields.tsx
|
|
3752
|
+
function RequestField(arg0) {
|
|
3753
|
+
const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
|
|
3754
|
+
const t = useBuiltInText();
|
|
3755
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
3756
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
3757
|
+
const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
|
|
3758
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
3759
|
+
const itemOptions = Array.isArray(itemSchema?.enum) ? itemSchema.enum.map(String) : [];
|
|
3760
|
+
const type = schemaToType(schema) ?? "string";
|
|
3761
|
+
const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
|
|
3762
|
+
const structured = type.includes("[]") || type.includes("object");
|
|
3763
|
+
const boolean = type.includes("boolean");
|
|
3764
|
+
const numeric = type.includes("integer") || type.includes("number");
|
|
3765
|
+
const fieldId = `openapi-parameter-${parameter.in ?? "query"}-${parameter.name ?? ""}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3766
|
+
const issueText = issue === "required" ? t("openapi.required") : issue ? t(`openapi.parameter${issue[0].toUpperCase()}${issue.slice(1)}`) : void 0;
|
|
3767
|
+
const controlProps = {
|
|
3768
|
+
"aria-label": parameter.name,
|
|
3769
|
+
"aria-invalid": issue ? true : void 0,
|
|
3770
|
+
"aria-describedby": issue ? `${fieldId}-issue` : void 0,
|
|
3771
|
+
disabled: !enabled
|
|
3772
|
+
};
|
|
3773
|
+
const arrayValue = (() => {
|
|
3774
|
+
try {
|
|
3775
|
+
const parsed = JSON.parse(value);
|
|
3776
|
+
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
3777
|
+
} catch {
|
|
3778
|
+
return [];
|
|
3779
|
+
}
|
|
3780
|
+
})();
|
|
3781
|
+
const descriptionTip = description ? /* @__PURE__ */ jsxs(Tooltip, {
|
|
3782
|
+
content: /* @__PURE__ */ jsx(Markdown, {
|
|
3783
|
+
className: "max-w-80 text-left *:first:mt-0 *:last:mb-0",
|
|
3784
|
+
children: description
|
|
3785
|
+
}),
|
|
3786
|
+
side: "bottom",
|
|
3787
|
+
className: "mr-1 shrink-0 *:[[role=tooltip]]:w-80 *:[[role=tooltip]]:max-w-[min(20rem,calc(100vw-2rem))] *:[[role=tooltip]]:border *:[[role=tooltip]]:border-(--clarify-theme-tokens-colors-border) *:[[role=tooltip]]:bg-(--clarify-theme-tokens-colors-surface) *:[[role=tooltip]]:p-3 *:[[role=tooltip]]:text-(--clarify-ui-text) *:[[role=tooltip]]:shadow-xl",
|
|
3788
|
+
triggerClassName: "clarify-field-description-trigger clarify-ui-control inline-flex size-7 items-center justify-center rounded-md !border-b-0 text-(--clarify-ui-text-faint) transition-colors",
|
|
3789
|
+
children: [/* @__PURE__ */ jsx(InfoIcon, {
|
|
3790
|
+
className: "size-4",
|
|
3791
|
+
"aria-hidden": "true"
|
|
3792
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3793
|
+
className: "sr-only",
|
|
3794
|
+
children: t("openapi.fieldDescription")
|
|
3284
3795
|
})]
|
|
3285
|
-
});
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3796
|
+
}) : null;
|
|
3797
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3798
|
+
className: "group grid min-w-0 grid-cols-[2rem_minmax(0,1fr)] sm:grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)] sm:items-stretch",
|
|
3799
|
+
children: [
|
|
3800
|
+
/* @__PURE__ */ jsx("div", {
|
|
3801
|
+
className: "flex min-h-8 items-center justify-center border-r border-(--clarify-theme-tokens-colors-border)",
|
|
3802
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
3803
|
+
type: "checkbox",
|
|
3804
|
+
checked: enabled,
|
|
3805
|
+
disabled: parameter.required,
|
|
3806
|
+
onChange: (event) => onEnabledChange(event.target.checked),
|
|
3807
|
+
"aria-label": `${t("openapi.includeParameter")}: ${parameter.name ?? ""}`,
|
|
3808
|
+
className: "size-3.5 shrink-0 accent-(--clarify-theme-tokens-colors-primary) disabled:cursor-not-allowed"
|
|
3809
|
+
})
|
|
3810
|
+
}),
|
|
3811
|
+
/* @__PURE__ */ jsx("div", {
|
|
3812
|
+
className: "flex min-h-8 min-w-0 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2",
|
|
3813
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
3814
|
+
htmlFor: fieldId,
|
|
3815
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-(--clarify-ui-text-strong)",
|
|
3816
|
+
children: [
|
|
3817
|
+
/* @__PURE__ */ jsx("span", {
|
|
3818
|
+
className: "truncate font-mono",
|
|
3819
|
+
children: parameter.name
|
|
3820
|
+
}),
|
|
3821
|
+
/* @__PURE__ */ jsx("span", {
|
|
3822
|
+
className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
|
|
3823
|
+
children: type
|
|
3824
|
+
}),
|
|
3825
|
+
parameter.required ? /* @__PURE__ */ jsx("span", {
|
|
3826
|
+
className: "text-(--clarify-error-accent-text)",
|
|
3827
|
+
children: "*"
|
|
3828
|
+
}) : null
|
|
3829
|
+
]
|
|
3830
|
+
})
|
|
3831
|
+
}),
|
|
3832
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3833
|
+
className: clsx("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "bg-(--clarify-ui-subtle-background)"),
|
|
3834
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3835
|
+
className: "min-w-0 flex-1",
|
|
3836
|
+
children: itemOptions.length > 0 ? /* @__PURE__ */ jsx(MultiInlineListbox, {
|
|
3837
|
+
label: parameter.name ?? "",
|
|
3838
|
+
value: arrayValue,
|
|
3839
|
+
options: itemOptions.map((option) => ({
|
|
3840
|
+
value: option,
|
|
3841
|
+
label: option
|
|
3842
|
+
})),
|
|
3843
|
+
onChange: (next) => onChange(JSON.stringify(next)),
|
|
3844
|
+
invalid: Boolean(issue),
|
|
3845
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3846
|
+
disabled: !enabled
|
|
3847
|
+
}) : options.length > 0 ? /* @__PURE__ */ jsx(InlineListbox, {
|
|
3848
|
+
label: parameter.name ?? "",
|
|
3849
|
+
value,
|
|
3850
|
+
options: [...parameter.required ? [] : [{
|
|
3851
|
+
value: "",
|
|
3852
|
+
label: t("openapi.none")
|
|
3853
|
+
}], ...options.map((option) => ({
|
|
3854
|
+
value: option,
|
|
3855
|
+
label: option
|
|
3856
|
+
}))],
|
|
3857
|
+
onChange,
|
|
3858
|
+
invalid: Boolean(issue),
|
|
3859
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3860
|
+
disabled: !enabled
|
|
3861
|
+
}) : boolean ? /* @__PURE__ */ jsx("input", {
|
|
3862
|
+
...controlProps,
|
|
3863
|
+
id: fieldId,
|
|
3864
|
+
type: "checkbox",
|
|
3865
|
+
checked: value === "true",
|
|
3866
|
+
onChange: (event) => onChange(String(event.target.checked)),
|
|
3867
|
+
className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
|
|
3868
|
+
}) : structured ? /* @__PURE__ */ jsx("textarea", {
|
|
3869
|
+
...controlProps,
|
|
3870
|
+
id: fieldId,
|
|
3871
|
+
value,
|
|
3872
|
+
required: parameter.required,
|
|
3873
|
+
onChange: (event) => onChange(event.target.value),
|
|
3874
|
+
rows: 3,
|
|
3875
|
+
spellCheck: false,
|
|
3876
|
+
placeholder: type.includes("[]") ? "[]" : "{}",
|
|
3877
|
+
className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden aria-invalid:text-(--clarify-error-accent-text) focus:bg-(--clarify-ui-hover-background)"
|
|
3878
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
3879
|
+
...controlProps,
|
|
3880
|
+
id: fieldId,
|
|
3881
|
+
value,
|
|
3882
|
+
type: numeric ? "number" : schemaRecord?.format === "date" ? "date" : schemaRecord?.format === "date-time" ? "datetime-local" : "text",
|
|
3883
|
+
required: parameter.required,
|
|
3884
|
+
onChange: (event) => onChange(event.target.value),
|
|
3885
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden transition placeholder:text-(--clarify-ui-text-faint) focus:bg-(--clarify-ui-hover-background) aria-invalid:text-(--clarify-error-accent-text)"
|
|
3886
|
+
})
|
|
3887
|
+
}), descriptionTip]
|
|
3888
|
+
}),
|
|
3889
|
+
issueText ? /* @__PURE__ */ jsx("span", {
|
|
3890
|
+
id: `${fieldId}-issue`,
|
|
3891
|
+
className: "col-start-2 border-t border-(--clarify-theme-tokens-colors-border) px-2 py-1 text-xs/5 font-medium text-(--clarify-error-accent-text) sm:col-start-3",
|
|
3892
|
+
children: issueText
|
|
3893
|
+
}) : null
|
|
3894
|
+
]
|
|
3895
|
+
});
|
|
3896
|
+
}
|
|
3897
|
+
function RequestSection(arg0) {
|
|
3898
|
+
const { title, count, defaultOpen, actions, className, contentClassName, children } = arg0;
|
|
3899
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
3900
|
+
open: defaultOpen,
|
|
3901
|
+
className: clsx("group shrink-0 border-b border-(--clarify-theme-tokens-colors-border)", className),
|
|
3902
|
+
children: [/* @__PURE__ */ jsxs("summary", {
|
|
3903
|
+
className: "flex min-h-11 cursor-pointer list-none items-center gap-2 bg-(--clarify-ui-subtle-background) px-2.5 text-sm font-medium text-(--clarify-ui-text-strong) hover:bg-(--clarify-ui-hover-background) group-open:border-b group-open:border-(--clarify-theme-tokens-colors-border)",
|
|
3904
|
+
children: [
|
|
3905
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3906
|
+
className: "size-4 shrink-0 -rotate-90 transition group-open:rotate-0",
|
|
3907
|
+
"aria-hidden": "true"
|
|
3908
|
+
}),
|
|
3909
|
+
/* @__PURE__ */ jsx("span", {
|
|
3910
|
+
className: "flex-1",
|
|
3911
|
+
children: title
|
|
3912
|
+
}),
|
|
3913
|
+
typeof count === "number" ? /* @__PURE__ */ jsx("span", {
|
|
3914
|
+
className: "font-mono text-xs text-(--clarify-ui-text-faint)",
|
|
3915
|
+
children: count
|
|
3916
|
+
}) : null,
|
|
3917
|
+
actions ? /* @__PURE__ */ jsx("span", {
|
|
3918
|
+
className: "flex items-center gap-1",
|
|
3919
|
+
onClick: (event) => {
|
|
3920
|
+
event.preventDefault();
|
|
3921
|
+
event.stopPropagation();
|
|
3922
|
+
},
|
|
3923
|
+
children: actions
|
|
3924
|
+
}) : null
|
|
3925
|
+
]
|
|
3926
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3927
|
+
className: clsx("divide-y divide-(--clarify-theme-tokens-colors-border)", contentClassName),
|
|
3928
|
+
children
|
|
3929
|
+
})]
|
|
3930
|
+
});
|
|
3931
|
+
}
|
|
3932
|
+
//#endregion
|
|
3933
|
+
//#region source/openapi/components/OpenApiResponseViewer.tsx
|
|
3934
|
+
function formatBytes(size) {
|
|
3935
|
+
if (size < 1024) return `${size} B`;
|
|
3936
|
+
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
|
|
3937
|
+
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
3938
|
+
}
|
|
3939
|
+
function parseJson(value) {
|
|
3940
|
+
try {
|
|
3941
|
+
return JSON.parse(value);
|
|
3942
|
+
} catch {
|
|
3943
|
+
return;
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
var textLanguages = {
|
|
3947
|
+
"application/graphql": "graphql",
|
|
3948
|
+
"application/javascript": "javascript",
|
|
3949
|
+
"application/sql": "sql",
|
|
3950
|
+
"application/typescript": "typescript",
|
|
3951
|
+
"application/xml": "xml",
|
|
3952
|
+
"application/x-httpd-php": "php",
|
|
3953
|
+
"application/x-sh": "shellscript",
|
|
3954
|
+
"application/xhtml+xml": "html",
|
|
3955
|
+
"application/x-www-form-urlencoded": "http",
|
|
3956
|
+
"text/css": "css",
|
|
3957
|
+
"text/csv": "csv",
|
|
3958
|
+
"text/html": "html",
|
|
3959
|
+
"text/javascript": "javascript",
|
|
3960
|
+
"text/markdown": "markdown",
|
|
3961
|
+
"text/plain": "text",
|
|
3962
|
+
"text/xml": "xml"
|
|
3963
|
+
};
|
|
3964
|
+
function normalizedMediaType(contentType) {
|
|
3965
|
+
return contentType.split(";", 1)[0].trim().toLowerCase();
|
|
3966
|
+
}
|
|
3967
|
+
function getResponseTextPreview(contentType, body) {
|
|
3968
|
+
const mediaType = normalizedMediaType(contentType);
|
|
3969
|
+
if (mediaType === "application/json" || mediaType.endsWith("+json")) {
|
|
3970
|
+
const parsed = parseJson(body);
|
|
3971
|
+
return {
|
|
3972
|
+
code: typeof parsed === "undefined" ? body : JSON.stringify(parsed, null, 2),
|
|
3973
|
+
language: "json"
|
|
3974
|
+
};
|
|
3975
|
+
}
|
|
3976
|
+
if (mediaType === "application/yaml" || mediaType === "application/x-yaml" || mediaType === "text/yaml" || mediaType === "text/x-yaml" || mediaType.endsWith("+yaml")) try {
|
|
3977
|
+
return {
|
|
3978
|
+
code: stringify(parse(body)).trimEnd(),
|
|
3979
|
+
language: "yaml"
|
|
3980
|
+
};
|
|
3981
|
+
} catch {
|
|
3982
|
+
return {
|
|
3983
|
+
code: body,
|
|
3984
|
+
language: "yaml"
|
|
3985
|
+
};
|
|
3986
|
+
}
|
|
3987
|
+
const language = textLanguages[mediaType] ?? (mediaType.startsWith("text/") ? mediaType.slice(5) || "text" : void 0);
|
|
3988
|
+
return language ? {
|
|
3989
|
+
code: body,
|
|
3990
|
+
language
|
|
3991
|
+
} : void 0;
|
|
3992
|
+
}
|
|
3993
|
+
function canPreviewResponse(contentType) {
|
|
3994
|
+
const mediaType = normalizedMediaType(contentType);
|
|
3995
|
+
return Boolean(getResponseTextPreview(contentType, "") || mediaType.startsWith("image/") || mediaType.startsWith("audio/") || mediaType.startsWith("video/"));
|
|
3996
|
+
}
|
|
3997
|
+
function ResponseState(arg0) {
|
|
3998
|
+
const { icon: Icon, title, description, tone = "default" } = arg0;
|
|
3999
|
+
const error = tone === "error";
|
|
4000
|
+
return /* @__PURE__ */ jsx("div", {
|
|
4001
|
+
className: "grid min-h-56 flex-1 place-items-center px-6 py-10 text-center",
|
|
4002
|
+
role: error ? "alert" : "status",
|
|
4003
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4004
|
+
className: "max-w-sm",
|
|
4005
|
+
children: [
|
|
4006
|
+
/* @__PURE__ */ jsx("span", {
|
|
4007
|
+
className: clsx("mx-auto mb-3 grid size-10 place-items-center rounded-full border", error ? "border-(--clarify-code-danger-border) bg-(--clarify-code-danger-background) text-(--clarify-code-danger)" : "border-(--clarify-code-border) bg-(--clarify-code-control-background) text-(--clarify-code-muted)"),
|
|
4008
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
4009
|
+
className: "size-4.5",
|
|
4010
|
+
"aria-hidden": "true"
|
|
4011
|
+
})
|
|
4012
|
+
}),
|
|
4013
|
+
/* @__PURE__ */ jsx("p", {
|
|
4014
|
+
className: clsx("text-sm font-semibold", error ? "text-(--clarify-code-danger)" : "text-(--clarify-code-text)"),
|
|
4015
|
+
children: title
|
|
4016
|
+
}),
|
|
4017
|
+
/* @__PURE__ */ jsx("p", {
|
|
4018
|
+
className: "mt-1 text-xs/5 text-(--clarify-code-faint)",
|
|
4019
|
+
children: description
|
|
4020
|
+
})
|
|
4021
|
+
]
|
|
4022
|
+
})
|
|
4023
|
+
});
|
|
4024
|
+
}
|
|
4025
|
+
function CopyButton(arg0) {
|
|
4026
|
+
const { value } = arg0;
|
|
4027
|
+
const t = useBuiltInText();
|
|
4028
|
+
const [copied, setCopied] = useState(false);
|
|
4029
|
+
async function copy() {
|
|
4030
|
+
const success = await copyTextToClipboard(value);
|
|
4031
|
+
setCopied(success);
|
|
4032
|
+
if (success) window.setTimeout(() => setCopied(false), 1600);
|
|
4033
|
+
}
|
|
4034
|
+
return /* @__PURE__ */ jsx("button", {
|
|
4035
|
+
type: "button",
|
|
4036
|
+
onClick: copy,
|
|
4037
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
4038
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
4039
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) 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)",
|
|
4040
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
4041
|
+
className: "size-4 text-(--clarify-code-success)",
|
|
4042
|
+
"aria-hidden": "true"
|
|
4043
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
4044
|
+
className: "size-4",
|
|
4045
|
+
"aria-hidden": "true"
|
|
4046
|
+
})
|
|
4047
|
+
});
|
|
4048
|
+
}
|
|
4049
|
+
function ResponseMedia(arg0) {
|
|
4050
|
+
const { blob, type } = arg0;
|
|
4051
|
+
const elementRef = useRef(null);
|
|
4052
|
+
useEffect(() => {
|
|
4053
|
+
const element = elementRef.current;
|
|
4054
|
+
if (!element) return;
|
|
4055
|
+
const url = URL.createObjectURL(blob);
|
|
4056
|
+
element.src = url;
|
|
4057
|
+
return () => {
|
|
4058
|
+
element.removeAttribute("src");
|
|
4059
|
+
URL.revokeObjectURL(url);
|
|
4060
|
+
};
|
|
4061
|
+
}, [blob]);
|
|
4062
|
+
if (type === "image") return /* @__PURE__ */ jsx("img", {
|
|
4063
|
+
ref: elementRef,
|
|
4064
|
+
alt: "",
|
|
4065
|
+
className: "max-h-128 max-w-full object-contain"
|
|
4066
|
+
});
|
|
4067
|
+
if (type === "audio") return /* @__PURE__ */ jsx("audio", {
|
|
4068
|
+
ref: elementRef,
|
|
4069
|
+
controls: true,
|
|
4070
|
+
className: "w-full"
|
|
4071
|
+
});
|
|
4072
|
+
return /* @__PURE__ */ jsx("video", {
|
|
4073
|
+
ref: elementRef,
|
|
4074
|
+
controls: true,
|
|
4075
|
+
className: "max-h-128 max-w-full"
|
|
4076
|
+
});
|
|
4077
|
+
}
|
|
4078
|
+
function ResponsePreview(arg0) {
|
|
4079
|
+
const { exchange } = arg0;
|
|
4080
|
+
const t = useBuiltInText();
|
|
4081
|
+
const contentType = normalizedMediaType(exchange.contentType);
|
|
4082
|
+
if (!exchange.size) return /* @__PURE__ */ jsx(ResponseState, {
|
|
4083
|
+
icon: FileX2Icon,
|
|
4084
|
+
title: t("openapi.responseBodyEmptyTitle"),
|
|
4085
|
+
description: t("openapi.responseBodyEmpty")
|
|
4086
|
+
});
|
|
4087
|
+
if (contentType.startsWith("image/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
4088
|
+
blob: exchange.blob,
|
|
4089
|
+
type: "image"
|
|
4090
|
+
});
|
|
4091
|
+
if (contentType.startsWith("audio/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
4092
|
+
blob: exchange.blob,
|
|
4093
|
+
type: "audio"
|
|
4094
|
+
});
|
|
4095
|
+
if (contentType.startsWith("video/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
4096
|
+
blob: exchange.blob,
|
|
4097
|
+
type: "video"
|
|
4098
|
+
});
|
|
4099
|
+
if (contentType === "text/html" || contentType === "application/xhtml+xml") return /* @__PURE__ */ jsx("iframe", {
|
|
4100
|
+
srcDoc: exchange.body,
|
|
4101
|
+
sandbox: "",
|
|
4102
|
+
title: "Response preview",
|
|
4103
|
+
className: "h-96 w-full border-0 bg-white"
|
|
4104
|
+
});
|
|
4105
|
+
const textPreview = getResponseTextPreview(exchange.contentType, exchange.body);
|
|
4106
|
+
if (textPreview) return /* @__PURE__ */ jsx("pre", {
|
|
4107
|
+
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4108
|
+
children: /* @__PURE__ */ jsx(HighlightedCode, {
|
|
4109
|
+
code: textPreview.code,
|
|
4110
|
+
language: textPreview.language
|
|
4111
|
+
})
|
|
4112
|
+
});
|
|
4113
|
+
return /* @__PURE__ */ jsx("div", {
|
|
4114
|
+
className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
|
|
4115
|
+
children: t("openapi.binaryPreview")
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
function ResponseHeaders(arg0) {
|
|
4119
|
+
const { headers: sourceHeaders } = arg0;
|
|
4120
|
+
const t = useBuiltInText();
|
|
4121
|
+
const [query, setQuery] = useState("");
|
|
4122
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
4123
|
+
const headers = normalizedQuery ? sourceHeaders.filter(([name, value]) => `${name} ${value}`.toLowerCase().includes(normalizedQuery)) : sourceHeaders;
|
|
4124
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4125
|
+
/* @__PURE__ */ jsxs("label", {
|
|
4126
|
+
className: "flex h-9 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-control-background) px-3",
|
|
4127
|
+
children: [
|
|
4128
|
+
/* @__PURE__ */ jsx(SearchIcon, {
|
|
4129
|
+
className: "size-4 shrink-0 text-(--clarify-code-muted)",
|
|
4130
|
+
"aria-hidden": "true"
|
|
4131
|
+
}),
|
|
4132
|
+
/* @__PURE__ */ jsx("span", {
|
|
4133
|
+
className: "sr-only",
|
|
4134
|
+
children: t("openapi.searchHeaders")
|
|
4135
|
+
}),
|
|
4136
|
+
/* @__PURE__ */ jsx("input", {
|
|
4137
|
+
value: query,
|
|
4138
|
+
onChange: (event) => setQuery(event.target.value),
|
|
4139
|
+
placeholder: t("openapi.searchHeaders"),
|
|
4140
|
+
className: "min-w-0 flex-1 bg-transparent text-xs text-(--clarify-code-text) outline-none placeholder:text-(--clarify-code-faint)"
|
|
4141
|
+
})
|
|
4142
|
+
]
|
|
4143
|
+
}),
|
|
4144
|
+
/* @__PURE__ */ jsx("div", {
|
|
4145
|
+
className: "overflow-x-auto",
|
|
4146
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
4147
|
+
className: "w-full min-w-96 table-fixed border-collapse text-left font-mono text-xs/5",
|
|
4148
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
4149
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
4150
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
4151
|
+
/* @__PURE__ */ jsx("th", {
|
|
4152
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
4153
|
+
children: t("openapi.headerName")
|
|
4154
|
+
}),
|
|
4155
|
+
/* @__PURE__ */ jsx("th", {
|
|
4156
|
+
className: "px-3 py-2 font-semibold",
|
|
4157
|
+
children: t("openapi.headerValue")
|
|
4158
|
+
}),
|
|
4159
|
+
/* @__PURE__ */ jsx("th", {
|
|
4160
|
+
className: "w-10",
|
|
4161
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
4162
|
+
className: "sr-only",
|
|
4163
|
+
children: t("actions.copy")
|
|
4164
|
+
})
|
|
4165
|
+
})
|
|
4166
|
+
] })
|
|
4167
|
+
}), /* @__PURE__ */ jsx("tbody", { children: headers.map(([name, value], index) => /* @__PURE__ */ jsxs("tr", {
|
|
4168
|
+
className: "border-t border-(--clarify-code-border) hover:bg-(--clarify-code-control-background)",
|
|
4169
|
+
children: [
|
|
4170
|
+
/* @__PURE__ */ jsx("td", {
|
|
4171
|
+
className: "break-all border-r border-(--clarify-code-border) px-3 py-2 align-top text-(--clarify-code-property)",
|
|
4172
|
+
children: name
|
|
4173
|
+
}),
|
|
4174
|
+
/* @__PURE__ */ jsx("td", {
|
|
4175
|
+
className: "break-all px-3 py-2 align-top text-(--clarify-code-text)",
|
|
4176
|
+
children: value
|
|
4177
|
+
}),
|
|
4178
|
+
/* @__PURE__ */ jsx("td", {
|
|
4179
|
+
className: "pr-1",
|
|
4180
|
+
children: /* @__PURE__ */ jsx(CopyButton, { value: `${name}: ${value}` })
|
|
4181
|
+
})
|
|
4182
|
+
]
|
|
4183
|
+
}, `${name}:${index}`)) })]
|
|
4184
|
+
})
|
|
4185
|
+
}),
|
|
4186
|
+
headers.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
4187
|
+
className: "border-t border-(--clarify-code-border) py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
4188
|
+
children: t("openapi.noHeaders")
|
|
4189
|
+
}) : null
|
|
4190
|
+
] });
|
|
4191
|
+
}
|
|
4192
|
+
function HiddenCookies() {
|
|
4193
|
+
const t = useBuiltInText();
|
|
4194
|
+
return /* @__PURE__ */ jsxs("table", {
|
|
4195
|
+
className: "w-full table-fixed border-collapse text-left text-xs/5",
|
|
4196
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
4197
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
4198
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
4199
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
4200
|
+
children: t("openapi.headerName")
|
|
4201
|
+
}), /* @__PURE__ */ jsx("th", {
|
|
4202
|
+
className: "px-3 py-2 font-semibold",
|
|
4203
|
+
children: t("openapi.headerValue")
|
|
4204
|
+
})] })
|
|
4205
|
+
}), /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx("tr", {
|
|
4206
|
+
className: "border-t border-(--clarify-code-border)",
|
|
4207
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
4208
|
+
colSpan: 2,
|
|
4209
|
+
className: "px-3 py-5 text-center text-(--clarify-code-faint)",
|
|
4210
|
+
children: t("openapi.cookiesBrowserHidden")
|
|
4211
|
+
})
|
|
4212
|
+
}) })]
|
|
4213
|
+
});
|
|
4214
|
+
}
|
|
4215
|
+
function OpenApiResponseViewer(arg0) {
|
|
4216
|
+
const { exchange, error } = arg0;
|
|
4217
|
+
const t = useBuiltInText();
|
|
4218
|
+
const [bodyModeSelection, setBodyModeSelection] = useState();
|
|
4219
|
+
const previewAvailable = exchange ? canPreviewResponse(exchange.contentType) : false;
|
|
4220
|
+
const selectedBodyMode = bodyModeSelection && bodyModeSelection.exchange === exchange ? bodyModeSelection.mode : "preview";
|
|
4221
|
+
const activeBodyMode = previewAvailable ? selectedBodyMode : "raw";
|
|
4222
|
+
function downloadBody() {
|
|
4223
|
+
if (!exchange) return;
|
|
4224
|
+
const url = URL.createObjectURL(exchange.blob);
|
|
4225
|
+
const anchor = document.createElement("a");
|
|
4226
|
+
anchor.href = url;
|
|
4227
|
+
anchor.download = `response.${exchange.contentType.includes("json") ? "json" : "bin"}`;
|
|
4228
|
+
anchor.click();
|
|
4229
|
+
URL.revokeObjectURL(url);
|
|
4230
|
+
}
|
|
4231
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
4232
|
+
className: "clarify-api-response flex h-full min-h-96 min-w-0 flex-col bg-(--clarify-code-background) text-(--clarify-code-text)",
|
|
4233
|
+
"aria-label": t("openapi.response"),
|
|
4234
|
+
children: [
|
|
4235
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4236
|
+
className: "sticky top-0 z-10 flex min-h-11 flex-wrap items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-2.5 text-sm font-medium",
|
|
4237
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4238
|
+
className: "mr-auto text-(--clarify-code-text)",
|
|
4239
|
+
children: t("openapi.response")
|
|
4240
|
+
}), exchange ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
4241
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4242
|
+
className: "text-xs font-semibold text-(--clarify-code-muted)",
|
|
4243
|
+
children: [exchange.duration, " ms"]
|
|
4244
|
+
}),
|
|
4245
|
+
/* @__PURE__ */ jsx("span", {
|
|
4246
|
+
className: "text-xs text-(--clarify-code-faint)",
|
|
4247
|
+
children: formatBytes(exchange.size)
|
|
4248
|
+
}),
|
|
4249
|
+
/* @__PURE__ */ jsx("span", { className: clsx("size-2 rounded-full", exchange.status < 400 ? "bg-(--clarify-code-success)" : "bg-(--clarify-code-danger)") }),
|
|
4250
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4251
|
+
className: clsx("text-xs font-semibold", exchange.status < 400 ? "text-(--clarify-code-success)" : "text-(--clarify-code-danger)"),
|
|
4252
|
+
children: [
|
|
4253
|
+
exchange.status,
|
|
4254
|
+
" ",
|
|
4255
|
+
exchange.statusText
|
|
4256
|
+
]
|
|
4257
|
+
})
|
|
4258
|
+
] }) : null]
|
|
4259
|
+
}),
|
|
4260
|
+
error ? /* @__PURE__ */ jsx(ResponseState, {
|
|
4261
|
+
icon: CircleAlertIcon,
|
|
4262
|
+
title: t("openapi.responseErrorTitle"),
|
|
4263
|
+
description: error,
|
|
4264
|
+
tone: "error"
|
|
4265
|
+
}) : null,
|
|
4266
|
+
!error && !exchange ? /* @__PURE__ */ jsx(ResponseState, {
|
|
4267
|
+
icon: SendIcon,
|
|
4268
|
+
title: t("openapi.responseEmptyTitle"),
|
|
4269
|
+
description: t("openapi.responseEmpty")
|
|
4270
|
+
}) : null,
|
|
4271
|
+
exchange ? /* @__PURE__ */ jsxs("div", {
|
|
4272
|
+
className: "min-h-0 flex-1 overflow-auto",
|
|
4273
|
+
children: [
|
|
4274
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4275
|
+
title: t("openapi.cookies"),
|
|
4276
|
+
count: 0,
|
|
4277
|
+
children: /* @__PURE__ */ jsx(HiddenCookies, {})
|
|
4278
|
+
}),
|
|
4279
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4280
|
+
title: t("openapi.requestHeaders"),
|
|
4281
|
+
count: exchange.request.headers.length,
|
|
4282
|
+
children: /* @__PURE__ */ jsx(ResponseHeaders, { headers: exchange.request.headers })
|
|
4283
|
+
}),
|
|
4284
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4285
|
+
title: t("openapi.responseHeaders"),
|
|
4286
|
+
count: exchange.headers.length,
|
|
4287
|
+
children: /* @__PURE__ */ jsx(ResponseHeaders, { headers: exchange.headers })
|
|
4288
|
+
}),
|
|
4289
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4290
|
+
title: t("openapi.body"),
|
|
4291
|
+
defaultOpen: true,
|
|
4292
|
+
actions: /* @__PURE__ */ jsx("span", {
|
|
4293
|
+
className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
|
|
4294
|
+
children: exchange.contentType || t("openapi.unknownContentType")
|
|
4295
|
+
}),
|
|
4296
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4297
|
+
className: "min-h-72",
|
|
4298
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4299
|
+
className: "flex h-10 items-center justify-between border-b border-(--clarify-code-border) px-3",
|
|
4300
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4301
|
+
role: "tablist",
|
|
4302
|
+
className: "flex",
|
|
4303
|
+
children: ["preview", "raw"].filter((mode) => mode === "raw" || previewAvailable).map((mode) => /* @__PURE__ */ jsx("button", {
|
|
4304
|
+
type: "button",
|
|
4305
|
+
role: "tab",
|
|
4306
|
+
"aria-selected": activeBodyMode === mode,
|
|
4307
|
+
onClick: () => setBodyModeSelection({
|
|
4308
|
+
exchange,
|
|
4309
|
+
mode
|
|
4310
|
+
}),
|
|
4311
|
+
className: clsx("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)"),
|
|
4312
|
+
children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
|
|
4313
|
+
}, mode))
|
|
4314
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4315
|
+
className: "flex",
|
|
4316
|
+
children: [/* @__PURE__ */ jsx(CopyButton, { value: exchange.body }), /* @__PURE__ */ jsx("button", {
|
|
4317
|
+
type: "button",
|
|
4318
|
+
onClick: downloadBody,
|
|
4319
|
+
"aria-label": t("openapi.downloadBody"),
|
|
4320
|
+
title: t("openapi.downloadBody"),
|
|
4321
|
+
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)",
|
|
4322
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, {
|
|
4323
|
+
className: "size-4",
|
|
4324
|
+
"aria-hidden": "true"
|
|
4325
|
+
})
|
|
4326
|
+
})]
|
|
4327
|
+
})]
|
|
4328
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4329
|
+
className: "p-4",
|
|
4330
|
+
children: activeBodyMode === "preview" ? /* @__PURE__ */ jsx(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ jsx("pre", {
|
|
4331
|
+
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4332
|
+
children: exchange.body
|
|
4333
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
4334
|
+
className: "py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
4335
|
+
children: t("openapi.responseBodyEmpty")
|
|
4336
|
+
})
|
|
4337
|
+
})]
|
|
4338
|
+
})
|
|
4339
|
+
})
|
|
4340
|
+
]
|
|
4341
|
+
}) : null
|
|
4342
|
+
]
|
|
4343
|
+
});
|
|
4344
|
+
}
|
|
4345
|
+
//#endregion
|
|
4346
|
+
//#region source/openapi/components/SendRequestButton.tsx
|
|
4347
|
+
function SendRequestButton(arg0) {
|
|
4348
|
+
const { label, busy = false, text, onClick } = arg0;
|
|
4349
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
4350
|
+
type: "button",
|
|
4351
|
+
disabled: busy,
|
|
4352
|
+
"aria-label": label,
|
|
4353
|
+
title: label,
|
|
4354
|
+
onClick,
|
|
4355
|
+
className: Boolean(text) ? "flex h-8 shrink-0 items-center gap-1.5 rounded bg-(--clarify-theme-tokens-colors-foreground) px-3 text-xs font-semibold text-(--clarify-theme-tokens-colors-background) transition hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60" : "grid size-7 shrink-0 place-items-center rounded bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors hover:bg-(--clarify-theme-tokens-colors-foreground) hover:text-(--clarify-theme-tokens-colors-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60",
|
|
4356
|
+
children: [busy ? /* @__PURE__ */ jsx(LoaderCircleIcon, {
|
|
4357
|
+
className: "size-4 animate-spin",
|
|
4358
|
+
"aria-hidden": "true"
|
|
4359
|
+
}) : /* @__PURE__ */ jsx(SendIcon, {
|
|
4360
|
+
className: "size-4",
|
|
4361
|
+
"aria-hidden": "true"
|
|
4362
|
+
}), text]
|
|
4363
|
+
});
|
|
4364
|
+
}
|
|
4365
|
+
//#endregion
|
|
4366
|
+
//#region source/openapi/lib/api-exchange.ts
|
|
4367
|
+
var ApiRequestError = class extends Error {
|
|
4368
|
+
category;
|
|
4369
|
+
constructor(message, options) {
|
|
4370
|
+
super(message, options);
|
|
4371
|
+
this.name = "ApiRequestError";
|
|
4372
|
+
this.category = "network";
|
|
4373
|
+
}
|
|
4374
|
+
};
|
|
4375
|
+
function requestBodySnapshot(body) {
|
|
4376
|
+
if (typeof body === "string") return body;
|
|
4377
|
+
if (body instanceof URLSearchParams) return body.toString();
|
|
4378
|
+
}
|
|
4379
|
+
function requestSnapshot(request) {
|
|
4380
|
+
return {
|
|
4381
|
+
url: request.url,
|
|
4382
|
+
method: request.init.method ?? "GET",
|
|
4383
|
+
headers: Array.from(new Headers(request.init.headers).entries()),
|
|
4384
|
+
body: requestBodySnapshot(request.init.body)
|
|
4385
|
+
};
|
|
4386
|
+
}
|
|
4387
|
+
async function executeApiRequest(request, options = {}) {
|
|
4388
|
+
const fetchRequest = options.fetch ?? fetch;
|
|
4389
|
+
const now = options.now ?? (() => performance.now());
|
|
4390
|
+
const startedAt = now();
|
|
4391
|
+
let response;
|
|
4392
|
+
try {
|
|
4393
|
+
response = await fetchRequest(request.url, {
|
|
4394
|
+
...request.init,
|
|
4395
|
+
signal: options.signal
|
|
4396
|
+
});
|
|
4397
|
+
} catch (cause) {
|
|
4398
|
+
if (cause instanceof DOMException && cause.name === "AbortError") throw cause;
|
|
4399
|
+
throw new ApiRequestError(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
4400
|
+
}
|
|
4401
|
+
const blob = await response.blob();
|
|
4402
|
+
return {
|
|
4403
|
+
request: requestSnapshot(request),
|
|
4404
|
+
status: response.status,
|
|
4405
|
+
statusText: response.statusText,
|
|
4406
|
+
url: response.url || request.url,
|
|
4407
|
+
redirected: response.redirected,
|
|
4408
|
+
duration: Math.round(now() - startedAt),
|
|
4409
|
+
size: blob.size,
|
|
4410
|
+
headers: Array.from(response.headers.entries()),
|
|
4411
|
+
contentType: response.headers.get("content-type") ?? blob.type,
|
|
4412
|
+
body: await blob.text(),
|
|
4413
|
+
blob
|
|
4414
|
+
};
|
|
4415
|
+
}
|
|
4416
|
+
//#endregion
|
|
4417
|
+
//#region source/openapi/lib/request-parameters.ts
|
|
4418
|
+
function structuredIssue(value, type) {
|
|
4419
|
+
if (!type.includes("[]") && !type.includes("object")) return void 0;
|
|
4420
|
+
try {
|
|
4421
|
+
const parsed = JSON.parse(value);
|
|
4422
|
+
if (type.includes("[]") && !Array.isArray(parsed)) return "invalidArray";
|
|
4423
|
+
if (type.includes("object") && !isRecord$1(parsed)) return "invalidObject";
|
|
4424
|
+
} catch {
|
|
4425
|
+
return type.includes("[]") ? "invalidArray" : "invalidObject";
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
function scalarIssue(value, type, format) {
|
|
4429
|
+
if (type.includes("integer") && !Number.isInteger(Number(value))) return "invalidInteger";
|
|
4430
|
+
if (type.includes("number") && !Number.isFinite(Number(value))) return "invalidNumber";
|
|
4431
|
+
if (format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return "invalidDate";
|
|
4432
|
+
if (format === "date-time" && Number.isNaN(Date.parse(value))) return "invalidDateTime";
|
|
4433
|
+
}
|
|
4434
|
+
function validateRequestParameter(spec, parameter, value) {
|
|
4435
|
+
if (!value) return parameter.required ? "required" : void 0;
|
|
4436
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4437
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4438
|
+
const type = schemaToType(schema) ?? "string";
|
|
4439
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
4440
|
+
if (options.length > 0 && !options.includes(value)) return "invalidEnum";
|
|
4441
|
+
return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
|
|
4442
|
+
}
|
|
4443
|
+
function validateRequestParameters(spec, parameters, values) {
|
|
4444
|
+
return Object.fromEntries(parameters.filter((parameter) => parameter.in !== "cookie").flatMap((parameter) => {
|
|
4445
|
+
const key = parameterKey(parameter);
|
|
4446
|
+
const issue = validateRequestParameter(spec, parameter, values[key] ?? "");
|
|
4447
|
+
return issue ? [[key, issue]] : [];
|
|
4448
|
+
}));
|
|
4449
|
+
}
|
|
4450
|
+
//#endregion
|
|
4451
|
+
//#region source/openapi/components/useOpenApiRequestState.ts
|
|
4452
|
+
function initialRequestBody(spec, content) {
|
|
4453
|
+
const example = getExampleEntries(content, spec)[0];
|
|
4454
|
+
if (!example?.generated) return stringifyExample(example?.value);
|
|
4455
|
+
const schema = resolveSchema(spec, content?.schema);
|
|
4456
|
+
if (isRecord$1(schema) && schema.format === "binary") return "";
|
|
4457
|
+
if (!isRecord$1(example.value) || !isRecord$1(schema) || !isRecord$1(schema.properties)) return stringifyExample(example.value);
|
|
4458
|
+
const value = { ...example.value };
|
|
4459
|
+
Object.entries(schema.properties).forEach(([name, propertySchema]) => {
|
|
4460
|
+
const resolved = resolveSchema(spec, propertySchema);
|
|
4461
|
+
if (isRecord$1(resolved) && resolved.format === "binary") delete value[name];
|
|
4462
|
+
});
|
|
4463
|
+
return stringifyExample(value);
|
|
4464
|
+
}
|
|
4465
|
+
function requestBodyForExample(spec, content, exampleKey) {
|
|
4466
|
+
const example = getExampleEntries(content, spec).find((entry) => !entry.generated && entry.key === exampleKey);
|
|
4467
|
+
return example ? stringifyExample(example.value) : initialRequestBody(spec, content);
|
|
4468
|
+
}
|
|
4469
|
+
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4470
|
+
const servers = getServers(spec, operation, path, operationSource);
|
|
4471
|
+
const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
|
|
4472
|
+
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
4473
|
+
const [serverVariables, setServerVariables] = useState(defaultServerVariables(selectedServer));
|
|
4474
|
+
const authOptions = getAuthOptions(spec, operation);
|
|
4475
|
+
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.key ?? "");
|
|
4476
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
4477
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
4478
|
+
const credentials = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
4479
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
4480
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
4481
|
+
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4482
|
+
const [mediaType, setMediaType] = useState(requestContents[0]?.mediaType ?? "");
|
|
4483
|
+
const selectedContent = requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0];
|
|
4484
|
+
const [body, setBody] = useState(initialRequestBody(spec, selectedContent?.value));
|
|
4485
|
+
const [bodyFiles, setBodyFiles] = useState({});
|
|
4486
|
+
function selectServer(value) {
|
|
4487
|
+
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
4488
|
+
setSelectedServerKey(value);
|
|
4489
|
+
setServerVariables(defaultServerVariables(nextServer));
|
|
4490
|
+
}
|
|
4491
|
+
function selectMediaType(value) {
|
|
4492
|
+
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4493
|
+
setMediaType(value);
|
|
4494
|
+
setBody(initialRequestBody(spec, content));
|
|
4495
|
+
setBodyFiles({});
|
|
4496
|
+
}
|
|
4497
|
+
function applyBodyExample(exampleKey) {
|
|
4498
|
+
setBody(requestBodyForExample(spec, selectedContent?.value, exampleKey));
|
|
4499
|
+
setBodyFiles({});
|
|
4500
|
+
}
|
|
4501
|
+
function setBodyFile(name, file) {
|
|
4502
|
+
setBodyFiles((current) => {
|
|
4503
|
+
const next = { ...current };
|
|
4504
|
+
if (file) next[name] = file;
|
|
4505
|
+
else delete next[name];
|
|
4506
|
+
return next;
|
|
4507
|
+
});
|
|
4508
|
+
}
|
|
4509
|
+
return {
|
|
4510
|
+
servers,
|
|
4511
|
+
selectedServer,
|
|
4512
|
+
selectedServerKey,
|
|
4513
|
+
serverVariables,
|
|
4514
|
+
setServerVariables,
|
|
4515
|
+
serverVariableEntries: Object.entries(selectedServer.variables ?? {}),
|
|
4516
|
+
selectServer,
|
|
4517
|
+
authOptions,
|
|
4518
|
+
selectedAuthName,
|
|
4519
|
+
setSelectedAuthName,
|
|
4520
|
+
selectedAuth,
|
|
4521
|
+
credentialScope,
|
|
4522
|
+
credentials,
|
|
4523
|
+
setCredential,
|
|
4524
|
+
clearCredential,
|
|
4525
|
+
requestContents,
|
|
4526
|
+
mediaType,
|
|
4527
|
+
selectedContent,
|
|
4528
|
+
body,
|
|
4529
|
+
setBody,
|
|
4530
|
+
bodyFiles,
|
|
4531
|
+
setBodyFile,
|
|
4532
|
+
applyBodyExample,
|
|
4533
|
+
selectMediaType
|
|
4534
|
+
};
|
|
4535
|
+
}
|
|
4536
|
+
function useOpenApiParameterState(spec, parameters, initialParameterValue, initialExampleKey = "") {
|
|
4537
|
+
const [parameterValues, setParameterValues] = useState(() => Object.fromEntries(parameters.map((parameter) => {
|
|
4538
|
+
const example = getParameterExampleEntries(parameter).find((entry) => entry.key === initialExampleKey);
|
|
4539
|
+
return [parameterKey(parameter), example ? stringifyExample(example.value) : initialParameterValue(parameter)];
|
|
4540
|
+
})));
|
|
4541
|
+
const [parameterEnabled, setParameterEnabled] = useState(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
|
|
4542
|
+
const [parameterIssues, setParameterIssues] = useState({});
|
|
4543
|
+
function setParameterGroupValues(grouped, mode) {
|
|
4544
|
+
const keys = new Set(grouped.map(parameterKey));
|
|
4545
|
+
setParameterValues((current) => ({
|
|
4546
|
+
...current,
|
|
4547
|
+
...Object.fromEntries(grouped.map((parameter) => [parameterKey(parameter), mode === "reset" ? initialParameterValue(parameter) : ""]))
|
|
4548
|
+
}));
|
|
4549
|
+
setParameterIssues((current) => Object.fromEntries(Object.entries(current).filter(([key]) => !keys.has(key))));
|
|
4550
|
+
}
|
|
4551
|
+
function setParameterIncluded(parameter, enabled) {
|
|
4552
|
+
const key = parameterKey(parameter);
|
|
4553
|
+
setParameterEnabled((current) => ({
|
|
4554
|
+
...current,
|
|
4555
|
+
[key]: enabled
|
|
4556
|
+
}));
|
|
4557
|
+
if (!enabled) setParameterIssues((current) => {
|
|
4558
|
+
const next = { ...current };
|
|
4559
|
+
delete next[key];
|
|
4560
|
+
return next;
|
|
4561
|
+
});
|
|
4562
|
+
}
|
|
4563
|
+
function updateParameterValue(parameter, value) {
|
|
4564
|
+
const key = parameterKey(parameter);
|
|
4565
|
+
setParameterValues((current) => ({
|
|
4566
|
+
...current,
|
|
4567
|
+
[key]: value
|
|
4568
|
+
}));
|
|
4569
|
+
setParameterIssues((current) => {
|
|
4570
|
+
const next = { ...current };
|
|
4571
|
+
delete next[key];
|
|
4572
|
+
return next;
|
|
4573
|
+
});
|
|
4574
|
+
}
|
|
4575
|
+
function applyParameterExample(exampleKey) {
|
|
4576
|
+
setParameterValues(Object.fromEntries(parameters.map((parameter) => {
|
|
4577
|
+
const example = getParameterExampleEntries(parameter).find((entry) => entry.key === exampleKey);
|
|
4578
|
+
return [parameterKey(parameter), example ? stringifyExample(example.value) : initialParameterValue(parameter)];
|
|
4579
|
+
})));
|
|
4580
|
+
setParameterIssues({});
|
|
4581
|
+
}
|
|
4582
|
+
function validate(parametersToValidate) {
|
|
4583
|
+
const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
|
|
4584
|
+
setParameterIssues(issues);
|
|
4585
|
+
return issues;
|
|
4586
|
+
}
|
|
4587
|
+
return {
|
|
4588
|
+
parameterValues,
|
|
4589
|
+
parameterEnabled,
|
|
4590
|
+
parameterIssues,
|
|
4591
|
+
setParameterGroupValues,
|
|
4592
|
+
setParameterIncluded,
|
|
4593
|
+
updateParameterValue,
|
|
4594
|
+
applyParameterExample,
|
|
4595
|
+
validate
|
|
4596
|
+
};
|
|
4597
|
+
}
|
|
4598
|
+
function useOpenApiRequestExecution() {
|
|
4599
|
+
const [exchange, setExchange] = useState();
|
|
4600
|
+
const [error, setError] = useState("");
|
|
4601
|
+
const [sending, setSending] = useState(false);
|
|
4602
|
+
const requestController = useRef(null);
|
|
4603
|
+
useEffect(() => () => requestController.current?.abort(), []);
|
|
4604
|
+
async function execute(request, corsHint) {
|
|
4605
|
+
requestController.current?.abort();
|
|
4606
|
+
const controller = new AbortController();
|
|
4607
|
+
requestController.current = controller;
|
|
4608
|
+
setSending(true);
|
|
4609
|
+
setError("");
|
|
4610
|
+
setExchange(void 0);
|
|
4611
|
+
try {
|
|
4612
|
+
setExchange(await executeApiRequest(request, { signal: controller.signal }));
|
|
4613
|
+
} catch (cause) {
|
|
4614
|
+
if (cause instanceof DOMException && cause.name === "AbortError") return;
|
|
4615
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4616
|
+
setError(`${message}. ${corsHint}`);
|
|
4617
|
+
} finally {
|
|
4618
|
+
if (requestController.current === controller) {
|
|
4619
|
+
requestController.current = null;
|
|
4620
|
+
setSending(false);
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4623
|
+
}
|
|
4624
|
+
return {
|
|
4625
|
+
exchange,
|
|
4626
|
+
error,
|
|
4627
|
+
sending,
|
|
4628
|
+
execute
|
|
4629
|
+
};
|
|
4630
|
+
}
|
|
4631
|
+
//#endregion
|
|
4632
|
+
//#region source/openapi/components/OpenApiRequest.tsx
|
|
4633
|
+
function initialParameterValue(spec, parameter) {
|
|
4634
|
+
if (typeof parameter.example !== "undefined") return stringifyExample(parameter.example);
|
|
4635
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4636
|
+
if (!isRecord$1(schema)) return "";
|
|
4637
|
+
return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
|
|
4638
|
+
}
|
|
4639
|
+
function parameterGroupLabel(location, t) {
|
|
4640
|
+
if (location === "path") return t("openapi.pathParameters");
|
|
4641
|
+
if (location === "header") return t("openapi.headers");
|
|
4642
|
+
if (location === "cookie") return t("openapi.cookies");
|
|
4643
|
+
return t("openapi.queryParameters");
|
|
4644
|
+
}
|
|
4645
|
+
function OpenApiRequestWorkbench(arg0) {
|
|
4646
|
+
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4647
|
+
const t = useBuiltInText();
|
|
4648
|
+
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4649
|
+
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);
|
|
4650
|
+
const requestExamples = getRequestExampleEntries(parameters, selectedContent?.value);
|
|
4651
|
+
const [selectedRequestExampleKey, setSelectedRequestExampleKey] = useState(requestExamples[0]?.key ?? "");
|
|
4652
|
+
const currentRequestExampleKey = requestExamples.some((example) => example.key === selectedRequestExampleKey) ? selectedRequestExampleKey : requestExamples[0]?.key ?? "";
|
|
4653
|
+
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter), currentRequestExampleKey);
|
|
4654
|
+
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue, applyParameterExample } = parameterState;
|
|
4655
|
+
const { exchange, error, sending, execute } = useOpenApiRequestExecution();
|
|
4656
|
+
const parameterGroups = [
|
|
4657
|
+
"cookie",
|
|
4658
|
+
"header",
|
|
4659
|
+
"query"
|
|
4660
|
+
].map((location) => ({
|
|
4661
|
+
location,
|
|
4662
|
+
parameters: parameters.filter((parameter) => parameter.in === location)
|
|
4663
|
+
})).filter((group) => group.parameters.length > 0);
|
|
4664
|
+
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4665
|
+
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4666
|
+
function applyRequestExample(exampleKey) {
|
|
4667
|
+
setSelectedRequestExampleKey(exampleKey);
|
|
4668
|
+
applyParameterExample(exampleKey);
|
|
4669
|
+
applyBodyExample(exampleKey);
|
|
4670
|
+
}
|
|
4671
|
+
function selectRequestMediaType(value) {
|
|
4672
|
+
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4673
|
+
const nextExampleKey = getRequestExampleEntries(parameters, content)[0]?.key ?? "";
|
|
4674
|
+
selectMediaType(value);
|
|
4675
|
+
setSelectedRequestExampleKey(nextExampleKey);
|
|
4676
|
+
applyParameterExample(nextExampleKey);
|
|
4677
|
+
}
|
|
4678
|
+
async function sendRequest() {
|
|
4679
|
+
const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
|
|
4680
|
+
const issues = parameterState.validate(enabledParameters);
|
|
4681
|
+
if (Object.keys(issues).length > 0) return;
|
|
4682
|
+
await execute(buildApiRequest({
|
|
4683
|
+
method,
|
|
4684
|
+
path,
|
|
4685
|
+
server: selectedServer,
|
|
4686
|
+
serverVariables,
|
|
4687
|
+
parameters,
|
|
4688
|
+
parameterValues,
|
|
4689
|
+
parameterEnabled,
|
|
4690
|
+
auth: selectedAuth?.schemes.map((option) => ({
|
|
4691
|
+
scheme: option.scheme,
|
|
4692
|
+
value: credentials[option.name] ?? ""
|
|
4693
|
+
})),
|
|
4694
|
+
mediaType,
|
|
4695
|
+
body,
|
|
4696
|
+
bodyFiles,
|
|
4697
|
+
baseUrl: window.location.href
|
|
4698
|
+
}), t("openapi.requestCorsHint"));
|
|
4699
|
+
}
|
|
4700
|
+
function renderParameterField(parameter) {
|
|
4701
|
+
const key = parameterKey(parameter);
|
|
4702
|
+
return /* @__PURE__ */ jsx(RequestField, {
|
|
4703
|
+
spec,
|
|
4704
|
+
parameter,
|
|
4705
|
+
value: parameterValues[key] ?? "",
|
|
4706
|
+
enabled: parameterEnabled[key] !== false,
|
|
4707
|
+
issue: parameterIssues[key],
|
|
4708
|
+
onEnabledChange: (enabled) => setParameterIncluded(parameter, enabled),
|
|
4709
|
+
onChange: (value) => updateParameterValue(parameter, value)
|
|
4710
|
+
}, key);
|
|
4711
|
+
}
|
|
4712
|
+
function renderParameterGroup(group) {
|
|
4713
|
+
const { location, parameters: grouped } = group;
|
|
4714
|
+
const actions = location === "cookie" ? void 0 : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
4715
|
+
type: "button",
|
|
4716
|
+
title: t("openapi.resetToExample"),
|
|
4717
|
+
"aria-label": t("openapi.resetToExample"),
|
|
4718
|
+
onClick: () => setParameterGroupValues(grouped, "reset"),
|
|
4719
|
+
className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4720
|
+
children: /* @__PURE__ */ jsx(RotateCcwIcon, {
|
|
4721
|
+
className: "size-3.5",
|
|
4722
|
+
"aria-hidden": "true"
|
|
4723
|
+
})
|
|
4724
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
4725
|
+
type: "button",
|
|
4726
|
+
title: t("openapi.clear"),
|
|
4727
|
+
"aria-label": t("openapi.clear"),
|
|
4728
|
+
onClick: () => setParameterGroupValues(grouped, "clear"),
|
|
4729
|
+
className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4730
|
+
children: /* @__PURE__ */ jsx(EraserIcon, {
|
|
4731
|
+
className: "size-3.5",
|
|
4732
|
+
"aria-hidden": "true"
|
|
4733
|
+
})
|
|
4734
|
+
})] });
|
|
4735
|
+
return /* @__PURE__ */ jsx(RequestSection, {
|
|
4736
|
+
title: parameterGroupLabel(location, t),
|
|
4737
|
+
count: grouped.length,
|
|
4738
|
+
defaultOpen: true,
|
|
4739
|
+
actions,
|
|
4740
|
+
children: location === "cookie" ? /* @__PURE__ */ jsx("p", {
|
|
4741
|
+
className: "px-3 py-4 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4742
|
+
children: t("openapi.cookieParametersBrowserManaged")
|
|
4743
|
+
}) : grouped.map(renderParameterField)
|
|
4744
|
+
}, location);
|
|
4745
|
+
}
|
|
4746
|
+
function renderHeader() {
|
|
4747
|
+
return /* @__PURE__ */ jsx("div", {
|
|
4748
|
+
className: "border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface)",
|
|
4749
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4750
|
+
className: "grid min-w-0 grid-cols-[auto_auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 px-2.5 py-2 lg:grid-cols-[auto_auto_minmax(0,1fr)_minmax(0,14rem)_auto_auto]",
|
|
4751
|
+
children: [
|
|
4752
|
+
/* @__PURE__ */ jsx("div", {
|
|
4753
|
+
className: "col-start-1 row-start-1",
|
|
4754
|
+
children: /* @__PURE__ */ jsx(EndpointMethodBadge, { method: method.toUpperCase() })
|
|
4755
|
+
}),
|
|
4756
|
+
servers.length > 0 ? /* @__PURE__ */ jsx(InlineListbox, {
|
|
4757
|
+
label: t("openapi.server"),
|
|
4758
|
+
value: selectedServerKey,
|
|
4759
|
+
options: servers.map((server, index) => ({
|
|
4760
|
+
value: getServerKey(server, index),
|
|
4761
|
+
label: server.url ?? `Server ${index + 1}`,
|
|
4762
|
+
description: server.description
|
|
4763
|
+
})),
|
|
4764
|
+
onChange: selectServer,
|
|
4765
|
+
title: selectedServer.url ?? t("openapi.server"),
|
|
4766
|
+
buttonContent: /* @__PURE__ */ jsx(ServerIcon, {
|
|
4767
|
+
className: "size-4",
|
|
4768
|
+
"aria-hidden": "true"
|
|
4769
|
+
}),
|
|
4770
|
+
className: "col-start-2 row-start-1 size-8 shrink-0",
|
|
4771
|
+
buttonClassName: "grid size-8 place-items-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-soft) outline-hidden transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) data-open:bg-(--clarify-ui-active-background)"
|
|
4772
|
+
}) : null,
|
|
4773
|
+
/* @__PURE__ */ jsx("span", {
|
|
4774
|
+
className: "col-start-3 row-start-1 min-w-0 truncate border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
|
|
4775
|
+
title: path || "/",
|
|
4776
|
+
children: path || "/"
|
|
4777
|
+
}),
|
|
4778
|
+
requestExamples.length > 1 ? /* @__PURE__ */ jsxs("div", {
|
|
4779
|
+
className: "col-span-full row-start-2 flex min-w-0 items-center gap-0.5 border-t border-(--clarify-theme-tokens-colors-border) pt-2 lg:col-span-1 lg:col-start-4 lg:row-start-1 lg:border-t-0 lg:pt-0",
|
|
4780
|
+
children: [/* @__PURE__ */ jsx(InlineListbox, {
|
|
4781
|
+
label: t("openapi.requestExample"),
|
|
4782
|
+
value: currentRequestExampleKey,
|
|
4783
|
+
options: requestExamples.map((example) => ({
|
|
4784
|
+
value: example.key,
|
|
4785
|
+
label: example.title,
|
|
4786
|
+
description: example.summary
|
|
4787
|
+
})),
|
|
4788
|
+
onChange: applyRequestExample,
|
|
4789
|
+
className: "min-w-0 flex-1",
|
|
4790
|
+
buttonClassName: "flex h-8 w-full min-w-0 max-w-full items-center gap-1 rounded-(--clarify-theme-tokens-radius-md) px-2 text-xs font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)"
|
|
4791
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
4792
|
+
type: "button",
|
|
4793
|
+
title: t("openapi.resetToExample"),
|
|
4794
|
+
"aria-label": t("openapi.resetToExample"),
|
|
4795
|
+
onClick: () => applyRequestExample(currentRequestExampleKey),
|
|
4796
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4797
|
+
children: /* @__PURE__ */ jsx(RotateCcwIcon, {
|
|
4798
|
+
className: "size-3.5",
|
|
4799
|
+
"aria-hidden": "true"
|
|
4800
|
+
})
|
|
4801
|
+
})]
|
|
4802
|
+
}) : null,
|
|
4803
|
+
/* @__PURE__ */ jsx("div", {
|
|
4804
|
+
className: "col-start-4 row-start-1 lg:col-start-5",
|
|
4805
|
+
children: /* @__PURE__ */ jsx(SendRequestButton, {
|
|
4806
|
+
label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
|
|
4807
|
+
busy: sending,
|
|
4808
|
+
text: t("openapi.sendRequest"),
|
|
4809
|
+
onClick: sendRequest
|
|
4810
|
+
})
|
|
4811
|
+
}),
|
|
4812
|
+
onClose ? /* @__PURE__ */ jsx("button", {
|
|
4813
|
+
type: "button",
|
|
4814
|
+
onClick: onClose,
|
|
4815
|
+
"aria-label": t("openapi.closeRequest"),
|
|
4816
|
+
title: t("openapi.closeRequest"),
|
|
4817
|
+
className: "col-start-5 row-start-1 grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) lg:col-start-6",
|
|
4818
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
4819
|
+
className: "size-4",
|
|
4820
|
+
"aria-hidden": "true"
|
|
4821
|
+
})
|
|
4822
|
+
}) : null
|
|
4823
|
+
]
|
|
4824
|
+
})
|
|
4825
|
+
});
|
|
4826
|
+
}
|
|
4827
|
+
function renderVariables() {
|
|
4828
|
+
if (serverVariableEntries.length === 0) return null;
|
|
4829
|
+
return /* @__PURE__ */ jsx(RequestSection, {
|
|
4830
|
+
title: t("openapi.variables"),
|
|
4831
|
+
count: serverVariableEntries.length,
|
|
4832
|
+
defaultOpen: true,
|
|
4833
|
+
children: serverVariableEntries.map(([name, variable]) => /* @__PURE__ */ jsxs("label", {
|
|
4834
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
4835
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4836
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
4837
|
+
children: name
|
|
4838
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
4839
|
+
value: serverVariables[name] ?? variable.default ?? "",
|
|
4840
|
+
onChange: (event) => setServerVariables((current) => ({
|
|
4841
|
+
...current,
|
|
4842
|
+
[name]: event.target.value
|
|
4843
|
+
})),
|
|
4844
|
+
className: "h-8 min-w-0 border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background) focus:ring-0"
|
|
4845
|
+
})]
|
|
4846
|
+
}, name))
|
|
4847
|
+
});
|
|
4848
|
+
}
|
|
4849
|
+
function renderRequestBody() {
|
|
4850
|
+
if (requestContents.length === 0) return null;
|
|
4851
|
+
return /* @__PURE__ */ jsxs(RequestSection, {
|
|
4852
|
+
title: t("openapi.requestBody"),
|
|
4853
|
+
count: 1,
|
|
4854
|
+
defaultOpen: true,
|
|
4855
|
+
className: "open:grid open:min-h-55 open:grow open:shrink open:basis-55 open:grid-rows-[auto_minmax(11rem,1fr)]",
|
|
4856
|
+
contentClassName: clsx("grid h-full min-h-0", requestContents.length > 1 ? "grid-rows-[auto_minmax(11rem,1fr)]" : "grid-rows-[minmax(11rem,1fr)]"),
|
|
4857
|
+
children: [requestContents.length > 1 ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(InlineListbox, {
|
|
4858
|
+
label: t("openapi.mediaType"),
|
|
4859
|
+
value: mediaType,
|
|
4860
|
+
options: requestContents.map((entry) => ({
|
|
4861
|
+
value: entry.mediaType,
|
|
4862
|
+
label: entry.mediaType
|
|
4863
|
+
})),
|
|
4864
|
+
onChange: selectRequestMediaType
|
|
4865
|
+
}) }) : null, /* @__PURE__ */ jsx(OpenApiRequestBodyEditor, {
|
|
4866
|
+
spec,
|
|
4867
|
+
mediaType,
|
|
4868
|
+
content: selectedContent?.value,
|
|
4869
|
+
body,
|
|
4870
|
+
files: bodyFiles,
|
|
4871
|
+
onBodyChange: setBody,
|
|
4872
|
+
onFileChange: setBodyFile
|
|
4873
|
+
})]
|
|
4874
|
+
});
|
|
4875
|
+
}
|
|
4876
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4877
|
+
className: clsx("clarify-api-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-theme-tokens-radius-lg:6px] [--clarify-theme-tokens-radius-md:4px] [--clarify-theme-tokens-radius-sm:2px] [--clarify-theme-tokens-radius-xl:8px] [--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"),
|
|
4878
|
+
children: [renderHeader(), /* @__PURE__ */ jsxs("div", {
|
|
4879
|
+
className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
|
|
4880
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4881
|
+
className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
|
|
4882
|
+
children: [
|
|
4883
|
+
authOptions.length > 0 ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4884
|
+
title: t("openapi.authentication"),
|
|
4885
|
+
count: selectedAuth?.schemes.length ?? 0,
|
|
4886
|
+
defaultOpen: true,
|
|
4887
|
+
children: /* @__PURE__ */ jsx(OpenApiAuthPanel, {
|
|
4888
|
+
authOptions,
|
|
4889
|
+
selectedAuthName,
|
|
4890
|
+
selectedAuth,
|
|
4891
|
+
authValues: credentials,
|
|
4892
|
+
onSelectAuth: setSelectedAuthName,
|
|
4893
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
4894
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name)
|
|
4895
|
+
})
|
|
4896
|
+
}) : null,
|
|
4897
|
+
renderVariables(),
|
|
4898
|
+
pathParameters.length > 0 ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4899
|
+
title: t("openapi.pathParameters"),
|
|
4900
|
+
count: pathParameters.length,
|
|
4901
|
+
defaultOpen: true,
|
|
4902
|
+
children: pathParameters.map(renderParameterField)
|
|
4903
|
+
}) : null,
|
|
4904
|
+
parameterGroups.map(renderParameterGroup),
|
|
4905
|
+
renderRequestBody(),
|
|
4906
|
+
!hasRequestConfiguration ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4907
|
+
title: t("openapi.requestConfiguration"),
|
|
4908
|
+
count: 0,
|
|
4909
|
+
defaultOpen: true,
|
|
4910
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
4911
|
+
className: "px-3 py-5 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4912
|
+
children: t("openapi.noRequestConfiguration")
|
|
4913
|
+
})
|
|
4914
|
+
}) : null
|
|
4915
|
+
]
|
|
4916
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4917
|
+
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",
|
|
4918
|
+
children: /* @__PURE__ */ jsx(OpenApiResponseViewer, {
|
|
4919
|
+
exchange,
|
|
4920
|
+
error
|
|
4921
|
+
})
|
|
4922
|
+
})]
|
|
4923
|
+
})]
|
|
4924
|
+
});
|
|
4925
|
+
}
|
|
4926
|
+
function OpenApiRequestDialog(arg0) {
|
|
4927
|
+
const { open, onClose, ...workbenchProps } = arg0;
|
|
4928
|
+
const t = useBuiltInText();
|
|
4929
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
4930
|
+
open,
|
|
4931
|
+
onClose: () => {},
|
|
4932
|
+
className: "relative z-50",
|
|
4933
|
+
children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ jsx("div", {
|
|
4934
|
+
className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
|
|
4935
|
+
children: /* @__PURE__ */ jsxs(DialogPanel, {
|
|
4936
|
+
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))]",
|
|
4937
|
+
children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
4938
|
+
className: "sr-only",
|
|
4939
|
+
children: t("openapi.tryRequest")
|
|
4940
|
+
}), /* @__PURE__ */ jsx(OpenApiRequestWorkbench, {
|
|
4941
|
+
...workbenchProps,
|
|
4942
|
+
compact: true,
|
|
4943
|
+
onClose
|
|
4944
|
+
})]
|
|
4945
|
+
})
|
|
4946
|
+
})]
|
|
4947
|
+
});
|
|
4948
|
+
}
|
|
4949
|
+
//#endregion
|
|
4950
|
+
//#region source/openapi/components/OpenApiOperation.tsx
|
|
4951
|
+
function EndpointPath(arg0) {
|
|
4952
|
+
const { path, copied = false, onCopy } = arg0;
|
|
4953
|
+
const t = useBuiltInText();
|
|
4954
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4955
|
+
className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
|
|
4956
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4957
|
+
className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
|
|
4958
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
4959
|
+
className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
|
|
4960
|
+
children: path || "/"
|
|
4961
|
+
})
|
|
4962
|
+
}), onCopy ? /* @__PURE__ */ jsx("button", {
|
|
4963
|
+
type: "button",
|
|
4964
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
4965
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
4966
|
+
onClick: onCopy,
|
|
4967
|
+
className: clsx("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
|
|
4968
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
4969
|
+
className: "h-3.5 w-3.5",
|
|
4970
|
+
"aria-hidden": "true"
|
|
4971
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
4972
|
+
className: "h-3.5 w-3.5",
|
|
4973
|
+
"aria-hidden": "true"
|
|
4974
|
+
})
|
|
4975
|
+
}) : null]
|
|
4976
|
+
});
|
|
4977
|
+
}
|
|
4978
|
+
function getServerPreviewUrl(server, variables) {
|
|
4979
|
+
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
4980
|
+
}
|
|
4981
|
+
function getFullEndpointUrl(server, variables, path) {
|
|
4982
|
+
return joinPath(getServerPreviewUrl(server, variables), path);
|
|
4983
|
+
}
|
|
4984
|
+
function getServerProtocolLabel(server, variables) {
|
|
4985
|
+
const url = getServerPreviewUrl(server, variables);
|
|
4986
|
+
const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
|
|
4987
|
+
return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
|
|
4988
|
+
}
|
|
4989
|
+
function getDefaultResponseStatus(operation, spec) {
|
|
4990
|
+
const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
|
|
4991
|
+
if (left.status === "default") return -1;
|
|
4992
|
+
if (right.status === "default") return 1;
|
|
4993
|
+
const leftCode = Number(left.status);
|
|
4994
|
+
const rightCode = Number(right.status);
|
|
4995
|
+
if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
|
|
4996
|
+
return left.status.localeCompare(right.status);
|
|
4997
|
+
});
|
|
4998
|
+
return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
|
|
4999
|
+
}
|
|
5000
|
+
function ServerUrlValue(arg0) {
|
|
5001
|
+
const { servers, selectedKey, server, variables, open, interactive, directSelect, onSelect, onToggle } = arg0;
|
|
5002
|
+
const url = getServerPreviewUrl(server, variables);
|
|
5003
|
+
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
5004
|
+
if (!interactive) return /* @__PURE__ */ jsxs("span", {
|
|
5005
|
+
"aria-label": "Server",
|
|
5006
|
+
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
|
|
5007
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5008
|
+
className: "sm:hidden",
|
|
5009
|
+
children: /* @__PURE__ */ jsx(ServerIcon, {
|
|
5010
|
+
className: "h-4 w-4",
|
|
5011
|
+
"aria-hidden": "true"
|
|
5012
|
+
})
|
|
5013
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
5014
|
+
className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
|
|
5015
|
+
children: [protocolLabel ? /* @__PURE__ */ jsx("span", {
|
|
5016
|
+
className: "shrink-0 rounded bg-sky-100 px-1.5 py-0.5 text-2xs font-black text-sky-700 dark:bg-sky-400/15 dark:text-sky-200",
|
|
5017
|
+
children: protocolLabel
|
|
5018
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
5019
|
+
className: "truncate font-semibold text-xs",
|
|
5020
|
+
children: url
|
|
5021
|
+
})]
|
|
5022
|
+
})]
|
|
5023
|
+
});
|
|
5024
|
+
if (directSelect) return /* @__PURE__ */ jsx(InlineListbox, {
|
|
5025
|
+
label: "Server",
|
|
5026
|
+
value: selectedKey,
|
|
5027
|
+
options: servers.map((option, index) => ({
|
|
5028
|
+
value: getServerKey(option, index),
|
|
5029
|
+
label: getServerLabel(option, index),
|
|
5030
|
+
description: option.description
|
|
5031
|
+
})),
|
|
5032
|
+
onChange: onSelect,
|
|
3295
5033
|
className: "w-8 shrink-0 sm:w-fit sm:min-w-16 sm:max-w-(--clarify-server-url-max-width)",
|
|
3296
5034
|
buttonClassName: "group flex h-8 w-full min-w-0 cursor-pointer items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) px-0 text-(--clarify-ui-text) transition-colors hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) data-open:bg-(--clarify-ui-active-background) data-open:text-(--clarify-theme-tokens-colors-foreground) sm:px-1.5",
|
|
3297
5035
|
buttonContent: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -3409,51 +5147,9 @@ function ServerPanel(arg0) {
|
|
|
3409
5147
|
})
|
|
3410
5148
|
});
|
|
3411
5149
|
}
|
|
3412
|
-
function AuthPanel(arg0) {
|
|
3413
|
-
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3414
|
-
if (authOptions.length === 0) return null;
|
|
3415
|
-
return /* @__PURE__ */ jsx("div", {
|
|
3416
|
-
className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) p-3",
|
|
3417
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
3418
|
-
className: "grid gap-3 sm:grid-cols-(--clarify-openapi-control-grid)",
|
|
3419
|
-
children: [/* @__PURE__ */ jsxs("label", {
|
|
3420
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3421
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3422
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3423
|
-
children: "Auth"
|
|
3424
|
-
}), /* @__PURE__ */ jsx(InlineListbox, {
|
|
3425
|
-
label: "Auth",
|
|
3426
|
-
value: selectedAuthName,
|
|
3427
|
-
options: authOptions.map(({ name, scheme }) => ({
|
|
3428
|
-
value: name,
|
|
3429
|
-
label: name,
|
|
3430
|
-
description: authLabel(name, scheme)
|
|
3431
|
-
})),
|
|
3432
|
-
onChange: onSelectAuth
|
|
3433
|
-
})]
|
|
3434
|
-
}), selectedAuth ? /* @__PURE__ */ jsxs("label", {
|
|
3435
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3436
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3437
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3438
|
-
children: "Credential"
|
|
3439
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3440
|
-
className: "flex min-w-0 items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 shadow-xs",
|
|
3441
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3442
|
-
className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3443
|
-
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
3444
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
3445
|
-
value: authValues[selectedAuth.name] ?? "",
|
|
3446
|
-
placeholder: authPlaceholder(selectedAuth),
|
|
3447
|
-
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
3448
|
-
className: "min-w-0 flex-1 border-0 bg-transparent px-0 py-0 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
|
|
3449
|
-
})]
|
|
3450
|
-
})]
|
|
3451
|
-
}) : null]
|
|
3452
|
-
})
|
|
3453
|
-
});
|
|
3454
|
-
}
|
|
3455
5150
|
function EndpointIdentity(arg0) {
|
|
3456
|
-
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen,
|
|
5151
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, onSelectServer, onChangeServerVariable, onToggleServer, onTryRequest } = arg0;
|
|
5152
|
+
const t = useBuiltInText();
|
|
3457
5153
|
const directServerSelect = servers.length > 1 && servers.every((server) => Object.keys(server.variables ?? {}).length === 0);
|
|
3458
5154
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3459
5155
|
const [copiedUrl, setCopiedUrl] = useState(false);
|
|
@@ -3468,61 +5164,40 @@ function EndpointIdentity(arg0) {
|
|
|
3468
5164
|
}
|
|
3469
5165
|
return /* @__PURE__ */ jsxs("div", {
|
|
3470
5166
|
className: "clarify-openai-endpoint-identity not-prose flex w-full flex-col overflow-hidden rounded-xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-xs",
|
|
3471
|
-
children: [
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
})
|
|
3506
|
-
}) : null
|
|
3507
|
-
]
|
|
3508
|
-
}),
|
|
3509
|
-
serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
|
|
3510
|
-
servers,
|
|
3511
|
-
selectedKey: selectedServerKey,
|
|
3512
|
-
selectedServer,
|
|
3513
|
-
variables: serverVariables,
|
|
3514
|
-
onSelectServer,
|
|
3515
|
-
onChangeVariable: onChangeServerVariable
|
|
3516
|
-
}) : null,
|
|
3517
|
-
authOpen ? /* @__PURE__ */ jsx(AuthPanel, {
|
|
3518
|
-
authOptions,
|
|
3519
|
-
selectedAuthName,
|
|
3520
|
-
selectedAuth,
|
|
3521
|
-
authValues,
|
|
3522
|
-
onSelectAuth,
|
|
3523
|
-
onChangeAuthValue
|
|
3524
|
-
}) : null
|
|
3525
|
-
]
|
|
5167
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
5168
|
+
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
5169
|
+
children: [
|
|
5170
|
+
/* @__PURE__ */ jsx(EndpointMethodBadge, { method }),
|
|
5171
|
+
operationSource === "webhook" ? /* @__PURE__ */ jsx(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
5172
|
+
/* @__PURE__ */ jsx(ServerUrlValue, {
|
|
5173
|
+
servers,
|
|
5174
|
+
selectedKey: selectedServerKey,
|
|
5175
|
+
server: selectedServer,
|
|
5176
|
+
variables: serverVariables,
|
|
5177
|
+
open: serverOpen,
|
|
5178
|
+
interactive: serverInteractive,
|
|
5179
|
+
directSelect: directServerSelect,
|
|
5180
|
+
onSelect: onSelectServer,
|
|
5181
|
+
onToggle: onToggleServer
|
|
5182
|
+
}),
|
|
5183
|
+
/* @__PURE__ */ jsx(EndpointPath, {
|
|
5184
|
+
path,
|
|
5185
|
+
copied: copiedUrl,
|
|
5186
|
+
onCopy: handleCopyUrl
|
|
5187
|
+
}),
|
|
5188
|
+
onTryRequest ? /* @__PURE__ */ jsx(SendRequestButton, {
|
|
5189
|
+
label: t("openapi.tryRequest"),
|
|
5190
|
+
onClick: onTryRequest
|
|
5191
|
+
}) : null
|
|
5192
|
+
]
|
|
5193
|
+
}), serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
|
|
5194
|
+
servers,
|
|
5195
|
+
selectedKey: selectedServerKey,
|
|
5196
|
+
selectedServer,
|
|
5197
|
+
variables: serverVariables,
|
|
5198
|
+
onSelectServer,
|
|
5199
|
+
onChangeVariable: onChangeServerVariable
|
|
5200
|
+
}) : null]
|
|
3526
5201
|
});
|
|
3527
5202
|
}
|
|
3528
5203
|
function OpenApiOperation(arg0) {
|
|
@@ -3535,6 +5210,7 @@ function OpenApiOperation(arg0) {
|
|
|
3535
5210
|
const authState = useOperationAuthState(spec, operation);
|
|
3536
5211
|
const [linkedExampleKey, setLinkedExampleKey] = useState("");
|
|
3537
5212
|
const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
|
|
5213
|
+
const [requestOpen, setRequestOpen] = useState(false);
|
|
3538
5214
|
return /* @__PURE__ */ jsxs("section", {
|
|
3539
5215
|
className: "clarify-openai-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
|
|
3540
5216
|
"aria-labelledby": id,
|
|
@@ -3552,23 +5228,19 @@ function OpenApiOperation(arg0) {
|
|
|
3552
5228
|
selectedServer: serverState.selectedServer,
|
|
3553
5229
|
serverVariables: serverState.serverVariables,
|
|
3554
5230
|
serverOpen: serverState.serverOpen,
|
|
3555
|
-
authOptions: authState.authOptions,
|
|
3556
|
-
selectedAuthName: authState.selectedAuthName,
|
|
3557
|
-
selectedAuth: authState.selectedAuth,
|
|
3558
|
-
authValues: authState.authValues,
|
|
3559
|
-
authOpen: authState.authOpen,
|
|
3560
5231
|
onSelectServer: serverState.onSelectServer,
|
|
3561
5232
|
onChangeServerVariable: serverState.onChangeServerVariable,
|
|
3562
|
-
onToggleServer:
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
5233
|
+
onToggleServer: serverState.onToggleServer,
|
|
5234
|
+
onTryRequest: () => setRequestOpen(true)
|
|
5235
|
+
}),
|
|
5236
|
+
/* @__PURE__ */ jsx(OpenApiRequestDialog, {
|
|
5237
|
+
open: requestOpen,
|
|
5238
|
+
onClose: () => setRequestOpen(false),
|
|
5239
|
+
spec,
|
|
5240
|
+
path,
|
|
5241
|
+
method,
|
|
5242
|
+
operation,
|
|
5243
|
+
operationSource
|
|
3572
5244
|
}),
|
|
3573
5245
|
/* @__PURE__ */ jsx(EndpointRequest, {
|
|
3574
5246
|
spec,
|
|
@@ -3602,6 +5274,6 @@ function OpenApiOperation(arg0) {
|
|
|
3602
5274
|
});
|
|
3603
5275
|
}
|
|
3604
5276
|
//#endregion
|
|
3605
|
-
export {
|
|
5277
|
+
export { Code as A, GridPattern as C, Tag as D, Heading as E, CardGroup as F, Callout as I, Button as L, Pre as M, Mermaid as N, Feedback as O, Card as P, Prose as S, Logo as T, WebFrame as _, ResponseExamplesPanel as a, Step as b, getAuthOptions as c, getOpenApiOperationEntry as d, listOpenApiOperations as f, primitives_exports as g, Markdown as h, RequestExamplesPanel as i, CodeGroup as j, Collapse as k, getServerKey as l, getRequestBody$1 as m, OpenApiOperation as n, authPlaceholder as o, getMediaTypeEntries as p, OpenApiRequestWorkbench as r, defaultServerVariables as s, EndpointIdentity as t, getServers as u, TabItem as v, HeroPattern as w, Steps as x, Tabs as y };
|
|
3606
5278
|
|
|
3607
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5279
|
+
//# sourceMappingURL=OpenApiOperation-CFo6_otd.js.map
|