fumadocs-openapi 9.0.4 → 9.0.5
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/playground/auth/oauth-dialog.d.ts +4 -2
- package/dist/playground/auth/oauth-dialog.d.ts.map +1 -1
- package/dist/playground/auth/oauth-dialog.js +113 -26
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +101 -63
- package/dist/playground/index.js +26 -15
- package/dist/playground/inputs.d.ts +8 -2
- package/dist/playground/inputs.d.ts.map +1 -1
- package/dist/playground/inputs.js +32 -31
- package/dist/render/heading.d.ts +1 -1
- package/dist/render/heading.d.ts.map +1 -1
- package/dist/render/heading.js +3 -3
- package/dist/render/markdown.d.ts +2 -2
- package/dist/render/markdown.d.ts.map +1 -1
- package/dist/render/markdown.js +4 -2
- package/dist/render/operation/index.d.ts.map +1 -1
- package/dist/render/operation/index.js +68 -58
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +3 -3
- package/dist/render/schema.d.ts.map +1 -1
- package/dist/render/schema.js +7 -8
- package/dist/ui/components/accordion.d.ts +8 -0
- package/dist/ui/components/accordion.d.ts.map +1 -0
- package/dist/ui/components/accordion.js +20 -0
- package/dist/ui/components/input.js +1 -1
- package/dist/ui/components/select.js +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +4 -2
- package/dist/ui/select-tabs.d.ts +13 -0
- package/dist/ui/select-tabs.d.ts.map +1 -0
- package/dist/ui/select-tabs.js +20 -0
- package/dist/ui/server-select.d.ts.map +1 -1
- package/dist/ui/server-select.js +22 -15
- package/dist/utils/schema-to-string.d.ts.map +1 -1
- package/dist/utils/schema-to-string.js +10 -1
- package/dist/utils/schema.d.ts +0 -1
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +0 -10
- package/package.json +10 -9
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, use, useMemo, useState, } from 'react';
|
|
4
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
|
|
5
|
+
import { cn } from 'fumadocs-ui/utils/cn';
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
export function SelectTabs({ defaultValue, children, }) {
|
|
8
|
+
const [type, setType] = useState(defaultValue ?? null);
|
|
9
|
+
return (_jsx(Context, { value: useMemo(() => ({ type, setType }), [type]), children: children }));
|
|
10
|
+
}
|
|
11
|
+
export function SelectTab({ value, ...props }) {
|
|
12
|
+
const { type } = use(Context);
|
|
13
|
+
if (value !== type)
|
|
14
|
+
return;
|
|
15
|
+
return _jsx("div", { ...props, children: props.children });
|
|
16
|
+
}
|
|
17
|
+
export function SelectTabTrigger({ items, ...props }) {
|
|
18
|
+
const { type, setType } = use(Context);
|
|
19
|
+
return (_jsxs(Select, { value: type ?? '', onValueChange: setType, children: [_jsx(SelectTrigger, { ...props, className: cn('not-prose w-fit', props.className), children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: items.map((type) => (_jsx(SelectItem, { value: type, children: type }, type))) })] }));
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-select.d.ts","sourceRoot":"","sources":["../../src/ui/server-select.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAejE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"server-select.d.ts","sourceRoot":"","sources":["../../src/ui/server-select.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAejE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,uDA+CzE"}
|
package/dist/ui/server-select.js
CHANGED
|
@@ -8,7 +8,7 @@ import { cn } from 'fumadocs-ui/utils/cn';
|
|
|
8
8
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from '../ui/components/dialog.js';
|
|
9
9
|
import { getUrl } from '../utils/server-url.js';
|
|
10
10
|
import { FormProvider, useController, useForm } from 'react-hook-form';
|
|
11
|
-
import {
|
|
11
|
+
import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
|
|
12
12
|
export default function ServerSelect(props) {
|
|
13
13
|
const { servers } = useApiContext();
|
|
14
14
|
const { server, setServer } = useServerSelectContext();
|
|
@@ -23,30 +23,37 @@ export default function ServerSelect(props) {
|
|
|
23
23
|
? server
|
|
24
24
|
? getUrl(server.url, server.variables)
|
|
25
25
|
: window.location.origin
|
|
26
|
-
: 'loading...' }), _jsxs(DialogContent, { ...props, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Server URL" }), _jsx(DialogDescription, { children: "The base URL of your API endpoint." })] }), _jsxs(Select, { value: server?.url, onValueChange: setServer, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: servers.map((item) => (_jsxs(SelectItem, { value: item.url, children: [item.url, _jsx("p", { className: "text-
|
|
26
|
+
: 'loading...' }), _jsxs(DialogContent, { ...props, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Server URL" }), _jsx(DialogDescription, { children: "The base URL of your API endpoint." })] }), _jsxs(Select, { value: server?.url, onValueChange: setServer, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: servers.map((item) => (_jsxs(SelectItem, { value: item.url, children: [_jsx("code", { className: "text-[13px]", children: item.url }), _jsx("p", { className: "text-fd-muted-foreground", children: item.description })] }, item.url))) })] }), server && server.variables && (_jsx(ServerSelectContent, { server: server }, server.url))] })] }));
|
|
27
27
|
}
|
|
28
|
-
function ServerSelectContent({ server
|
|
28
|
+
function ServerSelectContent({ server }) {
|
|
29
29
|
const { servers } = useApiContext();
|
|
30
30
|
const { setServerVariables } = useServerSelectContext();
|
|
31
31
|
const schema = servers.find((item) => item.url === server.url);
|
|
32
32
|
const form = useForm({
|
|
33
33
|
defaultValues: server.variables,
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
setServerVariables(
|
|
37
|
-
onClose();
|
|
35
|
+
const onChangeDebounced = useEffectEvent((values) => {
|
|
36
|
+
setServerVariables(values);
|
|
38
37
|
});
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
let timer = null;
|
|
40
|
+
return form.subscribe({
|
|
41
|
+
formState: {
|
|
42
|
+
values: true,
|
|
43
|
+
},
|
|
44
|
+
callback({ values }) {
|
|
45
|
+
if (timer !== null)
|
|
46
|
+
window.clearTimeout(timer);
|
|
47
|
+
timer = window.setTimeout(() => onChangeDebounced(values), 500);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `form` shouldn't be included
|
|
51
|
+
}, []);
|
|
39
52
|
if (!schema?.variables)
|
|
40
53
|
return;
|
|
41
|
-
return (_jsx(FormProvider, { ...form, children:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, children: [Object.entries(schema.variables).map(([key, variable]) => {
|
|
45
|
-
return (_jsxs("fieldset", { className: "flex flex-col gap-1", children: [_jsx("label", { className: cn(labelVariants()), htmlFor: key, children: key }), _jsx("p", { className: "text-xs text-fd-muted-foreground empty:hidden", children: variable.description }), _jsx(Field, { fieldName: key, variable: variable })] }, key));
|
|
46
|
-
}), _jsx("button", { type: "submit", className: cn(buttonVariants({
|
|
47
|
-
color: 'primary',
|
|
48
|
-
className: 'mt-2',
|
|
49
|
-
})), children: "Save" })] }) }));
|
|
54
|
+
return (_jsx(FormProvider, { ...form, children: _jsx("div", { className: "flex flex-col gap-4", children: Object.entries(schema.variables).map(([key, variable]) => {
|
|
55
|
+
return (_jsxs("fieldset", { className: "flex flex-col gap-1", children: [_jsx("label", { className: cn(labelVariants()), htmlFor: key, children: key }), _jsx("p", { className: "text-xs text-fd-muted-foreground empty:hidden", children: variable.description }), _jsx(Field, { fieldName: key, variable: variable })] }, key));
|
|
56
|
+
}) }) }));
|
|
50
57
|
}
|
|
51
58
|
function Field({ fieldName, variable, }) {
|
|
52
59
|
const { field } = useController({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/schema-to-string.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"schema-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/schema-to-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExE,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,UAAO,GAAG,MAAM,CA0D5E"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isNullable } from '../utils/schema.js';
|
|
2
1
|
export function schemaToString(schema, isRoot = true) {
|
|
3
2
|
if (schema === true)
|
|
4
3
|
return 'any';
|
|
@@ -47,3 +46,13 @@ export function schemaToString(schema, isRoot = true) {
|
|
|
47
46
|
}
|
|
48
47
|
return 'unknown';
|
|
49
48
|
}
|
|
49
|
+
function isNullable(schema) {
|
|
50
|
+
if (typeof schema === 'boolean')
|
|
51
|
+
return false;
|
|
52
|
+
if (Array.isArray(schema.type) && schema.type.includes('null'))
|
|
53
|
+
return true;
|
|
54
|
+
const combined = schema.anyOf ?? schema.oneOf ?? schema.allOf;
|
|
55
|
+
if (combined && combined.some(isNullable))
|
|
56
|
+
return true;
|
|
57
|
+
return schema.type === 'null';
|
|
58
|
+
}
|
package/dist/utils/schema.d.ts
CHANGED
|
@@ -9,6 +9,5 @@ type NoReferenceJSONSchema<T> = T extends (infer I)[] ? NoReference<I>[] : T ext
|
|
|
9
9
|
export type ParsedSchema = JSONSchema;
|
|
10
10
|
export type ResolvedSchema = NoReferenceJSONSchema<ParsedSchema>;
|
|
11
11
|
export declare function getPreferredType<B extends Record<string, unknown>>(body: B): keyof B | undefined;
|
|
12
|
-
export declare function isNullable(schema: ParsedSchema): boolean;
|
|
13
12
|
export {};
|
|
14
13
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,eAAe,GACvB,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAC3B,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,GACD,CAAC,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACjD,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GACf,CAAC,CAAC;AAER,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAEjE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,IAAI,EAAE,CAAC,GACN,MAAM,CAAC,GAAG,SAAS,CAIrB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,eAAe,GACvB,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAC3B,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,GACD,CAAC,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACjD,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GACf,CAAC,CAAC;AAER,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAEjE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,IAAI,EAAE,CAAC,GACN,MAAM,CAAC,GAAG,SAAS,CAIrB"}
|
package/dist/utils/schema.js
CHANGED
|
@@ -3,13 +3,3 @@ export function getPreferredType(body) {
|
|
|
3
3
|
return 'application/json';
|
|
4
4
|
return Object.keys(body)[0];
|
|
5
5
|
}
|
|
6
|
-
export function isNullable(schema) {
|
|
7
|
-
if (typeof schema === 'boolean')
|
|
8
|
-
return false;
|
|
9
|
-
if (Array.isArray(schema.type) && schema.type.includes('null'))
|
|
10
|
-
return true;
|
|
11
|
-
const combined = schema.anyOf ?? schema.oneOf ?? schema.allOf;
|
|
12
|
-
if (combined && combined.some(isNullable))
|
|
13
|
-
return true;
|
|
14
|
-
return schema.type === 'null';
|
|
15
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.5",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -46,10 +46,11 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@fumari/json-schema-to-typescript": "^1.1.3",
|
|
49
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
49
50
|
"@radix-ui/react-dialog": "^1.1.14",
|
|
50
51
|
"@radix-ui/react-select": "^2.2.5",
|
|
51
52
|
"@radix-ui/react-slot": "^1.2.3",
|
|
52
|
-
"@scalar/openapi-parser": "0.
|
|
53
|
+
"@scalar/openapi-parser": "0.13.0",
|
|
53
54
|
"ajv": "^8.17.1",
|
|
54
55
|
"class-variance-authority": "^0.7.1",
|
|
55
56
|
"github-slugger": "^2.0.0",
|
|
@@ -63,19 +64,19 @@
|
|
|
63
64
|
"shiki": "^3.4.2",
|
|
64
65
|
"tinyglobby": "^0.2.14",
|
|
65
66
|
"xml-js": "^1.6.11",
|
|
66
|
-
"fumadocs-core": "15.
|
|
67
|
-
"fumadocs-ui": "15.
|
|
67
|
+
"fumadocs-core": "15.5.0",
|
|
68
|
+
"fumadocs-ui": "15.5.0"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@scalar/api-client-react": "^1.3.
|
|
71
|
+
"@scalar/api-client-react": "^1.3.5",
|
|
71
72
|
"@types/js-yaml": "^4.0.9",
|
|
72
|
-
"@types/node": "22.15.
|
|
73
|
+
"@types/node": "22.15.28",
|
|
73
74
|
"@types/openapi-sampler": "^1.0.3",
|
|
74
|
-
"@types/react": "^19.1.
|
|
75
|
+
"@types/react": "^19.1.6",
|
|
75
76
|
"json-schema-typed": "^8.0.1",
|
|
76
|
-
"next": "15.3.
|
|
77
|
+
"next": "15.3.3",
|
|
77
78
|
"openapi-types": "^12.1.3",
|
|
78
|
-
"tailwindcss": "^4.1.
|
|
79
|
+
"tailwindcss": "^4.1.8",
|
|
79
80
|
"tsc-alias": "^1.8.16",
|
|
80
81
|
"eslint-config-custom": "0.0.0",
|
|
81
82
|
"tsconfig": "0.0.0"
|