fumadocs-openapi 10.9.1 → 10.10.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/css/generated/shared.css +60 -41
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +1 -1
- package/dist/scalar/client.js +1 -4
- package/dist/types.d.ts +1 -4
- package/dist/ui/base.d.ts +1 -0
- package/dist/ui/base.js +1 -17
- package/dist/ui/components/accordion.js +36 -11
- package/dist/ui/components/dialog.js +29 -32
- package/dist/ui/components/heading.js +14 -0
- package/dist/ui/components/select-tab.js +24 -9
- package/dist/ui/create-client.js +0 -17
- package/dist/ui/operation/client.js +1 -1
- package/dist/ui/operation/index.js +145 -141
- package/dist/ui/schema/client.js +339 -289
- package/dist/utils/auto-anchor.client.js +20 -0
- package/dist/utils/auto-anchor.js +17 -0
- package/dist/utils/merge-refs.js +11 -0
- package/package.json +6 -6
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useTranslations } from "../client/i18n.js";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import * as React from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { X } from "lucide-react";
|
|
7
6
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
@@ -10,13 +9,14 @@ import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
|
10
9
|
const Dialog = DialogPrimitive.Root;
|
|
11
10
|
const DialogTrigger = DialogPrimitive.Trigger;
|
|
12
11
|
const DialogPortal = DialogPrimitive.Portal;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
function DialogOverlay({ className, ref, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Overlay, {
|
|
14
|
+
ref,
|
|
15
|
+
className: cn("fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out", className),
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function DialogContent({ className, children, ref, ...props }) {
|
|
20
20
|
const t = useTranslations();
|
|
21
21
|
return /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogOverlay, {}), /* @__PURE__ */ jsxs(DialogPrimitive.Content, {
|
|
22
22
|
ref,
|
|
@@ -31,29 +31,26 @@ const DialogContent = React.forwardRef(({ className, children, ...props }, ref)
|
|
|
31
31
|
children: /* @__PURE__ */ jsx(X, {})
|
|
32
32
|
})]
|
|
33
33
|
})] });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
...props
|
|
56
|
-
}));
|
|
57
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
34
|
+
}
|
|
35
|
+
function DialogHeader({ className, ...props }) {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: cn("flex flex-col gap-1.5 text-center sm:text-start", className),
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function DialogTitle({ className, ref, ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Title, {
|
|
43
|
+
ref,
|
|
44
|
+
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
45
|
+
...props
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function DialogDescription({ className, ref, ...props }) {
|
|
49
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Description, {
|
|
50
|
+
ref,
|
|
51
|
+
className: cn("text-sm text-fd-muted-foreground", className),
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
58
55
|
//#endregion
|
|
59
56
|
export { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useAnchorId } from "../../utils/auto-anchor.client.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Heading } from "fumadocs-ui/components/heading";
|
|
5
|
+
//#region src/ui/components/heading.tsx
|
|
6
|
+
function Heading$1({ id: _id, depth, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(Heading, {
|
|
8
|
+
id: useAnchorId([_id]),
|
|
9
|
+
as: `h${depth}`,
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Heading$1 as Heading };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../utils/cn.js";
|
|
3
3
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
4
|
-
import {
|
|
4
|
+
import { anchorIdStartsWith } from "../../utils/auto-anchor.js";
|
|
5
|
+
import { AnchorSection, useAnchorId } from "../../utils/auto-anchor.client.js";
|
|
6
|
+
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
8
|
//#region src/ui/components/select-tab.tsx
|
|
7
9
|
const Context = createContext(null);
|
|
@@ -15,14 +17,24 @@ function SelectTabs({ defaultValue, children }) {
|
|
|
15
17
|
children
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
|
-
function SelectTab({ value, ...props }) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
20
|
+
function SelectTab({ value, anchorSegments, ...props }) {
|
|
21
|
+
const { value: currentValue, setValue } = use(Context);
|
|
22
|
+
const id = useAnchorId(anchorSegments ?? false);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (id && anchorIdStartsWith(window.location.hash.slice(1), id)) setValue(value);
|
|
25
|
+
}, [
|
|
26
|
+
id,
|
|
27
|
+
value,
|
|
28
|
+
setValue
|
|
29
|
+
]);
|
|
30
|
+
if (value !== currentValue) return;
|
|
31
|
+
const content = /* @__PURE__ */ jsx("div", { ...props });
|
|
32
|
+
return anchorSegments ? /* @__PURE__ */ jsx(AnchorSection, {
|
|
33
|
+
segments: anchorSegments,
|
|
34
|
+
children: content
|
|
35
|
+
}) : content;
|
|
24
36
|
}
|
|
25
|
-
function SelectTabTrigger({ items, className, ...props }) {
|
|
37
|
+
function SelectTabTrigger({ items, className, placeholder, ...props }) {
|
|
26
38
|
const { value, setValue } = use(Context);
|
|
27
39
|
return /* @__PURE__ */ jsxs(Select, {
|
|
28
40
|
value: value ?? "",
|
|
@@ -30,7 +42,10 @@ function SelectTabTrigger({ items, className, ...props }) {
|
|
|
30
42
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
31
43
|
className: cn("not-prose w-fit min-w-0 *:min-w-0", className),
|
|
32
44
|
...props,
|
|
33
|
-
children: /* @__PURE__ */ jsx(SelectValue, {
|
|
45
|
+
children: /* @__PURE__ */ jsx(SelectValue, {
|
|
46
|
+
placeholder,
|
|
47
|
+
children: value && items.find((item) => item.value === value)?.label
|
|
48
|
+
})
|
|
34
49
|
}), /* @__PURE__ */ jsx(SelectContent, { children: items.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, {
|
|
35
50
|
value,
|
|
36
51
|
children: label
|
package/dist/ui/create-client.js
CHANGED
|
@@ -5,11 +5,9 @@ import { AuthProvider } from "../playground/auth.js";
|
|
|
5
5
|
import { dereferenceDocument } from "../utils/document/dereference.js";
|
|
6
6
|
import { APIPage } from "./api-page.js";
|
|
7
7
|
import { boundary_exports } from "./client/boundary.js";
|
|
8
|
-
import { slug } from "github-slugger";
|
|
9
8
|
import { Children, useMemo } from "react";
|
|
10
9
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
11
10
|
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
import { Heading } from "fumadocs-ui/components/heading";
|
|
13
11
|
import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
|
|
14
12
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
15
13
|
import { remark } from "remark";
|
|
@@ -90,21 +88,6 @@ function createClientAPIPage({ shiki = defaultShikiFactory, shikiOptions = { the
|
|
|
90
88
|
provider: options.playground?.provider ?? renderPlaygroundProviderDefault,
|
|
91
89
|
render: options.playground?.render ?? renderPlaygroundDefault
|
|
92
90
|
},
|
|
93
|
-
renderHeading(depth, text, props) {
|
|
94
|
-
const id = typeof text === "string" ? slug(text) : props?.id;
|
|
95
|
-
if (!id) throw new Error("missing 'id' for non-string children");
|
|
96
|
-
if (options.renderHeading) return options.renderHeading({
|
|
97
|
-
id,
|
|
98
|
-
children: text,
|
|
99
|
-
...props
|
|
100
|
-
}, depth);
|
|
101
|
-
return /* @__PURE__ */ jsx(Heading, {
|
|
102
|
-
id,
|
|
103
|
-
as: `h${depth}`,
|
|
104
|
-
...props,
|
|
105
|
-
children: text
|
|
106
|
-
}, id);
|
|
107
|
-
},
|
|
108
91
|
renderMarkdown(text) {
|
|
109
92
|
if (options.renderMarkdown) return options.renderMarkdown(text);
|
|
110
93
|
processor ??= createMarkdownProcessor();
|
|
@@ -56,7 +56,7 @@ function CopyTypeScriptPanel({ name, code, className }) {
|
|
|
56
56
|
const t = useTranslations();
|
|
57
57
|
const useTypeText = t.useTypeInTypeScript.replace("{name}", name);
|
|
58
58
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
|
-
className: cn("flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose
|
|
59
|
+
className: cn("flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose", className),
|
|
60
60
|
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
61
61
|
className: "font-medium text-sm mb-2",
|
|
62
62
|
children: t.typeScriptDefinitions
|
|
@@ -7,11 +7,13 @@ import { cn } from "../../utils/cn.js";
|
|
|
7
7
|
import { Badge, MethodLabel } from "../components/method-label.js";
|
|
8
8
|
import { CopyTypeScriptPanel, OperationProvider } from "./client.js";
|
|
9
9
|
import { Schema } from "../schema/index.js";
|
|
10
|
+
import { AnchorSection } from "../../utils/auto-anchor.client.js";
|
|
10
11
|
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../components/accordion.js";
|
|
11
12
|
import { UsageTabs } from "./usage-tabs/index.js";
|
|
12
13
|
import { RequestTabs } from "./request-tabs.js";
|
|
13
14
|
import { getExampleRequests } from "./get-example-requests.js";
|
|
14
15
|
import { SelectTab, SelectTabTrigger, SelectTabs } from "../components/select-tab.js";
|
|
16
|
+
import { Heading } from "../components/heading.js";
|
|
15
17
|
import { Fragment, use, useMemo } from "react";
|
|
16
18
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
19
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
@@ -40,7 +42,12 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
40
42
|
const title = method.summary || (method.operationId ? idToTitle(method.operationId) : path);
|
|
41
43
|
headNode = /* @__PURE__ */ jsxs("div", {
|
|
42
44
|
className: "flex gap-2 items-center justify-between",
|
|
43
|
-
children: [
|
|
45
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
46
|
+
id: title,
|
|
47
|
+
depth: headingLevel,
|
|
48
|
+
className: "my-0!",
|
|
49
|
+
children: title
|
|
50
|
+
}), method.deprecated && /* @__PURE__ */ jsx(Badge, {
|
|
44
51
|
color: "yellow",
|
|
45
52
|
className: "text-xs not-prose",
|
|
46
53
|
children: /* @__PURE__ */ jsx(I18nLabel, { label: "deprecated" })
|
|
@@ -53,22 +60,24 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
53
60
|
className: "mt-0!"
|
|
54
61
|
});
|
|
55
62
|
const contentTypes = body?.content ? Object.entries(body.content) : null;
|
|
56
|
-
if (
|
|
57
|
-
const items = contentTypes.map(([
|
|
63
|
+
if (contentTypes && contentTypes.length > 0) {
|
|
64
|
+
const items = contentTypes.map(([type]) => ({
|
|
58
65
|
label: /* @__PURE__ */ jsx("code", {
|
|
59
66
|
className: "text-xs",
|
|
60
|
-
children:
|
|
67
|
+
children: type
|
|
61
68
|
}),
|
|
62
|
-
value:
|
|
69
|
+
value: type
|
|
63
70
|
}));
|
|
64
71
|
bodyNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
65
72
|
defaultValue: items[0].value,
|
|
66
73
|
children: [
|
|
67
74
|
/* @__PURE__ */ jsxs("div", {
|
|
68
75
|
className: "flex gap-2 items-center justify-between mt-10",
|
|
69
|
-
children: [
|
|
76
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
70
77
|
id: "request-body",
|
|
71
|
-
|
|
78
|
+
depth: headingLevel,
|
|
79
|
+
className: "my-0!",
|
|
80
|
+
children: /* @__PURE__ */ jsx(I18nLabel, { label: "titleRequestBody" })
|
|
72
81
|
}), contentTypes.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, {
|
|
73
82
|
items,
|
|
74
83
|
className: "font-medium"
|
|
@@ -81,6 +90,7 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
81
90
|
contentTypes.map(([type, content]) => {
|
|
82
91
|
if (!isMediaTypeSupported(type, ctx.mediaAdapters)) throw new Error(`Media type ${type} is not supported (in ${path})`);
|
|
83
92
|
return /* @__PURE__ */ jsx(SelectTab, {
|
|
93
|
+
anchorSegments: ["request-body", type],
|
|
84
94
|
value: type,
|
|
85
95
|
children: /* @__PURE__ */ jsx(RequestBodyContentItem, {
|
|
86
96
|
content,
|
|
@@ -94,7 +104,11 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
94
104
|
}
|
|
95
105
|
if (method.responses && ctx.showResponseSchema !== false) {
|
|
96
106
|
const statuses = Object.keys(method.responses);
|
|
97
|
-
responseNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
107
|
+
responseNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Heading, {
|
|
108
|
+
id: "response-body",
|
|
109
|
+
depth: headingLevel,
|
|
110
|
+
children: /* @__PURE__ */ jsx(I18nLabel, { label: "titleResponseBody" })
|
|
111
|
+
}), /* @__PURE__ */ jsx(Accordions, {
|
|
98
112
|
type: "multiple",
|
|
99
113
|
children: statuses.map((status) => /* @__PURE__ */ jsx(ResponseAccordion, {
|
|
100
114
|
status,
|
|
@@ -106,22 +120,29 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
106
120
|
const parameterNode = paramTypeKeys.map((type) => {
|
|
107
121
|
const params = method.parameters?.filter((param) => param.in === type);
|
|
108
122
|
if (!params || params.length === 0) return;
|
|
109
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Heading, {
|
|
124
|
+
id: `parameters-${type}`,
|
|
125
|
+
depth: headingLevel,
|
|
126
|
+
children: /* @__PURE__ */ jsx(I18nLabel, { label: `${type}Parameters` })
|
|
127
|
+
}), /* @__PURE__ */ jsx(AnchorSection, {
|
|
128
|
+
segments: ["parameters", type],
|
|
129
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
130
|
+
className: "flex flex-col",
|
|
131
|
+
children: params.map((param) => param.schema != null && /* @__PURE__ */ jsx(Schema, {
|
|
132
|
+
client: {
|
|
133
|
+
name: param.name,
|
|
134
|
+
required: param.required
|
|
135
|
+
},
|
|
136
|
+
root: typeof param.schema === "object" ? {
|
|
137
|
+
...param.schema,
|
|
138
|
+
description: param.description ?? param.schema?.description,
|
|
139
|
+
deprecated: (param.deprecated ?? false) || (param.schema?.deprecated ?? false)
|
|
140
|
+
} : param.schema,
|
|
141
|
+
readOnly: method.method === "get",
|
|
142
|
+
writeOnly: method.method !== "get",
|
|
143
|
+
ctx
|
|
144
|
+
}, param.name))
|
|
145
|
+
})
|
|
125
146
|
})] }, type);
|
|
126
147
|
});
|
|
127
148
|
const securities = (method.security ?? dereferenced.security ?? []).filter((v) => Object.keys(v).length > 0);
|
|
@@ -153,9 +174,11 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
153
174
|
defaultValue: items[0].value,
|
|
154
175
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
155
176
|
className: "flex items-start justify-between gap-2 mt-10",
|
|
156
|
-
children: [
|
|
177
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
157
178
|
id: "authorization",
|
|
158
|
-
|
|
179
|
+
depth: headingLevel,
|
|
180
|
+
className: "my-0!",
|
|
181
|
+
children: /* @__PURE__ */ jsx(I18nLabel, { label: "authorization" })
|
|
159
182
|
}), items.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, { items }) : /* @__PURE__ */ jsx("div", {
|
|
160
183
|
className: "not-prose",
|
|
161
184
|
children: items[0].label
|
|
@@ -174,39 +197,55 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
174
197
|
}, i))]
|
|
175
198
|
});
|
|
176
199
|
}
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
callbacksNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
187
|
-
defaultValue: items[0].value,
|
|
188
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
189
|
-
className: "flex justify-between gap-2 items-end mt-10",
|
|
190
|
-
children: [ctx.renderHeading(headingLevel, /* @__PURE__ */ jsx(I18nLabel, { label: "titleCallbacks" }), {
|
|
191
|
-
id: "callbacks",
|
|
192
|
-
className: "my-0!"
|
|
193
|
-
}), callbacks.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, {
|
|
194
|
-
items,
|
|
195
|
-
className: "font-medium"
|
|
196
|
-
}) : /* @__PURE__ */ jsx("p", {
|
|
197
|
-
className: "text-fd-muted-foreground not-prose",
|
|
198
|
-
children: items[0].label
|
|
199
|
-
})]
|
|
200
|
-
}), callbacks.map(([name, callback]) => /* @__PURE__ */ jsx(SelectTab, {
|
|
201
|
-
value: name,
|
|
202
|
-
children: /* @__PURE__ */ jsx(WebhookCallback, {
|
|
203
|
-
callback,
|
|
204
|
-
ctx,
|
|
205
|
-
headingLevel
|
|
206
|
-
})
|
|
207
|
-
}, name))]
|
|
200
|
+
const webhookCallbacks = [];
|
|
201
|
+
for (const [name, callbacks] of Object.entries(method.callbacks ?? {})) for (const [path, callback] of Object.entries(callbacks)) for (const method of methodKeys) {
|
|
202
|
+
if (!callback[method]) continue;
|
|
203
|
+
webhookCallbacks.push({
|
|
204
|
+
name,
|
|
205
|
+
path,
|
|
206
|
+
method,
|
|
207
|
+
callback,
|
|
208
|
+
operation: callback[method]
|
|
208
209
|
});
|
|
209
210
|
}
|
|
211
|
+
if (webhookCallbacks.length > 0) callbacksNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Heading, {
|
|
212
|
+
id: "callbacks",
|
|
213
|
+
depth: headingLevel,
|
|
214
|
+
children: /* @__PURE__ */ jsx(I18nLabel, { label: "titleCallbacks" })
|
|
215
|
+
}), /* @__PURE__ */ jsx(Accordions, {
|
|
216
|
+
type: "multiple",
|
|
217
|
+
children: webhookCallbacks.map((item, i) => /* @__PURE__ */ jsxs(AccordionItem, {
|
|
218
|
+
value: `${item.name}\0${item.path}\0${item.method}`,
|
|
219
|
+
anchorSegments: [
|
|
220
|
+
"callbacks",
|
|
221
|
+
item.name,
|
|
222
|
+
item.path,
|
|
223
|
+
item.method
|
|
224
|
+
],
|
|
225
|
+
children: [/* @__PURE__ */ jsxs(AccordionHeader, {
|
|
226
|
+
className: "flex-col gap-3",
|
|
227
|
+
children: [/* @__PURE__ */ jsx(AccordionTrigger, {
|
|
228
|
+
className: "font-mono",
|
|
229
|
+
children: item.name
|
|
230
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
231
|
+
className: "flex items-center gap-2 text-xs ps-4.5",
|
|
232
|
+
children: [/* @__PURE__ */ jsx(MethodLabel, { children: item.method }), /* @__PURE__ */ jsx("code", {
|
|
233
|
+
className: "text-fd-muted-foreground",
|
|
234
|
+
children: item.path
|
|
235
|
+
})]
|
|
236
|
+
})]
|
|
237
|
+
}), /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsx("div", {
|
|
238
|
+
className: "border p-3 ps-4.5 mb-2 @container prose-no-margin rounded-xl",
|
|
239
|
+
children: /* @__PURE__ */ jsx(Operation, {
|
|
240
|
+
type: "webhook",
|
|
241
|
+
path,
|
|
242
|
+
headingLevel: headingLevel + 1,
|
|
243
|
+
method: createMethod(item.method, item.callback, item.operation),
|
|
244
|
+
ctx
|
|
245
|
+
})
|
|
246
|
+
}) })]
|
|
247
|
+
}, i))
|
|
248
|
+
})] });
|
|
210
249
|
let { renderOperationLayout, renderWebhookLayout } = ctx.content ?? {};
|
|
211
250
|
if (type === "operation") {
|
|
212
251
|
renderOperationLayout ??= (slots) => {
|
|
@@ -273,7 +312,7 @@ function Operation({ type = "operation", path, method, ctx, showTitle, showDescr
|
|
|
273
312
|
renderWebhookLayout ??= (slots) => /* @__PURE__ */ jsxs("div", {
|
|
274
313
|
className: "flex flex-col-reverse gap-x-6 gap-y-4 @4xl:flex-row @4xl:items-start",
|
|
275
314
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
276
|
-
className: "min-w-0 flex-1",
|
|
315
|
+
className: "min-w-0 flex-1 prose-no-margin",
|
|
277
316
|
children: [
|
|
278
317
|
slots.header,
|
|
279
318
|
slots.description,
|
|
@@ -323,7 +362,7 @@ function RequestBodyContentItem({ content, method, ctx }) {
|
|
|
323
362
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [ts && /* @__PURE__ */ jsx(CopyTypeScriptPanel, {
|
|
324
363
|
name: "request body",
|
|
325
364
|
code: ts,
|
|
326
|
-
className: "
|
|
365
|
+
className: "my-4 last:mb-0"
|
|
327
366
|
}), content.schema && /* @__PURE__ */ jsx(Schema, {
|
|
328
367
|
client: {
|
|
329
368
|
name: "body",
|
|
@@ -339,48 +378,44 @@ function RequestBodyContentItem({ content, method, ctx }) {
|
|
|
339
378
|
function ResponseAccordion({ status, operation, ctx }) {
|
|
340
379
|
const response = operation.responses[status];
|
|
341
380
|
const contentTypes = response.content ? Object.entries(response.content) : [];
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
children: key
|
|
349
|
-
}),
|
|
350
|
-
value: key
|
|
351
|
-
}));
|
|
352
|
-
selectorNode = items.length === 1 ? /* @__PURE__ */ jsx("p", {
|
|
353
|
-
className: "text-fd-muted-foreground not-prose",
|
|
354
|
-
children: items[0].label
|
|
355
|
-
}) : /* @__PURE__ */ jsx(SelectTabTrigger, { items });
|
|
356
|
-
wrapper = (children) => /* @__PURE__ */ jsx(SelectTabs, {
|
|
357
|
-
defaultValue: items[0].value,
|
|
358
|
-
children
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
return wrapper(/* @__PURE__ */ jsxs(AccordionItem, {
|
|
362
|
-
value: status,
|
|
363
|
-
children: [/* @__PURE__ */ jsxs(AccordionHeader, { children: [/* @__PURE__ */ jsx(AccordionTrigger, {
|
|
364
|
-
className: "font-mono",
|
|
365
|
-
children: status
|
|
366
|
-
}), selectorNode] }), /* @__PURE__ */ jsxs(AccordionContent, {
|
|
367
|
-
className: "ps-4.5",
|
|
368
|
-
children: [response.description && /* @__PURE__ */ jsx("div", {
|
|
369
|
-
className: "prose-no-margin mb-2",
|
|
370
|
-
children: ctx.renderMarkdown(response.description)
|
|
371
|
-
}), contentTypes.map(([type, item]) => /* @__PURE__ */ jsx(SelectTab, {
|
|
372
|
-
value: type,
|
|
373
|
-
className: "mb-2",
|
|
374
|
-
children: /* @__PURE__ */ jsx(RepsonseAccordionItem, {
|
|
375
|
-
type,
|
|
376
|
-
status,
|
|
377
|
-
item,
|
|
378
|
-
operation,
|
|
379
|
-
ctx
|
|
380
|
-
})
|
|
381
|
-
}, type))]
|
|
382
|
-
})]
|
|
381
|
+
const items = contentTypes.map(([key]) => ({
|
|
382
|
+
label: /* @__PURE__ */ jsx("code", {
|
|
383
|
+
className: "text-xs",
|
|
384
|
+
children: key
|
|
385
|
+
}),
|
|
386
|
+
value: key
|
|
383
387
|
}));
|
|
388
|
+
return /* @__PURE__ */ jsx(AccordionItem, {
|
|
389
|
+
value: status,
|
|
390
|
+
anchorSegments: ["response", status],
|
|
391
|
+
className: "data-[state=open]:border-b-0",
|
|
392
|
+
children: /* @__PURE__ */ jsxs(SelectTabs, {
|
|
393
|
+
defaultValue: items[0]?.value,
|
|
394
|
+
children: [/* @__PURE__ */ jsxs(AccordionHeader, { children: [/* @__PURE__ */ jsx(AccordionTrigger, {
|
|
395
|
+
className: "font-mono",
|
|
396
|
+
children: status
|
|
397
|
+
}), items.length === 1 ? /* @__PURE__ */ jsx("p", {
|
|
398
|
+
className: "text-fd-muted-foreground not-prose",
|
|
399
|
+
children: items[0].label
|
|
400
|
+
}) : items.length > 0 && /* @__PURE__ */ jsx(SelectTabTrigger, { items })] }), /* @__PURE__ */ jsxs(AccordionContent, {
|
|
401
|
+
className: "ps-4.5 pe-3 border rounded-xl",
|
|
402
|
+
children: [response.description && /* @__PURE__ */ jsx("div", {
|
|
403
|
+
className: "prose-no-margin mt-3 mb-2",
|
|
404
|
+
children: ctx.renderMarkdown(response.description)
|
|
405
|
+
}), contentTypes.map(([type, item]) => /* @__PURE__ */ jsx(SelectTab, {
|
|
406
|
+
value: type,
|
|
407
|
+
anchorSegments: [type],
|
|
408
|
+
children: /* @__PURE__ */ jsx(RepsonseAccordionItem, {
|
|
409
|
+
type,
|
|
410
|
+
status,
|
|
411
|
+
item,
|
|
412
|
+
operation,
|
|
413
|
+
ctx
|
|
414
|
+
})
|
|
415
|
+
}, type))]
|
|
416
|
+
})]
|
|
417
|
+
})
|
|
418
|
+
});
|
|
384
419
|
}
|
|
385
420
|
function RepsonseAccordionItem({ type, status, operation, item: { schema }, ctx }) {
|
|
386
421
|
let ts = useMemo(() => {
|
|
@@ -405,49 +440,18 @@ function RepsonseAccordionItem({ type, status, operation, item: { schema }, ctx
|
|
|
405
440
|
if (ts instanceof Promise) ts = use(ts);
|
|
406
441
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [ts && /* @__PURE__ */ jsx(CopyTypeScriptPanel, {
|
|
407
442
|
name: "response body",
|
|
408
|
-
code: ts
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
ctx
|
|
419
|
-
})
|
|
443
|
+
code: ts,
|
|
444
|
+
className: "mb-2"
|
|
445
|
+
}), schema && /* @__PURE__ */ jsx(Schema, {
|
|
446
|
+
client: {
|
|
447
|
+
name: "response",
|
|
448
|
+
as: "body"
|
|
449
|
+
},
|
|
450
|
+
root: schema,
|
|
451
|
+
readOnly: true,
|
|
452
|
+
ctx
|
|
420
453
|
})] });
|
|
421
454
|
}
|
|
422
|
-
function WebhookCallback({ callback, ctx, headingLevel }) {
|
|
423
|
-
return /* @__PURE__ */ jsx(Accordions, {
|
|
424
|
-
type: "single",
|
|
425
|
-
collapsible: true,
|
|
426
|
-
children: Object.entries(callback).map(([path, pathItem]) => {
|
|
427
|
-
const pathNodes = methodKeys.map((method) => {
|
|
428
|
-
const operation = pathItem[method];
|
|
429
|
-
if (!operation) return null;
|
|
430
|
-
return /* @__PURE__ */ jsx("div", {
|
|
431
|
-
className: "border p-3 my-2 @container prose-no-margin rounded-lg",
|
|
432
|
-
children: /* @__PURE__ */ jsx(Operation, {
|
|
433
|
-
type: "webhook",
|
|
434
|
-
path,
|
|
435
|
-
headingLevel: headingLevel + 1,
|
|
436
|
-
method: createMethod(method, pathItem, operation),
|
|
437
|
-
ctx
|
|
438
|
-
})
|
|
439
|
-
}, method);
|
|
440
|
-
});
|
|
441
|
-
return /* @__PURE__ */ jsxs(AccordionItem, {
|
|
442
|
-
value: path,
|
|
443
|
-
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, {
|
|
444
|
-
className: "font-mono",
|
|
445
|
-
children: path
|
|
446
|
-
}) }), /* @__PURE__ */ jsx(AccordionContent, { children: pathNodes })]
|
|
447
|
-
}, path);
|
|
448
|
-
})
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
455
|
function AuthScheme({ scheme, scopes, ctx }) {
|
|
452
456
|
if (scheme.type === "http" || scheme.type === "oauth2") return /* @__PURE__ */ jsxs(AuthProperty, {
|
|
453
457
|
name: /* @__PURE__ */ jsx(I18nLabel, { label: "authorization" }),
|