@clarify-labs/renderer 0.10.0 → 0.10.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-CxhXBtsR.js → ClarifyShell-1LuBliwt.js} +124 -40
- package/output/ClarifyShell-1LuBliwt.js.map +1 -0
- package/output/{ClarifyShell-DjLRRW8T.cjs → ClarifyShell-C6li72Ce.cjs} +136 -52
- package/output/ClarifyShell-C6li72Ce.cjs.map +1 -0
- package/output/MermaidViewer-B6-BMCJG.cjs +101 -0
- package/output/MermaidViewer-B6-BMCJG.cjs.map +1 -0
- package/output/MermaidViewer-dXsomvM7.js +98 -0
- package/output/MermaidViewer-dXsomvM7.js.map +1 -0
- package/output/{OpenApiOperation-CyBkzvob.js → OpenApiOperation-CqNM-no4.js} +250 -188
- package/output/OpenApiOperation-CqNM-no4.js.map +1 -0
- package/output/{OpenApiOperation-qp5tFaWP.cjs → OpenApiOperation-DK46w2dq.cjs} +277 -203
- package/output/OpenApiOperation-DK46w2dq.cjs.map +1 -0
- package/output/{PageActions-GS_cxeJN.cjs → PageActions-BjB6PYmL.cjs} +73 -734
- package/output/PageActions-BjB6PYmL.cjs.map +1 -0
- package/output/{PageActions-Dn8IGWoL.js → PageActions-D7K9LDGf.js} +67 -680
- package/output/PageActions-D7K9LDGf.js.map +1 -0
- package/output/SearchDialog-CIPvXMT3.cjs +414 -0
- package/output/SearchDialog-CIPvXMT3.cjs.map +1 -0
- package/output/SearchDialog-CxYLjRi5.js +411 -0
- package/output/SearchDialog-CxYLjRi5.js.map +1 -0
- package/output/app/AppShell.d.ts +2 -2
- package/output/app/SectionHashSync.d.ts +6 -0
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/MermaidViewer.d.ts +7 -0
- package/output/context.d.ts +1 -1
- package/output/core/context.d.ts +3 -4
- package/output/core/i18n.d.ts +1 -1
- package/output/core/index.d.ts +1 -1
- package/output/core/types.d.ts +36 -19
- package/output/i18n-DnqZHFT7.js +247 -0
- package/output/i18n-DnqZHFT7.js.map +1 -0
- package/output/i18n-b4iTLeia.cjs +294 -0
- package/output/i18n-b4iTLeia.cjs.map +1 -0
- package/output/index.cjs +90 -93
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +5 -5
- package/output/index.js +83 -86
- package/output/index.js.map +1 -1
- package/output/openapi/components/EndpointSections.d.ts +3 -1
- package/output/openapi/components/ExamplePanels.d.ts +3 -1
- package/output/openapi/components/OpenApiOperation.d.ts +3 -1
- package/output/openapi/components/OpenApiOperation.state.d.ts +3 -3
- package/output/openapi/components/SchemaProperties.d.ts +1 -0
- package/output/openapi/components/helpers.d.ts +2 -2
- package/output/openapi/entry.d.ts +0 -1
- package/output/openapi/lib/helpers.d.ts +5 -3
- package/output/openapi/lib/request-code.d.ts +2 -1
- package/output/openapi/lib/spec-path.d.ts +6 -1
- package/output/openapi/lib/utils.d.ts +10 -4
- package/output/preview.cjs +7 -5
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +5 -3
- package/output/preview.js.map +1 -1
- package/output/{render-CV0a-qtD.js → render-DKj24Jqw.js} +15 -8
- package/output/render-DKj24Jqw.js.map +1 -0
- package/output/{render-CCCoUWDP.cjs → render-Di5B6Zc0.cjs} +15 -8
- package/output/render-Di5B6Zc0.cjs.map +1 -0
- package/output/renderer.css +54 -0
- package/output/runtime/ClarifyShell.d.ts +5 -6
- package/output/server.cjs +4 -4
- package/output/server.cjs.map +1 -1
- package/output/server.js +4 -4
- package/output/server.js.map +1 -1
- package/output/shell/Navigation.d.ts +1 -0
- package/output/shell/search/SearchDialog.d.ts +1 -1
- package/output/slots/RuntimeSlot.d.ts +7 -7
- package/output/slots/context.d.ts +5 -5
- package/output/slots/index.d.ts +2 -2
- package/output/slots/types.d.ts +1 -1
- package/output/utils/path.d.ts +1 -1
- package/package.json +1 -1
- package/output/ClarifyShell-CxhXBtsR.js.map +0 -1
- package/output/ClarifyShell-DjLRRW8T.cjs.map +0 -1
- package/output/OpenApiOperation-CyBkzvob.js.map +0 -1
- package/output/OpenApiOperation-qp5tFaWP.cjs.map +0 -1
- package/output/PageActions-Dn8IGWoL.js.map +0 -1
- package/output/PageActions-GS_cxeJN.cjs.map +0 -1
- package/output/render-CCCoUWDP.cjs.map +0 -1
- package/output/render-CV0a-qtD.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-DnqZHFT7.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-D7K9LDGf.js";
|
|
2
3
|
import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
|
|
3
4
|
import clsx from "clsx";
|
|
4
|
-
import { Children, createContext, createElement, forwardRef, isValidElement, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { Children, Suspense, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
6
|
import { Link } from "react-router-dom";
|
|
6
7
|
import { Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
7
|
-
import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, Info, Lightbulb, LinkIcon, LockKeyholeIcon,
|
|
8
|
+
import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, Info, Lightbulb, LinkIcon, LockKeyholeIcon, PackageIcon, ServerIcon, UnlockKeyholeIcon, XCircle } from "lucide-react";
|
|
8
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { motion, useInView } from "framer-motion";
|
|
10
11
|
import { create } from "zustand";
|
|
11
|
-
import { TransformComponent, TransformWrapper, useControls } from "react-zoom-pan-pinch";
|
|
12
12
|
import ReactMarkdown from "react-markdown";
|
|
13
13
|
import { slug } from "github-slugger";
|
|
14
14
|
import { snippetz } from "@scalar/snippetz";
|
|
@@ -209,63 +209,19 @@ function Card(arg0) {
|
|
|
209
209
|
}
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region source/components/Mermaid.tsx
|
|
212
|
+
var MermaidViewer = lazy(() => import("./MermaidViewer-dXsomvM7.js"));
|
|
212
213
|
var mermaidModulePromise;
|
|
213
214
|
async function loadMermaid() {
|
|
214
215
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
215
216
|
return mermaidModulePromise;
|
|
216
217
|
}
|
|
217
|
-
function ZoomControls() {
|
|
218
|
-
const { zoomIn, zoomOut, resetTransform } = useControls();
|
|
219
|
-
const t = useBuiltInText();
|
|
220
|
-
const buttonClassName = "flex h-7 w-7 items-center justify-center rounded-md bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) shadow-xs ring-1 ring-(--clarify-theme-tokens-colors-border) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)";
|
|
221
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
222
|
-
className: "clarify-mermaid-controls absolute top-2 right-2 z-10 flex gap-1 opacity-0 transition group-hover:opacity-100 focus-within:opacity-100",
|
|
223
|
-
children: [
|
|
224
|
-
/* @__PURE__ */ jsx("button", {
|
|
225
|
-
type: "button",
|
|
226
|
-
"aria-label": t("mermaid.zoomIn"),
|
|
227
|
-
title: t("mermaid.zoomIn"),
|
|
228
|
-
onClick: () => zoomIn(),
|
|
229
|
-
className: buttonClassName,
|
|
230
|
-
children: /* @__PURE__ */ jsx(ZoomIn, {
|
|
231
|
-
className: "h-4 w-4",
|
|
232
|
-
"aria-hidden": "true"
|
|
233
|
-
})
|
|
234
|
-
}),
|
|
235
|
-
/* @__PURE__ */ jsx("button", {
|
|
236
|
-
type: "button",
|
|
237
|
-
"aria-label": t("mermaid.zoomOut"),
|
|
238
|
-
title: t("mermaid.zoomOut"),
|
|
239
|
-
onClick: () => zoomOut(),
|
|
240
|
-
className: buttonClassName,
|
|
241
|
-
children: /* @__PURE__ */ jsx(ZoomOut, {
|
|
242
|
-
className: "h-4 w-4",
|
|
243
|
-
"aria-hidden": "true"
|
|
244
|
-
})
|
|
245
|
-
}),
|
|
246
|
-
/* @__PURE__ */ jsx("button", {
|
|
247
|
-
type: "button",
|
|
248
|
-
"aria-label": t("mermaid.resetZoom"),
|
|
249
|
-
title: t("mermaid.resetZoom"),
|
|
250
|
-
onClick: () => resetTransform(),
|
|
251
|
-
className: buttonClassName,
|
|
252
|
-
children: /* @__PURE__ */ jsx(Maximize2, {
|
|
253
|
-
className: "h-4 w-4",
|
|
254
|
-
"aria-hidden": "true"
|
|
255
|
-
})
|
|
256
|
-
})
|
|
257
|
-
]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
218
|
function Mermaid(arg0) {
|
|
261
219
|
const { chart, className } = arg0;
|
|
262
220
|
const t = useBuiltInText();
|
|
263
221
|
const { resolvedTheme } = useTheme();
|
|
264
222
|
const renderId = `clarify-mermaid-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
265
|
-
const containerRef = useRef(null);
|
|
266
223
|
const [svg, setSvg] = useState("");
|
|
267
224
|
const [error, setError] = useState(void 0);
|
|
268
|
-
const [focused, setFocused] = useState(false);
|
|
269
225
|
useEffect(() => {
|
|
270
226
|
let cancelled = false;
|
|
271
227
|
async function renderChart() {
|
|
@@ -328,42 +284,24 @@ function Mermaid(arg0) {
|
|
|
328
284
|
children: chart.trim()
|
|
329
285
|
})
|
|
330
286
|
});
|
|
287
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
288
|
+
fallback: /* @__PURE__ */ jsx(MermaidStaticSvg, {
|
|
289
|
+
svg,
|
|
290
|
+
className
|
|
291
|
+
}),
|
|
292
|
+
children: /* @__PURE__ */ jsx(MermaidViewer, {
|
|
293
|
+
svg,
|
|
294
|
+
className
|
|
295
|
+
})
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function MermaidStaticSvg(arg0) {
|
|
299
|
+
const { svg, className } = arg0;
|
|
331
300
|
return /* @__PURE__ */ jsx("div", {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
onFocus: () => setFocused(true),
|
|
337
|
-
onBlur: () => setFocused(false),
|
|
338
|
-
className: clsx("clarify-mermaid group not-prose relative my-6 overflow-hidden rounded-2xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", className),
|
|
339
|
-
children: /* @__PURE__ */ jsxs(TransformWrapper, {
|
|
340
|
-
minScale: .5,
|
|
341
|
-
maxScale: 8,
|
|
342
|
-
initialScale: 1,
|
|
343
|
-
centerOnInit: true,
|
|
344
|
-
smooth: true,
|
|
345
|
-
wheel: {
|
|
346
|
-
step: .05,
|
|
347
|
-
wheelDisabled: !focused,
|
|
348
|
-
touchPadDisabled: !focused
|
|
349
|
-
},
|
|
350
|
-
doubleClick: { mode: "reset" },
|
|
351
|
-
children: [
|
|
352
|
-
/* @__PURE__ */ jsx(ZoomControls, {}),
|
|
353
|
-
/* @__PURE__ */ jsx(TransformComponent, {
|
|
354
|
-
wrapperClass: "!w-full !cursor-grab active:!cursor-grabbing",
|
|
355
|
-
contentClass: "!w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
|
|
356
|
-
wrapperStyle: { height: "min(70vh, 32rem)" },
|
|
357
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
358
|
-
className: "flex h-full w-full items-center justify-center p-4",
|
|
359
|
-
dangerouslySetInnerHTML: { __html: svg }
|
|
360
|
-
})
|
|
361
|
-
}),
|
|
362
|
-
/* @__PURE__ */ jsx("p", {
|
|
363
|
-
className: clsx("clarify-mermaid-hint pointer-events-none absolute bottom-2 left-1/2 z-10 -translate-x-1/2 rounded-full bg-(--clarify-theme-tokens-colors-surface)/90 px-2.5 py-1 text-2xs text-(--clarify-ui-text-soft) shadow-xs ring-1 ring-(--clarify-theme-tokens-colors-border) backdrop-blur-sm transition", focused ? "opacity-0" : "opacity-0 group-hover:opacity-100"),
|
|
364
|
-
children: t("mermaid.scrollHint")
|
|
365
|
-
})
|
|
366
|
-
]
|
|
301
|
+
className: clsx("clarify-mermaid not-prose my-6 overflow-x-auto rounded-2xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-4", className),
|
|
302
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
303
|
+
className: "flex w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
|
|
304
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
367
305
|
})
|
|
368
306
|
});
|
|
369
307
|
}
|
|
@@ -404,8 +342,8 @@ function CopyButton(arg0) {
|
|
|
404
342
|
const copied = copyCount > 0;
|
|
405
343
|
useEffect(() => {
|
|
406
344
|
if (copyCount === 0) return void 0;
|
|
407
|
-
const timeout =
|
|
408
|
-
return () =>
|
|
345
|
+
const timeout = setTimeout(() => setCopyCount(0), 1e3);
|
|
346
|
+
return () => clearTimeout(timeout);
|
|
409
347
|
}, [copyCount]);
|
|
410
348
|
if (!code) return null;
|
|
411
349
|
return /* @__PURE__ */ jsx("button", {
|
|
@@ -1200,38 +1138,48 @@ function Markdown(arg0) {
|
|
|
1200
1138
|
}
|
|
1201
1139
|
//#endregion
|
|
1202
1140
|
//#region source/openapi/lib/helpers.ts
|
|
1203
|
-
function isRecord(value) {
|
|
1141
|
+
function isRecord$1(value) {
|
|
1204
1142
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1205
1143
|
}
|
|
1206
1144
|
function isReference(value) {
|
|
1207
|
-
return isRecord(value) && typeof value.$ref === "string";
|
|
1145
|
+
return isRecord$1(value) && typeof value.$ref === "string";
|
|
1208
1146
|
}
|
|
1209
1147
|
function resolveReferenceName(ref) {
|
|
1210
1148
|
return ref.split("/").filter(Boolean).at(-1) ?? ref;
|
|
1211
1149
|
}
|
|
1212
|
-
function resolveOpenApiRef(spec, ref) {
|
|
1150
|
+
function resolveOpenApiRef$1(spec, ref) {
|
|
1213
1151
|
if (!ref.startsWith("#/")) return void 0;
|
|
1214
|
-
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
1152
|
+
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord$1(current) ? current[part] : void 0, spec);
|
|
1215
1153
|
}
|
|
1216
1154
|
function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
|
|
1217
1155
|
if (!isReference(schema)) return schema;
|
|
1218
1156
|
if (seen.has(schema.$ref)) return schema;
|
|
1219
1157
|
seen.add(schema.$ref);
|
|
1220
|
-
return resolveSchema(spec, resolveOpenApiRef(spec, schema.$ref), seen) ?? schema;
|
|
1158
|
+
return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
|
|
1221
1159
|
}
|
|
1222
|
-
function getPathItem(spec, path) {
|
|
1160
|
+
function getPathItem$1(spec, path) {
|
|
1223
1161
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1224
1162
|
}
|
|
1163
|
+
function getOperationPathItem(spec, path, source = "path") {
|
|
1164
|
+
if (source === "path") return getPathItem$1(spec, path);
|
|
1165
|
+
const webhooks = spec.webhooks;
|
|
1166
|
+
return resolveObjectRef(spec, isRecord$1(webhooks) ? webhooks[path] : void 0);
|
|
1167
|
+
}
|
|
1168
|
+
function joinPath(base, path) {
|
|
1169
|
+
if (!base) return path || "/";
|
|
1170
|
+
if (!path) return base;
|
|
1171
|
+
return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
|
|
1172
|
+
}
|
|
1225
1173
|
function resolveObjectRef(spec, value) {
|
|
1226
|
-
const resolved = spec && isReference(value) ? resolveOpenApiRef(spec, value.$ref) : value;
|
|
1227
|
-
return isRecord(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
1174
|
+
const resolved = spec && isReference(value) ? resolveOpenApiRef$1(spec, value.$ref) : value;
|
|
1175
|
+
return isRecord$1(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
1228
1176
|
}
|
|
1229
1177
|
function schemaHasType(schema, type) {
|
|
1230
|
-
if (!isRecord(schema)) return false;
|
|
1178
|
+
if (!isRecord$1(schema)) return false;
|
|
1231
1179
|
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
1232
1180
|
}
|
|
1233
|
-
function getOperationParameters(spec, path, operation) {
|
|
1234
|
-
const pathParameters =
|
|
1181
|
+
function getOperationParameters(spec, path, operation, source = "path") {
|
|
1182
|
+
const pathParameters = getOperationPathItem(spec, path, source)?.parameters;
|
|
1235
1183
|
const operationParameters = operation.parameters;
|
|
1236
1184
|
const parameters = [...Array.isArray(pathParameters) ? pathParameters : [], ...Array.isArray(operationParameters) ? operationParameters : []].map((parameter) => resolveObjectRef(spec, parameter)).filter((parameter) => Boolean(parameter));
|
|
1237
1185
|
const deduped = /* @__PURE__ */ new Map();
|
|
@@ -1249,7 +1197,7 @@ function getRequestBody$1(spec, operation) {
|
|
|
1249
1197
|
return resolveObjectRef(spec, requestBody);
|
|
1250
1198
|
}
|
|
1251
1199
|
function getMediaTypeEntries(content, spec) {
|
|
1252
|
-
if (!isRecord(content)) return [];
|
|
1200
|
+
if (!isRecord$1(content)) return [];
|
|
1253
1201
|
return Object.entries(content).map(([mediaType, value]) => ({
|
|
1254
1202
|
mediaType,
|
|
1255
1203
|
value: resolveObjectRef(spec, value)
|
|
@@ -1261,12 +1209,12 @@ function getJsonLikeContent(content, spec) {
|
|
|
1261
1209
|
return getMediaTypeEntries(content, spec)[0];
|
|
1262
1210
|
}
|
|
1263
1211
|
function getExampleValue(example) {
|
|
1264
|
-
if (isRecord(example) && "value" in example) return example.value;
|
|
1265
|
-
if (isRecord(example) && "externalValue" in example) return void 0;
|
|
1212
|
+
if (isRecord$1(example) && "value" in example) return example.value;
|
|
1213
|
+
if (isRecord$1(example) && "externalValue" in example) return void 0;
|
|
1266
1214
|
return example;
|
|
1267
1215
|
}
|
|
1268
1216
|
function getExampleTitle(key, example) {
|
|
1269
|
-
if (isRecord(example)) {
|
|
1217
|
+
if (isRecord$1(example)) {
|
|
1270
1218
|
const summary = typeof example.summary === "string" ? example.summary : void 0;
|
|
1271
1219
|
return {
|
|
1272
1220
|
title: summary ?? key,
|
|
@@ -1275,9 +1223,9 @@ function getExampleTitle(key, example) {
|
|
|
1275
1223
|
}
|
|
1276
1224
|
return { title: key };
|
|
1277
1225
|
}
|
|
1278
|
-
function getExampleEntries(mediaType) {
|
|
1226
|
+
function getExampleEntries(mediaType, spec) {
|
|
1279
1227
|
if (!mediaType) return [];
|
|
1280
|
-
if (isRecord(mediaType.examples)) {
|
|
1228
|
+
if (isRecord$1(mediaType.examples)) {
|
|
1281
1229
|
const examples = [];
|
|
1282
1230
|
for (const [key, example] of Object.entries(mediaType.examples)) {
|
|
1283
1231
|
const value = getExampleValue(example);
|
|
@@ -1297,7 +1245,7 @@ function getExampleEntries(mediaType) {
|
|
|
1297
1245
|
title: "Example",
|
|
1298
1246
|
value: mediaType.example
|
|
1299
1247
|
}];
|
|
1300
|
-
const generated = schemaToExample(mediaType.schema);
|
|
1248
|
+
const generated = schemaToExample(spec ? resolveSchema(spec, mediaType.schema) : mediaType.schema);
|
|
1301
1249
|
return typeof generated === "undefined" ? [] : [{
|
|
1302
1250
|
key: "schema",
|
|
1303
1251
|
title: "schema",
|
|
@@ -1309,7 +1257,7 @@ function getContentExample(mediaType) {
|
|
|
1309
1257
|
return getExampleEntries(mediaType)[0]?.value;
|
|
1310
1258
|
}
|
|
1311
1259
|
function schemaToType(schema) {
|
|
1312
|
-
if (!isRecord(schema)) return void 0;
|
|
1260
|
+
if (!isRecord$1(schema)) return void 0;
|
|
1313
1261
|
if (isReference(schema)) return resolveReferenceName(schema.$ref);
|
|
1314
1262
|
if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
|
|
1315
1263
|
if (Array.isArray(schema.enum)) return "enum";
|
|
@@ -1321,14 +1269,14 @@ function schemaToType(schema) {
|
|
|
1321
1269
|
return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
1322
1270
|
}
|
|
1323
1271
|
function schemaToExample(schema, depth = 0) {
|
|
1324
|
-
if (!isRecord(schema) || depth > 3) return void 0;
|
|
1272
|
+
if (!isRecord$1(schema) || depth > 3) return void 0;
|
|
1325
1273
|
if (typeof schema.example !== "undefined") return schema.example;
|
|
1326
1274
|
if (typeof schema.default !== "undefined") return schema.default;
|
|
1327
1275
|
if (Array.isArray(schema.enum)) return schema.enum[0];
|
|
1328
1276
|
if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
|
|
1329
1277
|
if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
|
|
1330
|
-
if (schemaHasType(schema, "object") || isRecord(schema.properties)) {
|
|
1331
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
1278
|
+
if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
|
|
1279
|
+
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
1332
1280
|
return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1333
1281
|
}
|
|
1334
1282
|
return exampleForType(schemaToType(schema));
|
|
@@ -1348,7 +1296,7 @@ function stringifyExample(value) {
|
|
|
1348
1296
|
}
|
|
1349
1297
|
function getResponseEntries(operation, spec) {
|
|
1350
1298
|
const responses = operation.responses;
|
|
1351
|
-
if (!isRecord(responses)) return [];
|
|
1299
|
+
if (!isRecord$1(responses)) return [];
|
|
1352
1300
|
return Object.entries(responses).map(([status, response]) => ({
|
|
1353
1301
|
status,
|
|
1354
1302
|
response: resolveObjectRef(spec, response)
|
|
@@ -1363,14 +1311,99 @@ function codeLanguageForMediaType(mediaType) {
|
|
|
1363
1311
|
return "text";
|
|
1364
1312
|
}
|
|
1365
1313
|
//#endregion
|
|
1314
|
+
//#region source/openapi/lib/utils.ts
|
|
1315
|
+
var OPENAPI_HTTP_METHODS = [
|
|
1316
|
+
"get",
|
|
1317
|
+
"put",
|
|
1318
|
+
"post",
|
|
1319
|
+
"delete",
|
|
1320
|
+
"options",
|
|
1321
|
+
"head",
|
|
1322
|
+
"patch",
|
|
1323
|
+
"trace"
|
|
1324
|
+
];
|
|
1325
|
+
var CLARIFY_OPENAPI_SECTION_ID_EXTENSION = "x-clarify-section-id";
|
|
1326
|
+
function getOpenApiOperationSectionId(operation) {
|
|
1327
|
+
const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
|
|
1328
|
+
return typeof sectionId === "string" ? sectionId : "";
|
|
1329
|
+
}
|
|
1330
|
+
function createOpenApiOperationSectionId(operation, method, path, source) {
|
|
1331
|
+
return (typeof operation.operationId === "string" ? operation.operationId.trim() : "") || slug(`${source === "webhook" ? "webhook " : ""}${method.toLowerCase()} ${path}`);
|
|
1332
|
+
}
|
|
1333
|
+
function normalizeOpenApiOperationSectionId(operation, method, path, source) {
|
|
1334
|
+
const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
|
|
1335
|
+
if (typeof sectionId !== "string" || !sectionId) operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION] = createOpenApiOperationSectionId(operation, method, path, source);
|
|
1336
|
+
return operation;
|
|
1337
|
+
}
|
|
1338
|
+
function isOpenAPIHttpMethod(method) {
|
|
1339
|
+
return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
|
|
1340
|
+
}
|
|
1341
|
+
function isRecord(value) {
|
|
1342
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1343
|
+
}
|
|
1344
|
+
function resolveOpenApiRef(spec, ref) {
|
|
1345
|
+
if (!ref.startsWith("#/")) return void 0;
|
|
1346
|
+
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
1347
|
+
}
|
|
1348
|
+
function getPathItem(spec, path) {
|
|
1349
|
+
const pathItem = spec.paths?.[path];
|
|
1350
|
+
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
1351
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
1352
|
+
}
|
|
1353
|
+
function getWebhookItem(spec, path) {
|
|
1354
|
+
const webhooks = spec.webhooks;
|
|
1355
|
+
const pathItem = isRecord(webhooks) ? webhooks[path] : void 0;
|
|
1356
|
+
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
1357
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
1358
|
+
}
|
|
1359
|
+
function listOperationsFromPathItems(items, source, spec) {
|
|
1360
|
+
const operations = [];
|
|
1361
|
+
for (const path of Object.keys(items)) {
|
|
1362
|
+
const pathItem = source === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path);
|
|
1363
|
+
if (!pathItem) continue;
|
|
1364
|
+
for (const method of OPENAPI_HTTP_METHODS) {
|
|
1365
|
+
const operation = pathItem[method];
|
|
1366
|
+
if (isRecord(operation)) operations.push({
|
|
1367
|
+
path,
|
|
1368
|
+
method,
|
|
1369
|
+
operation: normalizeOpenApiOperationSectionId(operation, method, path, source),
|
|
1370
|
+
source
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return operations;
|
|
1375
|
+
}
|
|
1376
|
+
function getOpenApiOperationEntry(spec, path, method, source) {
|
|
1377
|
+
if (!isOpenAPIHttpMethod(method)) return void 0;
|
|
1378
|
+
const normalizedMethod = method.toLowerCase();
|
|
1379
|
+
const sources = source ? [source] : ["path", "webhook"];
|
|
1380
|
+
for (const currentSource of sources) {
|
|
1381
|
+
const operation = (currentSource === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path))?.[normalizedMethod];
|
|
1382
|
+
if (isRecord(operation)) return {
|
|
1383
|
+
path,
|
|
1384
|
+
method: normalizedMethod,
|
|
1385
|
+
operation: normalizeOpenApiOperationSectionId(operation, normalizedMethod, path, currentSource),
|
|
1386
|
+
source: currentSource
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
function listOpenApiOperations(spec) {
|
|
1391
|
+
const paths = spec.paths ?? {};
|
|
1392
|
+
const webhooks = spec.webhooks;
|
|
1393
|
+
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1394
|
+
}
|
|
1395
|
+
//#endregion
|
|
1366
1396
|
//#region source/openapi/lib/request-code.ts
|
|
1367
1397
|
var snippetGenerator = snippetz();
|
|
1368
1398
|
function getDefaultServer(spec) {
|
|
1369
1399
|
const servers = spec.servers;
|
|
1370
1400
|
if (!Array.isArray(servers)) return { url: "https://api.example.com" };
|
|
1371
|
-
const firstServer = servers.find(isRecord);
|
|
1401
|
+
const firstServer = servers.find(isRecord$1);
|
|
1372
1402
|
return firstServer && typeof firstServer.url === "string" ? firstServer : { url: "https://api.example.com" };
|
|
1373
1403
|
}
|
|
1404
|
+
function getDefaultWebhookServer() {
|
|
1405
|
+
return { url: "https://webhook.example.com" };
|
|
1406
|
+
}
|
|
1374
1407
|
function expandServerUrl(server, serverVariables = {}) {
|
|
1375
1408
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1376
1409
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
@@ -1378,7 +1411,8 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1378
1411
|
});
|
|
1379
1412
|
}
|
|
1380
1413
|
function buildOperationUrl(input) {
|
|
1381
|
-
|
|
1414
|
+
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1415
|
+
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1382
1416
|
}
|
|
1383
1417
|
function getQueryString(parameters, auth) {
|
|
1384
1418
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
@@ -1395,18 +1429,18 @@ function isFormMediaType(mediaType) {
|
|
|
1395
1429
|
return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
|
|
1396
1430
|
}
|
|
1397
1431
|
function isBinarySchema(schema) {
|
|
1398
|
-
return isRecord(schema) && schema.type === "string" && schema.format === "binary";
|
|
1432
|
+
return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
|
|
1399
1433
|
}
|
|
1400
1434
|
function getSchemaProperties(schema) {
|
|
1401
|
-
return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {};
|
|
1435
|
+
return isRecord$1(schema) && isRecord$1(schema.properties) ? schema.properties : {};
|
|
1402
1436
|
}
|
|
1403
1437
|
function getFieldValue(name, value, schema) {
|
|
1404
|
-
if (isRecord(value) && typeof value[name] !== "undefined") return value[name];
|
|
1438
|
+
if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
|
|
1405
1439
|
if (isBinarySchema(schema)) return `@${name}`;
|
|
1406
1440
|
}
|
|
1407
1441
|
function getFormParams(value, requestContent) {
|
|
1408
1442
|
const properties = getSchemaProperties(requestContent.value.schema);
|
|
1409
|
-
return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
1443
|
+
return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord$1(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
1410
1444
|
const fieldValue = getFieldValue(name, value, properties[name]);
|
|
1411
1445
|
if (typeof fieldValue === "undefined") return [];
|
|
1412
1446
|
const contentType = requestContent.value.encoding?.[name]?.contentType;
|
|
@@ -1831,7 +1865,7 @@ function CopyCodeButton(arg0) {
|
|
|
1831
1865
|
copyTextToClipboard(code).then((ok) => {
|
|
1832
1866
|
if (!ok) return;
|
|
1833
1867
|
setCopied(true);
|
|
1834
|
-
|
|
1868
|
+
setTimeout(() => setCopied(false), 1e3);
|
|
1835
1869
|
});
|
|
1836
1870
|
},
|
|
1837
1871
|
className: "flex items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
|
|
@@ -1888,12 +1922,12 @@ function CodeToolbar(arg0) {
|
|
|
1888
1922
|
}
|
|
1889
1923
|
//#endregion
|
|
1890
1924
|
//#region source/openapi/components/helpers.ts
|
|
1891
|
-
function getServers(spec, operation, path) {
|
|
1925
|
+
function getServers(spec, operation, path, source = "path") {
|
|
1892
1926
|
const operationServers = operation.servers;
|
|
1893
|
-
const pathServers = path ?
|
|
1894
|
-
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : spec.servers;
|
|
1927
|
+
const pathServers = path ? getOperationPathItem(spec, path, source)?.servers : void 0;
|
|
1928
|
+
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : source === "webhook" ? [{ url: "https://webhook.example.com" }] : spec.servers;
|
|
1895
1929
|
if (!Array.isArray(servers)) return [{ url: "https://api.example.com" }];
|
|
1896
|
-
const validServers = servers.filter((server) => isRecord(server) && typeof server.url === "string");
|
|
1930
|
+
const validServers = servers.filter((server) => isRecord$1(server) && typeof server.url === "string");
|
|
1897
1931
|
return validServers.length > 0 ? validServers : [{ url: "https://api.example.com" }];
|
|
1898
1932
|
}
|
|
1899
1933
|
function getServerKey(server, index) {
|
|
@@ -1907,14 +1941,14 @@ function defaultServerVariables(server) {
|
|
|
1907
1941
|
}
|
|
1908
1942
|
function getSecuritySchemes(spec) {
|
|
1909
1943
|
const schemes = spec.components;
|
|
1910
|
-
if (!isRecord(schemes) || !isRecord(schemes.securitySchemes)) return {};
|
|
1911
|
-
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord(entry[1])));
|
|
1944
|
+
if (!isRecord$1(schemes) || !isRecord$1(schemes.securitySchemes)) return {};
|
|
1945
|
+
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord$1(entry[1])));
|
|
1912
1946
|
}
|
|
1913
1947
|
function getSecurityRequirements(spec, operation) {
|
|
1914
1948
|
const operationSecurity = operation.security;
|
|
1915
|
-
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord);
|
|
1949
|
+
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord$1);
|
|
1916
1950
|
const specSecurity = spec.security;
|
|
1917
|
-
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord) : [];
|
|
1951
|
+
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord$1) : [];
|
|
1918
1952
|
}
|
|
1919
1953
|
function getAuthOptions(spec, operation) {
|
|
1920
1954
|
const schemes = getSecuritySchemes(spec);
|
|
@@ -2029,13 +2063,13 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2029
2063
|
})
|
|
2030
2064
|
});
|
|
2031
2065
|
}
|
|
2032
|
-
function firstExampleKeyForMediaType(requestContents, mediaType) {
|
|
2033
|
-
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value)[0]?.key ?? "";
|
|
2066
|
+
function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
|
|
2067
|
+
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
|
|
2034
2068
|
}
|
|
2035
2069
|
function useRequestExamplesState(arg0) {
|
|
2036
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2070
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2037
2071
|
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
2038
|
-
const examples = getExampleEntries(selectedContent?.value);
|
|
2072
|
+
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2039
2073
|
const [selectedExampleKey, setSelectedExampleKey] = useState(examples[0]?.key ?? "");
|
|
2040
2074
|
const [selectedLanguageKey, setSelectedLanguageKey] = useState("shell");
|
|
2041
2075
|
const [selectedClientKey, setSelectedClientKey] = useState("curl");
|
|
@@ -2056,7 +2090,8 @@ function useRequestExamplesState(arg0) {
|
|
|
2056
2090
|
} : void 0,
|
|
2057
2091
|
server: selectedServer,
|
|
2058
2092
|
serverVariables,
|
|
2059
|
-
auth
|
|
2093
|
+
auth,
|
|
2094
|
+
operationSource
|
|
2060
2095
|
});
|
|
2061
2096
|
const selectedLanguage = codeOptions.find((option) => option.languageKey === selectedLanguageKey) ?? codeOptions[0];
|
|
2062
2097
|
const selectedCode = codeOptions.find((option) => option.languageKey === selectedLanguage.languageKey && option.clientKey === selectedClientKey) ?? selectedLanguage;
|
|
@@ -2069,7 +2104,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2069
2104
|
examples,
|
|
2070
2105
|
onSelectMediaType: (value) => {
|
|
2071
2106
|
onSelectMediaType(value);
|
|
2072
|
-
setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value));
|
|
2107
|
+
setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value, spec));
|
|
2073
2108
|
},
|
|
2074
2109
|
onSelectExample: (value) => {
|
|
2075
2110
|
setSelectedExampleKey(value);
|
|
@@ -2084,7 +2119,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2084
2119
|
};
|
|
2085
2120
|
}
|
|
2086
2121
|
function RequestExamplesPanel(arg0) {
|
|
2087
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2122
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2088
2123
|
const t = useBuiltInText();
|
|
2089
2124
|
const state = useRequestExamplesState({
|
|
2090
2125
|
spec,
|
|
@@ -2097,6 +2132,7 @@ function RequestExamplesPanel(arg0) {
|
|
|
2097
2132
|
selectedServer,
|
|
2098
2133
|
serverVariables,
|
|
2099
2134
|
auth,
|
|
2135
|
+
operationSource,
|
|
2100
2136
|
sharedExampleKey,
|
|
2101
2137
|
onSelectExampleKey
|
|
2102
2138
|
});
|
|
@@ -2120,12 +2156,12 @@ function RequestExamplesPanel(arg0) {
|
|
|
2120
2156
|
onSelectClient: state.onSelectClient
|
|
2121
2157
|
});
|
|
2122
2158
|
}
|
|
2123
|
-
function firstExampleKeyForResponseContent(content) {
|
|
2124
|
-
return getExampleEntries(content?.value)[0]?.key ?? "";
|
|
2159
|
+
function firstExampleKeyForResponseContent(content, spec) {
|
|
2160
|
+
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2125
2161
|
}
|
|
2126
2162
|
function useResponseExamplesState(arg0) {
|
|
2127
2163
|
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2128
|
-
const orderedResponses = [...getResponseEntries(operation, spec)
|
|
2164
|
+
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2129
2165
|
if (left.status === "default") return -1;
|
|
2130
2166
|
if (right.status === "default") return 1;
|
|
2131
2167
|
const leftCode = Number(left.status);
|
|
@@ -2133,22 +2169,23 @@ function useResponseExamplesState(arg0) {
|
|
|
2133
2169
|
if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
|
|
2134
2170
|
return left.status.localeCompare(right.status);
|
|
2135
2171
|
});
|
|
2136
|
-
const
|
|
2172
|
+
const defaultStatus = orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
|
|
2173
|
+
const [internalSelectedStatus, setInternalSelectedStatus] = useState(defaultStatus);
|
|
2137
2174
|
const activeStatus = selectedStatus ?? internalSelectedStatus;
|
|
2138
2175
|
const selectedResponse = orderedResponses.find(({ status }) => status === activeStatus) ?? orderedResponses[0];
|
|
2139
2176
|
const responseContents = getMediaTypeEntries(selectedResponse?.response.content, spec);
|
|
2140
2177
|
const [selection, setSelection] = useState(() => ({
|
|
2141
2178
|
status: activeStatus,
|
|
2142
2179
|
mediaType: responseContents[0]?.mediaType ?? "",
|
|
2143
|
-
exampleKey: firstExampleKeyForResponseContent(responseContents[0])
|
|
2180
|
+
exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
|
|
2144
2181
|
}));
|
|
2145
2182
|
const resolvedSelection = selection.status === activeStatus ? selection : {
|
|
2146
2183
|
status: activeStatus,
|
|
2147
2184
|
mediaType: responseContents[0]?.mediaType ?? "",
|
|
2148
|
-
exampleKey: firstExampleKeyForResponseContent(responseContents[0])
|
|
2185
|
+
exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
|
|
2149
2186
|
};
|
|
2150
2187
|
const selectedContent = responseContents.find((content) => content.mediaType === resolvedSelection.mediaType) ?? responseContents[0];
|
|
2151
|
-
const examples = getExampleEntries(selectedContent?.value);
|
|
2188
|
+
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2152
2189
|
const selectedExampleKey = examples.some((example) => example.key === resolvedSelection.exampleKey) ? resolvedSelection.exampleKey : examples[0]?.key ?? "";
|
|
2153
2190
|
const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
|
|
2154
2191
|
const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
|
|
@@ -2159,7 +2196,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2159
2196
|
selectedContent,
|
|
2160
2197
|
examples,
|
|
2161
2198
|
selectedExample,
|
|
2162
|
-
responseCode: stringifyExample(selectedExample?.value)
|
|
2199
|
+
responseCode: selectedContent ? stringifyExample(selectedExample?.value) : `HTTP/1.1 ${selectedResponse?.status ?? defaultStatus}${selectedResponse?.status === "204" ? " No Content" : ""}`,
|
|
2163
2200
|
onSelectStatus: (value) => {
|
|
2164
2201
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2165
2202
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2167,7 +2204,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2167
2204
|
setSelection({
|
|
2168
2205
|
status: value,
|
|
2169
2206
|
mediaType: nextContents[0]?.mediaType ?? "",
|
|
2170
|
-
exampleKey: firstExampleKeyForResponseContent(nextContents[0])
|
|
2207
|
+
exampleKey: firstExampleKeyForResponseContent(nextContents[0], spec)
|
|
2171
2208
|
});
|
|
2172
2209
|
},
|
|
2173
2210
|
onSelectMediaType: (value) => {
|
|
@@ -2175,7 +2212,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2175
2212
|
setSelection((current) => ({
|
|
2176
2213
|
...current,
|
|
2177
2214
|
mediaType: value,
|
|
2178
|
-
exampleKey: firstExampleKeyForResponseContent(nextContent)
|
|
2215
|
+
exampleKey: firstExampleKeyForResponseContent(nextContent, spec)
|
|
2179
2216
|
}));
|
|
2180
2217
|
},
|
|
2181
2218
|
onSelectExample: (value) => {
|
|
@@ -2188,7 +2225,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2188
2225
|
};
|
|
2189
2226
|
}
|
|
2190
2227
|
function ResponseExamplesPanel(arg0) {
|
|
2191
|
-
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2228
|
+
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2192
2229
|
const t = useBuiltInText();
|
|
2193
2230
|
const state = useResponseExamplesState({
|
|
2194
2231
|
operation,
|
|
@@ -2198,18 +2235,18 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2198
2235
|
selectedStatus,
|
|
2199
2236
|
onSelectStatus
|
|
2200
2237
|
});
|
|
2201
|
-
if (!state.selectedResponse || !state.
|
|
2238
|
+
if (!state.selectedResponse || !state.responseCode) return null;
|
|
2202
2239
|
return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
|
|
2203
|
-
title: t("openapi.response"),
|
|
2240
|
+
title: title ?? t("openapi.response"),
|
|
2204
2241
|
tag: state.selectedResponse.status,
|
|
2205
2242
|
tagOptions: state.responses.map(({ status }) => status),
|
|
2206
2243
|
onSelectTag: state.onSelectStatus,
|
|
2207
|
-
label: state.selectedContent
|
|
2244
|
+
label: state.selectedContent?.mediaType,
|
|
2208
2245
|
labelOptions: state.responseContents.map((content) => content.mediaType),
|
|
2209
|
-
onSelectLabel: state.onSelectMediaType,
|
|
2246
|
+
onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
|
|
2210
2247
|
comfortableMeta: true,
|
|
2211
2248
|
code: state.responseCode,
|
|
2212
|
-
language: codeLanguageForMediaType(state.selectedContent.mediaType),
|
|
2249
|
+
language: state.selectedContent ? codeLanguageForMediaType(state.selectedContent.mediaType) : "http",
|
|
2213
2250
|
examples: state.examples,
|
|
2214
2251
|
selectedExampleKey: state.selectedExample?.key,
|
|
2215
2252
|
onSelectExample: state.onSelectExample
|
|
@@ -2220,7 +2257,7 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2220
2257
|
function getEnumDescriptions(schema) {
|
|
2221
2258
|
const descriptions = schema["x-enumDescriptions"];
|
|
2222
2259
|
if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
|
|
2223
|
-
if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2260
|
+
if (isRecord$1(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2224
2261
|
const description = descriptions[String(value)];
|
|
2225
2262
|
return typeof description === "string" ? description : void 0;
|
|
2226
2263
|
}) : [];
|
|
@@ -2286,7 +2323,7 @@ function getSchemaChildren(arg0) {
|
|
|
2286
2323
|
defaultExpanded
|
|
2287
2324
|
});
|
|
2288
2325
|
}
|
|
2289
|
-
if (!isRecord(schema)) return [];
|
|
2326
|
+
if (!isRecord$1(schema)) return [];
|
|
2290
2327
|
const arrayChildren = schemaHasType(schema, "array") ? getSchemaChildren({
|
|
2291
2328
|
spec,
|
|
2292
2329
|
schema: schema.items,
|
|
@@ -2297,10 +2334,10 @@ function getSchemaChildren(arg0) {
|
|
|
2297
2334
|
}) : [];
|
|
2298
2335
|
const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
|
|
2299
2336
|
const enumChildren = getEnumChildren(schema, path);
|
|
2300
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
2337
|
+
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
2301
2338
|
const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
|
|
2302
2339
|
const resolvedProperty = resolveSchema(spec, propertySchema);
|
|
2303
|
-
const property = isRecord(resolvedProperty) ? resolvedProperty : isRecord(propertySchema) ? propertySchema : {};
|
|
2340
|
+
const property = isRecord$1(resolvedProperty) ? resolvedProperty : isRecord$1(propertySchema) ? propertySchema : {};
|
|
2304
2341
|
const isArray = schemaHasType(property, "array");
|
|
2305
2342
|
const childPath = path ? `${path}.${name}` : name;
|
|
2306
2343
|
const children = getSchemaChildren({
|
|
@@ -2324,7 +2361,7 @@ function getSchemaChildren(arg0) {
|
|
|
2324
2361
|
children
|
|
2325
2362
|
};
|
|
2326
2363
|
});
|
|
2327
|
-
const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
|
|
2364
|
+
const additionalPropertyChildren = isRecord$1(schema.additionalProperties) ? [{
|
|
2328
2365
|
key: `${path || "root"}.*`,
|
|
2329
2366
|
name: "*",
|
|
2330
2367
|
kind: "property",
|
|
@@ -2344,7 +2381,7 @@ function getSchemaChildren(arg0) {
|
|
|
2344
2381
|
}] : [];
|
|
2345
2382
|
const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
|
|
2346
2383
|
const resolvedBranch = resolveSchema(spec, branchSchema);
|
|
2347
|
-
const branch = isRecord(resolvedBranch) ? resolvedBranch : void 0;
|
|
2384
|
+
const branch = isRecord$1(resolvedBranch) ? resolvedBranch : void 0;
|
|
2348
2385
|
return {
|
|
2349
2386
|
key: `${path || "root"}.${label}`,
|
|
2350
2387
|
name: label,
|
|
@@ -2376,7 +2413,7 @@ function getSchemaChildren(arg0) {
|
|
|
2376
2413
|
function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
2377
2414
|
if (isReference(schema)) {
|
|
2378
2415
|
const resolvedSchema = resolveSchema(spec, schema);
|
|
2379
|
-
const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
|
|
2416
|
+
const resolved = isRecord$1(resolvedSchema) ? resolvedSchema : {};
|
|
2380
2417
|
return {
|
|
2381
2418
|
key: schema.$ref,
|
|
2382
2419
|
name: resolveReferenceName(schema.$ref),
|
|
@@ -2394,7 +2431,7 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2394
2431
|
})
|
|
2395
2432
|
};
|
|
2396
2433
|
}
|
|
2397
|
-
if (!isRecord(schema)) return void 0;
|
|
2434
|
+
if (!isRecord$1(schema)) return void 0;
|
|
2398
2435
|
return {
|
|
2399
2436
|
key: "root",
|
|
2400
2437
|
name: "body",
|
|
@@ -2531,7 +2568,7 @@ function ParameterList(arg0) {
|
|
|
2531
2568
|
}, `${parameter.in}-${parameter.name}`)) })] });
|
|
2532
2569
|
}
|
|
2533
2570
|
function ResponseList(arg0) {
|
|
2534
|
-
const { operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2571
|
+
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2535
2572
|
const t = useBuiltInText();
|
|
2536
2573
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2537
2574
|
if (left.status === "default") return -1;
|
|
@@ -2580,12 +2617,12 @@ function ResponseList(arg0) {
|
|
|
2580
2617
|
};
|
|
2581
2618
|
if (orderedResponses.length === 1) {
|
|
2582
2619
|
const [{ status, response }] = orderedResponses;
|
|
2583
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), renderResponsePanel({
|
|
2620
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title ?? t("openapi.responses") }), renderResponsePanel({
|
|
2584
2621
|
status,
|
|
2585
2622
|
response
|
|
2586
2623
|
})] });
|
|
2587
2624
|
}
|
|
2588
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), /* @__PURE__ */ jsx(Tabs, {
|
|
2625
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title ?? t("openapi.responses") }), /* @__PURE__ */ jsx(Tabs, {
|
|
2589
2626
|
selectedIndex,
|
|
2590
2627
|
onChange: (index) => {
|
|
2591
2628
|
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
@@ -2604,7 +2641,7 @@ function ResponseList(arg0) {
|
|
|
2604
2641
|
//#endregion
|
|
2605
2642
|
//#region source/openapi/components/EndpointSections.tsx
|
|
2606
2643
|
function EndpointRequest(arg0) {
|
|
2607
|
-
const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2644
|
+
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2608
2645
|
const t = useBuiltInText();
|
|
2609
2646
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
2610
2647
|
const renderDescription = () => {
|
|
@@ -2656,6 +2693,7 @@ function EndpointRequest(arg0) {
|
|
|
2656
2693
|
selectedServer,
|
|
2657
2694
|
serverVariables,
|
|
2658
2695
|
auth,
|
|
2696
|
+
operationSource,
|
|
2659
2697
|
sharedExampleKey,
|
|
2660
2698
|
onSelectExampleKey
|
|
2661
2699
|
})
|
|
@@ -2664,7 +2702,10 @@ function EndpointRequest(arg0) {
|
|
|
2664
2702
|
})] });
|
|
2665
2703
|
}
|
|
2666
2704
|
function EndpointResponse(arg0) {
|
|
2667
|
-
const { spec, operation, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2705
|
+
const { spec, operation, operationSource = "path", sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2706
|
+
const t = useBuiltInText();
|
|
2707
|
+
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
2708
|
+
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
2668
2709
|
return /* @__PURE__ */ jsx("div", {
|
|
2669
2710
|
className: "mt-6",
|
|
2670
2711
|
children: /* @__PURE__ */ jsxs(Row, {
|
|
@@ -2672,6 +2713,7 @@ function EndpointResponse(arg0) {
|
|
|
2672
2713
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
|
|
2673
2714
|
className: "w-full",
|
|
2674
2715
|
children: /* @__PURE__ */ jsx(ResponseList, {
|
|
2716
|
+
title: responseTitle,
|
|
2675
2717
|
operation,
|
|
2676
2718
|
spec,
|
|
2677
2719
|
selectedStatus,
|
|
@@ -2684,6 +2726,7 @@ function EndpointResponse(arg0) {
|
|
|
2684
2726
|
children: /* @__PURE__ */ jsx(ResponseExamplesPanel, {
|
|
2685
2727
|
operation,
|
|
2686
2728
|
spec,
|
|
2729
|
+
title: responseExampleTitle,
|
|
2687
2730
|
sharedExampleKey,
|
|
2688
2731
|
onSelectExampleKey,
|
|
2689
2732
|
selectedStatus,
|
|
@@ -2696,8 +2739,8 @@ function EndpointResponse(arg0) {
|
|
|
2696
2739
|
}
|
|
2697
2740
|
//#endregion
|
|
2698
2741
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
2699
|
-
function useOperationRequestState(spec, path, operation) {
|
|
2700
|
-
const parameters = getOperationParameters(spec, path, operation);
|
|
2742
|
+
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
2743
|
+
const parameters = getOperationParameters(spec, path, operation, source);
|
|
2701
2744
|
const requestBody = getRequestBody$1(spec, operation);
|
|
2702
2745
|
const requestContents = getMediaTypeEntries(requestBody?.content, spec);
|
|
2703
2746
|
const [selectedRequestMediaType, setSelectedRequestMediaType] = useState(requestContents[0]?.mediaType ?? "");
|
|
@@ -2718,8 +2761,8 @@ function useOperationRequestState(spec, path, operation) {
|
|
|
2718
2761
|
groupedParameters
|
|
2719
2762
|
};
|
|
2720
2763
|
}
|
|
2721
|
-
function useOperationServerState(spec, operation, path) {
|
|
2722
|
-
const servers = getServers(spec, operation, path);
|
|
2764
|
+
function useOperationServerState(spec, operation, path, source = "path") {
|
|
2765
|
+
const servers = getServers(spec, operation, path, source);
|
|
2723
2766
|
const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
|
|
2724
2767
|
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
2725
2768
|
const [serverVariables, setServerVariables] = useState(defaultServerVariables(selectedServer));
|
|
@@ -2776,7 +2819,8 @@ var endpointMethodStyleVars = {
|
|
|
2776
2819
|
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
2777
2820
|
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
2778
2821
|
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
2779
|
-
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)"
|
|
2822
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
2823
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
2780
2824
|
};
|
|
2781
2825
|
function EndpointMethodBadge(arg0) {
|
|
2782
2826
|
const { method } = arg0;
|
|
@@ -2858,9 +2902,12 @@ function getServerPreviewUrl(server, variables) {
|
|
|
2858
2902
|
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
2859
2903
|
}
|
|
2860
2904
|
function getFullEndpointUrl(server, variables, path) {
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2905
|
+
return joinPath(getServerPreviewUrl(server, variables), path);
|
|
2906
|
+
}
|
|
2907
|
+
function getServerProtocolLabel(server, variables) {
|
|
2908
|
+
const url = getServerPreviewUrl(server, variables);
|
|
2909
|
+
const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
|
|
2910
|
+
return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
|
|
2864
2911
|
}
|
|
2865
2912
|
function getDefaultResponseStatus(operation, spec) {
|
|
2866
2913
|
const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
|
|
@@ -2876,6 +2923,7 @@ function getDefaultResponseStatus(operation, spec) {
|
|
|
2876
2923
|
function ServerUrlValue(arg0) {
|
|
2877
2924
|
const { server, variables, open, interactive, onToggle } = arg0;
|
|
2878
2925
|
const url = getServerPreviewUrl(server, variables);
|
|
2926
|
+
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
2879
2927
|
if (!interactive) return /* @__PURE__ */ jsxs("span", {
|
|
2880
2928
|
"aria-label": "Server",
|
|
2881
2929
|
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-foreground) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
|
|
@@ -2885,12 +2933,15 @@ function ServerUrlValue(arg0) {
|
|
|
2885
2933
|
className: "h-4 w-4",
|
|
2886
2934
|
"aria-hidden": "true"
|
|
2887
2935
|
})
|
|
2888
|
-
}), /* @__PURE__ */
|
|
2889
|
-
className: "hidden min-w-0 items-center overflow-hidden sm:flex",
|
|
2890
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
2936
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2937
|
+
className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
|
|
2938
|
+
children: [protocolLabel ? /* @__PURE__ */ jsx("span", {
|
|
2939
|
+
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",
|
|
2940
|
+
children: protocolLabel
|
|
2941
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
2891
2942
|
className: "truncate font-semibold text-xs",
|
|
2892
2943
|
children: url
|
|
2893
|
-
})
|
|
2944
|
+
})]
|
|
2894
2945
|
})]
|
|
2895
2946
|
});
|
|
2896
2947
|
return /* @__PURE__ */ jsxs("button", {
|
|
@@ -2907,13 +2958,20 @@ function ServerUrlValue(arg0) {
|
|
|
2907
2958
|
})
|
|
2908
2959
|
}), /* @__PURE__ */ jsxs("span", {
|
|
2909
2960
|
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
2910
|
-
children: [
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
"
|
|
2916
|
-
|
|
2961
|
+
children: [
|
|
2962
|
+
protocolLabel ? /* @__PURE__ */ jsx("span", {
|
|
2963
|
+
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",
|
|
2964
|
+
children: protocolLabel
|
|
2965
|
+
}) : null,
|
|
2966
|
+
/* @__PURE__ */ jsx("span", {
|
|
2967
|
+
className: "truncate font-semibold text-xs",
|
|
2968
|
+
children: url
|
|
2969
|
+
}),
|
|
2970
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
2971
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
|
|
2972
|
+
"aria-hidden": "true"
|
|
2973
|
+
})
|
|
2974
|
+
]
|
|
2917
2975
|
})]
|
|
2918
2976
|
});
|
|
2919
2977
|
}
|
|
@@ -3020,14 +3078,14 @@ function AuthPanel(arg0) {
|
|
|
3020
3078
|
});
|
|
3021
3079
|
}
|
|
3022
3080
|
function EndpointIdentity(arg0) {
|
|
3023
|
-
const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3081
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3024
3082
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3025
3083
|
const [copiedUrl, setCopiedUrl] = useState(false);
|
|
3026
3084
|
const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
|
|
3027
3085
|
useEffect(() => {
|
|
3028
3086
|
if (!copiedUrl) return void 0;
|
|
3029
|
-
const timeout =
|
|
3030
|
-
return () =>
|
|
3087
|
+
const timeout = setTimeout(() => setCopiedUrl(false), 1200);
|
|
3088
|
+
return () => clearTimeout(timeout);
|
|
3031
3089
|
}, [copiedUrl]);
|
|
3032
3090
|
async function handleCopyUrl() {
|
|
3033
3091
|
if (await copyTextToClipboard(fullUrl)) setCopiedUrl(true);
|
|
@@ -3039,6 +3097,7 @@ function EndpointIdentity(arg0) {
|
|
|
3039
3097
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
3040
3098
|
children: [
|
|
3041
3099
|
/* @__PURE__ */ jsx(EndpointMethodBadge, { method }),
|
|
3100
|
+
operationSource === "webhook" ? /* @__PURE__ */ jsx(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
3042
3101
|
/* @__PURE__ */ jsx(ServerUrlValue, {
|
|
3043
3102
|
server: selectedServer,
|
|
3044
3103
|
variables: serverVariables,
|
|
@@ -3087,12 +3146,12 @@ function EndpointIdentity(arg0) {
|
|
|
3087
3146
|
});
|
|
3088
3147
|
}
|
|
3089
3148
|
function OpenApiOperation(arg0) {
|
|
3090
|
-
const { spec, path, method, operation } = arg0;
|
|
3091
|
-
const id =
|
|
3149
|
+
const { spec, path, method, operation, operationSource = "path" } = arg0;
|
|
3150
|
+
const id = getOpenApiOperationSectionId(operation);
|
|
3092
3151
|
const summary = operation.summary ?? `${method} ${path}`;
|
|
3093
3152
|
const description = operation.description;
|
|
3094
|
-
const requestState = useOperationRequestState(spec, path, operation);
|
|
3095
|
-
const serverState = useOperationServerState(spec, operation, path);
|
|
3153
|
+
const requestState = useOperationRequestState(spec, path, operation, operationSource);
|
|
3154
|
+
const serverState = useOperationServerState(spec, operation, path, operationSource);
|
|
3096
3155
|
const authState = useOperationAuthState(spec, operation);
|
|
3097
3156
|
const [linkedExampleKey, setLinkedExampleKey] = useState("");
|
|
3098
3157
|
const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
|
|
@@ -3106,6 +3165,7 @@ function OpenApiOperation(arg0) {
|
|
|
3106
3165
|
}),
|
|
3107
3166
|
/* @__PURE__ */ jsx(EndpointIdentity, {
|
|
3108
3167
|
method,
|
|
3168
|
+
operationSource,
|
|
3109
3169
|
path,
|
|
3110
3170
|
servers: serverState.servers,
|
|
3111
3171
|
selectedServerKey: serverState.selectedServerKey,
|
|
@@ -3134,6 +3194,7 @@ function OpenApiOperation(arg0) {
|
|
|
3134
3194
|
spec,
|
|
3135
3195
|
path,
|
|
3136
3196
|
method,
|
|
3197
|
+
operationSource,
|
|
3137
3198
|
description,
|
|
3138
3199
|
groupedParameters: requestState.groupedParameters,
|
|
3139
3200
|
parameters: requestState.parameters,
|
|
@@ -3151,6 +3212,7 @@ function OpenApiOperation(arg0) {
|
|
|
3151
3212
|
/* @__PURE__ */ jsx(EndpointResponse, {
|
|
3152
3213
|
spec,
|
|
3153
3214
|
operation,
|
|
3215
|
+
operationSource,
|
|
3154
3216
|
sharedExampleKey: linkedExampleKey,
|
|
3155
3217
|
onSelectExampleKey: setLinkedExampleKey,
|
|
3156
3218
|
selectedStatus: selectedResponseStatus,
|
|
@@ -3160,6 +3222,6 @@ function OpenApiOperation(arg0) {
|
|
|
3160
3222
|
});
|
|
3161
3223
|
}
|
|
3162
3224
|
//#endregion
|
|
3163
|
-
export {
|
|
3225
|
+
export { CardGroup as A, Feedback as C, Pre as D, CodeGroup as E, Button as M, Mermaid as O, Tag as S, Code as T, Prose as _, authPlaceholder as a, Logo as b, getServerKey as c, listOpenApiOperations as d, getMediaTypeEntries as f, WebFrame as g, primitives_exports as h, ResponseExamplesPanel as i, Callout as j, Card as k, getServers as l, Markdown as m, OpenApiOperation as n, defaultServerVariables as o, getRequestBody$1 as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getOpenApiOperationEntry as u, GridPattern as v, Collapse as w, Heading as x, HeroPattern as y };
|
|
3164
3226
|
|
|
3165
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
3227
|
+
//# sourceMappingURL=OpenApiOperation-CqNM-no4.js.map
|