@clarify-labs/renderer 0.4.0 → 0.6.0
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/README.md +9 -0
- package/output/AppShell-D3FsVHQK.js +390 -0
- package/output/AppShell-D3FsVHQK.js.map +1 -0
- package/output/AppShell-DeaJ-rgo.cjs +409 -0
- package/output/AppShell-DeaJ-rgo.cjs.map +1 -0
- package/output/OpenApiOperation-DYXG-6Rw.js +1772 -0
- package/output/OpenApiOperation-DYXG-6Rw.js.map +1 -0
- package/output/OpenApiOperation-mhoi-s4N.cjs +1840 -0
- package/output/OpenApiOperation-mhoi-s4N.cjs.map +1 -0
- package/output/app/PageNavigation.d.ts +7 -0
- package/output/app/PageSkeleton.d.ts +1 -0
- package/output/{components → app}/SectionProvider.d.ts +3 -2
- package/output/chunk-DakpK96I.cjs +43 -0
- package/output/client.cjs +1 -1
- package/output/client.js +1 -1
- package/output/components/Button.d.ts +18 -0
- package/output/components/Code.d.ts +11 -7
- package/output/components/Collapse.d.ts +9 -0
- package/output/components/Heading.d.ts +10 -0
- package/output/components/Logo.d.ts +2 -0
- package/output/components/Prose.d.ts +7 -0
- package/output/components/Tag.d.ts +34 -0
- package/output/components/index.d.ts +9 -80
- package/output/components/patterns.d.ts +4 -2
- package/output/context.d.ts +1 -8
- package/output/core/context.d.ts +8 -0
- package/output/core/i18n.d.ts +5 -0
- package/output/core/index.d.ts +3 -0
- package/output/core/types.d.ts +174 -0
- package/output/i18n.d.ts +1 -5
- package/output/index.cjs +105 -1741
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +15 -4
- package/output/index.js +71 -1719
- package/output/index.js.map +1 -1
- package/output/markdown.cjs +3 -0
- package/output/markdown.d.ts +1 -0
- package/output/markdown.js +2 -0
- package/output/mdx/DocShell.d.ts +7 -0
- package/output/mdx/Markdown.d.ts +7 -0
- package/output/mdx/components.d.ts +7 -7
- package/output/mdx/primitives.d.ts +18 -12
- package/output/mdx/remark.d.ts +2 -0
- package/output/openapi/{example-panels.d.ts → components/ExamplePanels.d.ts} +14 -9
- package/output/openapi/components/OpenApiOperation.d.ts +33 -0
- package/output/openapi/components/SchemaProperties.d.ts +20 -0
- package/output/openapi/entry.d.ts +13 -0
- package/output/openapi/index.d.ts +3 -3
- package/output/openapi/{helpers.d.ts → lib/helpers.d.ts} +7 -6
- package/output/openapi/{request-code.d.ts → lib/request-code.d.ts} +7 -5
- package/output/openapi/types.d.ts +5 -1
- package/output/preview/openapi.d.ts +28 -0
- package/output/preview.cjs +734 -0
- package/output/preview.cjs.map +1 -0
- package/output/preview.d.ts +19 -0
- package/output/preview.js +731 -0
- package/output/preview.js.map +1 -0
- package/output/remark-DNOdJz5i.cjs +14 -0
- package/output/remark-DNOdJz5i.cjs.map +1 -0
- package/output/remark-o5sg9Ilv.js +7 -0
- package/output/remark-o5sg9Ilv.js.map +1 -0
- package/output/{render-BCiQn6Q1.js → render-BpavVnAe.js} +3 -2
- package/output/render-BpavVnAe.js.map +1 -0
- package/output/{render-CZsdzmme.cjs → render-CjZt3edL.cjs} +6 -5
- package/output/render-CjZt3edL.cjs.map +1 -0
- package/output/renderer.css +403 -63
- package/output/server.cjs +7 -5
- package/output/server.cjs.map +1 -1
- package/output/server.js +4 -2
- package/output/server.js.map +1 -1
- package/output/shell/Navigation.d.ts +3 -2
- package/output/shell/Search.d.ts +6 -4
- package/output/{components → shell}/SiteLogo.d.ts +1 -1
- package/output/shell/icons.d.ts +3 -2
- package/output/shell/mobile.d.ts +3 -2
- package/output/{AppShell-nQnuKyn2.js → shell-BlMMdTpZ.js} +1118 -1320
- package/output/shell-BlMMdTpZ.js.map +1 -0
- package/output/{AppShell-CZw1MrPG.cjs → shell-_MyLsMUI.cjs} +1192 -1394
- package/output/shell-_MyLsMUI.cjs.map +1 -0
- package/output/{components → theme}/ThemeProvider.d.ts +3 -2
- package/output/types.d.ts +1 -174
- package/output/utils/clipboard.d.ts +1 -0
- package/output/utils/hash.d.ts +1 -0
- package/output/utils/href.d.ts +5 -0
- package/output/utils/lucide.d.ts +17 -0
- package/package.json +15 -2
- package/output/AppShell-CZw1MrPG.cjs.map +0 -1
- package/output/AppShell-nQnuKyn2.js.map +0 -1
- package/output/components/PageNavigation.d.ts +0 -5
- package/output/openapi/openapi-page.d.ts +0 -19
- package/output/openapi/schema-properties.d.ts +0 -15
- package/output/render-BCiQn6Q1.js.map +0 -1
- package/output/render-CZsdzmme.cjs.map +0 -1
- /package/output/{components → app}/BuiltWithClarify.d.ts +0 -0
- /package/output/{components → app}/PageFooter.d.ts +0 -0
- /package/output/openapi/{spec-path.d.ts → lib/spec-path.d.ts} +0 -0
- /package/output/openapi/{utils.d.ts → lib/utils.d.ts} +0 -0
- /package/output/{components → theme}/ThemeToggle.d.ts +0 -0
|
@@ -0,0 +1,1840 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
2
|
+
const require_shell = require("./shell-_MyLsMUI.cjs");
|
|
3
|
+
const require_remark = require("./remark-DNOdJz5i.cjs");
|
|
4
|
+
let clsx = require("clsx");
|
|
5
|
+
clsx = require_chunk.__toESM(clsx, 1);
|
|
6
|
+
let react = require("react");
|
|
7
|
+
let react_router_dom = require("react-router-dom");
|
|
8
|
+
let _headlessui_react = require("@headlessui/react");
|
|
9
|
+
let lucide_react = require("lucide-react");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let react_markdown = require("react-markdown");
|
|
12
|
+
react_markdown = require_chunk.__toESM(react_markdown, 1);
|
|
13
|
+
let github_slugger = require("github-slugger");
|
|
14
|
+
let _scalar_snippetz = require("@scalar/snippetz");
|
|
15
|
+
//#region source/mdx/primitives.tsx
|
|
16
|
+
var primitives_exports = /* @__PURE__ */ require_chunk.__exportAll({
|
|
17
|
+
Button: () => require_shell.Button,
|
|
18
|
+
Callout: () => require_shell.Callout,
|
|
19
|
+
Card: () => require_shell.Card,
|
|
20
|
+
CardGroup: () => require_shell.CardGroup,
|
|
21
|
+
CodeGroup: () => require_shell.CodeGroup,
|
|
22
|
+
Col: () => Col,
|
|
23
|
+
Note: () => Note,
|
|
24
|
+
Properties: () => Properties,
|
|
25
|
+
Property: () => Property,
|
|
26
|
+
Row: () => Row,
|
|
27
|
+
a: () => a,
|
|
28
|
+
code: () => code,
|
|
29
|
+
h2: () => h2,
|
|
30
|
+
h3: () => h3,
|
|
31
|
+
pre: () => pre,
|
|
32
|
+
wrapper: () => wrapper
|
|
33
|
+
});
|
|
34
|
+
function wrapper(arg0) {
|
|
35
|
+
const { children } = arg0;
|
|
36
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("article", {
|
|
37
|
+
className: "clarify-mdx-page flex h-full flex-col pt-16 pb-10",
|
|
38
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.Prose, {
|
|
39
|
+
className: "flex-auto",
|
|
40
|
+
children
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function a(arg0) {
|
|
45
|
+
const { href = "", ...props } = arg0;
|
|
46
|
+
if (href.startsWith("/") && !href.startsWith("//")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.Link, {
|
|
47
|
+
to: href,
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
51
|
+
href,
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var code = require_shell.Code;
|
|
56
|
+
var pre = require_shell.Pre;
|
|
57
|
+
function h2(props) {
|
|
58
|
+
return (0, react.createElement)(require_shell.Heading, {
|
|
59
|
+
level: 2,
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function h3(props) {
|
|
64
|
+
return (0, react.createElement)(require_shell.Heading, {
|
|
65
|
+
level: 3,
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function InfoIcon(props) {
|
|
70
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
71
|
+
viewBox: "0 0 16 16",
|
|
72
|
+
"aria-hidden": "true",
|
|
73
|
+
...props,
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
76
|
+
cx: "8",
|
|
77
|
+
cy: "8",
|
|
78
|
+
r: "8",
|
|
79
|
+
strokeWidth: "0"
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
82
|
+
fill: "none",
|
|
83
|
+
strokeLinecap: "round",
|
|
84
|
+
strokeLinejoin: "round",
|
|
85
|
+
strokeWidth: "1.5",
|
|
86
|
+
d: "M6.75 7.75h1.5v3.5"
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
89
|
+
cx: "8",
|
|
90
|
+
cy: "4",
|
|
91
|
+
r: ".5",
|
|
92
|
+
fill: "none"
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function Note(arg0) {
|
|
98
|
+
const { children } = arg0;
|
|
99
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
100
|
+
className: "clarify-note my-6 flex gap-2.5 rounded-(--clarify-theme-tokens-radius-xl) border border-(--clarify-ui-accent-border) bg-(--clarify-ui-accent-background) p-4 text-sm/6 text-(--clarify-theme-tokens-colors-foreground) dark:text-zinc-100 dark:[--tw-prose-links-hover:var(--clarify-ui-accent-text)] dark:[--tw-prose-links:var(--color-white)]",
|
|
101
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(InfoIcon, { className: "mt-1 h-4 w-4 flex-none fill-(--clarify-ui-accent-text) stroke-(--clarify-theme-tokens-colors-surface) dark:fill-(--clarify-ui-accent-background) dark:stroke-(--clarify-ui-accent-text)" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
102
|
+
className: "*:first:mt-0 *:last:mb-0",
|
|
103
|
+
children
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function Row(arg0) {
|
|
108
|
+
const { children } = arg0;
|
|
109
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
110
|
+
className: "clarify-row grid grid-cols-1 items-start gap-x-8 gap-y-10 xl:max-w-none xl:grid-cols-2",
|
|
111
|
+
children
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function Col(arg0) {
|
|
115
|
+
const { children, sticky = false } = arg0;
|
|
116
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
117
|
+
className: (0, clsx.default)("clarify-col *:first:mt-0 *:last:mb-0", sticky && "xl:sticky xl:top-24"),
|
|
118
|
+
children
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function Properties(arg0) {
|
|
122
|
+
const { children } = arg0;
|
|
123
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
124
|
+
className: "clarify-properties my-6",
|
|
125
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
126
|
+
role: "list",
|
|
127
|
+
className: "m-0 list-none divide-y divide-zinc-900/5 p-0 dark:divide-white/5",
|
|
128
|
+
children
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function Property(arg0) {
|
|
133
|
+
const { name, children, type } = arg0;
|
|
134
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
135
|
+
className: "clarify-property m-0 px-0 py-4 first:pt-0 last:pb-0",
|
|
136
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dl", {
|
|
137
|
+
className: "m-0 flex flex-wrap items-center gap-x-3 gap-y-2",
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", {
|
|
140
|
+
className: "sr-only",
|
|
141
|
+
children: "Name"
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
144
|
+
className: "text-sm/5 font-semibold text-zinc-950 dark:text-white",
|
|
145
|
+
children: name
|
|
146
|
+
}) }),
|
|
147
|
+
type ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", {
|
|
148
|
+
className: "sr-only",
|
|
149
|
+
children: "Type"
|
|
150
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
|
151
|
+
className: "text-xs text-(--clarify-theme-tokens-colors-muted) dark:text-zinc-500",
|
|
152
|
+
children: type
|
|
153
|
+
})] }) : null,
|
|
154
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", {
|
|
155
|
+
className: "sr-only",
|
|
156
|
+
children: "Description"
|
|
157
|
+
}),
|
|
158
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", {
|
|
159
|
+
className: "w-full flex-none *:first:mt-0 *:last:mb-0",
|
|
160
|
+
children
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region source/mdx/Markdown.tsx
|
|
168
|
+
var markdownComponents = {
|
|
169
|
+
a(props) {
|
|
170
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(a, { ...props });
|
|
171
|
+
},
|
|
172
|
+
code(props) {
|
|
173
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(code, { ...props });
|
|
174
|
+
},
|
|
175
|
+
pre(arg0) {
|
|
176
|
+
const { children, ...props } = arg0;
|
|
177
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(pre, {
|
|
178
|
+
...props,
|
|
179
|
+
children
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
function Markdown(arg0) {
|
|
184
|
+
const { children, className } = arg0;
|
|
185
|
+
if (!children) return null;
|
|
186
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
187
|
+
className,
|
|
188
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_markdown.default, {
|
|
189
|
+
components: markdownComponents,
|
|
190
|
+
remarkPlugins: require_remark.markdownRemarkPlugins,
|
|
191
|
+
children
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region source/openapi/lib/helpers.ts
|
|
197
|
+
function isRecord(value) {
|
|
198
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
199
|
+
}
|
|
200
|
+
function isReference(value) {
|
|
201
|
+
return isRecord(value) && typeof value.$ref === "string";
|
|
202
|
+
}
|
|
203
|
+
function resolveReferenceName(ref) {
|
|
204
|
+
return ref.split("/").filter(Boolean).at(-1) ?? ref;
|
|
205
|
+
}
|
|
206
|
+
function resolveOpenApiRef(spec, ref) {
|
|
207
|
+
if (!ref.startsWith("#/")) return void 0;
|
|
208
|
+
return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
|
|
209
|
+
}
|
|
210
|
+
function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
|
|
211
|
+
if (!isReference(schema)) return schema;
|
|
212
|
+
if (seen.has(schema.$ref)) return schema;
|
|
213
|
+
seen.add(schema.$ref);
|
|
214
|
+
return resolveSchema(spec, resolveOpenApiRef(spec, schema.$ref), seen) ?? schema;
|
|
215
|
+
}
|
|
216
|
+
function getPathItem(spec, path) {
|
|
217
|
+
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
218
|
+
}
|
|
219
|
+
function resolveObjectRef(spec, value) {
|
|
220
|
+
const resolved = spec && isReference(value) ? resolveOpenApiRef(spec, value.$ref) : value;
|
|
221
|
+
return isRecord(resolved) && !isReference(resolved) ? resolved : void 0;
|
|
222
|
+
}
|
|
223
|
+
function schemaHasType(schema, type) {
|
|
224
|
+
if (!isRecord(schema)) return false;
|
|
225
|
+
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
226
|
+
}
|
|
227
|
+
function getOperationParameters(spec, path, operation) {
|
|
228
|
+
const pathParameters = getPathItem(spec, path)?.parameters;
|
|
229
|
+
const operationParameters = operation.parameters;
|
|
230
|
+
const parameters = [...Array.isArray(pathParameters) ? pathParameters : [], ...Array.isArray(operationParameters) ? operationParameters : []].map((parameter) => resolveObjectRef(spec, parameter)).filter((parameter) => Boolean(parameter));
|
|
231
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
232
|
+
for (const parameter of parameters) {
|
|
233
|
+
const key = parameter.name && parameter.in ? `${parameter.in}:${parameter.name}` : void 0;
|
|
234
|
+
if (key) deduped.set(key, parameter);
|
|
235
|
+
}
|
|
236
|
+
return parameters.filter((parameter) => {
|
|
237
|
+
const key = parameter.name && parameter.in ? `${parameter.in}:${parameter.name}` : void 0;
|
|
238
|
+
return key ? deduped.get(key) === parameter : true;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function getRequestBody$1(spec, operation) {
|
|
242
|
+
const requestBody = operation.requestBody;
|
|
243
|
+
return resolveObjectRef(spec, requestBody);
|
|
244
|
+
}
|
|
245
|
+
function getMediaTypeEntries(content, spec) {
|
|
246
|
+
if (!isRecord(content)) return [];
|
|
247
|
+
return Object.entries(content).map(([mediaType, value]) => ({
|
|
248
|
+
mediaType,
|
|
249
|
+
value: resolveObjectRef(spec, value)
|
|
250
|
+
})).filter((entry) => Boolean(entry.value)).sort((a, z) => {
|
|
251
|
+
return (a.mediaType.includes("json") ? 0 : 1) - (z.mediaType.includes("json") ? 0 : 1);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function getJsonLikeContent(content, spec) {
|
|
255
|
+
return getMediaTypeEntries(content, spec)[0];
|
|
256
|
+
}
|
|
257
|
+
function getExampleValue(example) {
|
|
258
|
+
if (isRecord(example) && "value" in example) return example.value;
|
|
259
|
+
if (isRecord(example) && "externalValue" in example) return void 0;
|
|
260
|
+
return example;
|
|
261
|
+
}
|
|
262
|
+
function getExampleTitle(key, example) {
|
|
263
|
+
if (isRecord(example)) {
|
|
264
|
+
const summary = typeof example.summary === "string" ? example.summary : void 0;
|
|
265
|
+
return {
|
|
266
|
+
title: summary ?? key,
|
|
267
|
+
summary
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
return { title: key };
|
|
271
|
+
}
|
|
272
|
+
function getExampleEntries(mediaType) {
|
|
273
|
+
if (!mediaType) return [];
|
|
274
|
+
if (isRecord(mediaType.examples)) {
|
|
275
|
+
const examples = [];
|
|
276
|
+
for (const [key, example] of Object.entries(mediaType.examples)) {
|
|
277
|
+
const value = getExampleValue(example);
|
|
278
|
+
if (typeof value === "undefined") continue;
|
|
279
|
+
const { title, summary } = getExampleTitle(key, example);
|
|
280
|
+
examples.push({
|
|
281
|
+
key,
|
|
282
|
+
title,
|
|
283
|
+
summary,
|
|
284
|
+
value
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
if (examples.length > 0) return examples;
|
|
288
|
+
}
|
|
289
|
+
if (typeof mediaType.example !== "undefined") return [{
|
|
290
|
+
key: "default",
|
|
291
|
+
title: "Example",
|
|
292
|
+
value: mediaType.example
|
|
293
|
+
}];
|
|
294
|
+
const generated = schemaToExample(mediaType.schema);
|
|
295
|
+
return typeof generated === "undefined" ? [] : [{
|
|
296
|
+
key: "schema",
|
|
297
|
+
title: "schema",
|
|
298
|
+
value: generated,
|
|
299
|
+
generated: true
|
|
300
|
+
}];
|
|
301
|
+
}
|
|
302
|
+
function getContentExample(mediaType) {
|
|
303
|
+
return getExampleEntries(mediaType)[0]?.value;
|
|
304
|
+
}
|
|
305
|
+
function schemaToType(schema) {
|
|
306
|
+
if (!isRecord(schema)) return void 0;
|
|
307
|
+
if (isReference(schema)) return resolveReferenceName(schema.$ref);
|
|
308
|
+
if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
|
|
309
|
+
if (Array.isArray(schema.enum)) return schema.enum.map(String).join(" | ");
|
|
310
|
+
const oneOf = schema.oneOf ?? schema.anyOf;
|
|
311
|
+
if (Array.isArray(oneOf)) return oneOf.map(schemaToType).filter(Boolean).join(" | ");
|
|
312
|
+
if (Array.isArray(schema.allOf)) return schema.allOf.map(schemaToType).filter(Boolean).join(" & ");
|
|
313
|
+
if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
|
|
314
|
+
const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
|
|
315
|
+
return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
316
|
+
}
|
|
317
|
+
function schemaToExample(schema, depth = 0) {
|
|
318
|
+
if (!isRecord(schema) || depth > 3) return void 0;
|
|
319
|
+
if (typeof schema.example !== "undefined") return schema.example;
|
|
320
|
+
if (typeof schema.default !== "undefined") return schema.default;
|
|
321
|
+
if (Array.isArray(schema.enum)) return schema.enum[0];
|
|
322
|
+
if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
|
|
323
|
+
if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
|
|
324
|
+
if (schemaHasType(schema, "object") || isRecord(schema.properties)) {
|
|
325
|
+
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
326
|
+
return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
327
|
+
}
|
|
328
|
+
return exampleForType(schemaToType(schema));
|
|
329
|
+
}
|
|
330
|
+
function exampleForType(type) {
|
|
331
|
+
if (!type) return "string";
|
|
332
|
+
if (type.endsWith("[]")) return [];
|
|
333
|
+
if (type.includes("integer") || type.includes("number")) return 42;
|
|
334
|
+
if (type.includes("boolean")) return true;
|
|
335
|
+
if (type.includes("object")) return {};
|
|
336
|
+
return "string";
|
|
337
|
+
}
|
|
338
|
+
function stringifyExample(value) {
|
|
339
|
+
if (typeof value === "undefined") return "";
|
|
340
|
+
if (typeof value === "string") return value;
|
|
341
|
+
return JSON.stringify(value, null, 2);
|
|
342
|
+
}
|
|
343
|
+
function getResponseEntries(operation, spec) {
|
|
344
|
+
const responses = operation.responses;
|
|
345
|
+
if (!isRecord(responses)) return [];
|
|
346
|
+
return Object.entries(responses).map(([status, response]) => ({
|
|
347
|
+
status,
|
|
348
|
+
response: resolveObjectRef(spec, response)
|
|
349
|
+
})).filter((entry) => Boolean(entry.response));
|
|
350
|
+
}
|
|
351
|
+
function codeLanguageForMediaType(mediaType) {
|
|
352
|
+
if (!mediaType) return "json";
|
|
353
|
+
if (mediaType.includes("json")) return "json";
|
|
354
|
+
if (mediaType.includes("yaml") || mediaType.includes("yml")) return "yaml";
|
|
355
|
+
if (mediaType.startsWith("text/")) return "text";
|
|
356
|
+
if (mediaType.includes("xml")) return "xml";
|
|
357
|
+
return "text";
|
|
358
|
+
}
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region source/openapi/lib/request-code.ts
|
|
361
|
+
var snippetGenerator = (0, _scalar_snippetz.snippetz)();
|
|
362
|
+
function getDefaultServer(spec) {
|
|
363
|
+
const servers = spec.servers;
|
|
364
|
+
if (!Array.isArray(servers)) return { url: "https://api.example.com" };
|
|
365
|
+
const firstServer = servers.find(isRecord);
|
|
366
|
+
return firstServer && typeof firstServer.url === "string" ? firstServer : { url: "https://api.example.com" };
|
|
367
|
+
}
|
|
368
|
+
function expandServerUrl(server, serverVariables = {}) {
|
|
369
|
+
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
370
|
+
const fallback = server.variables?.[name]?.default ?? name;
|
|
371
|
+
return serverVariables[name] ?? fallback;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function buildOperationUrl(input) {
|
|
375
|
+
return `${expandServerUrl(input.server ?? getDefaultServer(input.spec), input.serverVariables).replace(/\/$/, "")}${input.path}`;
|
|
376
|
+
}
|
|
377
|
+
function getQueryString(parameters, auth) {
|
|
378
|
+
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
379
|
+
name: parameter.name,
|
|
380
|
+
value: encodeUrlPlaceholders(`{${parameter.name}}`)
|
|
381
|
+
}));
|
|
382
|
+
if (auth?.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) queryString.push({
|
|
383
|
+
name: auth.scheme.name,
|
|
384
|
+
value: auth.value
|
|
385
|
+
});
|
|
386
|
+
return queryString;
|
|
387
|
+
}
|
|
388
|
+
function isFormMediaType(mediaType) {
|
|
389
|
+
return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
|
|
390
|
+
}
|
|
391
|
+
function isBinarySchema(schema) {
|
|
392
|
+
return isRecord(schema) && schema.type === "string" && schema.format === "binary";
|
|
393
|
+
}
|
|
394
|
+
function getSchemaProperties(schema) {
|
|
395
|
+
return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {};
|
|
396
|
+
}
|
|
397
|
+
function getFieldValue(name, value, schema) {
|
|
398
|
+
if (isRecord(value) && typeof value[name] !== "undefined") return value[name];
|
|
399
|
+
if (isBinarySchema(schema)) return `@${name}`;
|
|
400
|
+
}
|
|
401
|
+
function getFormParams(value, requestContent) {
|
|
402
|
+
const properties = getSchemaProperties(requestContent.value.schema);
|
|
403
|
+
return Array.from(new Set([...Object.keys(properties), ...isRecord(value) ? Object.keys(value) : []])).flatMap((name) => {
|
|
404
|
+
const fieldValue = getFieldValue(name, value, properties[name]);
|
|
405
|
+
if (typeof fieldValue === "undefined") return [];
|
|
406
|
+
const contentType = requestContent.value.encoding?.[name]?.contentType;
|
|
407
|
+
return [{
|
|
408
|
+
name,
|
|
409
|
+
value: typeof fieldValue === "string" ? fieldValue : stringifyExample(fieldValue),
|
|
410
|
+
...contentType ? { contentType } : {}
|
|
411
|
+
}];
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function getBodySize(requestBody) {
|
|
415
|
+
if (requestBody?.serialized) return requestBody.serialized.length;
|
|
416
|
+
return requestBody?.params?.reduce((size, param) => size + param.name.length + String(param.value ?? "").length, 0) ?? 0;
|
|
417
|
+
}
|
|
418
|
+
function getRequestBody(requestContent) {
|
|
419
|
+
const value = getContentExample(requestContent?.value);
|
|
420
|
+
if (!requestContent || typeof value === "undefined") return void 0;
|
|
421
|
+
if (isFormMediaType(requestContent.mediaType)) {
|
|
422
|
+
const params = getFormParams(value, requestContent);
|
|
423
|
+
return params.length > 0 ? { params } : void 0;
|
|
424
|
+
}
|
|
425
|
+
return { serialized: stringifyExample(value) };
|
|
426
|
+
}
|
|
427
|
+
function getAuthorizationValue(auth) {
|
|
428
|
+
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "bearer") return `Bearer ${auth.value}`;
|
|
429
|
+
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
|
|
430
|
+
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
431
|
+
}
|
|
432
|
+
function getAuthHeaders(auth) {
|
|
433
|
+
if (!auth) return {};
|
|
434
|
+
if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
|
|
435
|
+
const authorization = getAuthorizationValue(auth);
|
|
436
|
+
return authorization ? { Authorization: authorization } : {};
|
|
437
|
+
}
|
|
438
|
+
function getRequestHeaders(requestContent, auth) {
|
|
439
|
+
return {
|
|
440
|
+
...getAuthHeaders(auth),
|
|
441
|
+
Accept: "application/json",
|
|
442
|
+
...requestContent ? { "Content-Type": requestContent.mediaType } : {}
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function encodeUrlPlaceholders(url) {
|
|
446
|
+
return url.replace(/\{([^}]+)\}/g, (_, name) => `%7B${encodeURIComponent(name)}%7D`);
|
|
447
|
+
}
|
|
448
|
+
function decodeUrlPlaceholders(code) {
|
|
449
|
+
return code.replace(/%7B([^%]+)%7D/g, (_, name) => `{${decodeURIComponent(name)}}`);
|
|
450
|
+
}
|
|
451
|
+
function buildHarRequest(input) {
|
|
452
|
+
const requestBody = getRequestBody(input.requestContent);
|
|
453
|
+
const url = encodeUrlPlaceholders(buildOperationUrl(input));
|
|
454
|
+
return {
|
|
455
|
+
method: input.method,
|
|
456
|
+
url,
|
|
457
|
+
httpVersion: "HTTP/1.1",
|
|
458
|
+
cookies: [],
|
|
459
|
+
headers: Object.entries(getRequestHeaders(input.requestContent, input.auth)).map(([name, value]) => ({
|
|
460
|
+
name,
|
|
461
|
+
value
|
|
462
|
+
})),
|
|
463
|
+
queryString: getQueryString(input.parameters, input.auth),
|
|
464
|
+
headersSize: -1,
|
|
465
|
+
bodySize: getBodySize(requestBody),
|
|
466
|
+
postData: requestBody ? {
|
|
467
|
+
mimeType: input.requestContent?.mediaType ?? "",
|
|
468
|
+
...requestBody.serialized ? { text: requestBody.serialized } : {},
|
|
469
|
+
...requestBody.params ? { params: requestBody.params } : {}
|
|
470
|
+
} : void 0
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function buildSnippet(input, target) {
|
|
474
|
+
return decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || "");
|
|
475
|
+
}
|
|
476
|
+
var requestSnippetOptions = [
|
|
477
|
+
{
|
|
478
|
+
languageKey: "shell",
|
|
479
|
+
title: "Shell",
|
|
480
|
+
language: "bash",
|
|
481
|
+
target: "shell",
|
|
482
|
+
client: "curl",
|
|
483
|
+
clientTitle: "cURL"
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
languageKey: "shell",
|
|
487
|
+
title: "Shell",
|
|
488
|
+
language: "bash",
|
|
489
|
+
target: "shell",
|
|
490
|
+
client: "wget",
|
|
491
|
+
clientTitle: "Wget"
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
languageKey: "shell",
|
|
495
|
+
title: "Shell",
|
|
496
|
+
language: "bash",
|
|
497
|
+
target: "shell",
|
|
498
|
+
client: "httpie",
|
|
499
|
+
clientTitle: "HTTPie"
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
languageKey: "javascript",
|
|
503
|
+
title: "JavaScript",
|
|
504
|
+
language: "javascript",
|
|
505
|
+
target: "js",
|
|
506
|
+
client: "fetch",
|
|
507
|
+
clientTitle: "Fetch"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
languageKey: "javascript",
|
|
511
|
+
title: "JavaScript",
|
|
512
|
+
language: "javascript",
|
|
513
|
+
target: "js",
|
|
514
|
+
client: "axios",
|
|
515
|
+
clientTitle: "Axios"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
languageKey: "javascript",
|
|
519
|
+
title: "JavaScript",
|
|
520
|
+
language: "javascript",
|
|
521
|
+
target: "js",
|
|
522
|
+
client: "ofetch",
|
|
523
|
+
clientTitle: "ofetch"
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
languageKey: "javascript",
|
|
527
|
+
title: "JavaScript",
|
|
528
|
+
language: "javascript",
|
|
529
|
+
target: "js",
|
|
530
|
+
client: "xhr",
|
|
531
|
+
clientTitle: "XHR"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
languageKey: "typescript",
|
|
535
|
+
title: "TypeScript",
|
|
536
|
+
language: "typescript",
|
|
537
|
+
target: "js",
|
|
538
|
+
client: "fetch",
|
|
539
|
+
clientTitle: "Fetch"
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
languageKey: "typescript",
|
|
543
|
+
title: "TypeScript",
|
|
544
|
+
language: "typescript",
|
|
545
|
+
target: "js",
|
|
546
|
+
client: "axios",
|
|
547
|
+
clientTitle: "Axios"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
languageKey: "typescript",
|
|
551
|
+
title: "TypeScript",
|
|
552
|
+
language: "typescript",
|
|
553
|
+
target: "js",
|
|
554
|
+
client: "ofetch",
|
|
555
|
+
clientTitle: "ofetch"
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
languageKey: "python",
|
|
559
|
+
title: "Python",
|
|
560
|
+
language: "python",
|
|
561
|
+
target: "python",
|
|
562
|
+
client: "requests",
|
|
563
|
+
clientTitle: "Requests"
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
languageKey: "python",
|
|
567
|
+
title: "Python",
|
|
568
|
+
language: "python",
|
|
569
|
+
target: "python",
|
|
570
|
+
client: "python3",
|
|
571
|
+
clientTitle: "http.client"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
languageKey: "python",
|
|
575
|
+
title: "Python",
|
|
576
|
+
language: "python",
|
|
577
|
+
target: "python",
|
|
578
|
+
client: "httpx_sync",
|
|
579
|
+
clientTitle: "HTTPX"
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
languageKey: "python",
|
|
583
|
+
title: "Python",
|
|
584
|
+
language: "python",
|
|
585
|
+
target: "python",
|
|
586
|
+
client: "aiohttp",
|
|
587
|
+
clientTitle: "aiohttp"
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
languageKey: "go",
|
|
591
|
+
title: "Go",
|
|
592
|
+
language: "go",
|
|
593
|
+
target: "go",
|
|
594
|
+
client: "native",
|
|
595
|
+
clientTitle: "NewRequest"
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
languageKey: "node",
|
|
599
|
+
title: "Node.js",
|
|
600
|
+
language: "javascript",
|
|
601
|
+
target: "node",
|
|
602
|
+
client: "fetch",
|
|
603
|
+
clientTitle: "Fetch"
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
languageKey: "node",
|
|
607
|
+
title: "Node.js",
|
|
608
|
+
language: "javascript",
|
|
609
|
+
target: "node",
|
|
610
|
+
client: "axios",
|
|
611
|
+
clientTitle: "Axios"
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
languageKey: "node",
|
|
615
|
+
title: "Node.js",
|
|
616
|
+
language: "javascript",
|
|
617
|
+
target: "node",
|
|
618
|
+
client: "ofetch",
|
|
619
|
+
clientTitle: "ofetch"
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
languageKey: "node",
|
|
623
|
+
title: "Node.js",
|
|
624
|
+
language: "javascript",
|
|
625
|
+
target: "node",
|
|
626
|
+
client: "undici",
|
|
627
|
+
clientTitle: "undici"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
languageKey: "java",
|
|
631
|
+
title: "Java",
|
|
632
|
+
language: "java",
|
|
633
|
+
target: "java",
|
|
634
|
+
client: "nethttp",
|
|
635
|
+
clientTitle: "java.net.http"
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
languageKey: "java",
|
|
639
|
+
title: "Java",
|
|
640
|
+
language: "java",
|
|
641
|
+
target: "java",
|
|
642
|
+
client: "okhttp",
|
|
643
|
+
clientTitle: "OkHttp"
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
languageKey: "java",
|
|
647
|
+
title: "Java",
|
|
648
|
+
language: "java",
|
|
649
|
+
target: "java",
|
|
650
|
+
client: "unirest",
|
|
651
|
+
clientTitle: "Unirest"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
languageKey: "java",
|
|
655
|
+
title: "Java",
|
|
656
|
+
language: "java",
|
|
657
|
+
target: "java",
|
|
658
|
+
client: "asynchttp",
|
|
659
|
+
clientTitle: "AsyncHttp"
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
languageKey: "csharp",
|
|
663
|
+
title: "C#",
|
|
664
|
+
language: "csharp",
|
|
665
|
+
target: "csharp",
|
|
666
|
+
client: "httpclient",
|
|
667
|
+
clientTitle: "HttpClient"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
languageKey: "csharp",
|
|
671
|
+
title: "C#",
|
|
672
|
+
language: "csharp",
|
|
673
|
+
target: "csharp",
|
|
674
|
+
client: "restsharp",
|
|
675
|
+
clientTitle: "RestSharp"
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
languageKey: "php",
|
|
679
|
+
title: "PHP",
|
|
680
|
+
language: "php",
|
|
681
|
+
target: "php",
|
|
682
|
+
client: "guzzle",
|
|
683
|
+
clientTitle: "Guzzle"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
languageKey: "php",
|
|
687
|
+
title: "PHP",
|
|
688
|
+
language: "php",
|
|
689
|
+
target: "php",
|
|
690
|
+
client: "curl",
|
|
691
|
+
clientTitle: "cURL"
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
languageKey: "php",
|
|
695
|
+
title: "PHP",
|
|
696
|
+
language: "php",
|
|
697
|
+
target: "php",
|
|
698
|
+
client: "laravel",
|
|
699
|
+
clientTitle: "Laravel HTTP Client"
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
languageKey: "ruby",
|
|
703
|
+
title: "Ruby",
|
|
704
|
+
language: "ruby",
|
|
705
|
+
target: "ruby",
|
|
706
|
+
client: "native",
|
|
707
|
+
clientTitle: "net::http"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
languageKey: "rust",
|
|
711
|
+
title: "Rust",
|
|
712
|
+
language: "rust",
|
|
713
|
+
target: "rust",
|
|
714
|
+
client: "reqwest",
|
|
715
|
+
clientTitle: "reqwest"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
languageKey: "swift",
|
|
719
|
+
title: "Swift",
|
|
720
|
+
language: "swift",
|
|
721
|
+
target: "swift",
|
|
722
|
+
client: "nsurlsession",
|
|
723
|
+
clientTitle: "NSURLSession"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
languageKey: "kotlin",
|
|
727
|
+
title: "Kotlin",
|
|
728
|
+
language: "kotlin",
|
|
729
|
+
target: "kotlin",
|
|
730
|
+
client: "okhttp",
|
|
731
|
+
clientTitle: "OkHttp"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
languageKey: "powershell",
|
|
735
|
+
title: "PowerShell",
|
|
736
|
+
language: "powershell",
|
|
737
|
+
target: "powershell",
|
|
738
|
+
client: "restmethod",
|
|
739
|
+
clientTitle: "Invoke-RestMethod"
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
languageKey: "powershell",
|
|
743
|
+
title: "PowerShell",
|
|
744
|
+
language: "powershell",
|
|
745
|
+
target: "powershell",
|
|
746
|
+
client: "webrequest",
|
|
747
|
+
clientTitle: "Invoke-WebRequest"
|
|
748
|
+
}
|
|
749
|
+
];
|
|
750
|
+
function buildRequestCodeExamples(input) {
|
|
751
|
+
return requestSnippetOptions.map((option) => ({
|
|
752
|
+
key: `${option.languageKey}:${option.client}`,
|
|
753
|
+
title: option.title,
|
|
754
|
+
language: option.language,
|
|
755
|
+
languageKey: option.languageKey,
|
|
756
|
+
clientKey: option.client,
|
|
757
|
+
clientTitle: option.clientTitle,
|
|
758
|
+
code: buildSnippet(input, option)
|
|
759
|
+
}));
|
|
760
|
+
}
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region source/openapi/components/ExamplePanels.tsx
|
|
763
|
+
function SelectControl(arg0) {
|
|
764
|
+
const { label, value, options, onChange, icon, compact = false } = arg0;
|
|
765
|
+
const normalizedOptions = options.map((option) => typeof option === "string" ? {
|
|
766
|
+
value: option,
|
|
767
|
+
label: option
|
|
768
|
+
} : option);
|
|
769
|
+
const selectedOption = normalizedOptions.find((option) => option.value === value) ?? normalizedOptions[0];
|
|
770
|
+
const wrapperClassName = compact ? "clarify-api-select relative min-w-0 text-xs" : "clarify-api-select relative shrink-0 text-xs";
|
|
771
|
+
const buttonSizeClassName = compact ? "w-full min-w-0 max-w-32" : "min-w-28 max-w-48";
|
|
772
|
+
if (normalizedOptions.length <= 1) return null;
|
|
773
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
|
|
774
|
+
value,
|
|
775
|
+
onChange,
|
|
776
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
777
|
+
className: wrapperClassName,
|
|
778
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
|
|
779
|
+
"aria-label": label,
|
|
780
|
+
className: `clarify-api-select-button flex ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg bg-black/30 px-2 py-1 text-xs font-medium whitespace-nowrap text-zinc-100 outline-hidden transition hover:bg-black/50 focus:ring-2 focus:ring-emerald-400/25 data-open:bg-white/10 data-open:ring-2 data-open:ring-emerald-400/25`,
|
|
781
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
782
|
+
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
783
|
+
children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
784
|
+
className: "shrink-0 text-zinc-500",
|
|
785
|
+
children: icon
|
|
786
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
787
|
+
className: "truncate",
|
|
788
|
+
children: selectedOption?.label ?? value
|
|
789
|
+
})]
|
|
790
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronsUpDownIcon, {
|
|
791
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-500",
|
|
792
|
+
"aria-hidden": "true"
|
|
793
|
+
})]
|
|
794
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
|
|
795
|
+
anchor: "bottom end",
|
|
796
|
+
className: "clarify-api-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-[min(32rem,calc(100vw-2rem))] overflow-auto rounded-xl bg-zinc-900 p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-white/10 [--anchor-gap:--spacing(1)] focus:outline-none",
|
|
797
|
+
children: normalizedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
|
|
798
|
+
value: option.value,
|
|
799
|
+
className: "clarify-api-select-option group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-zinc-300 select-none data-focus:bg-white/10 data-focus:text-white data-selected:text-emerald-300",
|
|
800
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
801
|
+
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
802
|
+
"aria-hidden": "true"
|
|
803
|
+
})]
|
|
804
|
+
}, option.value))
|
|
805
|
+
})]
|
|
806
|
+
})
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
function getExampleLabel(example, t) {
|
|
810
|
+
return example.generated && example.title === "schema" ? t("openapi.schemaExample") : example.title;
|
|
811
|
+
}
|
|
812
|
+
function getLanguageOptions(codeOptions) {
|
|
813
|
+
const languages = /* @__PURE__ */ new Map();
|
|
814
|
+
for (const option of codeOptions ?? []) languages.set(option.languageKey, option.title);
|
|
815
|
+
return Array.from(languages, ([value, label]) => ({
|
|
816
|
+
value,
|
|
817
|
+
label
|
|
818
|
+
}));
|
|
819
|
+
}
|
|
820
|
+
function getClientOptions(codeOptions, languageKey) {
|
|
821
|
+
return (codeOptions ?? []).filter((option) => option.languageKey === languageKey).map((option) => ({
|
|
822
|
+
value: option.clientKey,
|
|
823
|
+
label: option.clientTitle
|
|
824
|
+
}));
|
|
825
|
+
}
|
|
826
|
+
function getServers(spec, operation, path) {
|
|
827
|
+
const operationServers = operation.servers;
|
|
828
|
+
const pathServers = path ? getPathItem(spec, path)?.servers : void 0;
|
|
829
|
+
const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : spec.servers;
|
|
830
|
+
if (!Array.isArray(servers)) return [{ url: "https://api.example.com" }];
|
|
831
|
+
const validServers = servers.filter((server) => isRecord(server) && typeof server.url === "string");
|
|
832
|
+
return validServers.length > 0 ? validServers : [{ url: "https://api.example.com" }];
|
|
833
|
+
}
|
|
834
|
+
function getServerKey(server, index) {
|
|
835
|
+
return `${index}:${server.url ?? ""}`;
|
|
836
|
+
}
|
|
837
|
+
function getServerLabel(server, index) {
|
|
838
|
+
return server.description ? `${server.description} (${server.url})` : server.url ?? `Server ${index + 1}`;
|
|
839
|
+
}
|
|
840
|
+
function defaultServerVariables(server) {
|
|
841
|
+
return Object.fromEntries(Object.entries(server?.variables ?? {}).map(([name, variable]) => [name, variable.default ?? variable.enum?.[0] ?? ""]));
|
|
842
|
+
}
|
|
843
|
+
function getSecuritySchemes(spec) {
|
|
844
|
+
const schemes = spec.components;
|
|
845
|
+
if (!isRecord(schemes) || !isRecord(schemes.securitySchemes)) return {};
|
|
846
|
+
return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord(entry[1])));
|
|
847
|
+
}
|
|
848
|
+
function getSecurityRequirements(spec, operation) {
|
|
849
|
+
const operationSecurity = operation.security;
|
|
850
|
+
if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord);
|
|
851
|
+
const specSecurity = spec.security;
|
|
852
|
+
return Array.isArray(specSecurity) ? specSecurity.filter(isRecord) : [];
|
|
853
|
+
}
|
|
854
|
+
function getAuthOptions(spec, operation) {
|
|
855
|
+
const schemes = getSecuritySchemes(spec);
|
|
856
|
+
const requirements = getSecurityRequirements(spec, operation);
|
|
857
|
+
const names = new Set(requirements.flatMap((requirement) => Object.keys(requirement)));
|
|
858
|
+
return Array.from(names).map((name) => ({
|
|
859
|
+
name,
|
|
860
|
+
scheme: schemes[name]
|
|
861
|
+
})).filter((option) => Boolean(option.scheme));
|
|
862
|
+
}
|
|
863
|
+
function authPlaceholder(auth) {
|
|
864
|
+
if (!auth) return "";
|
|
865
|
+
if (auth.scheme.type === "apiKey") return "{api_key}";
|
|
866
|
+
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return "{base64_credentials}";
|
|
867
|
+
return "{token}";
|
|
868
|
+
}
|
|
869
|
+
function authLabel(name, scheme) {
|
|
870
|
+
return `${name}${scheme.type === "apiKey" && scheme.in && scheme.name ? ` · ${scheme.in}: ${scheme.name}` : ""}`;
|
|
871
|
+
}
|
|
872
|
+
function CopyCodeButton(arg0) {
|
|
873
|
+
const { code } = arg0;
|
|
874
|
+
const t = require_shell.useBuiltInText();
|
|
875
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
876
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
877
|
+
type: "button",
|
|
878
|
+
onClick: () => {
|
|
879
|
+
require_shell.copyTextToClipboard(code).then((ok) => {
|
|
880
|
+
if (!ok) return;
|
|
881
|
+
setCopied(true);
|
|
882
|
+
window.setTimeout(() => setCopied(false), 1e3);
|
|
883
|
+
});
|
|
884
|
+
},
|
|
885
|
+
className: "flex items-center gap-1.5 rounded-full bg-black/ px-2.5 py-1.5 text-2xs font-medium text-zinc-400 transition hover:bg-black/50 hover:text-zinc-200 focus:bg-black/50 focus:text-zinc-200",
|
|
886
|
+
children: [copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
887
|
+
className: "h-3.5 w-3.5 text-emerald-300",
|
|
888
|
+
"aria-hidden": "true"
|
|
889
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ClipboardIcon, {
|
|
890
|
+
className: "h-3.5 w-3.5 text-zinc-500",
|
|
891
|
+
"aria-hidden": "true"
|
|
892
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: copied ? t("actions.copied") : t("actions.copy") })]
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
function ExampleMetaValue(arg0) {
|
|
896
|
+
const { label, value, options, onChange, className } = arg0;
|
|
897
|
+
if (options && options.length > 1 && onChange) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
898
|
+
label,
|
|
899
|
+
value,
|
|
900
|
+
options,
|
|
901
|
+
onChange
|
|
902
|
+
});
|
|
903
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
904
|
+
className,
|
|
905
|
+
children: value
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
function CodeToolbar(arg0) {
|
|
909
|
+
const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
910
|
+
const t = require_shell.useBuiltInText();
|
|
911
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
912
|
+
className: "absolute top-3.5 right-4 left-4 z-10 flex items-center justify-between gap-3",
|
|
913
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
914
|
+
className: "flex min-w-0 items-center gap-2",
|
|
915
|
+
children: [languageOptions && languageOptions.length > 1 && selectedLanguageKey && onSelectLanguage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
916
|
+
label: t("openapi.language"),
|
|
917
|
+
value: selectedLanguageKey,
|
|
918
|
+
options: languageOptions,
|
|
919
|
+
onChange: onSelectLanguage,
|
|
920
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CodeIcon, {
|
|
921
|
+
className: "h-3.5 w-3.5",
|
|
922
|
+
"aria-hidden": "true"
|
|
923
|
+
})
|
|
924
|
+
}) : null, clientOptions && clientOptions.length > 1 && selectedClientKey && onSelectClient ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
925
|
+
label: t("openapi.client"),
|
|
926
|
+
value: selectedClientKey,
|
|
927
|
+
options: clientOptions,
|
|
928
|
+
onChange: onSelectClient,
|
|
929
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PackageIcon, {
|
|
930
|
+
className: "h-3.5 w-3.5",
|
|
931
|
+
"aria-hidden": "true"
|
|
932
|
+
})
|
|
933
|
+
}) : null]
|
|
934
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyCodeButton, { code })]
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
function ApiExampleCodeGroup(arg0) {
|
|
938
|
+
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;
|
|
939
|
+
const t = require_shell.useBuiltInText();
|
|
940
|
+
const metaClassName = comfortableMeta ? "flex min-h-11 min-w-0 items-center gap-2 border-y border-t-transparent border-b-white/7.5 bg-zinc-900 px-4 py-2 dark:border-b-white/5 dark:bg-white/1" : "flex h-9 min-w-0 items-center gap-2 border-y border-t-transparent border-b-white/7.5 bg-zinc-900 px-4 dark:border-b-white/5 dark:bg-white/1";
|
|
941
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
942
|
+
className: "clarify-api-example my-6 overflow-hidden rounded-2xl bg-zinc-900 shadow-md dark:ring-1 dark:ring-white/10",
|
|
943
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
944
|
+
className: "not-prose",
|
|
945
|
+
children: [
|
|
946
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
947
|
+
className: "clarify-api-example-header flex min-h-[calc(--spacing(12)+1px)] items-center gap-3 border-b border-zinc-700 bg-zinc-800 px-4 py-2 dark:border-zinc-800 dark:bg-transparent",
|
|
948
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
949
|
+
className: "mr-auto min-w-16 truncate py-1 text-xs font-semibold text-white",
|
|
950
|
+
children: title
|
|
951
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
952
|
+
className: "ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
953
|
+
children: [mediaTypes && mediaTypes.length > 1 && selectedMediaType && onSelectMediaType ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
954
|
+
label: t("openapi.mediaType"),
|
|
955
|
+
value: selectedMediaType,
|
|
956
|
+
options: mediaTypes,
|
|
957
|
+
onChange: onSelectMediaType,
|
|
958
|
+
compact: true
|
|
959
|
+
}) : null, examples && examples.length > 1 && selectedExampleKey && onSelectExample ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
960
|
+
label: t("openapi.example"),
|
|
961
|
+
value: selectedExampleKey,
|
|
962
|
+
options: examples.map((example) => ({
|
|
963
|
+
value: example.key,
|
|
964
|
+
label: getExampleLabel(example, t)
|
|
965
|
+
})),
|
|
966
|
+
onChange: onSelectExample,
|
|
967
|
+
compact: true
|
|
968
|
+
}) : null]
|
|
969
|
+
})]
|
|
970
|
+
}),
|
|
971
|
+
tag || label ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
972
|
+
className: metaClassName,
|
|
973
|
+
children: [
|
|
974
|
+
tag ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
|
|
975
|
+
label: t("openapi.status"),
|
|
976
|
+
value: tag,
|
|
977
|
+
options: tagOptions,
|
|
978
|
+
onChange: onSelectTag,
|
|
979
|
+
className: "clarify-api-example-status font-semibold text-emerald-400"
|
|
980
|
+
}) : null,
|
|
981
|
+
tag && label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "h-0.5 w-0.5 shrink-0 rounded-full bg-zinc-500" }) : null,
|
|
982
|
+
label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
|
|
983
|
+
label: t("openapi.mediaType"),
|
|
984
|
+
value: label,
|
|
985
|
+
options: labelOptions,
|
|
986
|
+
onChange: onSelectLabel,
|
|
987
|
+
className: "min-w-0 truncate text-xs text-zinc-400"
|
|
988
|
+
}) : null
|
|
989
|
+
]
|
|
990
|
+
}) : null,
|
|
991
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
992
|
+
className: "clarify-api-example-code group relative",
|
|
993
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeToolbar, {
|
|
994
|
+
code,
|
|
995
|
+
languageOptions,
|
|
996
|
+
selectedLanguageKey,
|
|
997
|
+
onSelectLanguage,
|
|
998
|
+
clientOptions,
|
|
999
|
+
selectedClientKey,
|
|
1000
|
+
onSelectClient
|
|
1001
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
1002
|
+
className: `overflow-x-auto p-4 text-xs text-white ${languageOptions && languageOptions.length > 1 ? "pt-14" : ""}`,
|
|
1003
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
1004
|
+
className: `language-${language}`,
|
|
1005
|
+
children: code
|
|
1006
|
+
})
|
|
1007
|
+
})]
|
|
1008
|
+
})
|
|
1009
|
+
]
|
|
1010
|
+
})
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
function RequestExamplesPanel(arg0) {
|
|
1014
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth } = arg0;
|
|
1015
|
+
const t = require_shell.useBuiltInText();
|
|
1016
|
+
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
1017
|
+
const examples = getExampleEntries(selectedContent?.value);
|
|
1018
|
+
const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
|
|
1019
|
+
const [selectedLanguageKey, setSelectedLanguageKey] = (0, react.useState)("shell");
|
|
1020
|
+
const [selectedClientKey, setSelectedClientKey] = (0, react.useState)("curl");
|
|
1021
|
+
const selectedExample = examples.find((example) => example.key === selectedExampleKey) ?? examples[0];
|
|
1022
|
+
const codeOptions = buildRequestCodeExamples({
|
|
1023
|
+
spec,
|
|
1024
|
+
path,
|
|
1025
|
+
method,
|
|
1026
|
+
parameters,
|
|
1027
|
+
requestContent: selectedContent ? {
|
|
1028
|
+
...selectedContent,
|
|
1029
|
+
value: {
|
|
1030
|
+
...selectedContent.value,
|
|
1031
|
+
example: selectedExample?.value,
|
|
1032
|
+
examples: void 0
|
|
1033
|
+
}
|
|
1034
|
+
} : void 0,
|
|
1035
|
+
server: selectedServer,
|
|
1036
|
+
serverVariables,
|
|
1037
|
+
auth
|
|
1038
|
+
});
|
|
1039
|
+
const selectedLanguage = codeOptions.find((option) => option.languageKey === selectedLanguageKey) ?? codeOptions[0];
|
|
1040
|
+
const selectedCode = codeOptions.find((option) => option.languageKey === selectedLanguage.languageKey && option.clientKey === selectedClientKey) ?? selectedLanguage;
|
|
1041
|
+
const languageOptions = getLanguageOptions(codeOptions);
|
|
1042
|
+
const clientOptions = getClientOptions(codeOptions, selectedCode.languageKey);
|
|
1043
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
1044
|
+
title: t("openapi.request"),
|
|
1045
|
+
tag: method,
|
|
1046
|
+
label: path,
|
|
1047
|
+
code: selectedCode.code,
|
|
1048
|
+
language: selectedCode.language,
|
|
1049
|
+
mediaTypes: requestContents.map((content) => content.mediaType),
|
|
1050
|
+
selectedMediaType: selectedContent?.mediaType,
|
|
1051
|
+
onSelectMediaType: (value) => {
|
|
1052
|
+
onSelectMediaType(value);
|
|
1053
|
+
setSelectedExampleKey(getExampleEntries(requestContents.find((content) => content.mediaType === value)?.value)[0]?.key ?? "");
|
|
1054
|
+
},
|
|
1055
|
+
examples,
|
|
1056
|
+
selectedExampleKey: selectedExample?.key,
|
|
1057
|
+
onSelectExample: setSelectedExampleKey,
|
|
1058
|
+
languageOptions,
|
|
1059
|
+
selectedLanguageKey: selectedCode.languageKey,
|
|
1060
|
+
onSelectLanguage: (value) => {
|
|
1061
|
+
const nextCode = codeOptions.find((option) => option.languageKey === value);
|
|
1062
|
+
setSelectedLanguageKey(nextCode?.languageKey ?? value);
|
|
1063
|
+
setSelectedClientKey(nextCode?.clientKey ?? "");
|
|
1064
|
+
},
|
|
1065
|
+
clientOptions,
|
|
1066
|
+
selectedClientKey: selectedCode.clientKey,
|
|
1067
|
+
onSelectClient: setSelectedClientKey
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
function ResponseExamplesPanel(arg0) {
|
|
1071
|
+
const { operation, spec } = arg0;
|
|
1072
|
+
const t = require_shell.useBuiltInText();
|
|
1073
|
+
const responses = getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0);
|
|
1074
|
+
const [selectedStatus, setSelectedStatus] = (0, react.useState)(responses.find(({ status }) => status.startsWith("2"))?.status ?? responses[0]?.status ?? "");
|
|
1075
|
+
const selectedResponse = responses.find(({ status }) => status === selectedStatus) ?? responses[0];
|
|
1076
|
+
const responseContents = getMediaTypeEntries(selectedResponse?.response.content, spec);
|
|
1077
|
+
const [selectedMediaType, setSelectedMediaType] = (0, react.useState)(responseContents[0]?.mediaType ?? "");
|
|
1078
|
+
const selectedContent = responseContents.find((content) => content.mediaType === selectedMediaType) ?? responseContents[0];
|
|
1079
|
+
const examples = getExampleEntries(selectedContent?.value);
|
|
1080
|
+
const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
|
|
1081
|
+
const selectedExample = examples.find((example) => example.key === selectedExampleKey) ?? examples[0];
|
|
1082
|
+
const responseCode = stringifyExample(selectedExample?.value);
|
|
1083
|
+
if (!selectedResponse || !selectedContent || !responseCode) return null;
|
|
1084
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
1085
|
+
title: t("openapi.response"),
|
|
1086
|
+
tag: selectedResponse.status,
|
|
1087
|
+
tagOptions: responses.map(({ status }) => status),
|
|
1088
|
+
onSelectTag: (value) => {
|
|
1089
|
+
const nextContents = getMediaTypeEntries(responses.find(({ status }) => status === value)?.response.content, spec);
|
|
1090
|
+
setSelectedStatus(value);
|
|
1091
|
+
setSelectedMediaType(nextContents[0]?.mediaType ?? "");
|
|
1092
|
+
setSelectedExampleKey(getExampleEntries(nextContents[0]?.value)[0]?.key ?? "");
|
|
1093
|
+
},
|
|
1094
|
+
label: selectedContent.mediaType,
|
|
1095
|
+
labelOptions: responseContents.map((content) => content.mediaType),
|
|
1096
|
+
onSelectLabel: (value) => {
|
|
1097
|
+
setSelectedMediaType(value);
|
|
1098
|
+
setSelectedExampleKey(getExampleEntries(responseContents.find((content) => content.mediaType === value)?.value)[0]?.key ?? "");
|
|
1099
|
+
},
|
|
1100
|
+
comfortableMeta: true,
|
|
1101
|
+
code: responseCode,
|
|
1102
|
+
language: codeLanguageForMediaType(selectedContent.mediaType),
|
|
1103
|
+
examples,
|
|
1104
|
+
selectedExampleKey: selectedExample?.key,
|
|
1105
|
+
onSelectExample: setSelectedExampleKey
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
//#endregion
|
|
1109
|
+
//#region source/openapi/components/SchemaProperties.tsx
|
|
1110
|
+
function getSchemaDetails(schema) {
|
|
1111
|
+
const details = [
|
|
1112
|
+
Array.isArray(schema.enum) ? `enum: ${schema.enum.map(String).join(", ")}` : void 0,
|
|
1113
|
+
typeof schema.const !== "undefined" ? `const: ${String(schema.const)}` : void 0,
|
|
1114
|
+
typeof schema.default !== "undefined" ? `default: ${String(schema.default)}` : void 0,
|
|
1115
|
+
typeof schema.pattern === "string" ? `pattern: ${schema.pattern}` : void 0,
|
|
1116
|
+
typeof schema.minimum === "number" ? `minimum: ${String(schema.minimum)}` : void 0,
|
|
1117
|
+
typeof schema.maximum === "number" ? `maximum: ${String(schema.maximum)}` : void 0,
|
|
1118
|
+
typeof schema.additionalProperties === "boolean" ? `additionalProperties: ${String(schema.additionalProperties)}` : void 0
|
|
1119
|
+
].filter(Boolean);
|
|
1120
|
+
return details.length > 0 ? details.join("; ") : void 0;
|
|
1121
|
+
}
|
|
1122
|
+
function getSchemaDescription(schema) {
|
|
1123
|
+
return typeof schema.description === "string" ? schema.description : void 0;
|
|
1124
|
+
}
|
|
1125
|
+
function getComposedBranches(schema) {
|
|
1126
|
+
const entries = [];
|
|
1127
|
+
for (const key of [
|
|
1128
|
+
"allOf",
|
|
1129
|
+
"oneOf",
|
|
1130
|
+
"anyOf"
|
|
1131
|
+
]) {
|
|
1132
|
+
const items = schema[key];
|
|
1133
|
+
if (!Array.isArray(items)) continue;
|
|
1134
|
+
for (const [index, item] of items.entries()) entries.push({
|
|
1135
|
+
label: `${key}[${index}]`,
|
|
1136
|
+
schema: item
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
return entries;
|
|
1140
|
+
}
|
|
1141
|
+
function getSchemaChildren(arg0) {
|
|
1142
|
+
const { spec, schema, path, required = [], depth = 0, seen = /* @__PURE__ */ new Set() } = arg0;
|
|
1143
|
+
if (depth > 12) return [];
|
|
1144
|
+
if (isReference(schema)) {
|
|
1145
|
+
if (seen.has(schema.$ref)) return [];
|
|
1146
|
+
return getSchemaChildren({
|
|
1147
|
+
spec,
|
|
1148
|
+
schema: resolveSchema(spec, schema),
|
|
1149
|
+
path,
|
|
1150
|
+
required,
|
|
1151
|
+
depth,
|
|
1152
|
+
seen: new Set([...seen, schema.$ref])
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
if (!isRecord(schema)) return [];
|
|
1156
|
+
const arrayChildren = schemaHasType(schema, "array") ? getSchemaChildren({
|
|
1157
|
+
spec,
|
|
1158
|
+
schema: schema.items,
|
|
1159
|
+
path: `${path}[]`,
|
|
1160
|
+
depth: depth + 1,
|
|
1161
|
+
seen
|
|
1162
|
+
}) : [];
|
|
1163
|
+
const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
|
|
1164
|
+
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
1165
|
+
const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
|
|
1166
|
+
const resolvedProperty = resolveSchema(spec, propertySchema);
|
|
1167
|
+
const property = isRecord(resolvedProperty) ? resolvedProperty : isRecord(propertySchema) ? propertySchema : {};
|
|
1168
|
+
const isArray = schemaHasType(property, "array");
|
|
1169
|
+
const childPath = path ? `${path}.${name}` : name;
|
|
1170
|
+
const children = getSchemaChildren({
|
|
1171
|
+
spec,
|
|
1172
|
+
schema: isArray ? property.items : propertySchema,
|
|
1173
|
+
path: isArray ? `${childPath}[]` : childPath,
|
|
1174
|
+
depth: depth + 1,
|
|
1175
|
+
seen
|
|
1176
|
+
});
|
|
1177
|
+
return {
|
|
1178
|
+
key: childPath,
|
|
1179
|
+
name,
|
|
1180
|
+
type: schemaToType(propertySchema),
|
|
1181
|
+
description: getSchemaDescription(property),
|
|
1182
|
+
details: getSchemaDetails(property),
|
|
1183
|
+
required: objectRequired.includes(name),
|
|
1184
|
+
children
|
|
1185
|
+
};
|
|
1186
|
+
});
|
|
1187
|
+
const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
|
|
1188
|
+
key: `${path || "root"}.*`,
|
|
1189
|
+
name: "*",
|
|
1190
|
+
type: schemaToType(schema.additionalProperties),
|
|
1191
|
+
description: getSchemaDescription(schema.additionalProperties),
|
|
1192
|
+
details: getSchemaDetails(schema.additionalProperties),
|
|
1193
|
+
required: false,
|
|
1194
|
+
children: getSchemaChildren({
|
|
1195
|
+
spec,
|
|
1196
|
+
schema: schema.additionalProperties,
|
|
1197
|
+
path: `${path || "root"}.*`,
|
|
1198
|
+
depth: depth + 1,
|
|
1199
|
+
seen
|
|
1200
|
+
})
|
|
1201
|
+
}] : [];
|
|
1202
|
+
const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
|
|
1203
|
+
const resolvedBranch = resolveSchema(spec, branchSchema);
|
|
1204
|
+
const branch = isRecord(resolvedBranch) ? resolvedBranch : void 0;
|
|
1205
|
+
return {
|
|
1206
|
+
key: `${path || "root"}.${label}`,
|
|
1207
|
+
name: label,
|
|
1208
|
+
type: schemaToType(branchSchema),
|
|
1209
|
+
description: branch ? getSchemaDescription(branch) : void 0,
|
|
1210
|
+
details: branch ? getSchemaDetails(branch) : void 0,
|
|
1211
|
+
required: false,
|
|
1212
|
+
children: getSchemaChildren({
|
|
1213
|
+
spec,
|
|
1214
|
+
schema: branchSchema,
|
|
1215
|
+
path: `${path || "root"}.${label}`,
|
|
1216
|
+
required: objectRequired,
|
|
1217
|
+
depth: depth + 1,
|
|
1218
|
+
seen
|
|
1219
|
+
})
|
|
1220
|
+
};
|
|
1221
|
+
});
|
|
1222
|
+
return [
|
|
1223
|
+
...arrayChildren,
|
|
1224
|
+
...propertyChildren,
|
|
1225
|
+
...additionalPropertyChildren,
|
|
1226
|
+
...composedChildren
|
|
1227
|
+
];
|
|
1228
|
+
}
|
|
1229
|
+
function getRootSchemaNode(spec, schema) {
|
|
1230
|
+
if (isReference(schema)) {
|
|
1231
|
+
const resolvedSchema = resolveSchema(spec, schema);
|
|
1232
|
+
const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
|
|
1233
|
+
return {
|
|
1234
|
+
key: schema.$ref,
|
|
1235
|
+
name: resolveReferenceName(schema.$ref),
|
|
1236
|
+
type: schemaToType(schema),
|
|
1237
|
+
description: getSchemaDescription(resolved),
|
|
1238
|
+
details: getSchemaDetails(resolved),
|
|
1239
|
+
required: false,
|
|
1240
|
+
children: getSchemaChildren({
|
|
1241
|
+
spec,
|
|
1242
|
+
schema: resolvedSchema,
|
|
1243
|
+
path: resolveReferenceName(schema.$ref),
|
|
1244
|
+
seen: new Set([schema.$ref])
|
|
1245
|
+
})
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
if (!isRecord(schema)) return void 0;
|
|
1249
|
+
return {
|
|
1250
|
+
key: "root",
|
|
1251
|
+
name: "body",
|
|
1252
|
+
type: schemaToType(schema),
|
|
1253
|
+
description: getSchemaDescription(schema),
|
|
1254
|
+
details: getSchemaDetails(schema),
|
|
1255
|
+
required: false,
|
|
1256
|
+
children: getSchemaChildren({
|
|
1257
|
+
spec,
|
|
1258
|
+
schema,
|
|
1259
|
+
path: ""
|
|
1260
|
+
})
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
function SchemaNode(arg0) {
|
|
1264
|
+
const { node, depth = 0 } = arg0;
|
|
1265
|
+
const t = require_shell.useBuiltInText();
|
|
1266
|
+
const [expanded, setExpanded] = (0, react.useState)(depth < 1);
|
|
1267
|
+
const hasChildren = node.children.length > 0;
|
|
1268
|
+
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
1269
|
+
const fallbackDescription = node.required ? t("openapi.required") : t("openapi.optional");
|
|
1270
|
+
const rowClassName = (0, clsx.default)("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-[calc(100%+1rem)] px-2" : "w-full px-1");
|
|
1271
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1272
|
+
className: "min-w-0 flex-1",
|
|
1273
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1274
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",
|
|
1275
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1276
|
+
className: "text-sm/5 font-semibold text-zinc-950 dark:text-white",
|
|
1277
|
+
children: node.name
|
|
1278
|
+
}), type ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1279
|
+
className: "text-xs text-(--clarify-theme-tokens-colors-muted) dark:text-zinc-500",
|
|
1280
|
+
children: type
|
|
1281
|
+
}) : null]
|
|
1282
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1283
|
+
className: "mt-0.5 text-sm/5 text-zinc-600 *:first:mt-0 *:last:mb-0 dark:text-zinc-400",
|
|
1284
|
+
children: [node.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: node.description }) : fallbackDescription, node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1285
|
+
className: "text-xs text-zinc-500 dark:text-zinc-500",
|
|
1286
|
+
children: node.details
|
|
1287
|
+
}) : null]
|
|
1288
|
+
})]
|
|
1289
|
+
}), hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1290
|
+
className: "ml-2 flex h-5 w-5 flex-none items-center justify-center text-zinc-500 dark:text-zinc-400",
|
|
1291
|
+
"aria-hidden": "true",
|
|
1292
|
+
children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-4 w-4" })
|
|
1293
|
+
}) : null] });
|
|
1294
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
1295
|
+
className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
|
|
1296
|
+
children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1297
|
+
type: "button",
|
|
1298
|
+
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
1299
|
+
"aria-expanded": expanded,
|
|
1300
|
+
onClick: () => setExpanded((value) => !value),
|
|
1301
|
+
className: (0, clsx.default)(rowClassName, "cursor-pointer transition"),
|
|
1302
|
+
children: content
|
|
1303
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1304
|
+
className: rowClassName,
|
|
1305
|
+
children: content
|
|
1306
|
+
}), hasChildren && expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, {
|
|
1307
|
+
nodes: node.children,
|
|
1308
|
+
depth: depth + 1
|
|
1309
|
+
}) : null]
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
function SchemaTree(arg0) {
|
|
1313
|
+
const { nodes, depth = 0 } = arg0;
|
|
1314
|
+
if (nodes.length === 0) return null;
|
|
1315
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
1316
|
+
role: "list",
|
|
1317
|
+
className: (0, clsx.default)("m-0 list-none divide-y divide-zinc-900/5 p-0 dark:divide-white/5", depth > 0 && "mt-2 rounded-lg bg-zinc-950/2.5 px-2 py-1 dark:bg-white/4"),
|
|
1318
|
+
children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
|
|
1319
|
+
node,
|
|
1320
|
+
depth
|
|
1321
|
+
}, node.key))
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
function SchemaProperties(arg0) {
|
|
1325
|
+
const { title, schema, spec } = arg0;
|
|
1326
|
+
const root = getRootSchemaNode(spec, schema);
|
|
1327
|
+
if (!root || root.children.length === 0) return null;
|
|
1328
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1329
|
+
className: "clarify-schema-properties my-6",
|
|
1330
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, { nodes: root.children })
|
|
1331
|
+
})] });
|
|
1332
|
+
}
|
|
1333
|
+
function ParameterList(arg0) {
|
|
1334
|
+
const { title, parameters } = arg0;
|
|
1335
|
+
const t = require_shell.useBuiltInText();
|
|
1336
|
+
if (parameters.length === 0) return null;
|
|
1337
|
+
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, {
|
|
1338
|
+
name: parameter.name ?? t("openapi.parameter"),
|
|
1339
|
+
type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
|
|
1340
|
+
children: parameter.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: parameter.description }) : t("openapi.operationParameter")
|
|
1341
|
+
}, `${parameter.in}-${parameter.name}`)) })] });
|
|
1342
|
+
}
|
|
1343
|
+
function ResponseList(arg0) {
|
|
1344
|
+
const { operation, spec } = arg0;
|
|
1345
|
+
const t = require_shell.useBuiltInText();
|
|
1346
|
+
const responses = getResponseEntries(operation, spec);
|
|
1347
|
+
if (responses.length === 0) return null;
|
|
1348
|
+
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)(Properties, { children: responses.map(({ status, response }) => {
|
|
1349
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
|
|
1350
|
+
name: status,
|
|
1351
|
+
type: schemaToType(getJsonLikeContent(response.content, spec)?.value.schema),
|
|
1352
|
+
children: response.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: response.description }) : `${t("openapi.response")}.`
|
|
1353
|
+
}, status);
|
|
1354
|
+
}) })] });
|
|
1355
|
+
}
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region source/openapi/components/OpenApiOperation.tsx
|
|
1358
|
+
function EndpointExamples(arg0) {
|
|
1359
|
+
const { spec, path, method, operation, parameters, requestContents, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth } = arg0;
|
|
1360
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1361
|
+
className: "space-y-6",
|
|
1362
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestExamplesPanel, {
|
|
1363
|
+
spec,
|
|
1364
|
+
path,
|
|
1365
|
+
method,
|
|
1366
|
+
parameters,
|
|
1367
|
+
requestContents,
|
|
1368
|
+
selectedMediaType: selectedRequestMediaType,
|
|
1369
|
+
onSelectMediaType: onSelectRequestMediaType,
|
|
1370
|
+
selectedServer,
|
|
1371
|
+
serverVariables,
|
|
1372
|
+
auth
|
|
1373
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
|
|
1374
|
+
operation,
|
|
1375
|
+
spec
|
|
1376
|
+
})]
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
var endpointMethodStyles = {
|
|
1380
|
+
GET: "bg-emerald-400/15 text-emerald-600 dark:bg-emerald-400/20 dark:text-emerald-300",
|
|
1381
|
+
POST: "bg-sky-400/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300",
|
|
1382
|
+
PUT: "bg-amber-400/15 text-amber-600 dark:bg-amber-400/20 dark:text-amber-300",
|
|
1383
|
+
PATCH: "bg-amber-400/15 text-amber-600 dark:bg-amber-400/20 dark:text-amber-300",
|
|
1384
|
+
DELETE: "bg-rose-400/15 text-rose-600 dark:bg-rose-400/20 dark:text-rose-300"
|
|
1385
|
+
};
|
|
1386
|
+
function EndpointMethodBadge(arg0) {
|
|
1387
|
+
const { method } = arg0;
|
|
1388
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1389
|
+
className: (0, clsx.default)("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyles[method] ?? "bg-zinc-400/15 text-zinc-700 dark:bg-zinc-400/20 dark:text-zinc-200"),
|
|
1390
|
+
children: method
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
function InlineListbox(arg0) {
|
|
1394
|
+
const { label, value, options, onChange, compact = false } = arg0;
|
|
1395
|
+
const selected = options.find((option) => option.value === value) ?? options[0];
|
|
1396
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
|
|
1397
|
+
value: selected?.value ?? value,
|
|
1398
|
+
onChange,
|
|
1399
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1400
|
+
className: "pointer-events-auto relative inline-flex min-w-0",
|
|
1401
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
|
|
1402
|
+
"aria-label": label,
|
|
1403
|
+
className: (0, clsx.default)("inline-flex min-w-0 items-center gap-1 rounded-md border border-zinc-200 bg-white font-semibold text-zinc-900 shadow-xs outline-hidden transition hover:border-zinc-300 hover:bg-zinc-50 data-open:border-zinc-300 data-open:bg-zinc-50 dark:border-white/10 dark:bg-zinc-950 dark:text-zinc-100 dark:hover:border-white/15 dark:hover:bg-zinc-900 dark:data-open:border-white/15 dark:data-open:bg-zinc-900", compact ? "max-w-32 px-1.5 py-0.5 text-xs" : "w-full px-2.5 py-1.5 text-xs"),
|
|
1404
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1405
|
+
className: "truncate",
|
|
1406
|
+
children: selected?.label ?? value
|
|
1407
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
1408
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-500 dark:text-zinc-400",
|
|
1409
|
+
"aria-hidden": "true"
|
|
1410
|
+
})]
|
|
1411
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
|
|
1412
|
+
anchor: "bottom start",
|
|
1413
|
+
className: "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-[min(32rem,calc(100vw-2rem))] overflow-auto rounded-xl bg-white p-1 text-xs shadow-lg shadow-black/10 ring-1 ring-zinc-950/10 [--anchor-gap:--spacing(1)] focus:outline-none dark:bg-zinc-950 dark:ring-white/10",
|
|
1414
|
+
children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
|
|
1415
|
+
value: option.value,
|
|
1416
|
+
className: "group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-zinc-700 select-none data-focus:bg-zinc-100 data-selected:text-emerald-700 dark:text-zinc-200 dark:data-focus:bg-white/10 dark:data-selected:text-emerald-300",
|
|
1417
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1418
|
+
className: "min-w-0",
|
|
1419
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1420
|
+
className: "block truncate",
|
|
1421
|
+
children: option.label
|
|
1422
|
+
}), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1423
|
+
className: "mt-0.5 block truncate text-2xs text-zinc-500 dark:text-zinc-400",
|
|
1424
|
+
children: option.description
|
|
1425
|
+
}) : null]
|
|
1426
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
1427
|
+
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
1428
|
+
"aria-hidden": "true"
|
|
1429
|
+
})]
|
|
1430
|
+
}, option.value))
|
|
1431
|
+
})]
|
|
1432
|
+
})
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
function getServerPreviewUrl(server, variables) {
|
|
1436
|
+
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
1437
|
+
}
|
|
1438
|
+
function ServerUrlValue(arg0) {
|
|
1439
|
+
const { server, variables, open, onToggle } = arg0;
|
|
1440
|
+
const url = getServerPreviewUrl(server, variables);
|
|
1441
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1442
|
+
type: "button",
|
|
1443
|
+
"aria-expanded": open,
|
|
1444
|
+
"aria-label": "Server",
|
|
1445
|
+
onClick: onToggle,
|
|
1446
|
+
className: (0, clsx.default)("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-zinc-100/50 text-zinc-600 transition hover:bg-zinc-100 hover:text-zinc-950 dark:bg-white/5 dark:text-zinc-300 dark:hover:bg-white/10 dark:hover:text-white sm:w-auto sm:min-w-16 sm:max-w-[min(36%,16rem)] sm:px-1.5", open ? "bg-zinc-200 text-zinc-950 dark:bg-white/12 dark:text-white" : null),
|
|
1447
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1448
|
+
className: "sm:hidden",
|
|
1449
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
|
|
1450
|
+
className: "h-4 w-4",
|
|
1451
|
+
"aria-hidden": "true"
|
|
1452
|
+
})
|
|
1453
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1454
|
+
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
1455
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1456
|
+
className: "truncate text-xs",
|
|
1457
|
+
children: url
|
|
1458
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
1459
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
|
|
1460
|
+
"aria-hidden": "true"
|
|
1461
|
+
})]
|
|
1462
|
+
})]
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
function ServerVariableControl(arg0) {
|
|
1466
|
+
const { name, variable, value, onChange, compact = false } = arg0;
|
|
1467
|
+
if (variable?.enum?.length) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
1468
|
+
label: name,
|
|
1469
|
+
value,
|
|
1470
|
+
options: variable.enum.map((option) => ({
|
|
1471
|
+
value: option,
|
|
1472
|
+
label: option
|
|
1473
|
+
})),
|
|
1474
|
+
onChange,
|
|
1475
|
+
compact
|
|
1476
|
+
});
|
|
1477
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1478
|
+
"aria-label": name,
|
|
1479
|
+
value,
|
|
1480
|
+
placeholder: variable?.default ?? name,
|
|
1481
|
+
onChange: (event) => onChange(event.target.value),
|
|
1482
|
+
className: (0, clsx.default)("pointer-events-auto rounded-md border border-zinc-200 bg-white text-xs font-semibold text-zinc-900 shadow-xs outline-hidden transition placeholder:text-zinc-500 hover:border-zinc-300 hover:bg-zinc-50 focus:border-zinc-400 focus:bg-white dark:border-white/10 dark:bg-zinc-950 dark:text-zinc-100 dark:placeholder:text-zinc-500 dark:hover:border-white/15 dark:hover:bg-zinc-900 dark:focus:border-white/20 dark:focus:bg-zinc-950", compact ? "mx-0.5 w-24 px-1.5 py-0.5" : "w-full px-2.5 py-1.5")
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
function ServerPanel(arg0) {
|
|
1486
|
+
const { servers, selectedKey, selectedServer, variables, onSelectServer, onChangeVariable } = arg0;
|
|
1487
|
+
const variableEntries = Object.entries(selectedServer.variables ?? {});
|
|
1488
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1489
|
+
className: "border-t border-zinc-200 bg-zinc-100/70 p-3 dark:border-white/10 dark:bg-zinc-900/60",
|
|
1490
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1491
|
+
className: "grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)]",
|
|
1492
|
+
children: [servers.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1493
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
1494
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1495
|
+
className: "text-2xs font-semibold text-zinc-700 dark:text-zinc-300",
|
|
1496
|
+
children: "Server"
|
|
1497
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
1498
|
+
label: "Server",
|
|
1499
|
+
value: selectedKey,
|
|
1500
|
+
options: servers.map((server, index) => ({
|
|
1501
|
+
value: getServerKey(server, index),
|
|
1502
|
+
label: getServerLabel(server, index),
|
|
1503
|
+
description: server.description
|
|
1504
|
+
})),
|
|
1505
|
+
onChange: onSelectServer
|
|
1506
|
+
})]
|
|
1507
|
+
}) : null, variableEntries.map(([name, variable]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1508
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
1509
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1510
|
+
className: "text-2xs font-semibold text-zinc-700 dark:text-zinc-300",
|
|
1511
|
+
children: name
|
|
1512
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerVariableControl, {
|
|
1513
|
+
name,
|
|
1514
|
+
variable,
|
|
1515
|
+
value: variables[name] ?? variable.default ?? "",
|
|
1516
|
+
onChange: (value) => onChangeVariable(name, value)
|
|
1517
|
+
})]
|
|
1518
|
+
}, name))]
|
|
1519
|
+
})
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
function AuthPanel(arg0) {
|
|
1523
|
+
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
|
|
1524
|
+
if (authOptions.length === 0) return null;
|
|
1525
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1526
|
+
className: "border-t border-zinc-200 bg-zinc-100/70 p-3 dark:border-white/10 dark:bg-zinc-900/60",
|
|
1527
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1528
|
+
className: "grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.2fr)]",
|
|
1529
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1530
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
1531
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1532
|
+
className: "text-2xs font-semibold text-zinc-700 dark:text-zinc-300",
|
|
1533
|
+
children: "Auth"
|
|
1534
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
1535
|
+
label: "Auth",
|
|
1536
|
+
value: selectedAuthName,
|
|
1537
|
+
options: authOptions.map(({ name, scheme }) => ({
|
|
1538
|
+
value: name,
|
|
1539
|
+
label: name,
|
|
1540
|
+
description: authLabel(name, scheme)
|
|
1541
|
+
})),
|
|
1542
|
+
onChange: onSelectAuth
|
|
1543
|
+
})]
|
|
1544
|
+
}), selectedAuth ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1545
|
+
className: "flex min-w-0 flex-col gap-1.5",
|
|
1546
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1547
|
+
className: "text-2xs font-semibold text-zinc-700 dark:text-zinc-300",
|
|
1548
|
+
children: "Credential"
|
|
1549
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1550
|
+
className: "flex min-w-0 items-center rounded-md border border-zinc-200 bg-white px-2.5 py-1.5 shadow-xs dark:border-white/10 dark:bg-zinc-950",
|
|
1551
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1552
|
+
className: "mr-2 shrink-0 text-2xs font-semibold text-zinc-600 dark:text-zinc-400",
|
|
1553
|
+
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
1554
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1555
|
+
value: authValues[selectedAuth.name] ?? authPlaceholder(selectedAuth),
|
|
1556
|
+
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
1557
|
+
className: "min-w-0 flex-1 border-0 bg-transparent px-0 py-0 text-xs font-semibold text-zinc-900 outline-hidden placeholder:text-zinc-500 dark:text-zinc-100 dark:placeholder:text-zinc-500"
|
|
1558
|
+
})]
|
|
1559
|
+
})]
|
|
1560
|
+
}) : null]
|
|
1561
|
+
})
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
function EndpointIdentity(arg0) {
|
|
1565
|
+
const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
|
|
1566
|
+
const segments = path.split("/").filter(Boolean);
|
|
1567
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1568
|
+
className: "not-prose flex w-full flex-col overflow-hidden rounded-xl border border-zinc-200 bg-white shadow-xs dark:border-white/10 dark:bg-zinc-950",
|
|
1569
|
+
children: [
|
|
1570
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1571
|
+
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
1572
|
+
children: [
|
|
1573
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
|
|
1574
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
|
|
1575
|
+
server: selectedServer,
|
|
1576
|
+
variables: serverVariables,
|
|
1577
|
+
open: serverOpen,
|
|
1578
|
+
onToggle: onToggleServer
|
|
1579
|
+
}),
|
|
1580
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1581
|
+
className: "flex min-w-0 flex-1 items-center overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
|
|
1582
|
+
children: segments.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1583
|
+
className: "text-zinc-400",
|
|
1584
|
+
children: "/"
|
|
1585
|
+
}), segments.map((segment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1586
|
+
className: "flex items-center",
|
|
1587
|
+
children: [index > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1588
|
+
className: "text-zinc-400",
|
|
1589
|
+
children: "/"
|
|
1590
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1591
|
+
className: "font-bold text-zinc-800 dark:text-white",
|
|
1592
|
+
children: segment
|
|
1593
|
+
})]
|
|
1594
|
+
}, `${segment}-${index}`))] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1595
|
+
className: "font-bold text-zinc-800 dark:text-white",
|
|
1596
|
+
children: "/"
|
|
1597
|
+
})
|
|
1598
|
+
}),
|
|
1599
|
+
authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1600
|
+
type: "button",
|
|
1601
|
+
"aria-expanded": authOpen,
|
|
1602
|
+
"aria-label": "Auth",
|
|
1603
|
+
onClick: onToggleAuth,
|
|
1604
|
+
className: (0, clsx.default)("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-zinc-600 transition hover:bg-zinc-100 hover:text-emerald-700 dark:text-zinc-300 dark:hover:bg-white/10 dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-zinc-50 dark:bg-white/5"),
|
|
1605
|
+
children: authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.UnlockKeyholeIcon, {
|
|
1606
|
+
className: "h-4 w-4",
|
|
1607
|
+
"aria-hidden": "true"
|
|
1608
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LockKeyholeIcon, {
|
|
1609
|
+
className: "h-4 w-4",
|
|
1610
|
+
"aria-hidden": "true"
|
|
1611
|
+
})
|
|
1612
|
+
}) : null
|
|
1613
|
+
]
|
|
1614
|
+
}),
|
|
1615
|
+
serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
|
|
1616
|
+
servers,
|
|
1617
|
+
selectedKey: selectedServerKey,
|
|
1618
|
+
selectedServer,
|
|
1619
|
+
variables: serverVariables,
|
|
1620
|
+
onSelectServer,
|
|
1621
|
+
onChangeVariable: onChangeServerVariable
|
|
1622
|
+
}) : null,
|
|
1623
|
+
authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AuthPanel, {
|
|
1624
|
+
authOptions,
|
|
1625
|
+
selectedAuthName,
|
|
1626
|
+
selectedAuth,
|
|
1627
|
+
authValues,
|
|
1628
|
+
onSelectAuth,
|
|
1629
|
+
onChangeAuthValue
|
|
1630
|
+
}) : null
|
|
1631
|
+
]
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
function OpenApiOperation(arg0) {
|
|
1635
|
+
const { spec, path, method, operation } = arg0;
|
|
1636
|
+
const t = require_shell.useBuiltInText();
|
|
1637
|
+
const id = (0, github_slugger.slug)(`${method.toLowerCase()} ${path}`);
|
|
1638
|
+
const summary = operation.summary ?? `${method} ${path}`;
|
|
1639
|
+
const description = operation.description;
|
|
1640
|
+
const parameters = getOperationParameters(spec, path, operation);
|
|
1641
|
+
const requestBody = getRequestBody$1(spec, operation);
|
|
1642
|
+
const requestContents = getMediaTypeEntries(requestBody?.content, spec);
|
|
1643
|
+
const [selectedRequestMediaType, setSelectedRequestMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
|
|
1644
|
+
const selectedRequestContent = requestContents.find((content) => content.mediaType === selectedRequestMediaType) ?? requestContents[0];
|
|
1645
|
+
const requestSchema = selectedRequestContent?.value.schema;
|
|
1646
|
+
const servers = getServers(spec, operation, path);
|
|
1647
|
+
const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
|
|
1648
|
+
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
1649
|
+
const [serverVariables, setServerVariables] = (0, react.useState)(defaultServerVariables(selectedServer));
|
|
1650
|
+
const [serverOpen, setServerOpen] = (0, react.useState)(false);
|
|
1651
|
+
const authOptions = getAuthOptions(spec, operation);
|
|
1652
|
+
const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.name ?? "");
|
|
1653
|
+
const selectedAuth = authOptions.find((option) => option.name === selectedAuthName);
|
|
1654
|
+
const [authValues, setAuthValues] = (0, react.useState)({});
|
|
1655
|
+
const [authOpen, setAuthOpen] = (0, react.useState)(false);
|
|
1656
|
+
const authInput = selectedAuth ? {
|
|
1657
|
+
name: selectedAuth.name,
|
|
1658
|
+
scheme: selectedAuth.scheme,
|
|
1659
|
+
value: authValues[selectedAuth.name] ?? authPlaceholder(selectedAuth)
|
|
1660
|
+
} : void 0;
|
|
1661
|
+
const groupedParameters = {
|
|
1662
|
+
path: parameters.filter((parameter) => parameter.in === "path"),
|
|
1663
|
+
query: parameters.filter((parameter) => parameter.in === "query"),
|
|
1664
|
+
header: parameters.filter((parameter) => parameter.in === "header")
|
|
1665
|
+
};
|
|
1666
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1667
|
+
className: "clarify-api-endpoint scroll-mt-24 py-16 first:pt-0 last:pb-0",
|
|
1668
|
+
"aria-labelledby": id,
|
|
1669
|
+
children: [
|
|
1670
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointIdentity, {
|
|
1671
|
+
method,
|
|
1672
|
+
path,
|
|
1673
|
+
servers,
|
|
1674
|
+
selectedServerKey,
|
|
1675
|
+
selectedServer,
|
|
1676
|
+
serverVariables,
|
|
1677
|
+
serverOpen,
|
|
1678
|
+
authOptions,
|
|
1679
|
+
selectedAuthName,
|
|
1680
|
+
selectedAuth,
|
|
1681
|
+
authValues,
|
|
1682
|
+
authOpen,
|
|
1683
|
+
onSelectServer: (value) => {
|
|
1684
|
+
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
1685
|
+
setSelectedServerKey(value);
|
|
1686
|
+
setServerVariables(defaultServerVariables(nextServer));
|
|
1687
|
+
},
|
|
1688
|
+
onChangeServerVariable: (name, value) => setServerVariables((current) => ({
|
|
1689
|
+
...current,
|
|
1690
|
+
[name]: value
|
|
1691
|
+
})),
|
|
1692
|
+
onToggleServer: () => {
|
|
1693
|
+
setServerOpen((current) => !current);
|
|
1694
|
+
setAuthOpen(false);
|
|
1695
|
+
},
|
|
1696
|
+
onToggleAuth: () => {
|
|
1697
|
+
setAuthOpen((current) => !current);
|
|
1698
|
+
setServerOpen(false);
|
|
1699
|
+
},
|
|
1700
|
+
onSelectAuth: setSelectedAuthName,
|
|
1701
|
+
onChangeAuthValue: (name, value) => setAuthValues((current) => ({
|
|
1702
|
+
...current,
|
|
1703
|
+
[name]: value
|
|
1704
|
+
}))
|
|
1705
|
+
}),
|
|
1706
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.Heading, {
|
|
1707
|
+
id,
|
|
1708
|
+
className: "mt-6",
|
|
1709
|
+
children: summary
|
|
1710
|
+
}),
|
|
1711
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Col, { children: [
|
|
1712
|
+
description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
1713
|
+
className: "mt-4 *:first:mt-0 *:last:mb-0",
|
|
1714
|
+
children: description
|
|
1715
|
+
}) : null,
|
|
1716
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
|
|
1717
|
+
title: t("openapi.pathParameters"),
|
|
1718
|
+
parameters: groupedParameters.path
|
|
1719
|
+
}),
|
|
1720
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
|
|
1721
|
+
title: t("openapi.queryParameters"),
|
|
1722
|
+
parameters: groupedParameters.query
|
|
1723
|
+
}),
|
|
1724
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
|
|
1725
|
+
title: t("openapi.headers"),
|
|
1726
|
+
parameters: groupedParameters.header
|
|
1727
|
+
}),
|
|
1728
|
+
requestBody && requestContents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1729
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.requestBody") }),
|
|
1730
|
+
typeof requestBody.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
|
|
1731
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
|
|
1732
|
+
title: t("openapi.bodyProperties"),
|
|
1733
|
+
schema: requestSchema,
|
|
1734
|
+
spec
|
|
1735
|
+
})
|
|
1736
|
+
] }) : null,
|
|
1737
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
|
|
1738
|
+
operation,
|
|
1739
|
+
spec
|
|
1740
|
+
})
|
|
1741
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
|
|
1742
|
+
sticky: true,
|
|
1743
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointExamples, {
|
|
1744
|
+
spec,
|
|
1745
|
+
path,
|
|
1746
|
+
method,
|
|
1747
|
+
operation,
|
|
1748
|
+
parameters,
|
|
1749
|
+
requestContents,
|
|
1750
|
+
selectedRequestMediaType: selectedRequestContent?.mediaType ?? "",
|
|
1751
|
+
onSelectRequestMediaType: setSelectedRequestMediaType,
|
|
1752
|
+
selectedServer,
|
|
1753
|
+
serverVariables,
|
|
1754
|
+
auth: authInput
|
|
1755
|
+
})
|
|
1756
|
+
})] })
|
|
1757
|
+
]
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
//#endregion
|
|
1761
|
+
Object.defineProperty(exports, "EndpointIdentity", {
|
|
1762
|
+
enumerable: true,
|
|
1763
|
+
get: function() {
|
|
1764
|
+
return EndpointIdentity;
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
Object.defineProperty(exports, "Markdown", {
|
|
1768
|
+
enumerable: true,
|
|
1769
|
+
get: function() {
|
|
1770
|
+
return Markdown;
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
Object.defineProperty(exports, "OpenApiOperation", {
|
|
1774
|
+
enumerable: true,
|
|
1775
|
+
get: function() {
|
|
1776
|
+
return OpenApiOperation;
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
Object.defineProperty(exports, "RequestExamplesPanel", {
|
|
1780
|
+
enumerable: true,
|
|
1781
|
+
get: function() {
|
|
1782
|
+
return RequestExamplesPanel;
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
Object.defineProperty(exports, "ResponseExamplesPanel", {
|
|
1786
|
+
enumerable: true,
|
|
1787
|
+
get: function() {
|
|
1788
|
+
return ResponseExamplesPanel;
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1791
|
+
Object.defineProperty(exports, "authPlaceholder", {
|
|
1792
|
+
enumerable: true,
|
|
1793
|
+
get: function() {
|
|
1794
|
+
return authPlaceholder;
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
Object.defineProperty(exports, "defaultServerVariables", {
|
|
1798
|
+
enumerable: true,
|
|
1799
|
+
get: function() {
|
|
1800
|
+
return defaultServerVariables;
|
|
1801
|
+
}
|
|
1802
|
+
});
|
|
1803
|
+
Object.defineProperty(exports, "getAuthOptions", {
|
|
1804
|
+
enumerable: true,
|
|
1805
|
+
get: function() {
|
|
1806
|
+
return getAuthOptions;
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
Object.defineProperty(exports, "getMediaTypeEntries", {
|
|
1810
|
+
enumerable: true,
|
|
1811
|
+
get: function() {
|
|
1812
|
+
return getMediaTypeEntries;
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
Object.defineProperty(exports, "getRequestBody", {
|
|
1816
|
+
enumerable: true,
|
|
1817
|
+
get: function() {
|
|
1818
|
+
return getRequestBody$1;
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
1821
|
+
Object.defineProperty(exports, "getServerKey", {
|
|
1822
|
+
enumerable: true,
|
|
1823
|
+
get: function() {
|
|
1824
|
+
return getServerKey;
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
Object.defineProperty(exports, "getServers", {
|
|
1828
|
+
enumerable: true,
|
|
1829
|
+
get: function() {
|
|
1830
|
+
return getServers;
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
Object.defineProperty(exports, "primitives_exports", {
|
|
1834
|
+
enumerable: true,
|
|
1835
|
+
get: function() {
|
|
1836
|
+
return primitives_exports;
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
|
|
1840
|
+
//# sourceMappingURL=OpenApiOperation-mhoi-s4N.cjs.map
|