fumadocs-openapi 12.5.2 → 12.5.3
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/css/generated/shared.css +1 -1
- package/dist/.translations/index.d.ts +0 -32
- package/dist/.translations/keys.js +0 -32
- package/dist/generate-file.js +15 -17
- package/dist/index.browser.d.ts +8 -3
- package/dist/index.browser.js +11 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/packages/shared-api/dist/.translations/index.d.ts +34 -4
- package/dist/packages/shared-api/dist/.translations/keys.js +34 -4
- package/dist/packages/shared-api/dist/codegen.d.ts +21 -1
- package/dist/packages/shared-api/dist/codegen.js +63 -1
- package/dist/packages/shared-api/dist/components/copy-typescript.js +31 -0
- package/dist/packages/shared-api/dist/components/dialog.js +15 -1
- package/dist/packages/shared-api/dist/components/example.js +90 -16
- package/dist/packages/shared-api/dist/components/playground/fields.js +3 -3
- package/dist/packages/shared-api/dist/components/playground/json-editor.js +54 -0
- package/dist/packages/shared-api/dist/components/playground/panels.js +88 -5
- package/dist/packages/shared-api/dist/components/playground/result.js +187 -0
- package/dist/packages/shared-api/dist/components/schema/client.js +22 -0
- package/dist/packages/shared-api/dist/components/select-tab.js +8 -3
- package/dist/packages/shared-api/dist/source.d.ts +11 -0
- package/dist/packages/shared-api/dist/source.js +50 -0
- package/dist/requests/generators/curl.js +6 -9
- package/dist/requests/generators/go.js +5 -5
- package/dist/requests/generators/rust.js +3 -2
- package/dist/requests/media/adapter.js +16 -7
- package/dist/requests/media/resolve-adapter.js +15 -12
- package/dist/requests/string-utils.js +4 -32
- package/dist/server/index.d.ts +2 -7
- package/dist/server/index.js +26 -64
- package/dist/ui/base.js +2 -2
- package/dist/ui/operation/index.js +5 -36
- package/dist/ui/operation/usage-tabs.js +45 -56
- package/dist/ui/playground/client.js +18 -50
- package/dist/ui/playground/components/{oauth-panel.js → auth.js} +19 -7
- package/dist/ui/playground/components/request-panel.js +3 -65
- package/dist/ui/playground/components/response-panel.js +7 -18
- package/dist/ui/playground/components/result-display.js +45 -166
- package/dist/ui/playground/components/url-bar.js +2 -19
- package/dist/utils/create-page.d.ts +0 -4
- package/dist/utils/create-page.js +3 -5
- package/dist/utils/pages/preset-auto.js +139 -148
- package/package.json +5 -5
- package/dist/ui/playground/status-info.js +0 -39
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useOperation } from "../../../operation.js";
|
|
3
3
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../packages/shared-api/dist/components/select.js";
|
|
4
|
-
import { Markdown } from "../../components/markdown.js";
|
|
5
4
|
import { cn } from "../../../utils/cn.js";
|
|
6
5
|
import { Segmented, SegmentedList } from "../../../packages/shared-api/dist/components/segmented.js";
|
|
7
6
|
import { anyFields, useResolvedSchema } from "../../../packages/shared-api/dist/components/playground/schema.js";
|
|
8
7
|
import { FieldRow, FieldRows, LinkRow, ValueRow, getRemoval } from "../../../packages/shared-api/dist/components/playground/fields.js";
|
|
9
8
|
import { Crumb, FieldPanel, OverviewLayer, Panel, PanelNav, Section, useFieldStack } from "../../../packages/shared-api/dist/components/playground/panels.js";
|
|
9
|
+
import { JsonEditor } from "../../../packages/shared-api/dist/components/playground/json-editor.js";
|
|
10
10
|
import { Fragment, createContext, use, useState } from "react";
|
|
11
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { useDataEngine, useFieldValue } from "@fumari/stf";
|
|
13
12
|
import { stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
14
13
|
import { useTranslations } from "@fuma-translate/react";
|
|
15
|
-
import { Braces, Cookie, KeyRound, PlusIcon, Route, Rows3,
|
|
14
|
+
import { Braces, Cookie, KeyRound, PlusIcon, Route, Rows3, SlidersHorizontal } from "lucide-react";
|
|
16
15
|
//#region src/ui/playground/components/request-panel.tsx
|
|
17
16
|
const sectionIcons = {
|
|
18
17
|
path: Route,
|
|
@@ -192,20 +191,6 @@ function AuthPanelRow({ title, component }) {
|
|
|
192
191
|
children: title
|
|
193
192
|
});
|
|
194
193
|
}
|
|
195
|
-
/** mutual TLS schemes, they have no value */
|
|
196
|
-
const mutualTLSProvider = {
|
|
197
|
-
on: ({ scheme }) => scheme.type === "mutualTLS",
|
|
198
|
-
render: function MutualTLSNote({ field }) {
|
|
199
|
-
const t = useTranslations({ note: "playground" });
|
|
200
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
201
|
-
className: "flex gap-2 border-b px-4 py-2.5 text-xs text-fd-muted-foreground last:border-b-0",
|
|
202
|
-
children: [/* @__PURE__ */ jsx(ShieldCheck, { className: "mt-px size-3.5 shrink-0" }), /* @__PURE__ */ jsxs("div", {
|
|
203
|
-
className: "min-w-0 flex-1 [&_a]:underline",
|
|
204
|
-
children: [/* @__PURE__ */ jsx("p", { children: t("Requires a client certificate installed in your browser.") }), field.scheme.description && /* @__PURE__ */ jsx(Markdown, { md: field.scheme.description })]
|
|
205
|
-
})]
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
194
|
function BodySection({ body, renderBodyField, onNavigate }) {
|
|
210
195
|
const t = useTranslations({ note: "playground" });
|
|
211
196
|
const [mode, setMode] = useState("form");
|
|
@@ -247,52 +232,5 @@ function BodySection({ body, renderBodyField, onNavigate }) {
|
|
|
247
232
|
children: content
|
|
248
233
|
});
|
|
249
234
|
}
|
|
250
|
-
function JsonEditor({ fieldName }) {
|
|
251
|
-
const engine = useDataEngine();
|
|
252
|
-
const [value] = useFieldValue(fieldName);
|
|
253
|
-
const [draft, setDraft] = useState(() => ({
|
|
254
|
-
value,
|
|
255
|
-
text: formatJson(value),
|
|
256
|
-
error: ""
|
|
257
|
-
}));
|
|
258
|
-
if (draft.value !== value) setDraft({
|
|
259
|
-
value,
|
|
260
|
-
text: formatJson(value),
|
|
261
|
-
error: ""
|
|
262
|
-
});
|
|
263
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
264
|
-
className: "flex flex-col",
|
|
265
|
-
children: [/* @__PURE__ */ jsx("textarea", {
|
|
266
|
-
"aria-label": "JSON",
|
|
267
|
-
value: draft.text,
|
|
268
|
-
spellCheck: false,
|
|
269
|
-
onChange: (e) => {
|
|
270
|
-
const text = e.target.value;
|
|
271
|
-
try {
|
|
272
|
-
const parsed = JSON.parse(text);
|
|
273
|
-
setDraft({
|
|
274
|
-
value: parsed,
|
|
275
|
-
text,
|
|
276
|
-
error: ""
|
|
277
|
-
});
|
|
278
|
-
engine.update(fieldName, parsed);
|
|
279
|
-
} catch (err) {
|
|
280
|
-
setDraft({
|
|
281
|
-
...draft,
|
|
282
|
-
text,
|
|
283
|
-
error: err instanceof Error ? err.message : ""
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
className: "min-h-60 w-full resize-none bg-transparent px-4 py-3 font-mono text-[0.8125rem] leading-relaxed outline-none field-sizing-content"
|
|
288
|
-
}), draft.error && /* @__PURE__ */ jsx("p", {
|
|
289
|
-
className: "border-t px-4 py-2 font-mono text-xs text-red-400",
|
|
290
|
-
children: draft.error
|
|
291
|
-
})]
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
function formatJson(value) {
|
|
295
|
-
return JSON.stringify(value ?? {}, null, 2);
|
|
296
|
-
}
|
|
297
235
|
//#endregion
|
|
298
|
-
export { RequestPanel
|
|
236
|
+
export { RequestPanel };
|
|
@@ -6,9 +6,8 @@ import { Markdown } from "../../components/markdown.js";
|
|
|
6
6
|
import { cn } from "../../../utils/cn.js";
|
|
7
7
|
import { CodeUsages } from "../../operation/usage-tabs.js";
|
|
8
8
|
import { Segmented, SegmentedList, SegmentedPanel } from "../../../packages/shared-api/dist/components/segmented.js";
|
|
9
|
-
import { PanelHeader, panelCodeBlock } from "../../../packages/shared-api/dist/components/playground/panels.js";
|
|
9
|
+
import { PanelHeader, Placeholder, SendingOverlay, panelCodeBlock, panelTopCodeBlock } from "../../../packages/shared-api/dist/components/playground/panels.js";
|
|
10
10
|
import { DefaultResultDisplay } from "./result-display.js";
|
|
11
|
-
import { Spinner } from "../../../packages/shared-api/dist/components/spinner.js";
|
|
12
11
|
import { useState } from "react";
|
|
13
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
13
|
import { useTranslations } from "@fuma-translate/react";
|
|
@@ -20,7 +19,7 @@ function ResponsePanel({ response, loading, onReset, ResultDisplay = DefaultResu
|
|
|
20
19
|
className: cn("@container flex min-h-0 flex-col", className),
|
|
21
20
|
children: [/* @__PURE__ */ jsx(CodeUsages, {
|
|
22
21
|
title: t("Request"),
|
|
23
|
-
className:
|
|
22
|
+
className: panelTopCodeBlock.className,
|
|
24
23
|
viewportClassName: "max-h-[min(18rem,30vh)]"
|
|
25
24
|
}), /* @__PURE__ */ jsxs("div", {
|
|
26
25
|
className: "relative flex min-h-0 flex-1 flex-col",
|
|
@@ -28,10 +27,7 @@ function ResponsePanel({ response, loading, onReset, ResultDisplay = DefaultResu
|
|
|
28
27
|
data: response.result,
|
|
29
28
|
reset: onReset,
|
|
30
29
|
className: "starting:opacity-0 motion-safe:transition-[opacity,translate] motion-safe:duration-300 motion-safe:starting:translate-y-1"
|
|
31
|
-
}, response.id) : /* @__PURE__ */ jsx(ResponseExamples, {}), loading && /* @__PURE__ */
|
|
32
|
-
className: "absolute inset-0 flex items-center justify-center gap-2 bg-fd-card/70 text-sm text-fd-muted-foreground backdrop-blur-[1px] transition-opacity delay-150 duration-200 starting:opacity-0",
|
|
33
|
-
children: [/* @__PURE__ */ jsx(Spinner, { className: "size-3.5" }), t("Sending request...")]
|
|
34
|
-
})]
|
|
30
|
+
}, response.id) : /* @__PURE__ */ jsx(ResponseExamples, {}), loading && /* @__PURE__ */ jsx(SendingOverlay, {})]
|
|
35
31
|
})]
|
|
36
32
|
});
|
|
37
33
|
}
|
|
@@ -40,15 +36,9 @@ function ResponseExamples() {
|
|
|
40
36
|
const tabs = useResponseExamples();
|
|
41
37
|
const [code, setCode] = useState();
|
|
42
38
|
const [selected, setSelected] = useState(0);
|
|
43
|
-
if (tabs.length === 0) return /* @__PURE__ */
|
|
44
|
-
|
|
45
|
-
children:
|
|
46
|
-
className: "rounded-xl border bg-fd-secondary p-2.5 text-fd-muted-foreground",
|
|
47
|
-
children: /* @__PURE__ */ jsx(SendHorizontal, { className: "size-4" })
|
|
48
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
49
|
-
className: "text-sm text-fd-muted-foreground",
|
|
50
|
-
children: t("Send a request to see its response.")
|
|
51
|
-
})]
|
|
39
|
+
if (tabs.length === 0) return /* @__PURE__ */ jsx(Placeholder, {
|
|
40
|
+
icon: SendHorizontal,
|
|
41
|
+
children: t("Send a request to see its response.")
|
|
52
42
|
});
|
|
53
43
|
const tab = tabs.find((item) => item.code === code) ?? tabs[0];
|
|
54
44
|
const examples = tab.examples ?? [];
|
|
@@ -74,8 +64,7 @@ function ResponseExamples() {
|
|
|
74
64
|
label: item.label
|
|
75
65
|
})),
|
|
76
66
|
value: String(selected),
|
|
77
|
-
onValueChange: (v) => setSelected(Number(v))
|
|
78
|
-
className: "max-w-40"
|
|
67
|
+
onValueChange: (v) => setSelected(Number(v))
|
|
79
68
|
}),
|
|
80
69
|
/* @__PURE__ */ jsx(SegmentedList, {
|
|
81
70
|
className: "max-w-1/2 shrink-0 overflow-x-auto [scrollbar-width:none]",
|
|
@@ -1,51 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ClientCodeBlock } from "../../components/codeblock.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Fragment, useCallback, useMemo, useState } from "react";
|
|
8
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { iconButtonClassName, panelCodeBlock } from "../../../packages/shared-api/dist/components/playground/panels.js";
|
|
4
|
+
import { RequestError, ResponseView } from "../../../packages/shared-api/dist/components/playground/result.js";
|
|
5
|
+
import { useCallback, useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
7
|
import { useTranslations } from "@fuma-translate/react";
|
|
10
|
-
import { DownloadIcon, FileIcon
|
|
8
|
+
import { DownloadIcon, FileIcon } from "lucide-react";
|
|
11
9
|
//#region src/ui/playground/components/result-display.tsx
|
|
12
10
|
function DefaultResultDisplay({ data, reset, ...rest }) {
|
|
13
|
-
|
|
14
|
-
if (data.type === "client_error") return /* @__PURE__ */ jsxs("div", {
|
|
11
|
+
if (data.type === "client_error") return /* @__PURE__ */ jsx(RequestError, {
|
|
15
12
|
...rest,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/* @__PURE__ */ jsx("span", {
|
|
20
|
-
className: "text-[0.8125rem] font-medium",
|
|
21
|
-
children: t("Request Failed")
|
|
22
|
-
}),
|
|
23
|
-
/* @__PURE__ */ jsx("button", {
|
|
24
|
-
type: "button",
|
|
25
|
-
"aria-label": t("Clear"),
|
|
26
|
-
className: cn(iconButtonClassName, "ms-auto"),
|
|
27
|
-
onClick: reset,
|
|
28
|
-
children: /* @__PURE__ */ jsx(X, {})
|
|
29
|
-
})
|
|
30
|
-
] }), /* @__PURE__ */ jsxs("div", {
|
|
31
|
-
className: "flex flex-col gap-3 overflow-auto p-4 text-sm",
|
|
32
|
-
children: [
|
|
33
|
-
/* @__PURE__ */ jsx("p", { children: data.message }),
|
|
34
|
-
/* @__PURE__ */ jsx("p", {
|
|
35
|
-
className: "font-mono text-xs break-all text-fd-muted-foreground",
|
|
36
|
-
children: data.url
|
|
37
|
-
}),
|
|
38
|
-
/* @__PURE__ */ jsx("p", {
|
|
39
|
-
className: "rounded-lg border bg-fd-secondary p-3 text-xs text-fd-muted-foreground",
|
|
40
|
-
children: t("Check the server URL. If the API does not allow cross-origin requests from this site, a proxy is needed.")
|
|
41
|
-
})
|
|
42
|
-
]
|
|
43
|
-
})]
|
|
13
|
+
message: data.message,
|
|
14
|
+
url: data.url,
|
|
15
|
+
onClear: reset
|
|
44
16
|
});
|
|
45
17
|
return /* @__PURE__ */ jsx(ResponseResult, {
|
|
18
|
+
...rest,
|
|
46
19
|
data,
|
|
47
|
-
reset
|
|
48
|
-
...rest
|
|
20
|
+
reset
|
|
49
21
|
});
|
|
50
22
|
}
|
|
51
23
|
function getTextFormat(mime) {
|
|
@@ -63,21 +35,11 @@ function getTextFormat(mime) {
|
|
|
63
35
|
if (mime.startsWith("text/")) return "text";
|
|
64
36
|
return null;
|
|
65
37
|
}
|
|
66
|
-
function formatDuration(ms) {
|
|
67
|
-
return ms < 1e3 ? `${Math.round(ms)} ms` : `${(ms / 1e3).toFixed(2)} s`;
|
|
68
|
-
}
|
|
69
|
-
function formatSize(bytes) {
|
|
70
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
71
|
-
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} kB`;
|
|
72
|
-
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
73
|
-
}
|
|
74
38
|
function ResponseResult({ data, reset, ...rest }) {
|
|
75
39
|
const t = useTranslations({ note: "playground result display" });
|
|
76
|
-
const statusInfo = useStatusInfo(data.status);
|
|
77
|
-
const [view, setView] = useState("body");
|
|
78
40
|
const type = data.mediaType ?? "text/plain";
|
|
79
|
-
const headers = Array.from(data.headers);
|
|
80
41
|
const size = data.body.byteLength;
|
|
42
|
+
const lang = getTextFormat(type);
|
|
81
43
|
const bodyUrlRef = useCallback((element) => {
|
|
82
44
|
if (!element) return;
|
|
83
45
|
const url = URL.createObjectURL(new Blob([data.body], { type }));
|
|
@@ -94,124 +56,41 @@ function ResponseResult({ data, reset, ...rest }) {
|
|
|
94
56
|
className: "max-w-full rounded-lg border"
|
|
95
57
|
})
|
|
96
58
|
});
|
|
97
|
-
else if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
lang,
|
|
101
|
-
data
|
|
102
|
-
});
|
|
103
|
-
else body = /* @__PURE__ */ jsxs("div", {
|
|
104
|
-
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center",
|
|
105
|
-
children: [
|
|
106
|
-
/* @__PURE__ */ jsx(FileIcon, { className: "size-5 text-fd-muted-foreground" }),
|
|
107
|
-
/* @__PURE__ */ jsx("p", {
|
|
108
|
-
className: "text-sm font-medium",
|
|
109
|
-
children: t("Binary response body, {length} bytes", { variables: { length: String(size) } })
|
|
110
|
-
}),
|
|
111
|
-
type && /* @__PURE__ */ jsx("p", {
|
|
112
|
-
className: "font-mono text-xs text-fd-muted-foreground",
|
|
113
|
-
children: type
|
|
114
|
-
})
|
|
115
|
-
]
|
|
116
|
-
});
|
|
117
|
-
} else body = /* @__PURE__ */ jsxs("div", {
|
|
118
|
-
className: "flex h-full flex-col items-center justify-center gap-1 p-6 text-center",
|
|
119
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
120
|
-
className: "text-4xl font-light tracking-tight tabular-nums",
|
|
121
|
-
children: data.status
|
|
122
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
123
|
-
className: "text-sm text-fd-muted-foreground",
|
|
124
|
-
children: t("Empty response body")
|
|
125
|
-
})]
|
|
59
|
+
else if (lang) body = /* @__PURE__ */ jsx(TextResult, {
|
|
60
|
+
lang,
|
|
61
|
+
data
|
|
126
62
|
});
|
|
127
|
-
|
|
63
|
+
else body = /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center",
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ jsx(FileIcon, { className: "size-5 text-fd-muted-foreground" }),
|
|
67
|
+
/* @__PURE__ */ jsx("p", {
|
|
68
|
+
className: "text-sm font-medium",
|
|
69
|
+
children: t("Binary response body, {length} bytes", { variables: { length: String(size) } })
|
|
70
|
+
}),
|
|
71
|
+
type && /* @__PURE__ */ jsx("p", {
|
|
72
|
+
className: "font-mono text-xs text-fd-muted-foreground",
|
|
73
|
+
children: type
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
return /* @__PURE__ */ jsx(ResponseView, {
|
|
128
78
|
...rest,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
" ",
|
|
145
|
-
/* @__PURE__ */ jsx("span", {
|
|
146
|
-
className: "font-normal text-fd-muted-foreground",
|
|
147
|
-
children: statusInfo.description
|
|
148
|
-
})
|
|
149
|
-
]
|
|
150
|
-
}),
|
|
151
|
-
/* @__PURE__ */ jsxs("p", {
|
|
152
|
-
className: "hidden shrink-0 text-xs text-fd-muted-foreground tabular-nums @md:block",
|
|
153
|
-
children: [
|
|
154
|
-
formatDuration(data.duration),
|
|
155
|
-
" · ",
|
|
156
|
-
formatSize(size)
|
|
157
|
-
]
|
|
158
|
-
}),
|
|
159
|
-
/* @__PURE__ */ jsx(SegmentedList, {
|
|
160
|
-
className: "ms-auto shrink-0",
|
|
161
|
-
items: [{
|
|
162
|
-
value: "body",
|
|
163
|
-
label: t("Body")
|
|
164
|
-
}, {
|
|
165
|
-
value: "headers",
|
|
166
|
-
label: /* @__PURE__ */ jsxs(Fragment$1, { children: [t("Headers"), /* @__PURE__ */ jsx("span", {
|
|
167
|
-
className: "text-fd-muted-foreground tabular-nums",
|
|
168
|
-
children: headers.length
|
|
169
|
-
})] })
|
|
170
|
-
}]
|
|
171
|
-
}),
|
|
172
|
-
/* @__PURE__ */ jsxs("div", {
|
|
173
|
-
className: "flex shrink-0 items-center",
|
|
174
|
-
children: [size > 0 && /* @__PURE__ */ jsx("a", {
|
|
175
|
-
ref: bodyUrlRef,
|
|
176
|
-
download: data.fileName ?? "response",
|
|
177
|
-
"aria-label": t("Download"),
|
|
178
|
-
title: t("Download"),
|
|
179
|
-
className: iconButtonClassName,
|
|
180
|
-
children: /* @__PURE__ */ jsx(DownloadIcon, {})
|
|
181
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
182
|
-
type: "button",
|
|
183
|
-
"aria-label": t("Clear"),
|
|
184
|
-
title: t("Clear"),
|
|
185
|
-
className: iconButtonClassName,
|
|
186
|
-
onClick: reset,
|
|
187
|
-
children: /* @__PURE__ */ jsx(X, {})
|
|
188
|
-
})]
|
|
189
|
-
})
|
|
190
|
-
] }),
|
|
191
|
-
/* @__PURE__ */ jsx(SegmentedPanel, {
|
|
192
|
-
value: "body",
|
|
193
|
-
className: "min-h-0 flex-1 overflow-auto",
|
|
194
|
-
children: body
|
|
195
|
-
}),
|
|
196
|
-
/* @__PURE__ */ jsxs(SegmentedPanel, {
|
|
197
|
-
value: "headers",
|
|
198
|
-
className: "min-h-0 flex-1 overflow-auto",
|
|
199
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
200
|
-
className: "border-b px-4 py-2.5 font-mono text-xs break-all text-fd-muted-foreground",
|
|
201
|
-
children: data.url
|
|
202
|
-
}), /* @__PURE__ */ jsx("dl", {
|
|
203
|
-
className: "grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] font-mono text-xs",
|
|
204
|
-
children: headers.map(([name, value]) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
|
|
205
|
-
className: "truncate border-b py-2 ps-4 pe-2 text-fd-muted-foreground",
|
|
206
|
-
children: name
|
|
207
|
-
}), /* @__PURE__ */ jsx("dd", {
|
|
208
|
-
className: "border-b border-s px-3 py-2 break-all",
|
|
209
|
-
children: value
|
|
210
|
-
})] }, name))
|
|
211
|
-
})]
|
|
212
|
-
})
|
|
213
|
-
]
|
|
214
|
-
})
|
|
79
|
+
status: data.status,
|
|
80
|
+
duration: data.duration,
|
|
81
|
+
size,
|
|
82
|
+
url: data.url,
|
|
83
|
+
headers: Array.from(data.headers),
|
|
84
|
+
onClear: reset,
|
|
85
|
+
actions: size > 0 && /* @__PURE__ */ jsx("a", {
|
|
86
|
+
ref: bodyUrlRef,
|
|
87
|
+
download: data.fileName ?? "response",
|
|
88
|
+
"aria-label": t("Download"),
|
|
89
|
+
title: t("Download"),
|
|
90
|
+
className: iconButtonClassName,
|
|
91
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, {})
|
|
92
|
+
}),
|
|
93
|
+
children: body
|
|
215
94
|
});
|
|
216
95
|
}
|
|
217
96
|
function TextResult({ lang, data }) {
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { MethodLabel } from "../../components/method-label.js";
|
|
3
3
|
import { cn } from "../../../utils/cn.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SendButton } from "../../../packages/shared-api/dist/components/playground/panels.js";
|
|
5
5
|
import { ParamInput } from "../../../packages/shared-api/dist/components/playground/param-input.js";
|
|
6
6
|
import ServerSelect from "./server-select.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { useTranslations } from "@fuma-translate/react";
|
|
9
|
-
import { SendHorizontal } from "lucide-react";
|
|
10
|
-
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
11
8
|
//#region src/ui/playground/components/url-bar.tsx
|
|
12
9
|
function UrlBar({ method, route, parameters, deprecated = false, loading }) {
|
|
13
|
-
const t = useTranslations({ note: "playground" });
|
|
14
|
-
const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.userAgent);
|
|
15
10
|
return /* @__PURE__ */ jsxs("div", {
|
|
16
11
|
className: "flex items-center gap-2",
|
|
17
12
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -36,19 +31,7 @@ function UrlBar({ method, route, parameters, deprecated = false, loading }) {
|
|
|
36
31
|
})
|
|
37
32
|
})]
|
|
38
33
|
})]
|
|
39
|
-
}), /* @__PURE__ */
|
|
40
|
-
type: "submit",
|
|
41
|
-
disabled: loading,
|
|
42
|
-
className: cn(buttonVariants({ variant: "primary" }), "h-10 shrink-0 gap-2 rounded-xl px-4 transition-[background-color,scale] active:scale-[0.97] disabled:opacity-80 motion-reduce:transition-none"),
|
|
43
|
-
children: [
|
|
44
|
-
loading ? /* @__PURE__ */ jsx(Spinner, { className: "size-3.5" }) : /* @__PURE__ */ jsx(SendHorizontal, { className: "size-3.5" }),
|
|
45
|
-
t("Send"),
|
|
46
|
-
/* @__PURE__ */ jsxs("kbd", {
|
|
47
|
-
className: "hidden font-sans text-xs text-fd-primary-foreground/60 sm:inline",
|
|
48
|
-
children: [isMac ? "⌘" : "Ctrl", " ↵"]
|
|
49
|
-
})
|
|
50
|
-
]
|
|
51
|
-
})]
|
|
34
|
+
}), /* @__PURE__ */ jsx(SendButton, { sending: loading })]
|
|
52
35
|
});
|
|
53
36
|
}
|
|
54
37
|
//#endregion
|
|
@@ -205,10 +205,6 @@ export declare function useRenderContext(): RenderContext;
|
|
|
205
205
|
* Generate TypeScript definitions of a JSON schema, `undefined` when disabled.
|
|
206
206
|
*/
|
|
207
207
|
export declare function useTypeScriptDefinitions(schema: JsonSchema | undefined, options: Pick<GenerateTypeScriptDefinitionsContext, 'name' | 'readOnly' | 'writeOnly'>): string | undefined;
|
|
208
|
-
/**
|
|
209
|
-
* Create `<OpenAPIPage />` from your own UI, it takes the props of generated pages.
|
|
210
|
-
*/
|
|
211
|
-
export declare function createOpenAPIRenderer(options: CreateOpenAPIRendererOptions): FC<OpenAPIPageProps>;
|
|
212
208
|
/**
|
|
213
209
|
* `createOpenAPIRenderer()` with nothing built in: it highlights through the `shiki` you pass, and
|
|
214
210
|
* generates code usages and TypeScript definitions only when you pass them.
|
|
@@ -9,7 +9,6 @@ import { PlaygroundAuthProvider } from "../playground/auth.js";
|
|
|
9
9
|
import { createContext, use, useMemo } from "react";
|
|
10
10
|
import { getRaw } from "@scalar/json-magic/magic-proxy";
|
|
11
11
|
import { generate } from "@fumari/json-schema-ts";
|
|
12
|
-
import { defaultShikiFactory } from "fumadocs-core/highlight/shiki/full";
|
|
13
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
13
|
//#region src/utils/create-page.tsx
|
|
15
14
|
const OpenAPIContext = createContext(null);
|
|
@@ -129,12 +128,11 @@ const defaultTypeScriptDefinitions = (schema, ctx) => {
|
|
|
129
128
|
}
|
|
130
129
|
};
|
|
131
130
|
/**
|
|
132
|
-
*
|
|
131
|
+
* `createOpenAPIRenderer()` without the full Shiki bundle.
|
|
133
132
|
*/
|
|
134
|
-
function
|
|
133
|
+
function createRenderer(options) {
|
|
135
134
|
return createOpenAPIBaseRenderer({
|
|
136
135
|
...options,
|
|
137
|
-
shiki: options.shiki ?? defaultShikiFactory,
|
|
138
136
|
codeUsages: options.codeUsages ?? (defaultCodeUsages ??= registerDefault(createCodeUsageGeneratorRegistry())),
|
|
139
137
|
generateTypeScriptDefinitions: options.generateTypeScriptDefinitions ?? defaultTypeScriptDefinitions
|
|
140
138
|
});
|
|
@@ -220,4 +218,4 @@ function DefaultLayout({ operations, webhooks }) {
|
|
|
220
218
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [operations?.map((item) => item.children), webhooks?.map((item) => item.children)] });
|
|
221
219
|
}
|
|
222
220
|
//#endregion
|
|
223
|
-
export { createOpenAPIBaseRenderer,
|
|
221
|
+
export { createOpenAPIBaseRenderer, createRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions };
|