fumadocs-openapi 4.4.1 → 5.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/index.d.ts +113 -36
- package/dist/index.js +252 -1030
- package/dist/server/index.d.ts +211 -0
- package/dist/server/index.js +1093 -0
- package/dist/ui/client-client-CbQJObP6.js +91 -0
- package/dist/ui/index.d.ts +87 -43
- package/dist/ui/index.js +128 -185
- package/dist/ui/playground-client-W7yhm4ZD.js +1033 -0
- package/package.json +15 -10
- package/dist/chunk-N4P4W4VJ.js +0 -61
- package/dist/chunk-UG2WFM5D.js +0 -70
- package/dist/playground-GIGTWHCL.js +0 -1065
- package/dist/playground-vSsfCaVw.d.ts +0 -56
- package/dist/source/index.d.ts +0 -10
- package/dist/source/index.js +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"import": "./dist/ui/index.js",
|
|
21
21
|
"types": "./dist/ui/index.d.ts"
|
|
22
22
|
},
|
|
23
|
-
"./
|
|
24
|
-
"import": "./dist/
|
|
25
|
-
"types": "./dist/
|
|
23
|
+
"./server": {
|
|
24
|
+
"import": "./dist/server/index.js",
|
|
25
|
+
"types": "./dist/server/index.d.ts"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"ui": [
|
|
36
36
|
"./dist/ui/index.d.ts"
|
|
37
37
|
],
|
|
38
|
-
"
|
|
39
|
-
"./dist/
|
|
38
|
+
"server": [
|
|
39
|
+
"./dist/server/index.d.ts"
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
42
|
},
|
|
@@ -45,25 +45,30 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@apidevtools/json-schema-ref-parser": "^11.6.4",
|
|
48
|
+
"@mdx-js/mdx": "^3.0.1",
|
|
48
49
|
"@radix-ui/react-select": "^2.1.1",
|
|
49
50
|
"@radix-ui/react-slot": "^1.1.0",
|
|
51
|
+
"@types/mdx": "^2.0.13",
|
|
50
52
|
"class-variance-authority": "^0.7.0",
|
|
51
53
|
"fast-glob": "^3.3.1",
|
|
54
|
+
"github-slugger": "^2.0.0",
|
|
52
55
|
"js-yaml": "^4.1.0",
|
|
53
56
|
"json-schema-to-typescript": "^15.0.0",
|
|
54
57
|
"lucide-react": "^0.414.0",
|
|
55
58
|
"openapi-sampler": "^1.5.1",
|
|
56
59
|
"react-hook-form": "^7.52.1",
|
|
60
|
+
"remark": "^15.0.0",
|
|
57
61
|
"shiki": "^1.11.1",
|
|
58
62
|
"swr": "^2.2.5",
|
|
59
|
-
"fumadocs-core": "13.0
|
|
60
|
-
"fumadocs-ui": "13.0
|
|
63
|
+
"fumadocs-core": "13.1.0",
|
|
64
|
+
"fumadocs-ui": "13.1.0"
|
|
61
65
|
},
|
|
62
66
|
"devDependencies": {
|
|
63
67
|
"@types/js-yaml": "^4.0.9",
|
|
64
68
|
"@types/node": "20.14.12",
|
|
65
69
|
"@types/openapi-sampler": "^1.0.3",
|
|
66
70
|
"@types/react": "^18.3.3",
|
|
71
|
+
"bunchee": "^5.3.1",
|
|
67
72
|
"next": "^14.2.5",
|
|
68
73
|
"openapi-types": "^12.1.3",
|
|
69
74
|
"eslint-config-custom": "0.0.0",
|
|
@@ -78,9 +83,9 @@
|
|
|
78
83
|
"access": "public"
|
|
79
84
|
},
|
|
80
85
|
"scripts": {
|
|
81
|
-
"build": "
|
|
86
|
+
"build": "bunchee",
|
|
82
87
|
"clean": "rimraf dist",
|
|
83
|
-
"dev": "
|
|
88
|
+
"dev": "bunchee --watch",
|
|
84
89
|
"lint": "eslint .",
|
|
85
90
|
"types:check": "tsc --noEmit"
|
|
86
91
|
}
|
package/dist/chunk-N4P4W4VJ.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// src/ui/contexts/api.tsx
|
|
2
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
var ApiContext = createContext({
|
|
5
|
-
baseUrl: void 0,
|
|
6
|
-
setBaseUrl: () => void 0,
|
|
7
|
-
highlighter: null
|
|
8
|
-
});
|
|
9
|
-
function useApiContext() {
|
|
10
|
-
return useContext(ApiContext);
|
|
11
|
-
}
|
|
12
|
-
async function initHighlighter() {
|
|
13
|
-
const { createHighlighterCore } = await import("shiki/core");
|
|
14
|
-
const getWasm = await import("shiki/wasm");
|
|
15
|
-
return createHighlighterCore({
|
|
16
|
-
themes: [
|
|
17
|
-
import("shiki/themes/github-light.mjs"),
|
|
18
|
-
import("shiki/themes/github-dark.mjs")
|
|
19
|
-
],
|
|
20
|
-
langs: [import("shiki/langs/json.mjs")],
|
|
21
|
-
loadWasm: getWasm
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
var highlighterInstance;
|
|
25
|
-
function ApiProvider({
|
|
26
|
-
defaultBaseUrl,
|
|
27
|
-
children
|
|
28
|
-
}) {
|
|
29
|
-
const [highlighter, setHighlighter] = useState(null);
|
|
30
|
-
const [baseUrl, setBaseUrl] = useState(defaultBaseUrl);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
setBaseUrl((prev) => localStorage.getItem("apiBaseUrl") ?? prev);
|
|
33
|
-
if (highlighterInstance) setHighlighter(highlighterInstance);
|
|
34
|
-
else
|
|
35
|
-
void initHighlighter().then((res) => {
|
|
36
|
-
setHighlighter(res);
|
|
37
|
-
});
|
|
38
|
-
}, []);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (baseUrl) localStorage.setItem("apiBaseUrl", baseUrl);
|
|
41
|
-
}, [baseUrl]);
|
|
42
|
-
return /* @__PURE__ */ jsx(ApiContext.Provider, { value: { baseUrl, setBaseUrl, highlighter }, children });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/ui/contexts/schema.tsx
|
|
46
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
47
|
-
var SchemaContext = createContext2(
|
|
48
|
-
void 0
|
|
49
|
-
);
|
|
50
|
-
function useSchemaContext() {
|
|
51
|
-
const ctx = useContext2(SchemaContext);
|
|
52
|
-
if (!ctx) throw new Error("Missing provider");
|
|
53
|
-
return ctx;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
useApiContext,
|
|
58
|
-
ApiProvider,
|
|
59
|
-
SchemaContext,
|
|
60
|
-
useSchemaContext
|
|
61
|
-
};
|
package/dist/chunk-UG2WFM5D.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// src/ui/shared.ts
|
|
2
|
-
import { cva } from "class-variance-authority";
|
|
3
|
-
var badgeVariants = cva(
|
|
4
|
-
"rounded border px-1.5 py-1 text-xs font-medium leading-[12px]",
|
|
5
|
-
{
|
|
6
|
-
variants: {
|
|
7
|
-
color: {
|
|
8
|
-
green: "border-green-400/50 bg-green-400/20 text-green-600 dark:text-green-400",
|
|
9
|
-
yellow: "border-yellow-400/50 bg-yellow-400/20 text-yellow-600 dark:text-yellow-400",
|
|
10
|
-
red: "border-red-400/50 bg-red-400/20 text-red-600 dark:text-red-400",
|
|
11
|
-
blue: "border-blue-400/50 bg-blue-400/20 text-blue-600 dark:text-blue-400",
|
|
12
|
-
orange: "border-orange-400/50 bg-orange-400/20 text-orange-600 dark:text-orange-400"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
|
-
function getBadgeColor(method) {
|
|
18
|
-
switch (method) {
|
|
19
|
-
case "PUT":
|
|
20
|
-
return "yellow";
|
|
21
|
-
case "PATCH":
|
|
22
|
-
return "orange";
|
|
23
|
-
case "POST":
|
|
24
|
-
return "blue";
|
|
25
|
-
case "DELETE":
|
|
26
|
-
return "red";
|
|
27
|
-
default:
|
|
28
|
-
return "green";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function getDefaultValue(item, references) {
|
|
32
|
-
if (item.type === "object")
|
|
33
|
-
return Object.fromEntries(
|
|
34
|
-
Object.entries(item.properties).map(([key, prop]) => [
|
|
35
|
-
key,
|
|
36
|
-
getDefaultValue(references[prop.schema], references)
|
|
37
|
-
])
|
|
38
|
-
);
|
|
39
|
-
if (item.type === "array") return [];
|
|
40
|
-
if (item.type === "null") return null;
|
|
41
|
-
if (item.type === "switcher")
|
|
42
|
-
return getDefaultValue(
|
|
43
|
-
resolve(Object.values(item.items)[0], references),
|
|
44
|
-
references
|
|
45
|
-
);
|
|
46
|
-
if (item.type === "file") return void 0;
|
|
47
|
-
return String(item.defaultValue);
|
|
48
|
-
}
|
|
49
|
-
function getDefaultValues(field, context) {
|
|
50
|
-
return Object.fromEntries(
|
|
51
|
-
field.map((p) => [p.name, getDefaultValue(p, context)])
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
function resolve(schema, references) {
|
|
55
|
-
if (typeof schema === "string") return references[schema];
|
|
56
|
-
if (schema.type !== "ref") return schema;
|
|
57
|
-
return {
|
|
58
|
-
...references[schema.schema],
|
|
59
|
-
description: schema.description,
|
|
60
|
-
isRequired: schema.isRequired
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
badgeVariants,
|
|
66
|
-
getBadgeColor,
|
|
67
|
-
getDefaultValue,
|
|
68
|
-
getDefaultValues,
|
|
69
|
-
resolve
|
|
70
|
-
};
|