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.
Files changed (50) hide show
  1. package/css/generated/shared.css +1 -1
  2. package/dist/.translations/index.d.ts +63 -20
  3. package/dist/.translations/keys.js +63 -20
  4. package/dist/operation.d.ts +6 -1
  5. package/dist/operation.js +2 -4
  6. package/dist/packages/shared-api/dist/.translations/index.d.ts +1 -0
  7. package/dist/packages/shared-api/dist/.translations/keys.js +1 -0
  8. package/dist/packages/shared-api/dist/auto-anchor/index.js +54 -10
  9. package/dist/packages/shared-api/dist/components/accordion.js +3 -11
  10. package/dist/packages/shared-api/dist/components/collapsible.js +2 -2
  11. package/dist/packages/shared-api/dist/components/schema/client.d.ts +5 -0
  12. package/dist/packages/shared-api/dist/components/schema/client.js +408 -455
  13. package/dist/packages/shared-api/dist/components/select-tab.js +7 -12
  14. package/dist/packages/shared-api/dist/components/select.js +8 -7
  15. package/dist/playground/auth.d.ts +5 -1
  16. package/dist/playground/auth.js +7 -2
  17. package/dist/playground/fetcher.d.ts +8 -0
  18. package/dist/playground/fetcher.js +30 -1
  19. package/dist/playground/index.d.ts +2 -1
  20. package/dist/playground/index.js +2 -1
  21. package/dist/playground/use-playground.d.ts +62 -0
  22. package/dist/playground/use-playground.js +140 -0
  23. package/dist/ui/components/dialog.js +14 -0
  24. package/dist/ui/components/endpoint.js +40 -0
  25. package/dist/ui/components/heading.js +1 -1
  26. package/dist/ui/components/schema.js +1 -1
  27. package/dist/ui/components/segmented.js +21 -0
  28. package/dist/ui/operation/index.js +267 -250
  29. package/dist/ui/playground/client.d.ts +9 -26
  30. package/dist/ui/playground/client.js +150 -389
  31. package/dist/ui/playground/components/fields.js +693 -0
  32. package/dist/ui/playground/components/oauth-panel.js +182 -0
  33. package/dist/ui/playground/components/request-panel.js +480 -0
  34. package/dist/ui/playground/components/response-panel.js +150 -0
  35. package/dist/ui/playground/components/result-display.d.ts +1 -0
  36. package/dist/ui/playground/components/result-display.js +185 -168
  37. package/dist/ui/playground/components/server-select.js +100 -89
  38. package/dist/ui/playground/components/url-bar.js +96 -0
  39. package/dist/ui/playground/status-info.js +32 -45
  40. package/dist/utils/document/load.js +1 -1
  41. package/package.json +12 -12
  42. package/dist/packages/shared-api/dist/auto-anchor/client.js +0 -20
  43. package/dist/packages/shared-api/dist/components/collapsible.d.ts +0 -7
  44. package/dist/packages/shared-api/dist/components/dialog.js +0 -55
  45. package/dist/packages/shared-api/dist/components/input.js +0 -14
  46. package/dist/packages/shared-api/dist/components/label.js +0 -11
  47. package/dist/packages/shared-api/dist/components/playground/inputs.js +0 -439
  48. package/dist/packages/shared-api/dist/components/popover.js +0 -23
  49. package/dist/packages/shared-api/dist/utils/merge-refs.js +0 -11
  50. 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/client.js";
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__ */ jsxs("div", {
78
- className: "flex gap-2 items-center justify-between mt-10",
79
- children: [/* @__PURE__ */ jsx(Heading, {
80
- id: "request-body",
81
- depth: headingLevel,
82
- className: "my-0!",
83
- children: t("Request Body")
84
- }), contentTypes.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, {
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(RequestBodyContentItem, {
97
- content,
89
+ children: /* @__PURE__ */ jsx(MediaContent, {
90
+ schema: content.schema,
98
91
  required: requestBody.required,
99
- method
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__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Heading, {
106
- id: "response-body",
107
- depth: headingLevel,
108
- children: t("Response Body")
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(Heading, {
105
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(SectionHeader, {
116
106
  id: `parameters-${location}`,
117
107
  depth: headingLevel,
118
- children: parameterLabel
108
+ title: parameterLabel
119
109
  }), /* @__PURE__ */ jsx(AnchorSection, {
120
110
  segments: ["parameters", location],
121
111
  children: /* @__PURE__ */ jsx("div", {
122
- className: "flex flex-col",
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
- return {
146
- value: String(i),
147
- label: /* @__PURE__ */ jsx("div", {
148
- className: "flex flex-col text-xs min-w-0",
149
- children: requirement.map(({ key, scopes }) => /* @__PURE__ */ jsxs("code", {
150
- className: "truncate",
151
- children: [
152
- /* @__PURE__ */ jsx("span", {
153
- className: "font-medium",
154
- children: key
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__ */ jsxs("div", {
169
- className: "flex items-start justify-between gap-2 mt-10",
170
- children: [/* @__PURE__ */ jsx(Heading, {
171
- id: "authorization",
172
- depth: headingLevel,
173
- className: "my-0!",
174
- children: t("Authorization")
175
- }), items.length > 1 ? /* @__PURE__ */ jsx(SelectTabTrigger, { items }) : /* @__PURE__ */ jsx("div", {
176
- className: "not-prose",
177
- children: items[0].label
178
- })]
179
- }), security.map((requirement, i) => /* @__PURE__ */ jsx(SelectTab, {
180
- value: items[i].value,
181
- children: requirement.map(({ key, scopes, scheme }) => scheme && /* @__PURE__ */ jsx(AuthScheme, {
182
- scheme,
183
- scopes
184
- }, key))
185
- }, i))]
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(Heading, {
169
+ if (callbacks.length > 0) callbacksNode = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SectionHeader, {
189
170
  id: "callbacks",
190
171
  depth: headingLevel,
191
- children: t("Callbacks")
192
- }), /* @__PURE__ */ jsx(Accordions, {
193
- type: "multiple",
194
- children: callbacks.map((item, i) => /* @__PURE__ */ jsxs(AccordionItem, {
195
- value: `${item.name}\0${item.path}\0${item.method}`,
196
- anchorSegments: [
197
- "callbacks",
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
- ...options,
239
- writeOnly: true,
240
- readOnly: false
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 RequestBodyContentItem({ content, required, method }) {
321
- const ts = useTypeScriptDefinitions(content.schema, {
322
- name: "RequestBody",
323
- readOnly: false,
324
- writeOnly: true
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
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [ts && /* @__PURE__ */ jsx(CopyTypeScriptPanel, {
327
- name: "request body",
328
- code: ts,
329
- className: "my-4 last:mb-0"
330
- }), content.schema && /* @__PURE__ */ jsx(SchemaUI, {
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: content.schema,
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 ResponseAccordion({ item: { status, response, content } }) {
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(([key]) => ({
344
- label: /* @__PURE__ */ jsx("code", {
345
- className: "text-xs",
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(AccordionItem, {
361
+ return /* @__PURE__ */ jsx(SegmentedPanel, {
351
362
  value: status,
352
- anchorSegments: ["response", status],
353
- className: "data-[open]:border-b-0",
354
- children: /* @__PURE__ */ jsxs(SelectTabs, {
355
- defaultValue: items[0]?.value,
356
- children: [/* @__PURE__ */ jsxs(AccordionHeader, { children: [/* @__PURE__ */ jsx(AccordionTrigger, {
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 mt-3 mb-2",
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(ResponseAccordionItem, { item: media })
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
- if (scheme.type === "http" || scheme.type === "oauth2") return /* @__PURE__ */ jsxs(AuthProperty, {
401
- name: t("Authorization"),
402
- type: scheme.type === "http" && scheme.scheme === "basic" ? t("Basic <token>") : t("Bearer <token>"),
403
- deprecated: scheme.deprecated,
404
- scopes,
405
- children: [scheme.description && /* @__PURE__ */ jsx(Markdown, { md: scheme.description }), /* @__PURE__ */ jsxs("p", { children: [
406
- t("In"),
407
- ": ",
408
- /* @__PURE__ */ jsx("code", { children: "header" })
409
- ] })]
410
- });
411
- if (scheme.type === "apiKey") return /* @__PURE__ */ jsxs(AuthProperty, {
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: cn("text-sm border-t my-4 first:border-t-0", 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-3 not-prose",
400
+ className: "flex flex-wrap items-center gap-2 not-prose",
436
401
  children: [
437
- /* @__PURE__ */ jsx("span", {
438
- className: "font-medium font-mono text-fd-primary",
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("span", {
442
- className: "text-sm font-mono text-fd-muted-foreground",
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 pt-2.5 empty:hidden",
453
- children: [props.children, scopes.length > 0 && /* @__PURE__ */ jsxs("p", { 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 CopyTypeScriptPanel({ name, code, className }) {
462
- const [isChecked, onCopy] = useCopyButton(() => {
463
- navigator.clipboard.writeText(code);
464
- });
465
- const t = useTranslations({ note: "TypeScript definitions" });
466
- return /* @__PURE__ */ jsxs("div", {
467
- className: cn("flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose", className),
468
- children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
469
- className: "font-medium text-sm mb-2",
470
- children: t("TypeScript Definitions")
471
- }), /* @__PURE__ */ jsx("p", {
472
- className: "text-xs text-fd-muted-foreground",
473
- children: t("Use the {name} type in TypeScript.", { variables: { name } })
474
- })] }), /* @__PURE__ */ jsxs("button", {
475
- onClick: onCopy,
476
- className: cn(buttonVariants({
477
- variant: "secondary",
478
- className: "p-2 gap-2",
479
- size: "sm"
480
- })),
481
- children: [isChecked ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3.5" }), t("Copy")]
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
  }