fumadocs-openapi 10.2.0 → 10.2.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/dist/server/source-api.d.ts +5 -1
- package/dist/server/source-api.d.ts.map +1 -1
- package/dist/server/source-api.js +25 -20
- package/dist/ui/api-page.d.ts +1 -1
- package/dist/ui/api-page.d.ts.map +1 -1
- package/dist/ui/components/accordion.js +1 -1
- package/dist/ui/operation/client.js +1 -1
- package/dist/ui/schema/client.d.ts.map +1 -1
- package/dist/ui/schema/client.js +19 -19
- package/dist/ui/schema/index.d.ts.map +1 -1
- package/dist/ui/schema/index.js +12 -19
- package/dist/utils/pages/to-static-data.d.ts +10 -0
- package/dist/utils/pages/to-static-data.d.ts.map +1 -0
- package/dist/utils/pages/to-static-data.js +41 -0
- package/dist/utils/pages/to-text.d.ts.map +1 -1
- package/dist/utils/pages/to-text.js +2 -33
- package/dist/utils/schema-to-string.js +3 -3
- package/package.json +7 -8
|
@@ -2,6 +2,8 @@ import type { LoaderPlugin, MetaData, PageData, PageTreeTransformer, Source } fr
|
|
|
2
2
|
import type { OpenAPIServer } from '../server/create.js';
|
|
3
3
|
import type { SchemaToPagesOptions } from '../utils/pages/preset-auto.js';
|
|
4
4
|
import type { ApiPageProps } from '../ui/api-page.js';
|
|
5
|
+
import type { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
6
|
+
import type { TOCItemType } from 'fumadocs-core/toc';
|
|
5
7
|
declare module 'fumadocs-core/source' {
|
|
6
8
|
interface PageData {
|
|
7
9
|
/**
|
|
@@ -20,11 +22,13 @@ export interface InternalOpenAPIMeta {
|
|
|
20
22
|
export declare function openapiPlugin(): LoaderPlugin;
|
|
21
23
|
interface OpenAPIPageData extends PageData {
|
|
22
24
|
getAPIPageProps: () => ApiPageProps;
|
|
25
|
+
structuredData: StructuredData;
|
|
26
|
+
toc: TOCItemType[];
|
|
23
27
|
}
|
|
24
28
|
/**
|
|
25
29
|
* Generate virtual pages for Fumadocs Source API
|
|
26
30
|
*/
|
|
27
|
-
export declare function openapiSource(
|
|
31
|
+
export declare function openapiSource(server: OpenAPIServer, options?: SchemaToPagesOptions & {
|
|
28
32
|
baseDir?: string;
|
|
29
33
|
}): Promise<Source<{
|
|
30
34
|
metaData: MetaData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-api.d.ts","sourceRoot":"","sources":["../../src/server/source-api.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,MAAM,EAEP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAiB,QAAQ;QACvB;;WAEG;QACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;KAChC;CACF;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,YAAY,CAqC5C;AAED,UAAU,eAAgB,SAAQ,QAAQ;IACxC,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"source-api.d.ts","sourceRoot":"","sources":["../../src/server/source-api.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,MAAM,EAEP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAiB,QAAQ;QACvB;;WAEG;QACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;KAChC;CACF;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,YAAY,CAqC5C;AAED,UAAU,eAAgB,SAAQ,QAAQ;IACxC,eAAe,EAAE,MAAM,YAAY,CAAC;IACpC,cAAc,EAAE,cAAc,CAAC;IAC/B,GAAG,EAAE,WAAW,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,oBAAoB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,OAAO,CACR,MAAM,CAAC;IACL,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC,CACH,CAyCA;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,CAExD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MethodLabel } from '../ui/components/method-label.js';
|
|
3
|
+
import { toStaticData } from '../utils/pages/to-static-data.js';
|
|
3
4
|
/**
|
|
4
5
|
* Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
|
|
5
6
|
*/
|
|
@@ -31,32 +32,36 @@ export function openapiPlugin() {
|
|
|
31
32
|
/**
|
|
32
33
|
* Generate virtual pages for Fumadocs Source API
|
|
33
34
|
*/
|
|
34
|
-
export async function openapiSource(
|
|
35
|
+
export async function openapiSource(server, options = {}) {
|
|
35
36
|
const { baseDir = '' } = options;
|
|
36
37
|
const { createAutoPreset } = await import('../utils/pages/preset-auto.js');
|
|
37
38
|
const { fromServer } = await import('../utils/pages/builder.js');
|
|
38
39
|
const { toBody } = await import('../utils/pages/to-body.js');
|
|
39
40
|
const files = [];
|
|
40
|
-
const entries = await fromServer(
|
|
41
|
-
for (const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
const entries = await fromServer(server, createAutoPreset(options));
|
|
42
|
+
for (const [schemaId, list] of Object.entries(entries)) {
|
|
43
|
+
const dereferenced = (await server.getSchema(schemaId)).dereferenced;
|
|
44
|
+
for (const entry of list) {
|
|
45
|
+
const props = toBody(entry);
|
|
46
|
+
props.showDescription ?? (props.showDescription = true);
|
|
47
|
+
files.push({
|
|
48
|
+
type: 'page',
|
|
49
|
+
path: `${baseDir}/${entry.path}`,
|
|
50
|
+
data: {
|
|
51
|
+
...entry.info,
|
|
52
|
+
getAPIPageProps() {
|
|
53
|
+
return props;
|
|
54
|
+
},
|
|
55
|
+
...toStaticData(props, dereferenced),
|
|
56
|
+
_openapi: {
|
|
57
|
+
method: entry.type === 'operation' || entry.type === 'webhook'
|
|
58
|
+
? entry.item.method
|
|
59
|
+
: undefined,
|
|
60
|
+
webhook: entry.type === 'webhook',
|
|
61
|
+
},
|
|
51
62
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
? entry.item.method
|
|
55
|
-
: undefined,
|
|
56
|
-
webhook: entry.type === 'webhook',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
return {
|
|
62
67
|
files,
|
package/dist/ui/api-page.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface CreateAPIPageOptions {
|
|
|
54
54
|
/**
|
|
55
55
|
* @param generators - codegens for API example usages
|
|
56
56
|
*/
|
|
57
|
-
renderAPIExampleUsageTabs?: (generators: CodeUsageGenerator
|
|
57
|
+
renderAPIExampleUsageTabs?: (generators: CodeUsageGenerator[], ctx: RenderContext) => Awaitable<ReactNode>;
|
|
58
58
|
/**
|
|
59
59
|
* renderer of the entire page's layout (containing all operations & webhooks UI)
|
|
60
60
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-page.d.ts","sourceRoot":"","sources":["../../src/ui/api-page.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAmB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAcjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,C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,CAAC,CAAC;KAC5B,CAAC;IAEF,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,MAAM,GAAG,iBAAiB,CAAC;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC;CACjC;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,oBAAyB,GACjC,EAAE,CAAC,YAAY,CAAC,CAoFlB"}
|
|
@@ -16,5 +16,5 @@ export function AccordionHeader(props) {
|
|
|
16
16
|
return (_jsx(Primitive.Header, { ...props, className: cn('not-prose flex py-2 text-fd-foreground font-medium', props.className), children: props.children }));
|
|
17
17
|
}
|
|
18
18
|
export function AccordionTrigger(props) {
|
|
19
|
-
return (_jsxs(Primitive.Trigger, { ...props, className: cn('flex flex-1 items-center gap-1 text-start group/accordion focus-visible:outline-none', props.className), children: [_jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-data-[state=open]/accordion:rotate-90" }), props.children] }));
|
|
19
|
+
return (_jsxs(Primitive.Trigger, { ...props, className: cn('flex flex-1 items-center gap-1 text-start group/accordion focus-visible:outline-none', props.className), children: [_jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-focus-visible/accordion:text-fd-primary group-data-[state=open]/accordion:rotate-90" }), props.children] }));
|
|
20
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useCopyButton } from '
|
|
3
|
+
import { useCopyButton } from 'fumadocs-ui/utils/use-copy-button';
|
|
4
4
|
import { buttonVariants } from 'fumadocs-ui/components/ui/button';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
6
|
import { Check, Copy } from '../../ui/icons.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/ui/schema/client.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAc,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/ui/schema/client.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAc,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAyDrE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAEzB,SAAS,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,QAAgB,EAChB,EAAe,EACf,SAAS,GACV,EAAE,aAAa,2CAoBf"}
|
package/dist/ui/schema/client.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Badge } from '../../ui/components/method-label.js';
|
|
|
9
9
|
import { Popover, PopoverContent, PopoverTrigger, } from 'fumadocs-ui/components/ui/popover';
|
|
10
10
|
import { cn } from '../../utils/cn.js';
|
|
11
11
|
import { cva } from 'class-variance-authority';
|
|
12
|
-
const typeVariants = cva('text-sm text-start text-fd-muted-foreground
|
|
12
|
+
const typeVariants = cva('text-sm text-start text-fd-muted-foreground font-mono', {
|
|
13
13
|
variants: {
|
|
14
14
|
variant: {
|
|
15
15
|
trigger: 'underline hover:text-fd-accent-foreground data-[state=open]:text-fd-accent-foreground',
|
|
@@ -54,19 +54,14 @@ function SchemaUIProperty({ name, $type, overrides, }) {
|
|
|
54
54
|
const { refs } = useData();
|
|
55
55
|
const schema = refs[$type];
|
|
56
56
|
let type = schema.typeName;
|
|
57
|
-
if (schema.type === 'or'
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
type = (_jsx("span", { className: cn(typeVariants(), 'flex flex-row gap-2 items-center'), children: schema.items.map((item, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("span", { children: "&" }), renderRef({
|
|
66
|
-
pathName: name,
|
|
67
|
-
text: item.name,
|
|
68
|
-
$ref: item.$type,
|
|
69
|
-
})] }, item.$type))) }));
|
|
57
|
+
if ((schema.type === 'or' || schema.type === 'and') &&
|
|
58
|
+
schema.items.length > 0) {
|
|
59
|
+
type = renderRef({
|
|
60
|
+
text: schema.aliasName,
|
|
61
|
+
pathName: name,
|
|
62
|
+
$ref: $type,
|
|
63
|
+
inlineUnion: true,
|
|
64
|
+
});
|
|
70
65
|
}
|
|
71
66
|
if (schema.type === 'object' && schema.props.length > 0) {
|
|
72
67
|
type = renderRef({
|
|
@@ -78,7 +73,7 @@ function SchemaUIProperty({ name, $type, overrides, }) {
|
|
|
78
73
|
if (schema.type === 'array') {
|
|
79
74
|
type = renderRef({
|
|
80
75
|
text: schema.aliasName,
|
|
81
|
-
pathName:
|
|
76
|
+
pathName: name,
|
|
82
77
|
$ref: schema.item.$type,
|
|
83
78
|
});
|
|
84
79
|
}
|
|
@@ -109,19 +104,24 @@ function SchemaUIPopover({ initialPath, }) {
|
|
|
109
104
|
return (_jsxs(Fragment, { children: [i > 0 && '.', node] }, i));
|
|
110
105
|
}) }), _jsx(PropertyContext, { value: context, children: _jsx("div", { ref: ref, className: "px-2", children: _jsx(SchemaUIContent, { "$type": last.$ref }) }) })] }));
|
|
111
106
|
}
|
|
112
|
-
function RootRef({ text, $ref, pathName }) {
|
|
107
|
+
function RootRef({ text, $ref, pathName, inlineUnion }) {
|
|
113
108
|
const { refs } = useData();
|
|
114
109
|
const ref = useCallback((element) => {
|
|
115
110
|
if (!element || element.style.getPropertyValue('--initial-height'))
|
|
116
111
|
return;
|
|
117
112
|
element.style.setProperty('--initial-height', `${element.clientHeight}px`);
|
|
118
113
|
}, []);
|
|
114
|
+
const schema = refs[$ref];
|
|
115
|
+
if (inlineUnion && (schema.type === 'and' || schema.type === 'or')) {
|
|
116
|
+
const sep = schema.type === 'and' ? '&' : '|';
|
|
117
|
+
return (_jsx("span", { className: cn(typeVariants(), 'flex flex-row gap-2 items-center flex-wrap'), children: schema.items.map((item, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("span", { children: sep }), _jsx(RootRef, { pathName: pathName, text: item.name, "$ref": item.$type })] }, item.$type))) }));
|
|
118
|
+
}
|
|
119
119
|
if (!isExpandable(refs[$ref])) {
|
|
120
120
|
return _jsx("span", { className: cn(typeVariants()), children: text });
|
|
121
121
|
}
|
|
122
122
|
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { className: cn(typeVariants({ variant: 'trigger' })), children: text }), _jsx(PopoverContent, { ref: ref, className: "w-[600px] min-h-(--initial-height,0) max-h-[460px] p-0", children: _jsx(SchemaUIPopover, { initialPath: [
|
|
123
123
|
{
|
|
124
|
-
name: pathName,
|
|
124
|
+
name: (_jsxs(_Fragment, { children: [pathName, schema.type === 'array' && '[]'] })),
|
|
125
125
|
$ref: $ref,
|
|
126
126
|
},
|
|
127
127
|
] }) })] }));
|
|
@@ -135,10 +135,10 @@ function LinkRef({ $ref, pathName, onInsert, text, }) {
|
|
|
135
135
|
onInsert(pathName, $ref);
|
|
136
136
|
}, children: text }));
|
|
137
137
|
}
|
|
138
|
-
function Property({ name, type, required, deprecated, nested = false, ...props }) {
|
|
138
|
+
function Property({ name, type, required, deprecated, nested = false, className, ...props }) {
|
|
139
139
|
return (_jsxs("div", { className: cn('text-sm border-t', nested
|
|
140
140
|
? 'p-3 border-x bg-fd-card last:rounded-b-xl first:rounded-tr-xl last:border-b'
|
|
141
|
-
: 'py-4 first:border-t-0',
|
|
141
|
+
: 'py-4 first:border-t-0', className), children: [_jsxs("div", { className: "flex flex-wrap items-center gap-3 not-prose", children: [_jsxs("span", { className: "font-medium font-mono text-fd-primary", children: [name, required ? (_jsx("span", { className: "text-red-400", children: "*" })) : (_jsx("span", { className: "text-fd-muted-foreground", children: "?" }))] }), typeof type === 'string' ? (_jsx("span", { className: "text-sm font-mono text-fd-muted-foreground", children: type })) : (type), deprecated && (_jsx(Badge, { color: "yellow", className: "ms-auto text-xs", children: "Deprecated" }))] }), _jsx("div", { className: "prose-no-margin pt-2.5 empty:hidden", children: props.children })] }));
|
|
142
142
|
}
|
|
143
143
|
function isExpandable(schema) {
|
|
144
144
|
return schema.type !== 'primitive';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/schema/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IAEvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAChC,CACI;IACE,IAAI,EAAE,WAAW,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AO,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAClC;AAED,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,GAAG,OAAO,EACX,EAAE,eAAe,GAAG;IACnB,GAAG,EAAE,aAAa,CAAC;CACpB,8IAWA;AAED,wBAAgB,gBAAgB,CAC9B,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,eAAe,EAC9C,GAAG,EAAE,aAAa,GACjB,qBAAqB,CA+RvB"}
|
package/dist/ui/schema/index.js
CHANGED
|
@@ -127,23 +127,14 @@ export function generateSchemaUI({ root, readOnly, writeOnly }, ctx) {
|
|
|
127
127
|
...base(schema),
|
|
128
128
|
};
|
|
129
129
|
refs[id] = out;
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
oneOf: undefined,
|
|
139
|
-
});
|
|
140
|
-
out.items.push({
|
|
141
|
-
name: refs[$oneOf].aliasName,
|
|
142
|
-
$type: $oneOf,
|
|
143
|
-
}, {
|
|
144
|
-
name: refs[$anyOf].aliasName,
|
|
145
|
-
$type: $anyOf,
|
|
146
|
-
});
|
|
130
|
+
for (const omit of ['anyOf', 'oneOf']) {
|
|
131
|
+
const $type = `${id}_omit:${omit}`;
|
|
132
|
+
scanRefs($type, { ...schema, [omit]: undefined });
|
|
133
|
+
out.items.push({
|
|
134
|
+
name: refs[$type].aliasName,
|
|
135
|
+
$type,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
147
138
|
return;
|
|
148
139
|
}
|
|
149
140
|
// display both `oneOf` & `anyOf` as OR for simplified overview
|
|
@@ -158,7 +149,8 @@ export function generateSchemaUI({ root, readOnly, writeOnly }, ctx) {
|
|
|
158
149
|
for (const item of union) {
|
|
159
150
|
if (typeof item !== 'object' || !isVisible(item))
|
|
160
151
|
continue;
|
|
161
|
-
const
|
|
152
|
+
const itemId = getSchemaId(item);
|
|
153
|
+
const key = `${id}_extends:${itemId}`;
|
|
162
154
|
scanRefs(key, {
|
|
163
155
|
...schema,
|
|
164
156
|
oneOf: undefined,
|
|
@@ -171,7 +163,8 @@ export function generateSchemaUI({ root, readOnly, writeOnly }, ctx) {
|
|
|
171
163
|
});
|
|
172
164
|
out.items.push({
|
|
173
165
|
$type: key,
|
|
174
|
-
name: refs[
|
|
166
|
+
name: refs[itemId]?.aliasName ??
|
|
167
|
+
schemaToString(item, ctx.schema, FormatFlags.UseAlias),
|
|
175
168
|
});
|
|
176
169
|
}
|
|
177
170
|
return;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NoReference } from '../../utils/schema.js';
|
|
2
|
+
import type { Document } from '../../types.js';
|
|
3
|
+
import type { TOCItemType } from 'fumadocs-core/toc';
|
|
4
|
+
import type { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
5
|
+
import type { ApiPageProps } from '../../ui/index.js';
|
|
6
|
+
export declare function toStaticData(page: ApiPageProps, dereferenced: NoReference<Document>): {
|
|
7
|
+
toc: TOCItemType[];
|
|
8
|
+
structuredData: StructuredData;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=to-static-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-static-data.d.ts","sourceRoot":"","sources":["../../../src/utils/pages/to-static-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,SAAS,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,wBAAgB,YAAY,CAC1B,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,WAAW,CAAC,QAAQ,CAAC,GAClC;IACD,GAAG,EAAE,WAAW,EAAE,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;CAChC,CA6CA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Slugger from 'github-slugger';
|
|
2
|
+
import { idToTitle } from '../../utils/id-to-title.js';
|
|
3
|
+
export function toStaticData(page, dereferenced) {
|
|
4
|
+
const slugger = new Slugger();
|
|
5
|
+
const toc = [];
|
|
6
|
+
const structuredData = { headings: [], contents: [] };
|
|
7
|
+
function pathItem(item, defaultTitle) {
|
|
8
|
+
if (page.showTitle && item.operationId) {
|
|
9
|
+
const title = item.summary ||
|
|
10
|
+
(item.operationId ? idToTitle(item.operationId) : defaultTitle);
|
|
11
|
+
const id = slugger.slug(title);
|
|
12
|
+
toc.push({
|
|
13
|
+
depth: 2,
|
|
14
|
+
title,
|
|
15
|
+
url: `#${id}`,
|
|
16
|
+
});
|
|
17
|
+
structuredData.headings.push({
|
|
18
|
+
content: title,
|
|
19
|
+
id,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (item.description)
|
|
23
|
+
structuredData.contents.push({
|
|
24
|
+
content: item.description,
|
|
25
|
+
heading: structuredData.headings.at(-1)?.id,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
for (const item of page.operations ?? []) {
|
|
29
|
+
const operation = dereferenced.paths?.[item.path]?.[item.method];
|
|
30
|
+
if (!operation)
|
|
31
|
+
continue;
|
|
32
|
+
pathItem(operation, item.path);
|
|
33
|
+
}
|
|
34
|
+
for (const item of page.webhooks ?? []) {
|
|
35
|
+
const webhook = dereferenced.webhooks?.[item.name]?.[item.method];
|
|
36
|
+
if (!webhook)
|
|
37
|
+
continue;
|
|
38
|
+
pathItem(webhook, item.name);
|
|
39
|
+
}
|
|
40
|
+
return { toc, structuredData };
|
|
41
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-text.d.ts","sourceRoot":"","sources":["../../../src/utils/pages/to-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"to-text.d.ts","sourceRoot":"","sources":["../../../src/utils/pages/to-text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IAEJ;;;;OAIG;IACH,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,eAAe,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACxC;AAED,wBAAgB,MAAM,CACpB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,kBAAuB,UAqEjC;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CA+BR;AAED,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,SAAS,GAAG,SAAS,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { idToTitle } from '../../utils/id-to-title.js';
|
|
2
1
|
import { dump } from 'js-yaml';
|
|
3
|
-
import Slugger from 'github-slugger';
|
|
4
2
|
import { removeUndefined } from '../../utils/remove-undefined.js';
|
|
3
|
+
import { toStaticData } from '../../utils/pages/to-static-data.js';
|
|
5
4
|
export function toText(entry, processed, options = {}) {
|
|
6
5
|
switch (entry.type) {
|
|
7
6
|
case 'operation':
|
|
@@ -90,7 +89,7 @@ function generatePage(schemaId, processed, pageProps, options, context) {
|
|
|
90
89
|
webhook: true,
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
|
-
const data =
|
|
92
|
+
const data = toStaticData(page, processed.dereferenced);
|
|
94
93
|
const content = [];
|
|
95
94
|
if (options.description && includeDescription)
|
|
96
95
|
content.push(options.description);
|
|
@@ -107,36 +106,6 @@ function generatePage(schemaId, processed, pageProps, options, context) {
|
|
|
107
106
|
},
|
|
108
107
|
}, content.join('\n\n'), options);
|
|
109
108
|
}
|
|
110
|
-
function generateStaticData(dereferenced, props) {
|
|
111
|
-
const slugger = new Slugger();
|
|
112
|
-
const toc = [];
|
|
113
|
-
const structuredData = { headings: [], contents: [] };
|
|
114
|
-
for (const item of props.operations ?? []) {
|
|
115
|
-
const operation = dereferenced.paths?.[item.path]?.[item.method];
|
|
116
|
-
if (!operation)
|
|
117
|
-
continue;
|
|
118
|
-
if (props.showTitle && operation.operationId) {
|
|
119
|
-
const title = operation.summary ||
|
|
120
|
-
(operation.operationId ? idToTitle(operation.operationId) : item.path);
|
|
121
|
-
const id = slugger.slug(title);
|
|
122
|
-
toc.push({
|
|
123
|
-
depth: 2,
|
|
124
|
-
title,
|
|
125
|
-
url: `#${id}`,
|
|
126
|
-
});
|
|
127
|
-
structuredData.headings.push({
|
|
128
|
-
content: title,
|
|
129
|
-
id,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (operation.description)
|
|
133
|
-
structuredData.contents.push({
|
|
134
|
-
content: operation.description,
|
|
135
|
-
heading: structuredData.headings.at(-1)?.id,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return { toc, structuredData };
|
|
139
|
-
}
|
|
140
109
|
function pageContent({ showTitle, showDescription, document, webhooks, operations, }) {
|
|
141
110
|
const propStrs = [`document={${JSON.stringify(document)}}`];
|
|
142
111
|
// filter extra properties in props
|
|
@@ -27,9 +27,9 @@ export function schemaToString(value, ctx, flags = FormatFlags.None) {
|
|
|
27
27
|
if ((flags & FormatFlags.UseAlias) === FormatFlags.UseAlias) {
|
|
28
28
|
if (schema.title)
|
|
29
29
|
return schema.title;
|
|
30
|
-
const ref = ctx?.getRawRef(schema);
|
|
31
|
-
if (ref)
|
|
32
|
-
return ref.
|
|
30
|
+
const ref = ctx?.getRawRef(schema)?.split('/');
|
|
31
|
+
if (ref && ref.length > 0)
|
|
32
|
+
return ref[ref.length - 1];
|
|
33
33
|
}
|
|
34
34
|
if (Array.isArray(schema.type)) {
|
|
35
35
|
return union(schema.type.map((type) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.1",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
55
55
|
"@radix-ui/react-select": "^2.2.6",
|
|
56
56
|
"@radix-ui/react-slot": "^1.2.4",
|
|
57
|
-
"@scalar/json-magic": "^0.8.
|
|
58
|
-
"@scalar/openapi-parser": "0.23.
|
|
57
|
+
"@scalar/json-magic": "^0.8.8",
|
|
58
|
+
"@scalar/openapi-parser": "0.23.9",
|
|
59
59
|
"ajv": "^8.17.1",
|
|
60
60
|
"class-variance-authority": "^0.7.1",
|
|
61
61
|
"github-slugger": "^2.0.0",
|
|
@@ -67,11 +67,10 @@
|
|
|
67
67
|
"remark": "^15.0.1",
|
|
68
68
|
"remark-rehype": "^11.1.2",
|
|
69
69
|
"tailwind-merge": "^3.4.0",
|
|
70
|
-
"xml-js": "^1.6.11"
|
|
71
|
-
"@fumadocs/ui": "16.3.0"
|
|
70
|
+
"xml-js": "^1.6.11"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
|
-
"@scalar/api-client-react": "^1.3.
|
|
73
|
+
"@scalar/api-client-react": "^1.3.58",
|
|
75
74
|
"@types/js-yaml": "^4.0.9",
|
|
76
75
|
"@types/node": "24.10.2",
|
|
77
76
|
"@types/openapi-sampler": "^1.0.3",
|
|
@@ -81,8 +80,8 @@
|
|
|
81
80
|
"tailwindcss": "^4.1.18",
|
|
82
81
|
"tsc-alias": "^1.8.16",
|
|
83
82
|
"eslint-config-custom": "0.0.0",
|
|
84
|
-
"fumadocs-
|
|
85
|
-
"fumadocs-
|
|
83
|
+
"fumadocs-ui": "16.3.1",
|
|
84
|
+
"fumadocs-core": "16.3.1",
|
|
86
85
|
"tsconfig": "0.0.0"
|
|
87
86
|
},
|
|
88
87
|
"peerDependencies": {
|