fumadocs-openapi 12.1.1 → 12.3.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 +1 -1
- package/dist/.translations/index.d.ts +63 -20
- package/dist/.translations/keys.js +63 -20
- package/dist/operation.d.ts +6 -1
- package/dist/operation.js +2 -4
- package/dist/packages/shared-api/dist/.translations/index.d.ts +1 -0
- package/dist/packages/shared-api/dist/.translations/keys.js +1 -0
- package/dist/packages/shared-api/dist/auto-anchor/index.js +54 -10
- package/dist/packages/shared-api/dist/components/accordion.js +3 -11
- package/dist/packages/shared-api/dist/components/collapsible.js +2 -2
- package/dist/packages/shared-api/dist/components/schema/client.d.ts +5 -0
- package/dist/packages/shared-api/dist/components/schema/client.js +408 -455
- package/dist/packages/shared-api/dist/components/select-tab.js +7 -12
- package/dist/packages/shared-api/dist/components/select.js +8 -7
- package/dist/playground/auth.d.ts +5 -1
- package/dist/playground/auth.js +7 -2
- package/dist/playground/fetcher.d.ts +8 -0
- package/dist/playground/fetcher.js +30 -1
- package/dist/playground/index.d.ts +2 -1
- package/dist/playground/index.js +2 -1
- package/dist/playground/use-playground.d.ts +62 -0
- package/dist/playground/use-playground.js +140 -0
- package/dist/ui/components/dialog.js +14 -0
- package/dist/ui/components/endpoint.js +40 -0
- package/dist/ui/components/heading.js +1 -1
- package/dist/ui/components/schema.js +1 -1
- package/dist/ui/components/segmented.js +21 -0
- package/dist/ui/operation/index.js +267 -250
- package/dist/ui/playground/client.d.ts +9 -26
- package/dist/ui/playground/client.js +150 -389
- package/dist/ui/playground/components/fields.js +693 -0
- package/dist/ui/playground/components/oauth-panel.js +182 -0
- package/dist/ui/playground/components/request-panel.js +480 -0
- package/dist/ui/playground/components/response-panel.js +150 -0
- package/dist/ui/playground/components/result-display.d.ts +1 -0
- package/dist/ui/playground/components/result-display.js +185 -168
- package/dist/ui/playground/components/server-select.js +100 -89
- package/dist/ui/playground/components/url-bar.js +96 -0
- package/dist/ui/playground/status-info.js +32 -45
- package/dist/utils/document/load.js +1 -1
- package/package.json +12 -12
- package/dist/packages/shared-api/dist/auto-anchor/client.js +0 -20
- package/dist/packages/shared-api/dist/components/collapsible.d.ts +0 -7
- package/dist/packages/shared-api/dist/components/dialog.js +0 -55
- package/dist/packages/shared-api/dist/components/input.js +0 -14
- package/dist/packages/shared-api/dist/components/label.js +0 -11
- package/dist/packages/shared-api/dist/components/playground/inputs.js +0 -439
- package/dist/packages/shared-api/dist/components/popover.js +0 -23
- package/dist/packages/shared-api/dist/utils/merge-refs.js +0 -11
- package/dist/ui/playground/components/oauth-dialog.js +0 -259
|
@@ -3,8 +3,7 @@ import { useOpenAPI, useRenderContext, useTypeScriptDefinitions } from "../../ut
|
|
|
3
3
|
import { OperationProvider, useOperation } from "../../operation.js";
|
|
4
4
|
import { Badge } from "../../packages/shared-api/dist/components/badge.js";
|
|
5
5
|
import { MethodLabel } from "../components/method-label.js";
|
|
6
|
-
import { AnchorSection } from "../../packages/shared-api/dist/auto-anchor/
|
|
7
|
-
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../../packages/shared-api/dist/components/accordion.js";
|
|
6
|
+
import { AnchorSection, useAnchorLink } from "../../packages/shared-api/dist/auto-anchor/index.js";
|
|
8
7
|
import { Markdown } from "../components/markdown.js";
|
|
9
8
|
import { UsageTabs } from "./usage-tabs.js";
|
|
10
9
|
import { SchemaUI } from "../components/schema.js";
|
|
@@ -12,13 +11,17 @@ import { RequestTabs } from "./request-tabs.js";
|
|
|
12
11
|
import { cn } from "../../utils/cn.js";
|
|
13
12
|
import { SelectTab, SelectTabTrigger, SelectTabs } from "../../packages/shared-api/dist/components/select-tab.js";
|
|
14
13
|
import { Heading } from "../components/heading.js";
|
|
14
|
+
import { Segmented, SegmentedList, SegmentedPanel } from "../components/segmented.js";
|
|
15
|
+
import { EndpointBar } from "../components/endpoint.js";
|
|
16
|
+
import { DialogPopup } from "../components/dialog.js";
|
|
15
17
|
import PlaygroundClient from "../playground/client.js";
|
|
16
|
-
import { Fragment } from "react";
|
|
18
|
+
import { Fragment, useState } from "react";
|
|
17
19
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
18
20
|
import { useTranslations } from "@fuma-translate/react";
|
|
19
|
-
import { Check, Copy } from "lucide-react";
|
|
21
|
+
import { Check, ChevronRight, Copy, Plus, X } from "lucide-react";
|
|
20
22
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
21
23
|
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
24
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
22
25
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
23
26
|
//#region src/ui/operation/index.tsx
|
|
24
27
|
function Operation({ type, path, method, operation, pathItem, ...props }) {
|
|
@@ -65,61 +68,48 @@ function OperationContent({ showTitle, showDescription, headingLevel = 2 }) {
|
|
|
65
68
|
if (requestBody) {
|
|
66
69
|
const contentTypes = Object.entries(requestBody.content);
|
|
67
70
|
const items = contentTypes.map(([mediaType]) => ({
|
|
68
|
-
label: /* @__PURE__ */ jsx("code", {
|
|
69
|
-
className: "text-xs",
|
|
70
|
-
children: mediaType
|
|
71
|
-
}),
|
|
71
|
+
label: /* @__PURE__ */ jsx("code", { children: mediaType }),
|
|
72
72
|
value: mediaType
|
|
73
73
|
}));
|
|
74
74
|
bodyNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
75
75
|
defaultValue: items[0].value,
|
|
76
76
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
items,
|
|
86
|
-
className: "font-medium"
|
|
87
|
-
}) : /* @__PURE__ */ jsx("p", {
|
|
88
|
-
className: "text-fd-muted-foreground not-prose",
|
|
89
|
-
children: items[0].label
|
|
90
|
-
})]
|
|
77
|
+
/* @__PURE__ */ jsx(SectionHeader, {
|
|
78
|
+
id: "request-body",
|
|
79
|
+
depth: headingLevel,
|
|
80
|
+
title: t("Request Body")
|
|
81
|
+
}),
|
|
82
|
+
requestBody.description && /* @__PURE__ */ jsx("div", {
|
|
83
|
+
className: "mb-3 prose-no-margin text-fd-muted-foreground",
|
|
84
|
+
children: /* @__PURE__ */ jsx(Markdown, { md: requestBody.description })
|
|
91
85
|
}),
|
|
92
|
-
requestBody.description && /* @__PURE__ */ jsx(Markdown, { md: requestBody.description }),
|
|
93
86
|
contentTypes.map(([mediaType, content]) => /* @__PURE__ */ jsx(SelectTab, {
|
|
94
87
|
anchorSegments: ["request-body", mediaType],
|
|
95
88
|
value: mediaType,
|
|
96
|
-
children: /* @__PURE__ */ jsx(
|
|
97
|
-
content,
|
|
89
|
+
children: /* @__PURE__ */ jsx(MediaContent, {
|
|
90
|
+
schema: content.schema,
|
|
98
91
|
required: requestBody.required,
|
|
99
|
-
|
|
92
|
+
selector: /* @__PURE__ */ jsx(CardSelector, { items }),
|
|
93
|
+
request: true
|
|
100
94
|
})
|
|
101
95
|
}, mediaType))
|
|
102
96
|
]
|
|
103
97
|
});
|
|
104
98
|
}
|
|
105
|
-
if (responses.length > 0 && ctx.showResponseSchema !== false) responseNode = /* @__PURE__ */
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}), /* @__PURE__ */ jsx(Accordions, {
|
|
110
|
-
type: "multiple",
|
|
111
|
-
children: responses.map((item) => /* @__PURE__ */ jsx(ResponseAccordion, { item }, item.status))
|
|
112
|
-
})] });
|
|
99
|
+
if (responses.length > 0 && ctx.showResponseSchema !== false) responseNode = /* @__PURE__ */ jsx(ResponseSection, {
|
|
100
|
+
responses,
|
|
101
|
+
headingLevel
|
|
102
|
+
});
|
|
113
103
|
const parameterNode = parameters.map(({ in: location, items }) => {
|
|
114
104
|
const parameterLabel = location === "path" ? t("Path Parameters") : location === "query" ? t("Query Parameters") : location === "header" ? t("Header Parameters") : t("Cookie Parameters");
|
|
115
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(
|
|
105
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SectionHeader, {
|
|
116
106
|
id: `parameters-${location}`,
|
|
117
107
|
depth: headingLevel,
|
|
118
|
-
|
|
108
|
+
title: parameterLabel
|
|
119
109
|
}), /* @__PURE__ */ jsx(AnchorSection, {
|
|
120
110
|
segments: ["parameters", location],
|
|
121
111
|
children: /* @__PURE__ */ jsx("div", {
|
|
122
|
-
className: "
|
|
112
|
+
className: "rounded-xl border bg-fd-card px-3",
|
|
123
113
|
children: items.map((param) => {
|
|
124
114
|
if (param.schema == null) return;
|
|
125
115
|
const schema = resolve(param.schema);
|
|
@@ -141,87 +131,51 @@ function OperationContent({ showTitle, showDescription, headingLevel = 2 }) {
|
|
|
141
131
|
})] }, location);
|
|
142
132
|
});
|
|
143
133
|
if (security.length > 0) {
|
|
144
|
-
const items = security.map((requirement, i) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
scopes.length > 0 && /* @__PURE__ */ jsx("span", {
|
|
158
|
-
className: "text-fd-muted-foreground",
|
|
159
|
-
children: scopes.join(", ")
|
|
160
|
-
})
|
|
161
|
-
]
|
|
162
|
-
}, key))
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
});
|
|
134
|
+
const items = security.map((requirement, i) => ({
|
|
135
|
+
value: String(i),
|
|
136
|
+
label: /* @__PURE__ */ jsx("code", {
|
|
137
|
+
className: "flex min-w-0 items-center gap-1",
|
|
138
|
+
children: requirement.map(({ key, scopes }, j) => /* @__PURE__ */ jsxs(Fragment, { children: [j > 0 && /* @__PURE__ */ jsx(Plus, { className: "size-3 shrink-0 text-fd-muted-foreground" }), /* @__PURE__ */ jsxs("span", {
|
|
139
|
+
className: "truncate",
|
|
140
|
+
children: [key, scopes.length > 0 && /* @__PURE__ */ jsxs("span", {
|
|
141
|
+
className: "text-fd-muted-foreground",
|
|
142
|
+
children: [" ", scopes.join(", ")]
|
|
143
|
+
})]
|
|
144
|
+
})] }, key))
|
|
145
|
+
})
|
|
146
|
+
}));
|
|
166
147
|
authNode = /* @__PURE__ */ jsxs(SelectTabs, {
|
|
167
148
|
defaultValue: items[0].value,
|
|
168
|
-
children: [/* @__PURE__ */
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
},
|
|
185
|
-
}
|
|
149
|
+
children: [/* @__PURE__ */ jsx(SectionHeader, {
|
|
150
|
+
id: "authorization",
|
|
151
|
+
depth: headingLevel,
|
|
152
|
+
title: t("Authorization")
|
|
153
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
154
|
+
className: "overflow-hidden rounded-xl border bg-fd-card",
|
|
155
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
156
|
+
className: "flex h-9 items-center border-b ps-1.5 pe-1 text-[0.8125rem] not-prose",
|
|
157
|
+
children: /* @__PURE__ */ jsx(CardSelector, { items })
|
|
158
|
+
}), security.map((requirement, i) => /* @__PURE__ */ jsx(SelectTab, {
|
|
159
|
+
value: items[i].value,
|
|
160
|
+
className: "px-3",
|
|
161
|
+
children: requirement.map(({ key, scopes, scheme }) => scheme && /* @__PURE__ */ jsx(AuthScheme, {
|
|
162
|
+
scheme,
|
|
163
|
+
scopes
|
|
164
|
+
}, key))
|
|
165
|
+
}, i))]
|
|
166
|
+
})]
|
|
186
167
|
});
|
|
187
168
|
}
|
|
188
|
-
if (callbacks.length > 0) callbacksNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(
|
|
169
|
+
if (callbacks.length > 0) callbacksNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionHeader, {
|
|
189
170
|
id: "callbacks",
|
|
190
171
|
depth: headingLevel,
|
|
191
|
-
|
|
192
|
-
}), /* @__PURE__ */ jsx(
|
|
193
|
-
|
|
194
|
-
children: callbacks.map((item, i) => /* @__PURE__ */
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
item.name,
|
|
199
|
-
item.path,
|
|
200
|
-
item.method
|
|
201
|
-
],
|
|
202
|
-
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, {
|
|
203
|
-
className: "gap-3",
|
|
204
|
-
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
205
|
-
className: "font-mono mb-2",
|
|
206
|
-
children: item.name
|
|
207
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
208
|
-
className: "flex items-center gap-2 text-xs",
|
|
209
|
-
children: [/* @__PURE__ */ jsx(MethodLabel, { children: item.method }), /* @__PURE__ */ jsx("code", {
|
|
210
|
-
className: "text-fd-muted-foreground",
|
|
211
|
-
children: item.path
|
|
212
|
-
})]
|
|
213
|
-
})] })
|
|
214
|
-
}) }), /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsx("div", {
|
|
215
|
-
className: "border p-3 mb-2 @container prose-no-margin rounded-2xl",
|
|
216
|
-
children: /* @__PURE__ */ jsx(Operation, {
|
|
217
|
-
type: "webhook",
|
|
218
|
-
path,
|
|
219
|
-
headingLevel: headingLevel + 1,
|
|
220
|
-
method: item.method,
|
|
221
|
-
pathItem: item.pathItem,
|
|
222
|
-
operation: item.operation
|
|
223
|
-
})
|
|
224
|
-
}) })]
|
|
172
|
+
title: t("Callbacks")
|
|
173
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
174
|
+
className: "overflow-hidden rounded-xl border bg-fd-card not-prose",
|
|
175
|
+
children: callbacks.map((item, i) => /* @__PURE__ */ jsx(Callback, {
|
|
176
|
+
item,
|
|
177
|
+
path,
|
|
178
|
+
headingLevel: headingLevel + 1
|
|
225
179
|
}, i))
|
|
226
180
|
})] });
|
|
227
181
|
if (type === "operation") {
|
|
@@ -234,20 +188,11 @@ function OperationContent({ showTitle, showDescription, headingLevel = 2 }) {
|
|
|
234
188
|
method,
|
|
235
189
|
operation,
|
|
236
190
|
pathItem
|
|
237
|
-
}) : /* @__PURE__ */ jsx(PlaygroundClient, {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
} else apiPlayground = /* @__PURE__ */ jsxs("div", {
|
|
243
|
-
className: "flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose",
|
|
244
|
-
children: [/* @__PURE__ */ jsx(MethodLabel, {
|
|
245
|
-
className: "text-xs",
|
|
246
|
-
children: method
|
|
247
|
-
}), /* @__PURE__ */ jsx("code", {
|
|
248
|
-
className: cn("flex-1 overflow-auto text-nowrap text-[0.8125rem] text-fd-muted-foreground", operation.deprecated && "line-through"),
|
|
249
|
-
children: path
|
|
250
|
-
})]
|
|
191
|
+
}) : /* @__PURE__ */ jsx(PlaygroundClient, { ...options });
|
|
192
|
+
} else apiPlayground = /* @__PURE__ */ jsx(EndpointBar, {
|
|
193
|
+
method,
|
|
194
|
+
route: path,
|
|
195
|
+
deprecated: operation.deprecated
|
|
251
196
|
});
|
|
252
197
|
const slots = {
|
|
253
198
|
header: headNode,
|
|
@@ -317,140 +262,164 @@ function OperationContent({ showTitle, showDescription, headingLevel = 2 }) {
|
|
|
317
262
|
})]
|
|
318
263
|
});
|
|
319
264
|
}
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
265
|
+
function SectionHeader({ id, depth, title, children }) {
|
|
266
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
267
|
+
className: "flex flex-wrap items-center gap-2 mt-10 mb-3 first:mt-0",
|
|
268
|
+
children: [/* @__PURE__ */ jsx(Heading, {
|
|
269
|
+
id,
|
|
270
|
+
depth,
|
|
271
|
+
className: "my-0! me-auto",
|
|
272
|
+
children: title
|
|
273
|
+
}), children]
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/** selects the variant shown in a card, like the media type */
|
|
277
|
+
function CardSelector({ items }) {
|
|
278
|
+
if (items.length > 1) return /* @__PURE__ */ jsx(SelectTabTrigger, {
|
|
279
|
+
items,
|
|
280
|
+
className: "h-7 w-auto gap-1 border-0 bg-transparent px-1.5 py-0 text-[0.8125rem] font-medium hover:bg-fd-accent hover:text-fd-accent-foreground focus:ring-0 focus-visible:ring-2 focus-visible:ring-inset data-popup-open:bg-fd-accent"
|
|
281
|
+
});
|
|
282
|
+
return /* @__PURE__ */ jsx("span", {
|
|
283
|
+
className: "min-w-0 px-1.5 font-medium",
|
|
284
|
+
children: items[0].label
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/** the schema of a request body or response in a media type */
|
|
288
|
+
function MediaContent({ schema, required, selector, request = false }) {
|
|
289
|
+
const { method } = useOperation();
|
|
290
|
+
const ts = useTypeScriptDefinitions(schema, {
|
|
291
|
+
name: request ? "RequestBody" : "ResponseBody",
|
|
292
|
+
readOnly: !request,
|
|
293
|
+
writeOnly: request
|
|
325
294
|
});
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
295
|
+
if (!schema) return /* @__PURE__ */ jsx("div", {
|
|
296
|
+
className: "not-prose flex h-9 items-center rounded-xl border bg-fd-card ps-1.5 pe-1 text-[0.8125rem]",
|
|
297
|
+
children: selector
|
|
298
|
+
});
|
|
299
|
+
return /* @__PURE__ */ jsx(SchemaUI, {
|
|
331
300
|
client: {
|
|
332
|
-
name: "body",
|
|
301
|
+
name: request ? "body" : "response",
|
|
333
302
|
as: "body",
|
|
334
|
-
required
|
|
303
|
+
required,
|
|
304
|
+
selector,
|
|
305
|
+
actions: ts && /* @__PURE__ */ jsx(CopyTypeScript, {
|
|
306
|
+
code: ts,
|
|
307
|
+
name: request ? "request body" : "response body"
|
|
308
|
+
})
|
|
335
309
|
},
|
|
336
|
-
root:
|
|
337
|
-
readOnly: method === "get",
|
|
338
|
-
writeOnly: method !== "get"
|
|
339
|
-
})
|
|
310
|
+
root: schema,
|
|
311
|
+
readOnly: !request || method === "get",
|
|
312
|
+
writeOnly: request && method !== "get"
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function CopyTypeScript({ code, name }) {
|
|
316
|
+
const t = useTranslations({ note: "TypeScript definitions" });
|
|
317
|
+
const [isChecked, onCopy] = useCopyButton(() => navigator.clipboard.writeText(code));
|
|
318
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
319
|
+
type: "button",
|
|
320
|
+
title: t("Use the {name} type in TypeScript.", { variables: { name } }),
|
|
321
|
+
onClick: onCopy,
|
|
322
|
+
className: cn(buttonVariants({
|
|
323
|
+
variant: "ghost",
|
|
324
|
+
size: "sm"
|
|
325
|
+
}), "-my-1 shrink-0 gap-1.5 text-fd-muted-foreground [&_svg]:size-3.5"),
|
|
326
|
+
children: [isChecked ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Copy, {}), "TypeScript"]
|
|
327
|
+
});
|
|
340
328
|
}
|
|
341
|
-
function
|
|
329
|
+
function ResponseSection({ responses, headingLevel }) {
|
|
330
|
+
const t = useTranslations({ note: "operation page" });
|
|
331
|
+
const [selected, setSelected] = useState(responses[0].status);
|
|
332
|
+
return /* @__PURE__ */ jsxs(Segmented, {
|
|
333
|
+
value: selected,
|
|
334
|
+
onValueChange: setSelected,
|
|
335
|
+
className: "mt-10 first:mt-0",
|
|
336
|
+
children: [/* @__PURE__ */ jsx(SectionHeader, {
|
|
337
|
+
id: "response-body",
|
|
338
|
+
depth: headingLevel,
|
|
339
|
+
title: t("Response Body"),
|
|
340
|
+
children: /* @__PURE__ */ jsx(SegmentedList, {
|
|
341
|
+
className: "max-w-full overflow-x-auto font-mono [scrollbar-width:none]",
|
|
342
|
+
items: responses.map((item) => ({
|
|
343
|
+
value: item.status,
|
|
344
|
+
label: item.status
|
|
345
|
+
}))
|
|
346
|
+
})
|
|
347
|
+
}), responses.map((item) => /* @__PURE__ */ jsx(ResponseContent, {
|
|
348
|
+
item,
|
|
349
|
+
onLink: () => setSelected(item.status)
|
|
350
|
+
}, item.status))]
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function ResponseContent({ item: { status, response, content }, onLink }) {
|
|
354
|
+
const segments = ["response", status];
|
|
355
|
+
const ref = useAnchorLink(segments, onLink);
|
|
342
356
|
const contentTypes = Object.entries(content);
|
|
343
|
-
const items = contentTypes.map(([
|
|
344
|
-
label: /* @__PURE__ */ jsx("code", {
|
|
345
|
-
|
|
346
|
-
children: key
|
|
347
|
-
}),
|
|
348
|
-
value: key
|
|
357
|
+
const items = contentTypes.map(([mediaType]) => ({
|
|
358
|
+
label: /* @__PURE__ */ jsx("code", { children: mediaType }),
|
|
359
|
+
value: mediaType
|
|
349
360
|
}));
|
|
350
|
-
return /* @__PURE__ */ jsx(
|
|
361
|
+
return /* @__PURE__ */ jsx(SegmentedPanel, {
|
|
351
362
|
value: status,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
className: "font-mono",
|
|
358
|
-
children: status
|
|
359
|
-
}), items.length === 1 ? /* @__PURE__ */ jsx("p", {
|
|
360
|
-
className: "text-fd-muted-foreground not-prose py-2",
|
|
361
|
-
children: items[0].label
|
|
362
|
-
}) : items.length > 0 && /* @__PURE__ */ jsx(SelectTabTrigger, {
|
|
363
|
-
items,
|
|
364
|
-
className: "my-1.5 py-1"
|
|
365
|
-
})] }), /* @__PURE__ */ jsxs(AccordionContent, {
|
|
366
|
-
className: "ps-4.5 pe-3 border rounded-xl",
|
|
363
|
+
ref,
|
|
364
|
+
children: /* @__PURE__ */ jsx(AnchorSection, {
|
|
365
|
+
segments,
|
|
366
|
+
children: /* @__PURE__ */ jsxs(SelectTabs, {
|
|
367
|
+
defaultValue: items[0]?.value,
|
|
367
368
|
children: [response.description && /* @__PURE__ */ jsx("div", {
|
|
368
|
-
className: "prose-no-margin
|
|
369
|
+
className: "mb-3 prose-no-margin text-fd-muted-foreground",
|
|
369
370
|
children: /* @__PURE__ */ jsx(Markdown, { md: response.description })
|
|
370
371
|
}), contentTypes.map(([mediaType, media]) => /* @__PURE__ */ jsx(SelectTab, {
|
|
371
372
|
value: mediaType,
|
|
372
373
|
anchorSegments: [mediaType],
|
|
373
|
-
children: /* @__PURE__ */ jsx(
|
|
374
|
+
children: /* @__PURE__ */ jsx(MediaContent, {
|
|
375
|
+
schema: media.schema,
|
|
376
|
+
selector: /* @__PURE__ */ jsx(CardSelector, { items })
|
|
377
|
+
})
|
|
374
378
|
}, mediaType))]
|
|
375
|
-
})
|
|
379
|
+
})
|
|
376
380
|
})
|
|
377
381
|
});
|
|
378
382
|
}
|
|
379
|
-
function ResponseAccordionItem({ item: { schema } }) {
|
|
380
|
-
const ts = useTypeScriptDefinitions(schema, {
|
|
381
|
-
name: "ResponseBody",
|
|
382
|
-
readOnly: true,
|
|
383
|
-
writeOnly: false
|
|
384
|
-
});
|
|
385
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [ts && /* @__PURE__ */ jsx(CopyTypeScriptPanel, {
|
|
386
|
-
name: "response body",
|
|
387
|
-
code: ts,
|
|
388
|
-
className: "mb-2"
|
|
389
|
-
}), schema && /* @__PURE__ */ jsx(SchemaUI, {
|
|
390
|
-
client: {
|
|
391
|
-
name: "response",
|
|
392
|
-
as: "body"
|
|
393
|
-
},
|
|
394
|
-
root: schema,
|
|
395
|
-
readOnly: true
|
|
396
|
-
})] });
|
|
397
|
-
}
|
|
398
383
|
function AuthScheme({ scheme, scopes }) {
|
|
399
384
|
const t = useTranslations({ note: "security scheme" });
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
name: scheme.name,
|
|
413
|
-
type: "<token>",
|
|
414
|
-
deprecated: scheme.deprecated,
|
|
415
|
-
scopes,
|
|
416
|
-
children: [scheme.description && /* @__PURE__ */ jsx(Markdown, { md: scheme.description }), /* @__PURE__ */ jsxs("p", { children: [
|
|
417
|
-
t("In"),
|
|
418
|
-
": ",
|
|
419
|
-
/* @__PURE__ */ jsx("code", { children: scheme.in })
|
|
420
|
-
] })]
|
|
421
|
-
});
|
|
422
|
-
if (scheme.type === "openIdConnect") return /* @__PURE__ */ jsx(AuthProperty, {
|
|
423
|
-
name: t("OpenID Connect"),
|
|
424
|
-
type: "<token>",
|
|
425
|
-
deprecated: scheme.deprecated,
|
|
426
|
-
scopes,
|
|
427
|
-
children: scheme.description && /* @__PURE__ */ jsx(Markdown, { md: scheme.description })
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
function AuthProperty({ name, type, deprecated = false, scopes = [], className, ...props }) {
|
|
431
|
-
const t = useTranslations({ note: "security scheme" });
|
|
385
|
+
let name;
|
|
386
|
+
let type = "<token>";
|
|
387
|
+
let location;
|
|
388
|
+
if (scheme.type === "http" || scheme.type === "oauth2") {
|
|
389
|
+
name = t("Authorization");
|
|
390
|
+
type = scheme.type === "http" && scheme.scheme === "basic" ? t("Basic <token>") : t("Bearer <token>");
|
|
391
|
+
location = "header";
|
|
392
|
+
} else if (scheme.type === "apiKey") {
|
|
393
|
+
name = scheme.name;
|
|
394
|
+
location = scheme.in;
|
|
395
|
+
} else if (scheme.type === "openIdConnect") name = t("OpenID Connect");
|
|
396
|
+
else return null;
|
|
432
397
|
return /* @__PURE__ */ jsxs("div", {
|
|
433
|
-
className:
|
|
398
|
+
className: "border-t py-2.5 first:border-t-0",
|
|
434
399
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
435
|
-
className: "flex flex-wrap items-center gap-
|
|
400
|
+
className: "flex flex-wrap items-center gap-2 not-prose",
|
|
436
401
|
children: [
|
|
437
|
-
/* @__PURE__ */ jsx("span", {
|
|
438
|
-
className: "
|
|
402
|
+
location && /* @__PURE__ */ jsx("span", {
|
|
403
|
+
className: "rounded-md border bg-fd-secondary px-1.5 font-mono text-xs leading-5 text-fd-muted-foreground",
|
|
404
|
+
children: location
|
|
405
|
+
}),
|
|
406
|
+
/* @__PURE__ */ jsx("code", {
|
|
407
|
+
className: "text-[0.8125rem] font-medium text-fd-primary",
|
|
439
408
|
children: name
|
|
440
409
|
}),
|
|
441
|
-
/* @__PURE__ */ jsx("
|
|
442
|
-
className: "text-
|
|
410
|
+
/* @__PURE__ */ jsx("code", {
|
|
411
|
+
className: "text-xs text-fd-muted-foreground",
|
|
443
412
|
children: type
|
|
444
413
|
}),
|
|
445
|
-
deprecated && /* @__PURE__ */ jsx(Badge, {
|
|
414
|
+
scheme.deprecated && /* @__PURE__ */ jsx(Badge, {
|
|
446
415
|
color: "red",
|
|
447
416
|
className: "text-xs",
|
|
448
417
|
children: t("Deprecated")
|
|
449
418
|
})
|
|
450
419
|
]
|
|
451
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
452
|
-
className: "prose-no-margin
|
|
453
|
-
children: [
|
|
420
|
+
}), (scheme.description || scopes.length > 0) && /* @__PURE__ */ jsxs("div", {
|
|
421
|
+
className: "mt-1 prose-no-margin text-fd-muted-foreground",
|
|
422
|
+
children: [scheme.description && /* @__PURE__ */ jsx(Markdown, { md: scheme.description }), scopes.length > 0 && /* @__PURE__ */ jsxs("p", { children: [
|
|
454
423
|
t("Scope"),
|
|
455
424
|
": ",
|
|
456
425
|
/* @__PURE__ */ jsx("code", { children: scopes.join(", ") })
|
|
@@ -458,27 +427,75 @@ function AuthProperty({ name, type, deprecated = false, scopes = [], className,
|
|
|
458
427
|
})]
|
|
459
428
|
});
|
|
460
429
|
}
|
|
461
|
-
function
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
430
|
+
function Callback({ item, path, headingLevel }) {
|
|
431
|
+
const t = useTranslations({ note: "operation page" });
|
|
432
|
+
const segments = [
|
|
433
|
+
"callbacks",
|
|
434
|
+
item.name,
|
|
435
|
+
item.path,
|
|
436
|
+
item.method
|
|
437
|
+
];
|
|
438
|
+
const [open, setOpen] = useState(false);
|
|
439
|
+
const ref = useAnchorLink(segments, () => setOpen(true));
|
|
440
|
+
return /* @__PURE__ */ jsxs(Dialog.Root, {
|
|
441
|
+
open,
|
|
442
|
+
onOpenChange: setOpen,
|
|
443
|
+
children: [/* @__PURE__ */ jsxs(Dialog.Trigger, {
|
|
444
|
+
className: "group grid w-full grid-cols-[auto_minmax(0,1fr)_auto] items-baseline gap-x-2 gap-y-1 border-t px-4 py-3 text-start transition-colors first:border-t-0 hover:bg-fd-accent/40 focus-visible:bg-fd-accent/40 focus-visible:outline-none",
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ jsx("span", {
|
|
447
|
+
className: "col-span-2 font-mono text-[0.8125rem] font-medium",
|
|
448
|
+
children: item.name
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "row-span-2 ms-1 size-4 self-center text-fd-muted-foreground transition-transform group-hover:translate-x-0.5 motion-reduce:transition-none" }),
|
|
451
|
+
/* @__PURE__ */ jsx(MethodLabel, {
|
|
452
|
+
className: "text-xs",
|
|
453
|
+
children: item.method
|
|
454
|
+
}),
|
|
455
|
+
/* @__PURE__ */ jsx("code", {
|
|
456
|
+
className: "text-xs wrap-anywhere text-fd-muted-foreground",
|
|
457
|
+
children: item.path
|
|
458
|
+
})
|
|
459
|
+
]
|
|
460
|
+
}), /* @__PURE__ */ jsxs(DialogPopup, {
|
|
461
|
+
className: "sm:max-h-[min(52rem,calc(100dvh-3rem))] sm:w-[min(64rem,calc(100vw-3rem))]",
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsxs("div", {
|
|
464
|
+
className: "flex h-12 shrink-0 items-center gap-2 ps-4 pe-2 sm:ps-5",
|
|
465
|
+
children: [/* @__PURE__ */ jsx(Dialog.Title, {
|
|
466
|
+
className: "truncate font-mono text-sm font-medium",
|
|
467
|
+
children: item.name
|
|
468
|
+
}), /* @__PURE__ */ jsx(Dialog.Close, {
|
|
469
|
+
"aria-label": t("Close"),
|
|
470
|
+
className: cn(buttonVariants({
|
|
471
|
+
variant: "ghost",
|
|
472
|
+
size: "icon-sm"
|
|
473
|
+
}), "ms-auto shrink-0 text-fd-muted-foreground"),
|
|
474
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
475
|
+
})]
|
|
476
|
+
}),
|
|
477
|
+
/* @__PURE__ */ jsx(EndpointBar, {
|
|
478
|
+
method: item.method,
|
|
479
|
+
route: item.path,
|
|
480
|
+
deprecated: item.operation.deprecated,
|
|
481
|
+
className: "mx-3 mb-3 shrink-0 sm:mx-4"
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ jsx("div", {
|
|
484
|
+
ref,
|
|
485
|
+
className: "fd-scroll-container prose min-h-0 flex-1 overflow-y-auto border-t p-5 text-sm @container [--fd-docs-row-1:0px] [--fd-docs-row-3:0px]",
|
|
486
|
+
children: /* @__PURE__ */ jsx(AnchorSection, {
|
|
487
|
+
segments,
|
|
488
|
+
children: /* @__PURE__ */ jsx(Operation, {
|
|
489
|
+
type: "webhook",
|
|
490
|
+
path,
|
|
491
|
+
headingLevel,
|
|
492
|
+
method: item.method,
|
|
493
|
+
pathItem: item.pathItem,
|
|
494
|
+
operation: item.operation
|
|
495
|
+
})
|
|
496
|
+
})
|
|
497
|
+
})
|
|
498
|
+
]
|
|
482
499
|
})]
|
|
483
500
|
});
|
|
484
501
|
}
|