fumadocs-openapi 12.4.2 → 12.5.1
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 +12 -1
- package/dist/.translations/keys.js +12 -1
- package/dist/generate-file.js +3 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/operation.js +2 -2
- package/dist/packages/shared-api/dist/codegen.js +1 -3
- package/dist/packages/shared-api/dist/components/schema/client.js +1 -1
- package/dist/packages/shared-api/dist/components/select.js +6 -2
- package/dist/playground/auth.d.ts +84 -30
- package/dist/playground/auth.js +250 -150
- package/dist/playground/fetcher.js +11 -6
- package/dist/playground/index.d.ts +2 -2
- package/dist/playground/index.js +2 -2
- package/dist/playground/use-playground.d.ts +3 -3
- package/dist/playground/use-playground.js +46 -31
- package/dist/requests/generators/python.d.ts +0 -1
- package/dist/requests/generators/python.js +1 -1
- package/dist/server/index.d.ts +2 -9
- package/dist/server/index.js +2 -9
- package/dist/server/proxy.d.ts +5 -4
- package/dist/server/proxy.js +105 -25
- package/dist/types/openapi.d.ts +7 -2
- package/dist/types.d.ts +1 -0
- package/dist/ui/operation/index.js +66 -38
- package/dist/ui/operation/usage-tabs.js +272 -35
- package/dist/ui/playground/client.js +8 -4
- package/dist/ui/playground/components/fields.js +5 -7
- package/dist/ui/playground/components/oauth-panel.js +150 -39
- package/dist/ui/playground/components/request-panel.js +18 -3
- package/dist/ui/playground/components/response-panel.js +53 -90
- package/dist/utils/create-page.d.ts +2 -1
- package/dist/utils/pages/to-static-data.d.ts +12 -0
- package/dist/utils/use-server.js +1 -1
- package/package.json +8 -7
- package/dist/packages/shared-api/dist/components/accordion.js +0 -63
- package/dist/ui/operation/request-tabs.js +0 -92
- package/dist/ui/operation/response-tabs.js +0 -53
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { cn } from "../utils/cn.js";
|
|
3
|
-
import { AnchorSection, useAnchorLink } from "../auto-anchor/index.js";
|
|
4
|
-
import { createContext, use, useMemo, useState } from "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { ChevronRight } from "lucide-react";
|
|
7
|
-
import { Accordion } from "@base-ui/react/accordion";
|
|
8
|
-
//#region ../shared-api/dist/components/accordion.js
|
|
9
|
-
const Context = createContext(null);
|
|
10
|
-
function Accordions({ type = "single", defaultValue, ...props }) {
|
|
11
|
-
const [value, setValue] = useState(() => {
|
|
12
|
-
if (Array.isArray(defaultValue)) return defaultValue;
|
|
13
|
-
if (defaultValue) return [defaultValue];
|
|
14
|
-
return [];
|
|
15
|
-
});
|
|
16
|
-
return /* @__PURE__ */ jsx(Context, {
|
|
17
|
-
value: useMemo(() => ({
|
|
18
|
-
type,
|
|
19
|
-
setValue
|
|
20
|
-
}), [type]),
|
|
21
|
-
children: /* @__PURE__ */ jsx(Accordion.Root, {
|
|
22
|
-
multiple: type === "multiple",
|
|
23
|
-
value,
|
|
24
|
-
onValueChange: setValue,
|
|
25
|
-
...props
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function AccordionItem({ value, className, anchorSegments, ...props }) {
|
|
30
|
-
const ctx = use(Context);
|
|
31
|
-
useAnchorLink(anchorSegments ?? false, () => ctx.setValue([value]));
|
|
32
|
-
const content = /* @__PURE__ */ jsx(Accordion.Item, {
|
|
33
|
-
value,
|
|
34
|
-
className: cn("scroll-m-20 border-b last:border-b-0", className),
|
|
35
|
-
...props
|
|
36
|
-
});
|
|
37
|
-
return anchorSegments ? /* @__PURE__ */ jsx(AnchorSection, {
|
|
38
|
-
segments: anchorSegments,
|
|
39
|
-
children: content
|
|
40
|
-
}) : content;
|
|
41
|
-
}
|
|
42
|
-
function AccordionContent(props) {
|
|
43
|
-
return /* @__PURE__ */ jsx(Accordion.Panel, {
|
|
44
|
-
...props,
|
|
45
|
-
className: cn("h-(--accordion-panel-height) overflow-hidden transition-[height] ease-out data-ending-style:h-0 data-starting-style:h-0", props.className)
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function AccordionHeader(props) {
|
|
49
|
-
return /* @__PURE__ */ jsx(Accordion.Header, {
|
|
50
|
-
...props,
|
|
51
|
-
className: cn("not-prose flex text-fd-foreground font-medium", props.className),
|
|
52
|
-
children: props.children
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function AccordionTrigger(props) {
|
|
56
|
-
return /* @__PURE__ */ jsxs(Accordion.Trigger, {
|
|
57
|
-
...props,
|
|
58
|
-
className: cn("flex flex-1 items-center gap-1 text-start group/accordion py-2 focus-visible:outline-none", props.className),
|
|
59
|
-
children: [/* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-data-[panel-open]/accordion:rotate-90" }), props.children]
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useExampleRequests, useOperation } from "../../operation.js";
|
|
3
|
-
import { useRenderContext } from "../../utils/create-page.js";
|
|
4
|
-
import { MethodLabel } from "../components/method-label.js";
|
|
5
|
-
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../../packages/shared-api/dist/components/accordion.js";
|
|
6
|
-
import { Markdown } from "../components/markdown.js";
|
|
7
|
-
import { ClientCodeBlock } from "../components/codeblock.js";
|
|
8
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { useTranslations } from "@fuma-translate/react";
|
|
10
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from "fumadocs-ui/components/tabs";
|
|
11
|
-
//#region src/ui/operation/request-tabs.tsx
|
|
12
|
-
function RequestTabs() {
|
|
13
|
-
const ctx = useRenderContext();
|
|
14
|
-
const { path, method, operation, pathItem } = useOperation();
|
|
15
|
-
const { items } = useExampleRequests();
|
|
16
|
-
if (!operation.requestBody) return null;
|
|
17
|
-
if (ctx.content?.renderRequestTabs) return ctx.content.renderRequestTabs({
|
|
18
|
-
items,
|
|
19
|
-
route: path,
|
|
20
|
-
method,
|
|
21
|
-
pathItem,
|
|
22
|
-
operation
|
|
23
|
-
}, ctx);
|
|
24
|
-
return /* @__PURE__ */ jsx(RequestTabsDefaultContent, { items });
|
|
25
|
-
}
|
|
26
|
-
function RequestTabsDefaultContent({ items }) {
|
|
27
|
-
const t = useTranslations({ note: "operation page" });
|
|
28
|
-
let children;
|
|
29
|
-
if (items.length > 1) children = /* @__PURE__ */ jsxs(Tabs, {
|
|
30
|
-
defaultValue: items[0].id,
|
|
31
|
-
children: [/* @__PURE__ */ jsx(TabsList, { children: items.map((item) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
32
|
-
value: item.id,
|
|
33
|
-
children: item.id === "_default" ? t("Default") : item.name
|
|
34
|
-
}, item.id)) }), items.map((item) => /* @__PURE__ */ jsx(TabsContent, {
|
|
35
|
-
value: item.id,
|
|
36
|
-
children: /* @__PURE__ */ jsx(RequestTabsItem, { item })
|
|
37
|
-
}, item.id))]
|
|
38
|
-
});
|
|
39
|
-
else if (items.length === 1) children = /* @__PURE__ */ jsx(RequestTabsItem, { item: items[0] });
|
|
40
|
-
else children = /* @__PURE__ */ jsx("p", {
|
|
41
|
-
className: "text-fd-muted-foreground text-xs",
|
|
42
|
-
children: t("Empty")
|
|
43
|
-
});
|
|
44
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
45
|
-
className: "p-3 rounded-xl border prose-no-margin bg-fd-card text-fd-card-foreground shadow-md",
|
|
46
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
47
|
-
className: "font-semibold border-b pb-2",
|
|
48
|
-
children: t("Example Requests")
|
|
49
|
-
}), children]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function RequestTabsItem({ item }) {
|
|
53
|
-
const t = useTranslations({ note: "operation page" });
|
|
54
|
-
const requestData = item.data;
|
|
55
|
-
const displayNames = {
|
|
56
|
-
body: /* @__PURE__ */ jsxs(Fragment, { children: [t("Request Body"), /* @__PURE__ */ jsx("code", {
|
|
57
|
-
className: "text-xs text-fd-muted-foreground ms-auto",
|
|
58
|
-
children: requestData.bodyMediaType
|
|
59
|
-
})] }),
|
|
60
|
-
cookie: t("Cookie Parameters"),
|
|
61
|
-
header: t("Header Parameters"),
|
|
62
|
-
query: t("Query Parameters"),
|
|
63
|
-
path: t("Path Parameters")
|
|
64
|
-
};
|
|
65
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
|
-
item.description && /* @__PURE__ */ jsx(Markdown, { md: item.description }),
|
|
67
|
-
/* @__PURE__ */ jsxs("div", {
|
|
68
|
-
className: "flex flex-row gap-2 items-center justify-between",
|
|
69
|
-
children: [/* @__PURE__ */ jsx(MethodLabel, { children: requestData.method }), /* @__PURE__ */ jsx("code", { children: item.pathname })]
|
|
70
|
-
}),
|
|
71
|
-
/* @__PURE__ */ jsx(Accordions, {
|
|
72
|
-
type: "multiple",
|
|
73
|
-
className: "mt-2",
|
|
74
|
-
children: Object.entries(displayNames).map(([k, v]) => {
|
|
75
|
-
const data = requestData[k];
|
|
76
|
-
if (!data || Object.keys(data).length === 0) return;
|
|
77
|
-
return /* @__PURE__ */ jsxs(AccordionItem, {
|
|
78
|
-
value: k,
|
|
79
|
-
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: v }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
80
|
-
className: "prose-no-margin",
|
|
81
|
-
children: /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
82
|
-
lang: "json",
|
|
83
|
-
code: JSON.stringify(data, null, 2)
|
|
84
|
-
})
|
|
85
|
-
})]
|
|
86
|
-
}, k);
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
] });
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
export { RequestTabs };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useResponseExamples } from "../../operation.js";
|
|
3
|
-
import { useRenderContext } from "../../utils/create-page.js";
|
|
4
|
-
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "../../packages/shared-api/dist/components/accordion.js";
|
|
5
|
-
import { Markdown } from "../components/markdown.js";
|
|
6
|
-
import { ClientCodeBlock } from "../components/codeblock.js";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { useTranslations } from "@fuma-translate/react";
|
|
9
|
-
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
10
|
-
//#region src/ui/operation/response-tabs.tsx
|
|
11
|
-
function ResponseTabs() {
|
|
12
|
-
const ctx = useRenderContext();
|
|
13
|
-
const tabs = useResponseExamples();
|
|
14
|
-
if (tabs.length === 0) return null;
|
|
15
|
-
if (ctx.content?.renderResponseTabs) return ctx.content.renderResponseTabs({ tabs }, ctx);
|
|
16
|
-
return /* @__PURE__ */ jsx(ResponseTabsDefaultContent, { tabs });
|
|
17
|
-
}
|
|
18
|
-
function ResponseTabsDefaultContent({ tabs }) {
|
|
19
|
-
const t = useTranslations({ note: "operation page" });
|
|
20
|
-
function renderExampleContent(example) {
|
|
21
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [example.description && /* @__PURE__ */ jsx(Markdown, { md: example.description }), /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
22
|
-
lang: "json",
|
|
23
|
-
code: JSON.stringify(example.sample, null, 2)
|
|
24
|
-
})] });
|
|
25
|
-
}
|
|
26
|
-
return /* @__PURE__ */ jsx(Tabs, {
|
|
27
|
-
groupId: "fumadocs_openapi_responses",
|
|
28
|
-
items: tabs.map((tab) => tab.code),
|
|
29
|
-
children: tabs.map((tab) => {
|
|
30
|
-
const { examples = [] } = tab;
|
|
31
|
-
let slot = t("Empty");
|
|
32
|
-
if (examples.length > 1) slot = /* @__PURE__ */ jsx(Accordions, {
|
|
33
|
-
type: "single",
|
|
34
|
-
className: "pt-2",
|
|
35
|
-
defaultValue: "0",
|
|
36
|
-
children: examples.map((example, i) => /* @__PURE__ */ jsxs(AccordionItem, {
|
|
37
|
-
value: i.toString(),
|
|
38
|
-
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: example.label }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
39
|
-
className: "prose-no-margin",
|
|
40
|
-
children: renderExampleContent(example)
|
|
41
|
-
})]
|
|
42
|
-
}, i))
|
|
43
|
-
});
|
|
44
|
-
else if (examples.length === 1) slot = renderExampleContent(examples[0]);
|
|
45
|
-
return /* @__PURE__ */ jsx(Tab, {
|
|
46
|
-
value: tab.code,
|
|
47
|
-
children: slot
|
|
48
|
-
}, tab.code);
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
export { ResponseTabs };
|