@clarify-labs/renderer 0.9.4 → 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-D2P0iZ_m.js → ClarifyShell-1LuBliwt.js} +124 -40
- package/output/ClarifyShell-1LuBliwt.js.map +1 -0
- package/output/{ClarifyShell-7r92MZg9.cjs → ClarifyShell-C6li72Ce.cjs} +138 -54
- 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-Dhlz3JSx.js → OpenApiOperation-CqNM-no4.js} +274 -206
- package/output/OpenApiOperation-CqNM-no4.js.map +1 -0
- package/output/{OpenApiOperation-CyyPlZL6.cjs → OpenApiOperation-DK46w2dq.cjs} +305 -225
- package/output/OpenApiOperation-DK46w2dq.cjs.map +1 -0
- package/output/{PageActions-CTn2XkPg.cjs → PageActions-BjB6PYmL.cjs} +76 -735
- package/output/PageActions-BjB6PYmL.cjs.map +1 -0
- package/output/{PageActions-D0PA8Zv5.js → PageActions-D7K9LDGf.js} +67 -678
- 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 +91 -94
- 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/markdown.cjs +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/remark-Dd2WU50s.js.map +1 -1
- package/output/{remark-Dv3owbSH.cjs → remark-zSQT0MBv.cjs} +3 -3
- package/output/{remark-Dv3owbSH.cjs.map → remark-zSQT0MBv.cjs.map} +1 -1
- package/output/{render-CwSsfrs7.js → render-DKj24Jqw.js} +15 -8
- package/output/render-DKj24Jqw.js.map +1 -0
- package/output/{render-DXDSIfZ8.cjs → render-Di5B6Zc0.cjs} +15 -8
- package/output/render-Di5B6Zc0.cjs.map +1 -0
- package/output/renderer.css +55 -1
- 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 +10 -10
- package/output/ClarifyShell-7r92MZg9.cjs.map +0 -1
- package/output/ClarifyShell-D2P0iZ_m.js.map +0 -1
- package/output/OpenApiOperation-CyyPlZL6.cjs.map +0 -1
- package/output/OpenApiOperation-Dhlz3JSx.js.map +0 -1
- package/output/PageActions-CTn2XkPg.cjs.map +0 -1
- package/output/PageActions-D0PA8Zv5.js.map +0 -1
- package/output/render-CwSsfrs7.js.map +0 -1
- package/output/render-DXDSIfZ8.cjs.map +0 -1
- /package/output/{chunk-DakpK96I.cjs → rolldown-runtime-DakpK96I.cjs} +0 -0
|
@@ -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(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
|
}) : [];
|
|
@@ -2282,11 +2319,11 @@ function getSchemaChildren(arg0) {
|
|
|
2282
2319
|
path,
|
|
2283
2320
|
required,
|
|
2284
2321
|
depth,
|
|
2285
|
-
seen: new Set([...seen, schema.$ref]),
|
|
2322
|
+
seen: /* @__PURE__ */ new Set([...seen, schema.$ref]),
|
|
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),
|
|
@@ -2389,12 +2426,12 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2389
2426
|
spec,
|
|
2390
2427
|
schema: resolvedSchema,
|
|
2391
2428
|
path: resolveReferenceName(schema.$ref),
|
|
2392
|
-
seen: new Set([schema.$ref]),
|
|
2429
|
+
seen: /* @__PURE__ */ new Set([schema.$ref]),
|
|
2393
2430
|
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",
|
|
@@ -2518,22 +2555,20 @@ function SchemaProperties(arg0) {
|
|
|
2518
2555
|
})] });
|
|
2519
2556
|
}
|
|
2520
2557
|
function ParameterList(arg0) {
|
|
2521
|
-
const { title, parameters } = arg0;
|
|
2522
2558
|
const t = useBuiltInText();
|
|
2523
|
-
|
|
2559
|
+
const { title, parameters } = arg0;
|
|
2560
|
+
if (parameters.length === 0) return null;
|
|
2561
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ jsx(Property, {
|
|
2524
2562
|
name: parameter.name ?? t("openapi.parameter"),
|
|
2525
2563
|
type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
|
|
2526
2564
|
children: parameter.description ? /* @__PURE__ */ jsx(Markdown, {
|
|
2527
2565
|
className: "*:first:mt-0 *:last:mb-0",
|
|
2528
2566
|
children: parameter.description
|
|
2529
2567
|
}) : t("openapi.operationParameter")
|
|
2530
|
-
}, `${parameter.in}-${parameter.name}`))
|
|
2531
|
-
className: "text-sm/5 text-(--clarify-ui-text-soft)",
|
|
2532
|
-
children: t("openapi.none")
|
|
2533
|
-
}) })] });
|
|
2568
|
+
}, `${parameter.in}-${parameter.name}`)) })] });
|
|
2534
2569
|
}
|
|
2535
2570
|
function ResponseList(arg0) {
|
|
2536
|
-
const { operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2571
|
+
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2537
2572
|
const t = useBuiltInText();
|
|
2538
2573
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2539
2574
|
if (left.status === "default") return -1;
|
|
@@ -2582,12 +2617,12 @@ function ResponseList(arg0) {
|
|
|
2582
2617
|
};
|
|
2583
2618
|
if (orderedResponses.length === 1) {
|
|
2584
2619
|
const [{ status, response }] = orderedResponses;
|
|
2585
|
-
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({
|
|
2586
2621
|
status,
|
|
2587
2622
|
response
|
|
2588
2623
|
})] });
|
|
2589
2624
|
}
|
|
2590
|
-
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, {
|
|
2591
2626
|
selectedIndex,
|
|
2592
2627
|
onChange: (index) => {
|
|
2593
2628
|
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
@@ -2606,9 +2641,25 @@ function ResponseList(arg0) {
|
|
|
2606
2641
|
//#endregion
|
|
2607
2642
|
//#region source/openapi/components/EndpointSections.tsx
|
|
2608
2643
|
function EndpointRequest(arg0) {
|
|
2609
|
-
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;
|
|
2610
2645
|
const t = useBuiltInText();
|
|
2611
|
-
|
|
2646
|
+
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
2647
|
+
const renderDescription = () => {
|
|
2648
|
+
if (!description) return null;
|
|
2649
|
+
return /* @__PURE__ */ jsx(Markdown, { children: description });
|
|
2650
|
+
};
|
|
2651
|
+
const renderRequestBody = () => {
|
|
2652
|
+
if (!hasRequestBody) return /* @__PURE__ */ jsx("p", {
|
|
2653
|
+
className: "text-sm/5 text-(--clarify-ui-text-soft)",
|
|
2654
|
+
children: t("openapi.requestBodyEmpty")
|
|
2655
|
+
});
|
|
2656
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [typeof requestBody?.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null, /* @__PURE__ */ jsx(SchemaProperties, {
|
|
2657
|
+
title: t("openapi.bodyProperties"),
|
|
2658
|
+
schema: requestSchema,
|
|
2659
|
+
spec
|
|
2660
|
+
})] });
|
|
2661
|
+
};
|
|
2662
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [renderDescription(), /* @__PURE__ */ jsxs(Row, {
|
|
2612
2663
|
className: "relative mt-6",
|
|
2613
2664
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsxs("div", {
|
|
2614
2665
|
className: "w-full",
|
|
@@ -2625,15 +2676,7 @@ function EndpointRequest(arg0) {
|
|
|
2625
2676
|
title: t("openapi.headers"),
|
|
2626
2677
|
parameters: groupedParameters.header
|
|
2627
2678
|
}),
|
|
2628
|
-
|
|
2629
|
-
/* @__PURE__ */ jsx("h3", { children: t("openapi.requestBody") }),
|
|
2630
|
-
typeof requestBody.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null,
|
|
2631
|
-
/* @__PURE__ */ jsx(SchemaProperties, {
|
|
2632
|
-
title: t("openapi.bodyProperties"),
|
|
2633
|
-
schema: requestSchema,
|
|
2634
|
-
spec
|
|
2635
|
-
})
|
|
2636
|
-
] }) : null
|
|
2679
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.requestBody") }), renderRequestBody()] })
|
|
2637
2680
|
]
|
|
2638
2681
|
}) }), /* @__PURE__ */ jsx(Col, {
|
|
2639
2682
|
sticky: true,
|
|
@@ -2650,6 +2693,7 @@ function EndpointRequest(arg0) {
|
|
|
2650
2693
|
selectedServer,
|
|
2651
2694
|
serverVariables,
|
|
2652
2695
|
auth,
|
|
2696
|
+
operationSource,
|
|
2653
2697
|
sharedExampleKey,
|
|
2654
2698
|
onSelectExampleKey
|
|
2655
2699
|
})
|
|
@@ -2658,7 +2702,10 @@ function EndpointRequest(arg0) {
|
|
|
2658
2702
|
})] });
|
|
2659
2703
|
}
|
|
2660
2704
|
function EndpointResponse(arg0) {
|
|
2661
|
-
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");
|
|
2662
2709
|
return /* @__PURE__ */ jsx("div", {
|
|
2663
2710
|
className: "mt-6",
|
|
2664
2711
|
children: /* @__PURE__ */ jsxs(Row, {
|
|
@@ -2666,6 +2713,7 @@ function EndpointResponse(arg0) {
|
|
|
2666
2713
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
|
|
2667
2714
|
className: "w-full",
|
|
2668
2715
|
children: /* @__PURE__ */ jsx(ResponseList, {
|
|
2716
|
+
title: responseTitle,
|
|
2669
2717
|
operation,
|
|
2670
2718
|
spec,
|
|
2671
2719
|
selectedStatus,
|
|
@@ -2678,6 +2726,7 @@ function EndpointResponse(arg0) {
|
|
|
2678
2726
|
children: /* @__PURE__ */ jsx(ResponseExamplesPanel, {
|
|
2679
2727
|
operation,
|
|
2680
2728
|
spec,
|
|
2729
|
+
title: responseExampleTitle,
|
|
2681
2730
|
sharedExampleKey,
|
|
2682
2731
|
onSelectExampleKey,
|
|
2683
2732
|
selectedStatus,
|
|
@@ -2690,8 +2739,8 @@ function EndpointResponse(arg0) {
|
|
|
2690
2739
|
}
|
|
2691
2740
|
//#endregion
|
|
2692
2741
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
2693
|
-
function useOperationRequestState(spec, path, operation) {
|
|
2694
|
-
const parameters = getOperationParameters(spec, path, operation);
|
|
2742
|
+
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
2743
|
+
const parameters = getOperationParameters(spec, path, operation, source);
|
|
2695
2744
|
const requestBody = getRequestBody$1(spec, operation);
|
|
2696
2745
|
const requestContents = getMediaTypeEntries(requestBody?.content, spec);
|
|
2697
2746
|
const [selectedRequestMediaType, setSelectedRequestMediaType] = useState(requestContents[0]?.mediaType ?? "");
|
|
@@ -2712,8 +2761,8 @@ function useOperationRequestState(spec, path, operation) {
|
|
|
2712
2761
|
groupedParameters
|
|
2713
2762
|
};
|
|
2714
2763
|
}
|
|
2715
|
-
function useOperationServerState(spec, operation, path) {
|
|
2716
|
-
const servers = getServers(spec, operation, path);
|
|
2764
|
+
function useOperationServerState(spec, operation, path, source = "path") {
|
|
2765
|
+
const servers = getServers(spec, operation, path, source);
|
|
2717
2766
|
const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
|
|
2718
2767
|
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
2719
2768
|
const [serverVariables, setServerVariables] = useState(defaultServerVariables(selectedServer));
|
|
@@ -2770,7 +2819,8 @@ var endpointMethodStyleVars = {
|
|
|
2770
2819
|
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
2771
2820
|
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
2772
2821
|
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
2773
|
-
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)"
|
|
2774
2824
|
};
|
|
2775
2825
|
function EndpointMethodBadge(arg0) {
|
|
2776
2826
|
const { method } = arg0;
|
|
@@ -2852,9 +2902,12 @@ function getServerPreviewUrl(server, variables) {
|
|
|
2852
2902
|
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
2853
2903
|
}
|
|
2854
2904
|
function getFullEndpointUrl(server, variables, path) {
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
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;
|
|
2858
2911
|
}
|
|
2859
2912
|
function getDefaultResponseStatus(operation, spec) {
|
|
2860
2913
|
const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
|
|
@@ -2870,6 +2923,7 @@ function getDefaultResponseStatus(operation, spec) {
|
|
|
2870
2923
|
function ServerUrlValue(arg0) {
|
|
2871
2924
|
const { server, variables, open, interactive, onToggle } = arg0;
|
|
2872
2925
|
const url = getServerPreviewUrl(server, variables);
|
|
2926
|
+
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
2873
2927
|
if (!interactive) return /* @__PURE__ */ jsxs("span", {
|
|
2874
2928
|
"aria-label": "Server",
|
|
2875
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",
|
|
@@ -2879,12 +2933,15 @@ function ServerUrlValue(arg0) {
|
|
|
2879
2933
|
className: "h-4 w-4",
|
|
2880
2934
|
"aria-hidden": "true"
|
|
2881
2935
|
})
|
|
2882
|
-
}), /* @__PURE__ */
|
|
2883
|
-
className: "hidden min-w-0 items-center overflow-hidden sm:flex",
|
|
2884
|
-
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", {
|
|
2885
2942
|
className: "truncate font-semibold text-xs",
|
|
2886
2943
|
children: url
|
|
2887
|
-
})
|
|
2944
|
+
})]
|
|
2888
2945
|
})]
|
|
2889
2946
|
});
|
|
2890
2947
|
return /* @__PURE__ */ jsxs("button", {
|
|
@@ -2901,13 +2958,20 @@ function ServerUrlValue(arg0) {
|
|
|
2901
2958
|
})
|
|
2902
2959
|
}), /* @__PURE__ */ jsxs("span", {
|
|
2903
2960
|
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
2904
|
-
children: [
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
"
|
|
2910
|
-
|
|
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
|
+
]
|
|
2911
2975
|
})]
|
|
2912
2976
|
});
|
|
2913
2977
|
}
|
|
@@ -3014,14 +3078,14 @@ function AuthPanel(arg0) {
|
|
|
3014
3078
|
});
|
|
3015
3079
|
}
|
|
3016
3080
|
function EndpointIdentity(arg0) {
|
|
3017
|
-
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;
|
|
3018
3082
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3019
3083
|
const [copiedUrl, setCopiedUrl] = useState(false);
|
|
3020
3084
|
const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
|
|
3021
3085
|
useEffect(() => {
|
|
3022
3086
|
if (!copiedUrl) return void 0;
|
|
3023
|
-
const timeout =
|
|
3024
|
-
return () =>
|
|
3087
|
+
const timeout = setTimeout(() => setCopiedUrl(false), 1200);
|
|
3088
|
+
return () => clearTimeout(timeout);
|
|
3025
3089
|
}, [copiedUrl]);
|
|
3026
3090
|
async function handleCopyUrl() {
|
|
3027
3091
|
if (await copyTextToClipboard(fullUrl)) setCopiedUrl(true);
|
|
@@ -3033,6 +3097,7 @@ function EndpointIdentity(arg0) {
|
|
|
3033
3097
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
3034
3098
|
children: [
|
|
3035
3099
|
/* @__PURE__ */ jsx(EndpointMethodBadge, { method }),
|
|
3100
|
+
operationSource === "webhook" ? /* @__PURE__ */ jsx(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
3036
3101
|
/* @__PURE__ */ jsx(ServerUrlValue, {
|
|
3037
3102
|
server: selectedServer,
|
|
3038
3103
|
variables: serverVariables,
|
|
@@ -3081,12 +3146,12 @@ function EndpointIdentity(arg0) {
|
|
|
3081
3146
|
});
|
|
3082
3147
|
}
|
|
3083
3148
|
function OpenApiOperation(arg0) {
|
|
3084
|
-
const { spec, path, method, operation } = arg0;
|
|
3085
|
-
const id =
|
|
3149
|
+
const { spec, path, method, operation, operationSource = "path" } = arg0;
|
|
3150
|
+
const id = getOpenApiOperationSectionId(operation);
|
|
3086
3151
|
const summary = operation.summary ?? `${method} ${path}`;
|
|
3087
3152
|
const description = operation.description;
|
|
3088
|
-
const requestState = useOperationRequestState(spec, path, operation);
|
|
3089
|
-
const serverState = useOperationServerState(spec, operation, path);
|
|
3153
|
+
const requestState = useOperationRequestState(spec, path, operation, operationSource);
|
|
3154
|
+
const serverState = useOperationServerState(spec, operation, path, operationSource);
|
|
3090
3155
|
const authState = useOperationAuthState(spec, operation);
|
|
3091
3156
|
const [linkedExampleKey, setLinkedExampleKey] = useState("");
|
|
3092
3157
|
const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
|
|
@@ -3100,6 +3165,7 @@ function OpenApiOperation(arg0) {
|
|
|
3100
3165
|
}),
|
|
3101
3166
|
/* @__PURE__ */ jsx(EndpointIdentity, {
|
|
3102
3167
|
method,
|
|
3168
|
+
operationSource,
|
|
3103
3169
|
path,
|
|
3104
3170
|
servers: serverState.servers,
|
|
3105
3171
|
selectedServerKey: serverState.selectedServerKey,
|
|
@@ -3128,6 +3194,7 @@ function OpenApiOperation(arg0) {
|
|
|
3128
3194
|
spec,
|
|
3129
3195
|
path,
|
|
3130
3196
|
method,
|
|
3197
|
+
operationSource,
|
|
3131
3198
|
description,
|
|
3132
3199
|
groupedParameters: requestState.groupedParameters,
|
|
3133
3200
|
parameters: requestState.parameters,
|
|
@@ -3145,6 +3212,7 @@ function OpenApiOperation(arg0) {
|
|
|
3145
3212
|
/* @__PURE__ */ jsx(EndpointResponse, {
|
|
3146
3213
|
spec,
|
|
3147
3214
|
operation,
|
|
3215
|
+
operationSource,
|
|
3148
3216
|
sharedExampleKey: linkedExampleKey,
|
|
3149
3217
|
onSelectExampleKey: setLinkedExampleKey,
|
|
3150
3218
|
selectedStatus: selectedResponseStatus,
|
|
@@ -3154,6 +3222,6 @@ function OpenApiOperation(arg0) {
|
|
|
3154
3222
|
});
|
|
3155
3223
|
}
|
|
3156
3224
|
//#endregion
|
|
3157
|
-
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 };
|
|
3158
3226
|
|
|
3159
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
3227
|
+
//# sourceMappingURL=OpenApiOperation-CqNM-no4.js.map
|