fumadocs-openapi 3.3.0 → 4.0.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/dist/chunk-RSFOKBAM.js +115 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +232 -25
- package/dist/playground-D8pYn13F.d.ts +52 -0
- package/dist/playground-XE3Y6DRJ.js +963 -0
- package/dist/ui/index.d.ts +46 -0
- package/dist/ui/index.js +197 -0
- package/package.json +38 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import { A as APIPlaygroundProps } from '../playground-D8pYn13F.js';
|
|
4
|
+
import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
|
|
5
|
+
|
|
6
|
+
interface RootProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function Root({ children, baseUrl, className, ...props }: RootProps): React.ReactElement;
|
|
10
|
+
declare function API({ className, children, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
11
|
+
interface APIInfoProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
route: string;
|
|
13
|
+
method?: string;
|
|
14
|
+
badgeClassName?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function APIInfo({ children, className, route, badgeClassName, method, ...props }: APIInfoProps): React.ReactElement;
|
|
17
|
+
interface PropertyProps {
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
required: boolean;
|
|
21
|
+
deprecated: boolean;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
declare function Property({ name, type, required, deprecated, children, }: PropertyProps): React.ReactElement;
|
|
25
|
+
declare function APIExample({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement;
|
|
26
|
+
declare function ResponseTypes(props: {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}): React.ReactElement;
|
|
29
|
+
declare function ExampleResponse(props: {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}): React.ReactElement;
|
|
32
|
+
declare function TypeScriptResponse(props: {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
}): React.ReactElement;
|
|
35
|
+
declare function ObjectCollapsible(props: {
|
|
36
|
+
name: string;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}): React.ReactElement;
|
|
39
|
+
|
|
40
|
+
declare const APIPlayground: react.ComponentType<APIPlaygroundProps & react.HTMLAttributes<HTMLFormElement>>;
|
|
41
|
+
declare const Responses: typeof Tabs;
|
|
42
|
+
declare const Response: typeof Tab;
|
|
43
|
+
declare const Requests: typeof Tabs;
|
|
44
|
+
declare const Request: typeof Tab;
|
|
45
|
+
|
|
46
|
+
export { API, APIExample, APIInfo, type APIInfoProps, APIPlayground, ExampleResponse, ObjectCollapsible, Property, Request, Requests, Response, ResponseTypes, Responses, Root, type RootProps, TypeScriptResponse };
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
ApiProvider,
|
|
4
|
+
badgeVariants,
|
|
5
|
+
getBadgeColor,
|
|
6
|
+
useApiContext
|
|
7
|
+
} from "../chunk-RSFOKBAM.js";
|
|
8
|
+
|
|
9
|
+
// src/ui/index.ts
|
|
10
|
+
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
11
|
+
import dynamic from "next/dynamic";
|
|
12
|
+
|
|
13
|
+
// src/ui/components.tsx
|
|
14
|
+
import {
|
|
15
|
+
Fragment
|
|
16
|
+
} from "react";
|
|
17
|
+
import { Check, Copy } from "lucide-react";
|
|
18
|
+
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
|
|
19
|
+
import { cn, useCopyButton, buttonVariants } from "fumadocs-ui/components/api";
|
|
20
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
function Root({
|
|
22
|
+
children,
|
|
23
|
+
baseUrl,
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}) {
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: cn(
|
|
31
|
+
"flex flex-col gap-24 text-sm text-muted-foreground",
|
|
32
|
+
className
|
|
33
|
+
),
|
|
34
|
+
...props,
|
|
35
|
+
children: /* @__PURE__ */ jsx(ApiProvider, { defaultBaseUrl: baseUrl, children })
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function API({
|
|
40
|
+
className,
|
|
41
|
+
children,
|
|
42
|
+
...props
|
|
43
|
+
}) {
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
className: cn(
|
|
48
|
+
"flex flex-col gap-x-6 gap-y-2 xl:flex-row xl:items-start",
|
|
49
|
+
className
|
|
50
|
+
),
|
|
51
|
+
...props,
|
|
52
|
+
children
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
function Route({ route }) {
|
|
57
|
+
const segments = route.split("/").filter((part) => part.length > 0);
|
|
58
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-row items-center gap-1 text-sm", children: segments.map((part, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "/" }),
|
|
60
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground", children: part })
|
|
61
|
+
] }, index)) });
|
|
62
|
+
}
|
|
63
|
+
function APIInfo({
|
|
64
|
+
children,
|
|
65
|
+
className,
|
|
66
|
+
route,
|
|
67
|
+
badgeClassName,
|
|
68
|
+
method = "GET",
|
|
69
|
+
...props
|
|
70
|
+
}) {
|
|
71
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("min-w-0 flex-1 prose-no-margin", className), ...props, children: [
|
|
72
|
+
/* @__PURE__ */ jsxs(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
className: cn(
|
|
76
|
+
"sticky top-24 z-10 flex flex-row items-center gap-2 rounded-lg border bg-card p-3 md:top-10"
|
|
77
|
+
),
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
"span",
|
|
81
|
+
{
|
|
82
|
+
className: cn(
|
|
83
|
+
badgeVariants({ color: getBadgeColor(method) }),
|
|
84
|
+
badgeClassName
|
|
85
|
+
),
|
|
86
|
+
children: method
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx(Route, { route }),
|
|
90
|
+
/* @__PURE__ */ jsx(CopyRouteButton, { className: "ms-auto size-6 p-1", route })
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
children
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
97
|
+
function Property({
|
|
98
|
+
name,
|
|
99
|
+
type,
|
|
100
|
+
required,
|
|
101
|
+
deprecated,
|
|
102
|
+
children
|
|
103
|
+
}) {
|
|
104
|
+
return /* @__PURE__ */ jsxs("div", { className: "mb-4 flex flex-col rounded-lg border bg-card p-3 prose-no-margin", children: [
|
|
105
|
+
/* @__PURE__ */ jsxs("h4", { className: "inline-flex items-center gap-4", children: [
|
|
106
|
+
/* @__PURE__ */ jsx("code", { children: name }),
|
|
107
|
+
required ? /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ color: "red" })), children: "Required" }) : null,
|
|
108
|
+
deprecated ? /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ color: "yellow" })), children: "Deprecated" }) : null,
|
|
109
|
+
/* @__PURE__ */ jsx("span", { className: "ms-auto font-mono text-[13px] text-muted-foreground", children: type })
|
|
110
|
+
] }),
|
|
111
|
+
children
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
function APIExample({
|
|
115
|
+
children,
|
|
116
|
+
className,
|
|
117
|
+
...props
|
|
118
|
+
}) {
|
|
119
|
+
return /* @__PURE__ */ jsx(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
className: cn("sticky top-10 prose-no-margin xl:w-[400px]", className),
|
|
123
|
+
...props,
|
|
124
|
+
children
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
function ResponseTypes(props) {
|
|
129
|
+
return /* @__PURE__ */ jsx(
|
|
130
|
+
Accordions,
|
|
131
|
+
{
|
|
132
|
+
type: "single",
|
|
133
|
+
className: "!-m-4 border-none pt-2",
|
|
134
|
+
defaultValue: "Response",
|
|
135
|
+
children: props.children
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
function ExampleResponse(props) {
|
|
140
|
+
return /* @__PURE__ */ jsx(Accordion, { title: "Response", children: props.children });
|
|
141
|
+
}
|
|
142
|
+
function TypeScriptResponse(props) {
|
|
143
|
+
return /* @__PURE__ */ jsx(Accordion, { title: "Typescript", children: props.children });
|
|
144
|
+
}
|
|
145
|
+
function ObjectCollapsible(props) {
|
|
146
|
+
return /* @__PURE__ */ jsx(Accordions, { type: "single", children: /* @__PURE__ */ jsx(Accordion, { title: props.name, children: props.children }) });
|
|
147
|
+
}
|
|
148
|
+
function CopyRouteButton({
|
|
149
|
+
className,
|
|
150
|
+
route,
|
|
151
|
+
...props
|
|
152
|
+
}) {
|
|
153
|
+
const { baseUrl } = useApiContext();
|
|
154
|
+
const [checked, onCopy] = useCopyButton(() => {
|
|
155
|
+
void navigator.clipboard.writeText(`${baseUrl ?? ""}${route}`);
|
|
156
|
+
});
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
type: "button",
|
|
161
|
+
className: cn(
|
|
162
|
+
buttonVariants({
|
|
163
|
+
color: "ghost",
|
|
164
|
+
className
|
|
165
|
+
})
|
|
166
|
+
),
|
|
167
|
+
onClick: onCopy,
|
|
168
|
+
...props,
|
|
169
|
+
children: checked ? /* @__PURE__ */ jsx(Check, { className: "size-3" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3" })
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/ui/index.ts
|
|
175
|
+
var APIPlayground = dynamic(
|
|
176
|
+
() => import("../playground-XE3Y6DRJ.js").then((mod) => mod.APIPlayground)
|
|
177
|
+
);
|
|
178
|
+
var Responses = Tabs;
|
|
179
|
+
var Response = Tab;
|
|
180
|
+
var Requests = Tabs;
|
|
181
|
+
var Request = Tab;
|
|
182
|
+
export {
|
|
183
|
+
API,
|
|
184
|
+
APIExample,
|
|
185
|
+
APIInfo,
|
|
186
|
+
APIPlayground,
|
|
187
|
+
ExampleResponse,
|
|
188
|
+
ObjectCollapsible,
|
|
189
|
+
Property,
|
|
190
|
+
Request,
|
|
191
|
+
Requests,
|
|
192
|
+
Response,
|
|
193
|
+
ResponseTypes,
|
|
194
|
+
Responses,
|
|
195
|
+
Root,
|
|
196
|
+
TypeScriptResponse
|
|
197
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -11,26 +11,61 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Fuma Nama",
|
|
13
13
|
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./ui": {
|
|
20
|
+
"import": "./dist/ui/index.js",
|
|
21
|
+
"types": "./dist/ui/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
14
24
|
"main": "./dist/index.js",
|
|
15
25
|
"types": "./dist/index.d.ts",
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
".": [
|
|
29
|
+
"./dist/index.d.ts"
|
|
30
|
+
],
|
|
31
|
+
"ui": [
|
|
32
|
+
"./dist/ui/index.d.ts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
16
36
|
"files": [
|
|
17
37
|
"dist"
|
|
18
38
|
],
|
|
19
39
|
"dependencies": {
|
|
20
40
|
"@apidevtools/json-schema-ref-parser": "^11.6.4",
|
|
41
|
+
"@radix-ui/react-select": "^2.1.1",
|
|
42
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
43
|
+
"class-variance-authority": "^0.7.0",
|
|
21
44
|
"fast-glob": "^3.3.1",
|
|
22
45
|
"js-yaml": "^4.1.0",
|
|
23
46
|
"json-schema-to-typescript": "^14.1.0",
|
|
24
|
-
"
|
|
47
|
+
"lucide-react": "^0.408.0",
|
|
48
|
+
"openapi-sampler": "^1.5.1",
|
|
49
|
+
"react-hook-form": "^7.52.1",
|
|
50
|
+
"shiki": "^1.10.3",
|
|
51
|
+
"swr": "^2.2.5",
|
|
52
|
+
"fumadocs-ui": "12.5.0"
|
|
25
53
|
},
|
|
26
54
|
"devDependencies": {
|
|
27
55
|
"@types/js-yaml": "^4.0.9",
|
|
28
|
-
"@types/node": "20.14.
|
|
56
|
+
"@types/node": "20.14.10",
|
|
29
57
|
"@types/openapi-sampler": "^1.0.3",
|
|
58
|
+
"@types/react": "^18.3.3",
|
|
59
|
+
"next": "^14.2.5",
|
|
30
60
|
"openapi-types": "^12.1.3",
|
|
31
61
|
"eslint-config-custom": "0.0.0",
|
|
32
62
|
"tsconfig": "0.0.0"
|
|
33
63
|
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"next": ">= 14.1.0",
|
|
66
|
+
"react": ">= 18",
|
|
67
|
+
"react-dom": ">= 18"
|
|
68
|
+
},
|
|
34
69
|
"publishConfig": {
|
|
35
70
|
"access": "public"
|
|
36
71
|
},
|