@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,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_i18n = require("./i18n-b4iTLeia.cjs");
|
|
3
|
+
const require_PageActions = require("./PageActions-BjB6PYmL.cjs");
|
|
3
4
|
const require_remark = require("./remark-zSQT0MBv.cjs");
|
|
4
5
|
let clsx = require("clsx");
|
|
5
6
|
clsx = require_rolldown_runtime.__toESM(clsx, 1);
|
|
@@ -10,14 +11,13 @@ let lucide_react = require("lucide-react");
|
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
let framer_motion = require("framer-motion");
|
|
12
13
|
let zustand = require("zustand");
|
|
13
|
-
let react_zoom_pan_pinch = require("react-zoom-pan-pinch");
|
|
14
14
|
let react_markdown = require("react-markdown");
|
|
15
15
|
react_markdown = require_rolldown_runtime.__toESM(react_markdown, 1);
|
|
16
16
|
let github_slugger = require("github-slugger");
|
|
17
17
|
let _scalar_snippetz = require("@scalar/snippetz");
|
|
18
18
|
//#region source/components/LocalizedLink.tsx
|
|
19
19
|
function useLocalizedHref(href) {
|
|
20
|
-
return require_PageActions.localizeHref(href,
|
|
20
|
+
return require_PageActions.localizeHref(href, require_i18n.useConfig(), require_i18n.useLocale());
|
|
21
21
|
}
|
|
22
22
|
function LocalizedLink(arg0) {
|
|
23
23
|
const { href, ...props } = arg0;
|
|
@@ -116,7 +116,7 @@ var defaultTitleKeys = {
|
|
|
116
116
|
};
|
|
117
117
|
function Callout(arg0) {
|
|
118
118
|
const { children, type = "info", title, icon = true, className, ...props } = arg0;
|
|
119
|
-
const t =
|
|
119
|
+
const t = require_i18n.useBuiltInText();
|
|
120
120
|
const style = calloutStyles[type];
|
|
121
121
|
const Icon = style.Icon;
|
|
122
122
|
const resolvedTitle = title === void 0 ? t(defaultTitleKeys[type]) : title;
|
|
@@ -200,63 +200,19 @@ function Card(arg0) {
|
|
|
200
200
|
}
|
|
201
201
|
//#endregion
|
|
202
202
|
//#region source/components/Mermaid.tsx
|
|
203
|
+
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-B6-BMCJG.cjs")));
|
|
203
204
|
var mermaidModulePromise;
|
|
204
205
|
async function loadMermaid() {
|
|
205
206
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
206
207
|
return mermaidModulePromise;
|
|
207
208
|
}
|
|
208
|
-
function ZoomControls() {
|
|
209
|
-
const { zoomIn, zoomOut, resetTransform } = (0, react_zoom_pan_pinch.useControls)();
|
|
210
|
-
const t = require_PageActions.useBuiltInText();
|
|
211
|
-
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)";
|
|
212
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
213
|
-
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",
|
|
214
|
-
children: [
|
|
215
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
216
|
-
type: "button",
|
|
217
|
-
"aria-label": t("mermaid.zoomIn"),
|
|
218
|
-
title: t("mermaid.zoomIn"),
|
|
219
|
-
onClick: () => zoomIn(),
|
|
220
|
-
className: buttonClassName,
|
|
221
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ZoomIn, {
|
|
222
|
-
className: "h-4 w-4",
|
|
223
|
-
"aria-hidden": "true"
|
|
224
|
-
})
|
|
225
|
-
}),
|
|
226
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
227
|
-
type: "button",
|
|
228
|
-
"aria-label": t("mermaid.zoomOut"),
|
|
229
|
-
title: t("mermaid.zoomOut"),
|
|
230
|
-
onClick: () => zoomOut(),
|
|
231
|
-
className: buttonClassName,
|
|
232
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ZoomOut, {
|
|
233
|
-
className: "h-4 w-4",
|
|
234
|
-
"aria-hidden": "true"
|
|
235
|
-
})
|
|
236
|
-
}),
|
|
237
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
238
|
-
type: "button",
|
|
239
|
-
"aria-label": t("mermaid.resetZoom"),
|
|
240
|
-
title: t("mermaid.resetZoom"),
|
|
241
|
-
onClick: () => resetTransform(),
|
|
242
|
-
className: buttonClassName,
|
|
243
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Maximize2, {
|
|
244
|
-
className: "h-4 w-4",
|
|
245
|
-
"aria-hidden": "true"
|
|
246
|
-
})
|
|
247
|
-
})
|
|
248
|
-
]
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
209
|
function Mermaid(arg0) {
|
|
252
210
|
const { chart, className } = arg0;
|
|
253
|
-
const t =
|
|
211
|
+
const t = require_i18n.useBuiltInText();
|
|
254
212
|
const { resolvedTheme } = require_PageActions.useTheme();
|
|
255
213
|
const renderId = `clarify-mermaid-${(0, react.useId)().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
256
|
-
const containerRef = (0, react.useRef)(null);
|
|
257
214
|
const [svg, setSvg] = (0, react.useState)("");
|
|
258
215
|
const [error, setError] = (0, react.useState)(void 0);
|
|
259
|
-
const [focused, setFocused] = (0, react.useState)(false);
|
|
260
216
|
(0, react.useEffect)(() => {
|
|
261
217
|
let cancelled = false;
|
|
262
218
|
async function renderChart() {
|
|
@@ -319,42 +275,24 @@ function Mermaid(arg0) {
|
|
|
319
275
|
children: chart.trim()
|
|
320
276
|
})
|
|
321
277
|
});
|
|
278
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
|
|
279
|
+
fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MermaidStaticSvg, {
|
|
280
|
+
svg,
|
|
281
|
+
className
|
|
282
|
+
}),
|
|
283
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MermaidViewer, {
|
|
284
|
+
svg,
|
|
285
|
+
className
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function MermaidStaticSvg(arg0) {
|
|
290
|
+
const { svg, className } = arg0;
|
|
322
291
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
onFocus: () => setFocused(true),
|
|
328
|
-
onBlur: () => setFocused(false),
|
|
329
|
-
className: (0, clsx.default)("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),
|
|
330
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_zoom_pan_pinch.TransformWrapper, {
|
|
331
|
-
minScale: .5,
|
|
332
|
-
maxScale: 8,
|
|
333
|
-
initialScale: 1,
|
|
334
|
-
centerOnInit: true,
|
|
335
|
-
smooth: true,
|
|
336
|
-
wheel: {
|
|
337
|
-
step: .05,
|
|
338
|
-
wheelDisabled: !focused,
|
|
339
|
-
touchPadDisabled: !focused
|
|
340
|
-
},
|
|
341
|
-
doubleClick: { mode: "reset" },
|
|
342
|
-
children: [
|
|
343
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomControls, {}),
|
|
344
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_zoom_pan_pinch.TransformComponent, {
|
|
345
|
-
wrapperClass: "!w-full !cursor-grab active:!cursor-grabbing",
|
|
346
|
-
contentClass: "!w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
|
|
347
|
-
wrapperStyle: { height: "min(70vh, 32rem)" },
|
|
348
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
349
|
-
className: "flex h-full w-full items-center justify-center p-4",
|
|
350
|
-
dangerouslySetInnerHTML: { __html: svg }
|
|
351
|
-
})
|
|
352
|
-
}),
|
|
353
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
354
|
-
className: (0, clsx.default)("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"),
|
|
355
|
-
children: t("mermaid.scrollHint")
|
|
356
|
-
})
|
|
357
|
-
]
|
|
292
|
+
className: (0, clsx.default)("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),
|
|
293
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
294
|
+
className: "flex w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
|
|
295
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
358
296
|
})
|
|
359
297
|
});
|
|
360
298
|
}
|
|
@@ -390,13 +328,13 @@ function getNodeText(node) {
|
|
|
390
328
|
}
|
|
391
329
|
function CopyButton(arg0) {
|
|
392
330
|
const { code } = arg0;
|
|
393
|
-
const t =
|
|
331
|
+
const t = require_i18n.useBuiltInText();
|
|
394
332
|
const [copyCount, setCopyCount] = (0, react.useState)(0);
|
|
395
333
|
const copied = copyCount > 0;
|
|
396
334
|
(0, react.useEffect)(() => {
|
|
397
335
|
if (copyCount === 0) return void 0;
|
|
398
|
-
const timeout =
|
|
399
|
-
return () =>
|
|
336
|
+
const timeout = setTimeout(() => setCopyCount(0), 1e3);
|
|
337
|
+
return () => clearTimeout(timeout);
|
|
400
338
|
}, [copyCount]);
|
|
401
339
|
if (!code) return null;
|
|
402
340
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
@@ -455,7 +393,7 @@ function CodePanel(arg0) {
|
|
|
455
393
|
}
|
|
456
394
|
function CodeGroupHeader(arg0) {
|
|
457
395
|
const { title, children, selectedIndex } = arg0;
|
|
458
|
-
const t =
|
|
396
|
+
const t = require_i18n.useBuiltInText();
|
|
459
397
|
const hasTabs = react.Children.count(children) > 1;
|
|
460
398
|
if (!title && !hasTabs) return null;
|
|
461
399
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -534,7 +472,7 @@ function useTabGroupProps(availableLanguages) {
|
|
|
534
472
|
var CodeGroupContext = (0, react.createContext)(false);
|
|
535
473
|
function CodeGroup(arg0) {
|
|
536
474
|
const { children, title, ...props } = arg0;
|
|
537
|
-
const t =
|
|
475
|
+
const t = require_i18n.useBuiltInText();
|
|
538
476
|
const tabGroupProps = useTabGroupProps(react.Children.map(children, (child) => getPanelTitle({
|
|
539
477
|
...(0, react.isValidElement)(child) ? child.props : {},
|
|
540
478
|
fallbackTitle: t("actions.code")
|
|
@@ -641,7 +579,7 @@ function FeedbackButton(props) {
|
|
|
641
579
|
}
|
|
642
580
|
var FeedbackForm = (0, react.forwardRef)(function FeedbackForm(arg0, ref) {
|
|
643
581
|
const { onSubmit, className, ...props } = arg0;
|
|
644
|
-
const t =
|
|
582
|
+
const t = require_i18n.useBuiltInText();
|
|
645
583
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
646
584
|
...props,
|
|
647
585
|
ref,
|
|
@@ -668,7 +606,7 @@ var FeedbackForm = (0, react.forwardRef)(function FeedbackForm(arg0, ref) {
|
|
|
668
606
|
});
|
|
669
607
|
var FeedbackThanks = (0, react.forwardRef)(function FeedbackThanks(arg0, ref) {
|
|
670
608
|
const { className, ...props } = arg0;
|
|
671
|
-
const t =
|
|
609
|
+
const t = require_i18n.useBuiltInText();
|
|
672
610
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
673
611
|
...props,
|
|
674
612
|
ref,
|
|
@@ -1191,38 +1129,48 @@ function Markdown(arg0) {
|
|
|
1191
1129
|
}
|
|
1192
1130
|
//#endregion
|
|
1193
1131
|
//#region source/openapi/lib/helpers.ts
|
|
1194
|
-
function isRecord(value) {
|
|
1132
|
+
function isRecord$1(value) {
|
|
1195
1133
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1196
1134
|
}
|
|
1197
1135
|
function isReference(value) {
|
|
1198
|
-
return isRecord(value) && typeof value.$ref === "string";
|
|
1136
|
+
return isRecord$1(value) && typeof value.$ref === "string";
|
|
1199
1137
|
}
|
|
1200
1138
|
function resolveReferenceName(ref) {
|
|
1201
1139
|
return ref.split("/").filter(Boolean).at(-1) ?? ref;
|
|
1202
1140
|
}
|
|
1203
|
-
function resolveOpenApiRef(spec, ref) {
|
|
1141
|
+
function resolveOpenApiRef$1(spec, ref) {
|
|
1204
1142
|
if (!ref.startsWith("#/")) return void 0;
|
|
1205
|
-
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
1143
|
+
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);
|
|
1206
1144
|
}
|
|
1207
1145
|
function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
|
|
1208
1146
|
if (!isReference(schema)) return schema;
|
|
1209
1147
|
if (seen.has(schema.$ref)) return schema;
|
|
1210
1148
|
seen.add(schema.$ref);
|
|
1211
|
-
return resolveSchema(spec, resolveOpenApiRef(spec, schema.$ref), seen) ?? schema;
|
|
1149
|
+
return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
|
|
1212
1150
|
}
|
|
1213
|
-
function getPathItem(spec, path) {
|
|
1151
|
+
function getPathItem$1(spec, path) {
|
|
1214
1152
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1215
1153
|
}
|
|
1154
|
+
function getOperationPathItem(spec, path, source = "path") {
|
|
1155
|
+
if (source === "path") return getPathItem$1(spec, path);
|
|
1156
|
+
const webhooks = spec.webhooks;
|
|
1157
|
+
return resolveObjectRef(spec, isRecord$1(webhooks) ? webhooks[path] : void 0);
|
|
1158
|
+
}
|
|
1159
|
+
function joinPath(base, path) {
|
|
1160
|
+
if (!base) return path || "/";
|
|
1161
|
+
if (!path) return base;
|
|
1162
|
+
return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
|
|
1163
|
+
}
|
|
1216
1164
|
function resolveObjectRef(spec, value) {
|
|
1217
|
-
const resolved = spec && isReference(value) ? resolveOpenApiRef(spec, value.$ref) : value;
|
|
1218
|
-
return isRecord(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
1165
|
+
const resolved = spec && isReference(value) ? resolveOpenApiRef$1(spec, value.$ref) : value;
|
|
1166
|
+
return isRecord$1(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
1219
1167
|
}
|
|
1220
1168
|
function schemaHasType(schema, type) {
|
|
1221
|
-
if (!isRecord(schema)) return false;
|
|
1169
|
+
if (!isRecord$1(schema)) return false;
|
|
1222
1170
|
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
1223
1171
|
}
|
|
1224
|
-
function getOperationParameters(spec, path, operation) {
|
|
1225
|
-
const pathParameters =
|
|
1172
|
+
function getOperationParameters(spec, path, operation, source = "path") {
|
|
1173
|
+
const pathParameters = getOperationPathItem(spec, path, source)?.parameters;
|
|
1226
1174
|
const operationParameters = operation.parameters;
|
|
1227
1175
|
const parameters = [...Array.isArray(pathParameters) ? pathParameters : [], ...Array.isArray(operationParameters) ? operationParameters : []].map((parameter) => resolveObjectRef(spec, parameter)).filter((parameter) => Boolean(parameter));
|
|
1228
1176
|
const deduped = /* @__PURE__ */ new Map();
|
|
@@ -1240,7 +1188,7 @@ function getRequestBody$1(spec, operation) {
|
|
|
1240
1188
|
return resolveObjectRef(spec, requestBody);
|
|
1241
1189
|
}
|
|
1242
1190
|
function getMediaTypeEntries(content, spec) {
|
|
1243
|
-
if (!isRecord(content)) return [];
|
|
1191
|
+
if (!isRecord$1(content)) return [];
|
|
1244
1192
|
return Object.entries(content).map(([mediaType, value]) => ({
|
|
1245
1193
|
mediaType,
|
|
1246
1194
|
value: resolveObjectRef(spec, value)
|
|
@@ -1252,12 +1200,12 @@ function getJsonLikeContent(content, spec) {
|
|
|
1252
1200
|
return getMediaTypeEntries(content, spec)[0];
|
|
1253
1201
|
}
|
|
1254
1202
|
function getExampleValue(example) {
|
|
1255
|
-
if (isRecord(example) && "value" in example) return example.value;
|
|
1256
|
-
if (isRecord(example) && "externalValue" in example) return void 0;
|
|
1203
|
+
if (isRecord$1(example) && "value" in example) return example.value;
|
|
1204
|
+
if (isRecord$1(example) && "externalValue" in example) return void 0;
|
|
1257
1205
|
return example;
|
|
1258
1206
|
}
|
|
1259
1207
|
function getExampleTitle(key, example) {
|
|
1260
|
-
if (isRecord(example)) {
|
|
1208
|
+
if (isRecord$1(example)) {
|
|
1261
1209
|
const summary = typeof example.summary === "string" ? example.summary : void 0;
|
|
1262
1210
|
return {
|
|
1263
1211
|
title: summary ?? key,
|
|
@@ -1266,9 +1214,9 @@ function getExampleTitle(key, example) {
|
|
|
1266
1214
|
}
|
|
1267
1215
|
return { title: key };
|
|
1268
1216
|
}
|
|
1269
|
-
function getExampleEntries(mediaType) {
|
|
1217
|
+
function getExampleEntries(mediaType, spec) {
|
|
1270
1218
|
if (!mediaType) return [];
|
|
1271
|
-
if (isRecord(mediaType.examples)) {
|
|
1219
|
+
if (isRecord$1(mediaType.examples)) {
|
|
1272
1220
|
const examples = [];
|
|
1273
1221
|
for (const [key, example] of Object.entries(mediaType.examples)) {
|
|
1274
1222
|
const value = getExampleValue(example);
|
|
@@ -1288,7 +1236,7 @@ function getExampleEntries(mediaType) {
|
|
|
1288
1236
|
title: "Example",
|
|
1289
1237
|
value: mediaType.example
|
|
1290
1238
|
}];
|
|
1291
|
-
const generated = schemaToExample(mediaType.schema);
|
|
1239
|
+
const generated = schemaToExample(spec ? resolveSchema(spec, mediaType.schema) : mediaType.schema);
|
|
1292
1240
|
return typeof generated === "undefined" ? [] : [{
|
|
1293
1241
|
key: "schema",
|
|
1294
1242
|
title: "schema",
|
|
@@ -1300,7 +1248,7 @@ function getContentExample(mediaType) {
|
|
|
1300
1248
|
return getExampleEntries(mediaType)[0]?.value;
|
|
1301
1249
|
}
|
|
1302
1250
|
function schemaToType(schema) {
|
|
1303
|
-
if (!isRecord(schema)) return void 0;
|
|
1251
|
+
if (!isRecord$1(schema)) return void 0;
|
|
1304
1252
|
if (isReference(schema)) return resolveReferenceName(schema.$ref);
|
|
1305
1253
|
if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
|
|
1306
1254
|
if (Array.isArray(schema.enum)) return "enum";
|
|
@@ -1312,14 +1260,14 @@ function schemaToType(schema) {
|
|
|
1312
1260
|
return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
1313
1261
|
}
|
|
1314
1262
|
function schemaToExample(schema, depth = 0) {
|
|
1315
|
-
if (!isRecord(schema) || depth > 3) return void 0;
|
|
1263
|
+
if (!isRecord$1(schema) || depth > 3) return void 0;
|
|
1316
1264
|
if (typeof schema.example !== "undefined") return schema.example;
|
|
1317
1265
|
if (typeof schema.default !== "undefined") return schema.default;
|
|
1318
1266
|
if (Array.isArray(schema.enum)) return schema.enum[0];
|
|
1319
1267
|
if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
|
|
1320
1268
|
if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
|
|
1321
|
-
if (schemaHasType(schema, "object") || isRecord(schema.properties)) {
|
|
1322
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
1269
|
+
if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
|
|
1270
|
+
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
1323
1271
|
return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1324
1272
|
}
|
|
1325
1273
|
return exampleForType(schemaToType(schema));
|
|
@@ -1339,7 +1287,7 @@ function stringifyExample(value) {
|
|
|
1339
1287
|
}
|
|
1340
1288
|
function getResponseEntries(operation, spec) {
|
|
1341
1289
|
const responses = operation.responses;
|
|
1342
|
-
if (!isRecord(responses)) return [];
|
|
1290
|
+
if (!isRecord$1(responses)) return [];
|
|
1343
1291
|
return Object.entries(responses).map(([status, response]) => ({
|
|
1344
1292
|
status,
|
|
1345
1293
|
response: resolveObjectRef(spec, response)
|
|
@@ -1354,14 +1302,99 @@ function codeLanguageForMediaType(mediaType) {
|
|
|
1354
1302
|
return "text";
|
|
1355
1303
|
}
|
|
1356
1304
|
//#endregion
|
|
1305
|
+
//#region source/openapi/lib/utils.ts
|
|
1306
|
+
var OPENAPI_HTTP_METHODS = [
|
|
1307
|
+
"get",
|
|
1308
|
+
"put",
|
|
1309
|
+
"post",
|
|
1310
|
+
"delete",
|
|
1311
|
+
"options",
|
|
1312
|
+
"head",
|
|
1313
|
+
"patch",
|
|
1314
|
+
"trace"
|
|
1315
|
+
];
|
|
1316
|
+
var CLARIFY_OPENAPI_SECTION_ID_EXTENSION = "x-clarify-section-id";
|
|
1317
|
+
function getOpenApiOperationSectionId(operation) {
|
|
1318
|
+
const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
|
|
1319
|
+
return typeof sectionId === "string" ? sectionId : "";
|
|
1320
|
+
}
|
|
1321
|
+
function createOpenApiOperationSectionId(operation, method, path, source) {
|
|
1322
|
+
return (typeof operation.operationId === "string" ? operation.operationId.trim() : "") || (0, github_slugger.slug)(`${source === "webhook" ? "webhook " : ""}${method.toLowerCase()} ${path}`);
|
|
1323
|
+
}
|
|
1324
|
+
function normalizeOpenApiOperationSectionId(operation, method, path, source) {
|
|
1325
|
+
const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
|
|
1326
|
+
if (typeof sectionId !== "string" || !sectionId) operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION] = createOpenApiOperationSectionId(operation, method, path, source);
|
|
1327
|
+
return operation;
|
|
1328
|
+
}
|
|
1329
|
+
function isOpenAPIHttpMethod(method) {
|
|
1330
|
+
return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
|
|
1331
|
+
}
|
|
1332
|
+
function isRecord(value) {
|
|
1333
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1334
|
+
}
|
|
1335
|
+
function resolveOpenApiRef(spec, ref) {
|
|
1336
|
+
if (!ref.startsWith("#/")) return void 0;
|
|
1337
|
+
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
1338
|
+
}
|
|
1339
|
+
function getPathItem(spec, path) {
|
|
1340
|
+
const pathItem = spec.paths?.[path];
|
|
1341
|
+
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
1342
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
1343
|
+
}
|
|
1344
|
+
function getWebhookItem(spec, path) {
|
|
1345
|
+
const webhooks = spec.webhooks;
|
|
1346
|
+
const pathItem = isRecord(webhooks) ? webhooks[path] : void 0;
|
|
1347
|
+
const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
|
|
1348
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
1349
|
+
}
|
|
1350
|
+
function listOperationsFromPathItems(items, source, spec) {
|
|
1351
|
+
const operations = [];
|
|
1352
|
+
for (const path of Object.keys(items)) {
|
|
1353
|
+
const pathItem = source === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path);
|
|
1354
|
+
if (!pathItem) continue;
|
|
1355
|
+
for (const method of OPENAPI_HTTP_METHODS) {
|
|
1356
|
+
const operation = pathItem[method];
|
|
1357
|
+
if (isRecord(operation)) operations.push({
|
|
1358
|
+
path,
|
|
1359
|
+
method,
|
|
1360
|
+
operation: normalizeOpenApiOperationSectionId(operation, method, path, source),
|
|
1361
|
+
source
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
return operations;
|
|
1366
|
+
}
|
|
1367
|
+
function getOpenApiOperationEntry(spec, path, method, source) {
|
|
1368
|
+
if (!isOpenAPIHttpMethod(method)) return void 0;
|
|
1369
|
+
const normalizedMethod = method.toLowerCase();
|
|
1370
|
+
const sources = source ? [source] : ["path", "webhook"];
|
|
1371
|
+
for (const currentSource of sources) {
|
|
1372
|
+
const operation = (currentSource === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path))?.[normalizedMethod];
|
|
1373
|
+
if (isRecord(operation)) return {
|
|
1374
|
+
path,
|
|
1375
|
+
method: normalizedMethod,
|
|
1376
|
+
operation: normalizeOpenApiOperationSectionId(operation, normalizedMethod, path, currentSource),
|
|
1377
|
+
source: currentSource
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function listOpenApiOperations(spec) {
|
|
1382
|
+
const paths = spec.paths ?? {};
|
|
1383
|
+
const webhooks = spec.webhooks;
|
|
1384
|
+
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1385
|
+
}
|
|
1386
|
+
//#endregion
|
|
1357
1387
|
//#region source/openapi/lib/request-code.ts
|
|
1358
1388
|
var snippetGenerator = (0, _scalar_snippetz.snippetz)();
|
|
1359
1389
|
function getDefaultServer(spec) {
|
|
1360
1390
|
const servers = spec.servers;
|
|
1361
1391
|
if (!Array.isArray(servers)) return { url: "https://api.example.com" };
|
|
1362
|
-
const firstServer = servers.find(isRecord);
|
|
1392
|
+
const firstServer = servers.find(isRecord$1);
|
|
1363
1393
|
return firstServer && typeof firstServer.url === "string" ? firstServer : { url: "https://api.example.com" };
|
|
1364
1394
|
}
|
|
1395
|
+
function getDefaultWebhookServer() {
|
|
1396
|
+
return { url: "https://webhook.example.com" };
|
|
1397
|
+
}
|
|
1365
1398
|
function expandServerUrl(server, serverVariables = {}) {
|
|
1366
1399
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1367
1400
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
@@ -1369,7 +1402,8 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1369
1402
|
});
|
|
1370
1403
|
}
|
|
1371
1404
|
function buildOperationUrl(input) {
|
|
1372
|
-
|
|
1405
|
+
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1406
|
+
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1373
1407
|
}
|
|
1374
1408
|
function getQueryString(parameters, auth) {
|
|
1375
1409
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
@@ -1386,18 +1420,18 @@ function isFormMediaType(mediaType) {
|
|
|
1386
1420
|
return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
|
|
1387
1421
|
}
|
|
1388
1422
|
function isBinarySchema(schema) {
|
|
1389
|
-
return isRecord(schema) && schema.type === "string" && schema.format === "binary";
|
|
1423
|
+
return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
|
|
1390
1424
|
}
|
|
1391
1425
|
function getSchemaProperties(schema) {
|
|
1392
|
-
return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {};
|
|
1426
|
+
return isRecord$1(schema) && isRecord$1(schema.properties) ? schema.properties : {};
|
|
1393
1427
|
}
|
|
1394
1428
|
function getFieldValue(name, value, schema) {
|
|
1395
|
-
if (isRecord(value) && typeof value[name] !== "undefined") return value[name];
|
|
1429
|
+
if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
|
|
1396
1430
|
if (isBinarySchema(schema)) return `@${name}`;
|
|
1397
1431
|
}
|
|
1398
1432
|
function getFormParams(value, requestContent) {
|
|
1399
1433
|
const properties = getSchemaProperties(requestContent.value.schema);
|
|
1400
|
-
return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
1434
|
+
return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord$1(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
1401
1435
|
const fieldValue = getFieldValue(name, value, properties[name]);
|
|
1402
1436
|
if (typeof fieldValue === "undefined") return [];
|
|
1403
1437
|
const contentType = requestContent.value.encoding?.[name]?.contentType;
|
|
@@ -1814,7 +1848,7 @@ function SelectControl(arg0) {
|
|
|
1814
1848
|
//#region source/openapi/components/CodeDisplay.tsx
|
|
1815
1849
|
function CopyCodeButton(arg0) {
|
|
1816
1850
|
const { code } = arg0;
|
|
1817
|
-
const t =
|
|
1851
|
+
const t = require_i18n.useBuiltInText();
|
|
1818
1852
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
1819
1853
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1820
1854
|
type: "button",
|
|
@@ -1822,7 +1856,7 @@ function CopyCodeButton(arg0) {
|
|
|
1822
1856
|
require_PageActions.copyTextToClipboard(code).then((ok) => {
|
|
1823
1857
|
if (!ok) return;
|
|
1824
1858
|
setCopied(true);
|
|
1825
|
-
|
|
1859
|
+
setTimeout(() => setCopied(false), 1e3);
|
|
1826
1860
|
});
|
|
1827
1861
|
},
|
|
1828
1862
|
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)",
|
|
@@ -1850,7 +1884,7 @@ function ExampleMetaValue(arg0) {
|
|
|
1850
1884
|
}
|
|
1851
1885
|
function CodeToolbar(arg0) {
|
|
1852
1886
|
const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1853
|
-
const t =
|
|
1887
|
+
const t = require_i18n.useBuiltInText();
|
|
1854
1888
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1855
1889
|
className: "absolute top-3.5 right-4 left-4 z-10 flex items-center justify-between gap-3",
|
|
1856
1890
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -1879,12 +1913,12 @@ function CodeToolbar(arg0) {
|
|
|
1879
1913
|
}
|
|
1880
1914
|
//#endregion
|
|
1881
1915
|
//#region source/openapi/components/helpers.ts
|
|
1882
|
-
function getServers(spec, operation, path) {
|
|
1916
|
+
function getServers(spec, operation, path, source = "path") {
|
|
1883
1917
|
const operationServers = operation.servers;
|
|
1884
|
-
const pathServers = path ?
|
|
1885
|
-
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : spec.servers;
|
|
1918
|
+
const pathServers = path ? getOperationPathItem(spec, path, source)?.servers : void 0;
|
|
1919
|
+
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : source === "webhook" ? [{ url: "https://webhook.example.com" }] : spec.servers;
|
|
1886
1920
|
if (!Array.isArray(servers)) return [{ url: "https://api.example.com" }];
|
|
1887
|
-
const validServers = servers.filter((server) => isRecord(server) && typeof server.url === "string");
|
|
1921
|
+
const validServers = servers.filter((server) => isRecord$1(server) && typeof server.url === "string");
|
|
1888
1922
|
return validServers.length > 0 ? validServers : [{ url: "https://api.example.com" }];
|
|
1889
1923
|
}
|
|
1890
1924
|
function getServerKey(server, index) {
|
|
@@ -1898,14 +1932,14 @@ function defaultServerVariables(server) {
|
|
|
1898
1932
|
}
|
|
1899
1933
|
function getSecuritySchemes(spec) {
|
|
1900
1934
|
const schemes = spec.components;
|
|
1901
|
-
if (!isRecord(schemes) || !isRecord(schemes.securitySchemes)) return {};
|
|
1902
|
-
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord(entry[1])));
|
|
1935
|
+
if (!isRecord$1(schemes) || !isRecord$1(schemes.securitySchemes)) return {};
|
|
1936
|
+
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord$1(entry[1])));
|
|
1903
1937
|
}
|
|
1904
1938
|
function getSecurityRequirements(spec, operation) {
|
|
1905
1939
|
const operationSecurity = operation.security;
|
|
1906
|
-
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord);
|
|
1940
|
+
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord$1);
|
|
1907
1941
|
const specSecurity = spec.security;
|
|
1908
|
-
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord) : [];
|
|
1942
|
+
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord$1) : [];
|
|
1909
1943
|
}
|
|
1910
1944
|
function getAuthOptions(spec, operation) {
|
|
1911
1945
|
const schemes = getSecuritySchemes(spec);
|
|
@@ -1946,7 +1980,7 @@ function getClientOptions(codeOptions, languageKey) {
|
|
|
1946
1980
|
//#region source/openapi/components/ExamplePanels.tsx
|
|
1947
1981
|
function ApiExampleCodeGroup(arg0) {
|
|
1948
1982
|
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1949
|
-
const t =
|
|
1983
|
+
const t = require_i18n.useBuiltInText();
|
|
1950
1984
|
const metaClassName = comfortableMeta ? "flex min-h-11 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4 py-2" : "flex h-9 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4";
|
|
1951
1985
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1952
1986
|
className: "clarify-api-example my-6 overflow-hidden rounded-2xl bg-(--clarify-code-background) shadow-md ring-1 ring-(--clarify-code-border)",
|
|
@@ -2020,13 +2054,13 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2020
2054
|
})
|
|
2021
2055
|
});
|
|
2022
2056
|
}
|
|
2023
|
-
function firstExampleKeyForMediaType(requestContents, mediaType) {
|
|
2024
|
-
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value)[0]?.key ?? "";
|
|
2057
|
+
function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
|
|
2058
|
+
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
|
|
2025
2059
|
}
|
|
2026
2060
|
function useRequestExamplesState(arg0) {
|
|
2027
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2061
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2028
2062
|
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
2029
|
-
const examples = getExampleEntries(selectedContent?.value);
|
|
2063
|
+
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2030
2064
|
const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
|
|
2031
2065
|
const [selectedLanguageKey, setSelectedLanguageKey] = (0, react.useState)("shell");
|
|
2032
2066
|
const [selectedClientKey, setSelectedClientKey] = (0, react.useState)("curl");
|
|
@@ -2047,7 +2081,8 @@ function useRequestExamplesState(arg0) {
|
|
|
2047
2081
|
} : void 0,
|
|
2048
2082
|
server: selectedServer,
|
|
2049
2083
|
serverVariables,
|
|
2050
|
-
auth
|
|
2084
|
+
auth,
|
|
2085
|
+
operationSource
|
|
2051
2086
|
});
|
|
2052
2087
|
const selectedLanguage = codeOptions.find((option) => option.languageKey === selectedLanguageKey) ?? codeOptions[0];
|
|
2053
2088
|
const selectedCode = codeOptions.find((option) => option.languageKey === selectedLanguage.languageKey && option.clientKey === selectedClientKey) ?? selectedLanguage;
|
|
@@ -2060,7 +2095,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2060
2095
|
examples,
|
|
2061
2096
|
onSelectMediaType: (value) => {
|
|
2062
2097
|
onSelectMediaType(value);
|
|
2063
|
-
setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value));
|
|
2098
|
+
setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value, spec));
|
|
2064
2099
|
},
|
|
2065
2100
|
onSelectExample: (value) => {
|
|
2066
2101
|
setSelectedExampleKey(value);
|
|
@@ -2075,8 +2110,8 @@ function useRequestExamplesState(arg0) {
|
|
|
2075
2110
|
};
|
|
2076
2111
|
}
|
|
2077
2112
|
function RequestExamplesPanel(arg0) {
|
|
2078
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2079
|
-
const t =
|
|
2113
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2114
|
+
const t = require_i18n.useBuiltInText();
|
|
2080
2115
|
const state = useRequestExamplesState({
|
|
2081
2116
|
spec,
|
|
2082
2117
|
path,
|
|
@@ -2088,6 +2123,7 @@ function RequestExamplesPanel(arg0) {
|
|
|
2088
2123
|
selectedServer,
|
|
2089
2124
|
serverVariables,
|
|
2090
2125
|
auth,
|
|
2126
|
+
operationSource,
|
|
2091
2127
|
sharedExampleKey,
|
|
2092
2128
|
onSelectExampleKey
|
|
2093
2129
|
});
|
|
@@ -2111,12 +2147,12 @@ function RequestExamplesPanel(arg0) {
|
|
|
2111
2147
|
onSelectClient: state.onSelectClient
|
|
2112
2148
|
});
|
|
2113
2149
|
}
|
|
2114
|
-
function firstExampleKeyForResponseContent(content) {
|
|
2115
|
-
return getExampleEntries(content?.value)[0]?.key ?? "";
|
|
2150
|
+
function firstExampleKeyForResponseContent(content, spec) {
|
|
2151
|
+
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2116
2152
|
}
|
|
2117
2153
|
function useResponseExamplesState(arg0) {
|
|
2118
2154
|
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2119
|
-
const orderedResponses = [...getResponseEntries(operation, spec)
|
|
2155
|
+
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2120
2156
|
if (left.status === "default") return -1;
|
|
2121
2157
|
if (right.status === "default") return 1;
|
|
2122
2158
|
const leftCode = Number(left.status);
|
|
@@ -2124,22 +2160,23 @@ function useResponseExamplesState(arg0) {
|
|
|
2124
2160
|
if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
|
|
2125
2161
|
return left.status.localeCompare(right.status);
|
|
2126
2162
|
});
|
|
2127
|
-
const
|
|
2163
|
+
const defaultStatus = orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
|
|
2164
|
+
const [internalSelectedStatus, setInternalSelectedStatus] = (0, react.useState)(defaultStatus);
|
|
2128
2165
|
const activeStatus = selectedStatus ?? internalSelectedStatus;
|
|
2129
2166
|
const selectedResponse = orderedResponses.find(({ status }) => status === activeStatus) ?? orderedResponses[0];
|
|
2130
2167
|
const responseContents = getMediaTypeEntries(selectedResponse?.response.content, spec);
|
|
2131
2168
|
const [selection, setSelection] = (0, react.useState)(() => ({
|
|
2132
2169
|
status: activeStatus,
|
|
2133
2170
|
mediaType: responseContents[0]?.mediaType ?? "",
|
|
2134
|
-
exampleKey: firstExampleKeyForResponseContent(responseContents[0])
|
|
2171
|
+
exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
|
|
2135
2172
|
}));
|
|
2136
2173
|
const resolvedSelection = selection.status === activeStatus ? selection : {
|
|
2137
2174
|
status: activeStatus,
|
|
2138
2175
|
mediaType: responseContents[0]?.mediaType ?? "",
|
|
2139
|
-
exampleKey: firstExampleKeyForResponseContent(responseContents[0])
|
|
2176
|
+
exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
|
|
2140
2177
|
};
|
|
2141
2178
|
const selectedContent = responseContents.find((content) => content.mediaType === resolvedSelection.mediaType) ?? responseContents[0];
|
|
2142
|
-
const examples = getExampleEntries(selectedContent?.value);
|
|
2179
|
+
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2143
2180
|
const selectedExampleKey = examples.some((example) => example.key === resolvedSelection.exampleKey) ? resolvedSelection.exampleKey : examples[0]?.key ?? "";
|
|
2144
2181
|
const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
|
|
2145
2182
|
const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
|
|
@@ -2150,7 +2187,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2150
2187
|
selectedContent,
|
|
2151
2188
|
examples,
|
|
2152
2189
|
selectedExample,
|
|
2153
|
-
responseCode: stringifyExample(selectedExample?.value)
|
|
2190
|
+
responseCode: selectedContent ? stringifyExample(selectedExample?.value) : `HTTP/1.1 ${selectedResponse?.status ?? defaultStatus}${selectedResponse?.status === "204" ? " No Content" : ""}`,
|
|
2154
2191
|
onSelectStatus: (value) => {
|
|
2155
2192
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2156
2193
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2158,7 +2195,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2158
2195
|
setSelection({
|
|
2159
2196
|
status: value,
|
|
2160
2197
|
mediaType: nextContents[0]?.mediaType ?? "",
|
|
2161
|
-
exampleKey: firstExampleKeyForResponseContent(nextContents[0])
|
|
2198
|
+
exampleKey: firstExampleKeyForResponseContent(nextContents[0], spec)
|
|
2162
2199
|
});
|
|
2163
2200
|
},
|
|
2164
2201
|
onSelectMediaType: (value) => {
|
|
@@ -2166,7 +2203,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2166
2203
|
setSelection((current) => ({
|
|
2167
2204
|
...current,
|
|
2168
2205
|
mediaType: value,
|
|
2169
|
-
exampleKey: firstExampleKeyForResponseContent(nextContent)
|
|
2206
|
+
exampleKey: firstExampleKeyForResponseContent(nextContent, spec)
|
|
2170
2207
|
}));
|
|
2171
2208
|
},
|
|
2172
2209
|
onSelectExample: (value) => {
|
|
@@ -2179,8 +2216,8 @@ function useResponseExamplesState(arg0) {
|
|
|
2179
2216
|
};
|
|
2180
2217
|
}
|
|
2181
2218
|
function ResponseExamplesPanel(arg0) {
|
|
2182
|
-
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2183
|
-
const t =
|
|
2219
|
+
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2220
|
+
const t = require_i18n.useBuiltInText();
|
|
2184
2221
|
const state = useResponseExamplesState({
|
|
2185
2222
|
operation,
|
|
2186
2223
|
spec,
|
|
@@ -2189,18 +2226,18 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2189
2226
|
selectedStatus,
|
|
2190
2227
|
onSelectStatus
|
|
2191
2228
|
});
|
|
2192
|
-
if (!state.selectedResponse || !state.
|
|
2229
|
+
if (!state.selectedResponse || !state.responseCode) return null;
|
|
2193
2230
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
2194
|
-
title: t("openapi.response"),
|
|
2231
|
+
title: title ?? t("openapi.response"),
|
|
2195
2232
|
tag: state.selectedResponse.status,
|
|
2196
2233
|
tagOptions: state.responses.map(({ status }) => status),
|
|
2197
2234
|
onSelectTag: state.onSelectStatus,
|
|
2198
|
-
label: state.selectedContent
|
|
2235
|
+
label: state.selectedContent?.mediaType,
|
|
2199
2236
|
labelOptions: state.responseContents.map((content) => content.mediaType),
|
|
2200
|
-
onSelectLabel: state.onSelectMediaType,
|
|
2237
|
+
onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
|
|
2201
2238
|
comfortableMeta: true,
|
|
2202
2239
|
code: state.responseCode,
|
|
2203
|
-
language: codeLanguageForMediaType(state.selectedContent.mediaType),
|
|
2240
|
+
language: state.selectedContent ? codeLanguageForMediaType(state.selectedContent.mediaType) : "http",
|
|
2204
2241
|
examples: state.examples,
|
|
2205
2242
|
selectedExampleKey: state.selectedExample?.key,
|
|
2206
2243
|
onSelectExample: state.onSelectExample
|
|
@@ -2211,7 +2248,7 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2211
2248
|
function getEnumDescriptions(schema) {
|
|
2212
2249
|
const descriptions = schema["x-enumDescriptions"];
|
|
2213
2250
|
if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
|
|
2214
|
-
if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2251
|
+
if (isRecord$1(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
|
|
2215
2252
|
const description = descriptions[String(value)];
|
|
2216
2253
|
return typeof description === "string" ? description : void 0;
|
|
2217
2254
|
}) : [];
|
|
@@ -2277,7 +2314,7 @@ function getSchemaChildren(arg0) {
|
|
|
2277
2314
|
defaultExpanded
|
|
2278
2315
|
});
|
|
2279
2316
|
}
|
|
2280
|
-
if (!isRecord(schema)) return [];
|
|
2317
|
+
if (!isRecord$1(schema)) return [];
|
|
2281
2318
|
const arrayChildren = schemaHasType(schema, "array") ? getSchemaChildren({
|
|
2282
2319
|
spec,
|
|
2283
2320
|
schema: schema.items,
|
|
@@ -2288,10 +2325,10 @@ function getSchemaChildren(arg0) {
|
|
|
2288
2325
|
}) : [];
|
|
2289
2326
|
const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
|
|
2290
2327
|
const enumChildren = getEnumChildren(schema, path);
|
|
2291
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
2328
|
+
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
2292
2329
|
const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
|
|
2293
2330
|
const resolvedProperty = resolveSchema(spec, propertySchema);
|
|
2294
|
-
const property = isRecord(resolvedProperty) ? resolvedProperty : isRecord(propertySchema) ? propertySchema : {};
|
|
2331
|
+
const property = isRecord$1(resolvedProperty) ? resolvedProperty : isRecord$1(propertySchema) ? propertySchema : {};
|
|
2295
2332
|
const isArray = schemaHasType(property, "array");
|
|
2296
2333
|
const childPath = path ? `${path}.${name}` : name;
|
|
2297
2334
|
const children = getSchemaChildren({
|
|
@@ -2315,7 +2352,7 @@ function getSchemaChildren(arg0) {
|
|
|
2315
2352
|
children
|
|
2316
2353
|
};
|
|
2317
2354
|
});
|
|
2318
|
-
const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
|
|
2355
|
+
const additionalPropertyChildren = isRecord$1(schema.additionalProperties) ? [{
|
|
2319
2356
|
key: `${path || "root"}.*`,
|
|
2320
2357
|
name: "*",
|
|
2321
2358
|
kind: "property",
|
|
@@ -2335,7 +2372,7 @@ function getSchemaChildren(arg0) {
|
|
|
2335
2372
|
}] : [];
|
|
2336
2373
|
const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
|
|
2337
2374
|
const resolvedBranch = resolveSchema(spec, branchSchema);
|
|
2338
|
-
const branch = isRecord(resolvedBranch) ? resolvedBranch : void 0;
|
|
2375
|
+
const branch = isRecord$1(resolvedBranch) ? resolvedBranch : void 0;
|
|
2339
2376
|
return {
|
|
2340
2377
|
key: `${path || "root"}.${label}`,
|
|
2341
2378
|
name: label,
|
|
@@ -2367,7 +2404,7 @@ function getSchemaChildren(arg0) {
|
|
|
2367
2404
|
function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
2368
2405
|
if (isReference(schema)) {
|
|
2369
2406
|
const resolvedSchema = resolveSchema(spec, schema);
|
|
2370
|
-
const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
|
|
2407
|
+
const resolved = isRecord$1(resolvedSchema) ? resolvedSchema : {};
|
|
2371
2408
|
return {
|
|
2372
2409
|
key: schema.$ref,
|
|
2373
2410
|
name: resolveReferenceName(schema.$ref),
|
|
@@ -2385,7 +2422,7 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2385
2422
|
})
|
|
2386
2423
|
};
|
|
2387
2424
|
}
|
|
2388
|
-
if (!isRecord(schema)) return void 0;
|
|
2425
|
+
if (!isRecord$1(schema)) return void 0;
|
|
2389
2426
|
return {
|
|
2390
2427
|
key: "root",
|
|
2391
2428
|
name: "body",
|
|
@@ -2432,7 +2469,7 @@ function EnumValueNode(arg0) {
|
|
|
2432
2469
|
}
|
|
2433
2470
|
function SchemaNode(arg0) {
|
|
2434
2471
|
const { node, depth = 0, defaultExpanded } = arg0;
|
|
2435
|
-
const t =
|
|
2472
|
+
const t = require_i18n.useBuiltInText();
|
|
2436
2473
|
const [expanded, setExpanded] = (0, react.useState)(defaultExpanded ?? depth < 1);
|
|
2437
2474
|
const hasChildren = node.children.length > 0;
|
|
2438
2475
|
if (node.kind === "enum") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnumValueNode, {
|
|
@@ -2509,7 +2546,7 @@ function SchemaProperties(arg0) {
|
|
|
2509
2546
|
})] });
|
|
2510
2547
|
}
|
|
2511
2548
|
function ParameterList(arg0) {
|
|
2512
|
-
const t =
|
|
2549
|
+
const t = require_i18n.useBuiltInText();
|
|
2513
2550
|
const { title, parameters } = arg0;
|
|
2514
2551
|
if (parameters.length === 0) return null;
|
|
2515
2552
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
|
|
@@ -2522,8 +2559,8 @@ function ParameterList(arg0) {
|
|
|
2522
2559
|
}, `${parameter.in}-${parameter.name}`)) })] });
|
|
2523
2560
|
}
|
|
2524
2561
|
function ResponseList(arg0) {
|
|
2525
|
-
const { operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2526
|
-
const t =
|
|
2562
|
+
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
2563
|
+
const t = require_i18n.useBuiltInText();
|
|
2527
2564
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2528
2565
|
if (left.status === "default") return -1;
|
|
2529
2566
|
if (right.status === "default") return 1;
|
|
@@ -2571,12 +2608,12 @@ function ResponseList(arg0) {
|
|
|
2571
2608
|
};
|
|
2572
2609
|
if (orderedResponses.length === 1) {
|
|
2573
2610
|
const [{ status, response }] = orderedResponses;
|
|
2574
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), renderResponsePanel({
|
|
2611
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title ?? t("openapi.responses") }), renderResponsePanel({
|
|
2575
2612
|
status,
|
|
2576
2613
|
response
|
|
2577
2614
|
})] });
|
|
2578
2615
|
}
|
|
2579
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
2616
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title ?? t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
|
|
2580
2617
|
selectedIndex,
|
|
2581
2618
|
onChange: (index) => {
|
|
2582
2619
|
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
@@ -2595,8 +2632,8 @@ function ResponseList(arg0) {
|
|
|
2595
2632
|
//#endregion
|
|
2596
2633
|
//#region source/openapi/components/EndpointSections.tsx
|
|
2597
2634
|
function EndpointRequest(arg0) {
|
|
2598
|
-
const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2599
|
-
const t =
|
|
2635
|
+
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2636
|
+
const t = require_i18n.useBuiltInText();
|
|
2600
2637
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
2601
2638
|
const renderDescription = () => {
|
|
2602
2639
|
if (!description) return null;
|
|
@@ -2647,6 +2684,7 @@ function EndpointRequest(arg0) {
|
|
|
2647
2684
|
selectedServer,
|
|
2648
2685
|
serverVariables,
|
|
2649
2686
|
auth,
|
|
2687
|
+
operationSource,
|
|
2650
2688
|
sharedExampleKey,
|
|
2651
2689
|
onSelectExampleKey
|
|
2652
2690
|
})
|
|
@@ -2655,7 +2693,10 @@ function EndpointRequest(arg0) {
|
|
|
2655
2693
|
})] });
|
|
2656
2694
|
}
|
|
2657
2695
|
function EndpointResponse(arg0) {
|
|
2658
|
-
const { spec, operation, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2696
|
+
const { spec, operation, operationSource = "path", sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2697
|
+
const t = require_i18n.useBuiltInText();
|
|
2698
|
+
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
2699
|
+
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
2659
2700
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2660
2701
|
className: "mt-6",
|
|
2661
2702
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
@@ -2663,6 +2704,7 @@ function EndpointResponse(arg0) {
|
|
|
2663
2704
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2664
2705
|
className: "w-full",
|
|
2665
2706
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
|
|
2707
|
+
title: responseTitle,
|
|
2666
2708
|
operation,
|
|
2667
2709
|
spec,
|
|
2668
2710
|
selectedStatus,
|
|
@@ -2675,6 +2717,7 @@ function EndpointResponse(arg0) {
|
|
|
2675
2717
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
|
|
2676
2718
|
operation,
|
|
2677
2719
|
spec,
|
|
2720
|
+
title: responseExampleTitle,
|
|
2678
2721
|
sharedExampleKey,
|
|
2679
2722
|
onSelectExampleKey,
|
|
2680
2723
|
selectedStatus,
|
|
@@ -2687,8 +2730,8 @@ function EndpointResponse(arg0) {
|
|
|
2687
2730
|
}
|
|
2688
2731
|
//#endregion
|
|
2689
2732
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
2690
|
-
function useOperationRequestState(spec, path, operation) {
|
|
2691
|
-
const parameters = getOperationParameters(spec, path, operation);
|
|
2733
|
+
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
2734
|
+
const parameters = getOperationParameters(spec, path, operation, source);
|
|
2692
2735
|
const requestBody = getRequestBody$1(spec, operation);
|
|
2693
2736
|
const requestContents = getMediaTypeEntries(requestBody?.content, spec);
|
|
2694
2737
|
const [selectedRequestMediaType, setSelectedRequestMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
|
|
@@ -2709,8 +2752,8 @@ function useOperationRequestState(spec, path, operation) {
|
|
|
2709
2752
|
groupedParameters
|
|
2710
2753
|
};
|
|
2711
2754
|
}
|
|
2712
|
-
function useOperationServerState(spec, operation, path) {
|
|
2713
|
-
const servers = getServers(spec, operation, path);
|
|
2755
|
+
function useOperationServerState(spec, operation, path, source = "path") {
|
|
2756
|
+
const servers = getServers(spec, operation, path, source);
|
|
2714
2757
|
const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
|
|
2715
2758
|
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
2716
2759
|
const [serverVariables, setServerVariables] = (0, react.useState)(defaultServerVariables(selectedServer));
|
|
@@ -2767,7 +2810,8 @@ var endpointMethodStyleVars = {
|
|
|
2767
2810
|
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
2768
2811
|
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
2769
2812
|
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
2770
|
-
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)"
|
|
2813
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
2814
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
2771
2815
|
};
|
|
2772
2816
|
function EndpointMethodBadge(arg0) {
|
|
2773
2817
|
const { method } = arg0;
|
|
@@ -2778,7 +2822,7 @@ function EndpointMethodBadge(arg0) {
|
|
|
2778
2822
|
}
|
|
2779
2823
|
function EndpointPath(arg0) {
|
|
2780
2824
|
const { path, copied = false, onCopy } = arg0;
|
|
2781
|
-
const t =
|
|
2825
|
+
const t = require_i18n.useBuiltInText();
|
|
2782
2826
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2783
2827
|
className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
|
|
2784
2828
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -2849,9 +2893,12 @@ function getServerPreviewUrl(server, variables) {
|
|
|
2849
2893
|
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
2850
2894
|
}
|
|
2851
2895
|
function getFullEndpointUrl(server, variables, path) {
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2896
|
+
return joinPath(getServerPreviewUrl(server, variables), path);
|
|
2897
|
+
}
|
|
2898
|
+
function getServerProtocolLabel(server, variables) {
|
|
2899
|
+
const url = getServerPreviewUrl(server, variables);
|
|
2900
|
+
const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
|
|
2901
|
+
return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
|
|
2855
2902
|
}
|
|
2856
2903
|
function getDefaultResponseStatus(operation, spec) {
|
|
2857
2904
|
const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
|
|
@@ -2867,6 +2914,7 @@ function getDefaultResponseStatus(operation, spec) {
|
|
|
2867
2914
|
function ServerUrlValue(arg0) {
|
|
2868
2915
|
const { server, variables, open, interactive, onToggle } = arg0;
|
|
2869
2916
|
const url = getServerPreviewUrl(server, variables);
|
|
2917
|
+
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
2870
2918
|
if (!interactive) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2871
2919
|
"aria-label": "Server",
|
|
2872
2920
|
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",
|
|
@@ -2876,12 +2924,15 @@ function ServerUrlValue(arg0) {
|
|
|
2876
2924
|
className: "h-4 w-4",
|
|
2877
2925
|
"aria-hidden": "true"
|
|
2878
2926
|
})
|
|
2879
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2880
|
-
className: "hidden min-w-0 items-center overflow-hidden sm:flex",
|
|
2881
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2927
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2928
|
+
className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
|
|
2929
|
+
children: [protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2930
|
+
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",
|
|
2931
|
+
children: protocolLabel
|
|
2932
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2882
2933
|
className: "truncate font-semibold text-xs",
|
|
2883
2934
|
children: url
|
|
2884
|
-
})
|
|
2935
|
+
})]
|
|
2885
2936
|
})]
|
|
2886
2937
|
});
|
|
2887
2938
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -2898,13 +2949,20 @@ function ServerUrlValue(arg0) {
|
|
|
2898
2949
|
})
|
|
2899
2950
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2900
2951
|
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
2901
|
-
children: [
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
"
|
|
2907
|
-
|
|
2952
|
+
children: [
|
|
2953
|
+
protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2954
|
+
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",
|
|
2955
|
+
children: protocolLabel
|
|
2956
|
+
}) : null,
|
|
2957
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2958
|
+
className: "truncate font-semibold text-xs",
|
|
2959
|
+
children: url
|
|
2960
|
+
}),
|
|
2961
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
2962
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
|
|
2963
|
+
"aria-hidden": "true"
|
|
2964
|
+
})
|
|
2965
|
+
]
|
|
2908
2966
|
})]
|
|
2909
2967
|
});
|
|
2910
2968
|
}
|
|
@@ -3011,14 +3069,14 @@ function AuthPanel(arg0) {
|
|
|
3011
3069
|
});
|
|
3012
3070
|
}
|
|
3013
3071
|
function EndpointIdentity(arg0) {
|
|
3014
|
-
const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3072
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3015
3073
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3016
3074
|
const [copiedUrl, setCopiedUrl] = (0, react.useState)(false);
|
|
3017
3075
|
const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
|
|
3018
3076
|
(0, react.useEffect)(() => {
|
|
3019
3077
|
if (!copiedUrl) return void 0;
|
|
3020
|
-
const timeout =
|
|
3021
|
-
return () =>
|
|
3078
|
+
const timeout = setTimeout(() => setCopiedUrl(false), 1200);
|
|
3079
|
+
return () => clearTimeout(timeout);
|
|
3022
3080
|
}, [copiedUrl]);
|
|
3023
3081
|
async function handleCopyUrl() {
|
|
3024
3082
|
if (await require_PageActions.copyTextToClipboard(fullUrl)) setCopiedUrl(true);
|
|
@@ -3030,6 +3088,7 @@ function EndpointIdentity(arg0) {
|
|
|
3030
3088
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
3031
3089
|
children: [
|
|
3032
3090
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
|
|
3091
|
+
operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
3033
3092
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
|
|
3034
3093
|
server: selectedServer,
|
|
3035
3094
|
variables: serverVariables,
|
|
@@ -3078,12 +3137,12 @@ function EndpointIdentity(arg0) {
|
|
|
3078
3137
|
});
|
|
3079
3138
|
}
|
|
3080
3139
|
function OpenApiOperation(arg0) {
|
|
3081
|
-
const { spec, path, method, operation } = arg0;
|
|
3082
|
-
const id = (
|
|
3140
|
+
const { spec, path, method, operation, operationSource = "path" } = arg0;
|
|
3141
|
+
const id = getOpenApiOperationSectionId(operation);
|
|
3083
3142
|
const summary = operation.summary ?? `${method} ${path}`;
|
|
3084
3143
|
const description = operation.description;
|
|
3085
|
-
const requestState = useOperationRequestState(spec, path, operation);
|
|
3086
|
-
const serverState = useOperationServerState(spec, operation, path);
|
|
3144
|
+
const requestState = useOperationRequestState(spec, path, operation, operationSource);
|
|
3145
|
+
const serverState = useOperationServerState(spec, operation, path, operationSource);
|
|
3087
3146
|
const authState = useOperationAuthState(spec, operation);
|
|
3088
3147
|
const [linkedExampleKey, setLinkedExampleKey] = (0, react.useState)("");
|
|
3089
3148
|
const [selectedResponseStatus, setSelectedResponseStatus] = (0, react.useState)(() => getDefaultResponseStatus(operation, spec));
|
|
@@ -3097,6 +3156,7 @@ function OpenApiOperation(arg0) {
|
|
|
3097
3156
|
}),
|
|
3098
3157
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointIdentity, {
|
|
3099
3158
|
method,
|
|
3159
|
+
operationSource,
|
|
3100
3160
|
path,
|
|
3101
3161
|
servers: serverState.servers,
|
|
3102
3162
|
selectedServerKey: serverState.selectedServerKey,
|
|
@@ -3125,6 +3185,7 @@ function OpenApiOperation(arg0) {
|
|
|
3125
3185
|
spec,
|
|
3126
3186
|
path,
|
|
3127
3187
|
method,
|
|
3188
|
+
operationSource,
|
|
3128
3189
|
description,
|
|
3129
3190
|
groupedParameters: requestState.groupedParameters,
|
|
3130
3191
|
parameters: requestState.parameters,
|
|
@@ -3142,6 +3203,7 @@ function OpenApiOperation(arg0) {
|
|
|
3142
3203
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointResponse, {
|
|
3143
3204
|
spec,
|
|
3144
3205
|
operation,
|
|
3206
|
+
operationSource,
|
|
3145
3207
|
sharedExampleKey: linkedExampleKey,
|
|
3146
3208
|
onSelectExampleKey: setLinkedExampleKey,
|
|
3147
3209
|
selectedStatus: selectedResponseStatus,
|
|
@@ -3307,6 +3369,12 @@ Object.defineProperty(exports, "getMediaTypeEntries", {
|
|
|
3307
3369
|
return getMediaTypeEntries;
|
|
3308
3370
|
}
|
|
3309
3371
|
});
|
|
3372
|
+
Object.defineProperty(exports, "getOpenApiOperationEntry", {
|
|
3373
|
+
enumerable: true,
|
|
3374
|
+
get: function() {
|
|
3375
|
+
return getOpenApiOperationEntry;
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3310
3378
|
Object.defineProperty(exports, "getRequestBody", {
|
|
3311
3379
|
enumerable: true,
|
|
3312
3380
|
get: function() {
|
|
@@ -3325,6 +3393,12 @@ Object.defineProperty(exports, "getServers", {
|
|
|
3325
3393
|
return getServers;
|
|
3326
3394
|
}
|
|
3327
3395
|
});
|
|
3396
|
+
Object.defineProperty(exports, "listOpenApiOperations", {
|
|
3397
|
+
enumerable: true,
|
|
3398
|
+
get: function() {
|
|
3399
|
+
return listOpenApiOperations;
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3328
3402
|
Object.defineProperty(exports, "primitives_exports", {
|
|
3329
3403
|
enumerable: true,
|
|
3330
3404
|
get: function() {
|
|
@@ -3332,4 +3406,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
3332
3406
|
}
|
|
3333
3407
|
});
|
|
3334
3408
|
|
|
3335
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
3409
|
+
//# sourceMappingURL=OpenApiOperation-DK46w2dq.cjs.map
|