fumadocs-openapi 8.1.6 → 8.1.7
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/media/adapter.d.ts +26 -1
- package/dist/media/adapter.d.ts.map +1 -1
- package/dist/media/adapter.js +124 -7
- package/dist/playground/client.d.ts +1 -3
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +2 -1
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +1 -2
- package/dist/render/api-page.d.ts.map +1 -1
- package/dist/render/api-page.js +12 -6
- package/dist/render/operation/api-example.d.ts.map +1 -1
- package/dist/render/operation/api-example.js +1 -1
- package/dist/render/renderer.js +1 -1
- package/dist/requests/python.d.ts.map +1 -1
- package/dist/requests/python.js +9 -15
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/client.d.ts +0 -1
- package/dist/ui/client.d.ts.map +1 -1
- package/dist/ui/client.js +0 -1
- package/dist/ui/contexts/api.d.ts +8 -7
- package/dist/ui/contexts/api.d.ts.map +1 -1
- package/dist/ui/contexts/api.js +14 -6
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/lazy.d.ts +14 -0
- package/dist/ui/lazy.d.ts.map +1 -0
- package/dist/ui/lazy.js +7 -0
- package/dist/utils/input-to-string.d.ts.map +1 -1
- package/dist/utils/input-to-string.js +2 -1
- package/package.json +3 -3
- package/dist/media/adapter.client.d.ts +0 -8
- package/dist/media/adapter.client.d.ts.map +0 -1
- package/dist/media/adapter.client.js +0 -118
- package/dist/playground/client.lazy.d.ts +0 -2
- package/dist/playground/client.lazy.d.ts.map +0 -1
- package/dist/playground/client.lazy.js +0 -3
- package/dist/ui/contexts/code-example.lazy.d.ts +0 -12
- package/dist/ui/contexts/code-example.lazy.d.ts.map +0 -1
- package/dist/ui/contexts/code-example.lazy.js +0 -5
package/dist/media/adapter.d.ts
CHANGED
|
@@ -32,6 +32,31 @@ export interface MediaAdapter {
|
|
|
32
32
|
*/
|
|
33
33
|
generateExample: (data: RequestData, ctx: MediaContext) => string | undefined;
|
|
34
34
|
}
|
|
35
|
-
export declare const defaultAdapters:
|
|
35
|
+
export declare const defaultAdapters: {
|
|
36
|
+
'application/json': {
|
|
37
|
+
encode(data: RequestData): string;
|
|
38
|
+
generateExample(data: RequestData, ctx: MediaContext): string | undefined;
|
|
39
|
+
};
|
|
40
|
+
'application/xml': {
|
|
41
|
+
encode(data: RequestData): Promise<any>;
|
|
42
|
+
generateExample(data: RequestData, ctx: MediaContext): string | undefined;
|
|
43
|
+
};
|
|
44
|
+
'application/x-ndjson': {
|
|
45
|
+
encode(data: RequestData): string;
|
|
46
|
+
generateExample(data: RequestData, ctx: MediaContext): string | undefined;
|
|
47
|
+
};
|
|
48
|
+
'application/x-www-form-urlencoded': {
|
|
49
|
+
encode(data: RequestData): URLSearchParams;
|
|
50
|
+
generateExample(data: RequestData, ctx: MediaContext): string | undefined;
|
|
51
|
+
};
|
|
52
|
+
'multipart/form-data': {
|
|
53
|
+
encode(data: RequestData): FormData;
|
|
54
|
+
generateExample(data: RequestData, ctx: MediaContext): string | undefined;
|
|
55
|
+
};
|
|
56
|
+
'application/octet-stream': {
|
|
57
|
+
encode(data: RequestData): BodyInit;
|
|
58
|
+
generateExample(): undefined;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
36
61
|
export {};
|
|
37
62
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/media/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/media/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,UAAU,SAAS;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAED,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,iBAAiB,GACjB;IACE,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,CAAC;AAEN,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5D;;;;;;;;OAQG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,KAAK,MAAM,GAAG,SAAS,CAAC;CAC/E;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;mCAwHF,QAAQ;;;CAOM,CAAC"}
|
package/dist/media/adapter.js
CHANGED
|
@@ -1,9 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { inputToString } from '../utils/input-to-string.js';
|
|
2
3
|
export const defaultAdapters = {
|
|
3
|
-
'application/json':
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
'application/json': {
|
|
5
|
+
encode(data) {
|
|
6
|
+
return JSON.stringify(data.body);
|
|
7
|
+
},
|
|
8
|
+
generateExample(data, ctx) {
|
|
9
|
+
return str(data.body, 'json', ctx);
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
'application/xml': {
|
|
13
|
+
async encode(data) {
|
|
14
|
+
// @ts-expect-error -- untyped
|
|
15
|
+
const { js2xml } = await import('xml-js/lib/js2xml');
|
|
16
|
+
return js2xml(data.body, {
|
|
17
|
+
compact: true,
|
|
18
|
+
spaces: 2,
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
generateExample(data, ctx) {
|
|
22
|
+
return str(data.body, 'xml', ctx);
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
'application/x-ndjson': {
|
|
26
|
+
encode(data) {
|
|
27
|
+
if (Array.isArray(data.body)) {
|
|
28
|
+
return data.body.map((v) => JSON.stringify(v)).join('\n');
|
|
29
|
+
}
|
|
30
|
+
return JSON.stringify(data.body);
|
|
31
|
+
},
|
|
32
|
+
generateExample(data, ctx) {
|
|
33
|
+
return str(data.body, 'ndjson', ctx);
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
'application/x-www-form-urlencoded': {
|
|
37
|
+
encode(data) {
|
|
38
|
+
if (typeof data.body !== 'object')
|
|
39
|
+
throw new Error(`Input value must be object, received: ${typeof data.body}`);
|
|
40
|
+
const params = new URLSearchParams();
|
|
41
|
+
for (const key in data.body) {
|
|
42
|
+
params.set(key, String(data.body[key]));
|
|
43
|
+
}
|
|
44
|
+
return params;
|
|
45
|
+
},
|
|
46
|
+
generateExample(data, ctx) {
|
|
47
|
+
if (ctx.lang === 'js') {
|
|
48
|
+
return `const body = new URLSearchParams(${JSON.stringify(data.body, null, 2)})`;
|
|
49
|
+
}
|
|
50
|
+
return str(data.body, 'url', ctx);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
'multipart/form-data': {
|
|
54
|
+
encode(data) {
|
|
55
|
+
const formData = new FormData();
|
|
56
|
+
const body = data.body;
|
|
57
|
+
if (typeof body !== 'object' || !body) {
|
|
58
|
+
throw new Error(`Unsupported body type: ${typeof body}, expected: object`);
|
|
59
|
+
}
|
|
60
|
+
for (const key in body) {
|
|
61
|
+
const prop = body[key];
|
|
62
|
+
if (typeof prop === 'object' && prop instanceof File) {
|
|
63
|
+
formData.set(key, prop);
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(prop) && prop.every((item) => item instanceof File)) {
|
|
66
|
+
for (const item of prop) {
|
|
67
|
+
formData.append(key, item);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (prop && !(prop instanceof File)) {
|
|
71
|
+
formData.set(key, JSON.stringify(prop));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return formData;
|
|
75
|
+
},
|
|
76
|
+
generateExample(data, ctx) {
|
|
77
|
+
if (ctx.lang === 'python') {
|
|
78
|
+
return `body = ${JSON.stringify(data.body, null, 2)}`;
|
|
79
|
+
}
|
|
80
|
+
const s = [];
|
|
81
|
+
if (ctx.lang === 'js') {
|
|
82
|
+
s.push(`const body = new FormData();`);
|
|
83
|
+
for (const [key, value] of Object.entries(data.body)) {
|
|
84
|
+
s.push(`body.set(${key}, ${inputToString(value)})`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (ctx.lang === 'go' && 'addImport' in ctx) {
|
|
88
|
+
ctx.addImport('mime/multipart');
|
|
89
|
+
ctx.addImport('bytes');
|
|
90
|
+
s.push('body := new(bytes.Buffer)');
|
|
91
|
+
s.push('mp := multipart.NewWriter(payload)');
|
|
92
|
+
for (const [key, value] of Object.entries(data.body)) {
|
|
93
|
+
s.push(`mp.WriteField("${key}", ${inputToString(value, 'json', 'backtick')})`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (s.length > 0)
|
|
97
|
+
return s.join('\n');
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
'application/octet-stream': {
|
|
101
|
+
encode(data) {
|
|
102
|
+
return data.body;
|
|
103
|
+
},
|
|
104
|
+
generateExample() {
|
|
105
|
+
// not supported
|
|
106
|
+
return undefined;
|
|
107
|
+
},
|
|
108
|
+
},
|
|
9
109
|
};
|
|
110
|
+
function str(init, format, ctx) {
|
|
111
|
+
if (ctx.lang === 'js') {
|
|
112
|
+
if (format === 'json') {
|
|
113
|
+
return `const body = JSON.stringify(${JSON.stringify(init, null, 2)})`;
|
|
114
|
+
}
|
|
115
|
+
return `const body = ${inputToString(init, format, 'backtick')}`;
|
|
116
|
+
}
|
|
117
|
+
if (ctx.lang === 'python') {
|
|
118
|
+
if (format === 'json')
|
|
119
|
+
return `body = ${JSON.stringify(init, null, 2)}`;
|
|
120
|
+
return `body = ${inputToString(init, format, 'python')}`;
|
|
121
|
+
}
|
|
122
|
+
if (ctx.lang === 'go' && 'addImport' in ctx) {
|
|
123
|
+
ctx.addImport('strings');
|
|
124
|
+
return `body := strings.NewReader(${inputToString(init, format, 'backtick')})`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -3,7 +3,6 @@ import type { ControllerFieldState, ControllerRenderProps, FieldPath, UseFormSta
|
|
|
3
3
|
import type { FetchResult } from '../playground/fetcher.js';
|
|
4
4
|
import type { ParameterField, RequestSchema } from '../playground/index.js';
|
|
5
5
|
import type { Security } from '../utils/get-security.js';
|
|
6
|
-
import type { MediaAdapter } from '../media/adapter.js';
|
|
7
6
|
interface FormValues {
|
|
8
7
|
authorization: string | {
|
|
9
8
|
username: string;
|
|
@@ -52,8 +51,7 @@ export type ClientProps = HTMLAttributes<HTMLFormElement> & {
|
|
|
52
51
|
data: FetchResult;
|
|
53
52
|
}>;
|
|
54
53
|
}>;
|
|
55
|
-
mediaAdapters: Record<string, MediaAdapter>;
|
|
56
54
|
};
|
|
57
|
-
export default function Client({ route, method, authorization, parameters, body, fields, references, proxyUrl,
|
|
55
|
+
export default function Client({ route, method, authorization, parameters, body, fields, references, proxyUrl, components: { ResultDisplay }, ...rest }: ClientProps): import("react/jsx-runtime").JSX.Element;
|
|
58
56
|
export {};
|
|
59
57
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/playground/client.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EAAE,EAEP,KAAK,cAAc,EAEnB,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAC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aAAoC,EAAO,EACzD,GAAG,IAAI,EACR,EAAE,WAAW,2CAkHb"}
|
|
@@ -28,11 +28,12 @@ function toRequestData(method, mediaType, value) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
const ServerSelect = lazy(() => import('../ui/server-select.js'));
|
|
31
|
-
export default function Client({ route, method = 'GET', authorization, parameters, body, fields, references, proxyUrl,
|
|
31
|
+
export default function Client({ route, method = 'GET', authorization, parameters, body, fields, references, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...rest }) {
|
|
32
32
|
const { server } = useServerSelectContext();
|
|
33
33
|
const requestData = useRequestData();
|
|
34
34
|
const fieldInfoMap = useMemo(() => new Map(), []);
|
|
35
35
|
const authInfo = usePersistentAuthInfo(authorization);
|
|
36
|
+
const { mediaAdapters } = useApiContext();
|
|
36
37
|
const defaultValues = useMemo(() => ({
|
|
37
38
|
authorization: authInfo.info,
|
|
38
39
|
path: requestData.data.path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playground/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC;AAQzC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B;AAED,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,GACP,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playground/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC;AAQzC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B;AAED,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,GACP,EAAE,kBAAkB,oDAuCpB"}
|
package/dist/playground/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getPreferredType } from '../utils/schema.js';
|
|
3
3
|
import { getSecurities } from '../utils/get-security.js';
|
|
4
|
-
import { ClientLazy } from '../
|
|
4
|
+
import { ClientLazy } from '../ui/lazy.js';
|
|
5
5
|
export async function APIPlayground({ path, method, ctx, client, }) {
|
|
6
6
|
let currentId = 0;
|
|
7
7
|
const bodyContent = method.requestBody?.content;
|
|
@@ -17,7 +17,6 @@ export async function APIPlayground({ path, method, ctx, client, }) {
|
|
|
17
17
|
authorization: getAuthorizationField(method, ctx),
|
|
18
18
|
method: method.method,
|
|
19
19
|
route: path,
|
|
20
|
-
mediaAdapters: ctx.mediaAdapters,
|
|
21
20
|
parameters: method.parameters?.map((v) => ({
|
|
22
21
|
name: v.name,
|
|
23
22
|
in: v.in,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-page.d.ts","sourceRoot":"","sources":["../../src/render/api-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAIlC,KAAK,mBAAmB,GAAG,IAAI,CAC7B,OAAO,CAAC,aAAa,CAAC,EACpB,cAAc,GACd,0BAA0B,GAC1B,qBAAqB,GACrB,UAAU,GACV,oBAAoB,GACpB,mBAAmB,GACnB,eAAe,CAClB,CAAC;AAEF,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE7B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB;;OAEG;IACH,YAAY,CA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,CAAC;IACb,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC;CACjC;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,oDAsEhD;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,mBAAmB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACzB,GACL,OAAO,CAAC,aAAa,CAAC,CA0CxB"}
|
package/dist/render/api-page.js
CHANGED
|
@@ -5,7 +5,6 @@ import { createMethod } from '../server/create-method.js';
|
|
|
5
5
|
import { createRenders } from '../render/renderer.js';
|
|
6
6
|
import { processDocument, } from '../utils/process-document.js';
|
|
7
7
|
import { getUrl } from '../utils/server-url.js';
|
|
8
|
-
import { defaultAdapters } from '../media/adapter.js';
|
|
9
8
|
export async function APIPage(props) {
|
|
10
9
|
const { operations, hasHead = true, webhooks, disableCache = process.env.NODE_ENV === 'development', } = props;
|
|
11
10
|
const processed = await processDocument(props.document, disableCache);
|
|
@@ -14,19 +13,19 @@ export async function APIPage(props) {
|
|
|
14
13
|
return (_jsxs(ctx.renderer.Root, { ctx: ctx, children: [operations?.map((item) => {
|
|
15
14
|
const pathItem = document.paths?.[item.path];
|
|
16
15
|
if (!pathItem)
|
|
17
|
-
|
|
16
|
+
throw new Error(`[Fumadocs OpenAPI] Path not found in OpenAPI schema: ${item.path}`);
|
|
18
17
|
const operation = pathItem[item.method];
|
|
19
18
|
if (!operation)
|
|
20
|
-
|
|
19
|
+
throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in operation: ${item.path}`);
|
|
21
20
|
const method = createMethod(item.method, pathItem, operation);
|
|
22
21
|
return (_jsx(Operation, { method: method, path: item.path, ctx: ctx, hasHead: hasHead }, `${item.path}:${item.method}`));
|
|
23
22
|
}), webhooks?.map((item) => {
|
|
24
23
|
const webhook = document.webhooks?.[item.name];
|
|
25
24
|
if (!webhook)
|
|
26
|
-
|
|
25
|
+
throw new Error(`[Fumadocs OpenAPI] Webhook not found in OpenAPI schema: ${item.name}`);
|
|
27
26
|
const hook = webhook[item.method];
|
|
28
27
|
if (!hook)
|
|
29
|
-
|
|
28
|
+
throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in webhook: ${item.name}`);
|
|
30
29
|
const method = createMethod(item.method, webhook, hook);
|
|
31
30
|
return (_jsx(Operation, { type: "webhook", method: method, ctx: {
|
|
32
31
|
...ctx,
|
|
@@ -57,7 +56,14 @@ export async function getContext(schema, options = {}) {
|
|
|
57
56
|
: {}),
|
|
58
57
|
servers,
|
|
59
58
|
mediaAdapters: {
|
|
60
|
-
...
|
|
59
|
+
...{
|
|
60
|
+
'application/octet-stream': true,
|
|
61
|
+
'application/json': true,
|
|
62
|
+
'multipart/form-data': true,
|
|
63
|
+
'application/xml': true,
|
|
64
|
+
'application/x-ndjson': true,
|
|
65
|
+
'application/x-www-form-urlencoded': true,
|
|
66
|
+
},
|
|
61
67
|
...options.mediaAdapters,
|
|
62
68
|
},
|
|
63
69
|
slugger: new Slugger(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-example.d.ts","sourceRoot":"","sources":["../../../src/render/operation/api-example.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"api-example.d.ts","sourceRoot":"","sources":["../../../src/render/operation/api-example.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAM3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAqBtD,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAeA;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,aAAa,GACjB,eAAe,EAAE,CA8BnB;AAED,wBAAsB,UAAU,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;IAC3C,GAAG,EAAE,aAAa,CAAC;CACpB,oDAmCA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Markdown } from '../../render/markdown.js';
|
|
3
3
|
import { CodeBlock } from '../../render/codeblock.js';
|
|
4
|
-
import { CodeExample, CodeExampleProvider
|
|
4
|
+
import { CodeExample, CodeExampleProvider } from '../../ui/lazy.js';
|
|
5
5
|
import { getPreferredType } from '../../utils/schema.js';
|
|
6
6
|
import { getRequestData } from '../../render/operation/get-request-data.js';
|
|
7
7
|
import { sample } from 'openapi-sampler';
|
package/dist/render/renderer.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
|
|
3
3
|
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
|
|
4
4
|
import { API, APIExample, APIInfo, ObjectCollapsible, Property, Root, } from '../ui/index.js';
|
|
5
5
|
import { APIPlayground } from '../playground/index.js';
|
|
6
|
-
import { CodeExampleSelector } from '../ui/
|
|
6
|
+
import { CodeExampleSelector } from '../ui/lazy.js';
|
|
7
7
|
export function createRenders() {
|
|
8
8
|
return {
|
|
9
9
|
Root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,eAAO,MAAM,SAAS,EAAE,eAkCvB,CAAC"}
|
package/dist/requests/python.js
CHANGED
|
@@ -4,22 +4,16 @@ export const generator = (url, data, { mediaAdapters }) => {
|
|
|
4
4
|
const headers = { ...data.header };
|
|
5
5
|
const params = [`"${data.method}"`, 'url'];
|
|
6
6
|
let body;
|
|
7
|
-
if (data.body && data.bodyMediaType) {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (data.body && data.bodyMediaType && data.bodyMediaType in mediaAdapters) {
|
|
8
|
+
headers['Content-Type'] = data.bodyMediaType;
|
|
9
|
+
body = mediaAdapters[data.bodyMediaType].generateExample(data, {
|
|
10
|
+
lang: 'python',
|
|
11
|
+
});
|
|
12
|
+
if (body && data.bodyMediaType === 'application/json') {
|
|
13
|
+
params.push('json = body');
|
|
10
14
|
}
|
|
11
|
-
else if (
|
|
12
|
-
|
|
13
|
-
params.push(`data = ${JSON.stringify(data.body, null, 2)}`);
|
|
14
|
-
}
|
|
15
|
-
else if (data.bodyMediaType in mediaAdapters) {
|
|
16
|
-
headers['Content-Type'] = data.bodyMediaType;
|
|
17
|
-
body = mediaAdapters[data.bodyMediaType].generateExample(data, {
|
|
18
|
-
lang: 'python',
|
|
19
|
-
});
|
|
20
|
-
if (body) {
|
|
21
|
-
params.push('data = body');
|
|
22
|
-
}
|
|
15
|
+
else if (body) {
|
|
16
|
+
params.push('data = body');
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
19
|
if (Object.keys(headers).length > 0) {
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AACrC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,yBA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Y,GAAG,IAAI,CAAC,CAAC;CACpD"}
|
package/dist/ui/client.d.ts
CHANGED
package/dist/ui/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAOA,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CAgChE"}
|
package/dist/ui/client.js
CHANGED
|
@@ -4,7 +4,6 @@ import { useCopyButton } from 'fumadocs-ui/utils/use-copy-button';
|
|
|
4
4
|
import { buttonVariants } from 'fumadocs-ui/components/ui/button';
|
|
5
5
|
import { cn } from 'fumadocs-ui/utils/cn';
|
|
6
6
|
import { Check, Copy } from '../icons.js';
|
|
7
|
-
export { ClientLazy as APIPlayground } from '../playground/client.lazy.js';
|
|
8
7
|
export function CopyResponseTypeScript({ code }) {
|
|
9
8
|
const [isChecked, onCopy] = useCopyButton(() => {
|
|
10
9
|
void navigator.clipboard.writeText(code);
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { RenderContext, ServerObject } from '../../types.js';
|
|
3
|
-
import type
|
|
4
|
-
export interface ApiProviderProps {
|
|
3
|
+
import { type MediaAdapter } from '../../media/adapter.js';
|
|
4
|
+
export interface ApiProviderProps extends ApiContextType {
|
|
5
5
|
/**
|
|
6
6
|
* Base URL for API requests
|
|
7
7
|
*/
|
|
8
8
|
defaultBaseUrl?: string;
|
|
9
|
-
servers: ServerObject[];
|
|
10
|
-
shikiOptions: RenderContext['shikiOptions'];
|
|
11
|
-
mediaAdapters: Record<string, MediaAdapter>;
|
|
12
9
|
children?: ReactNode;
|
|
13
10
|
}
|
|
14
11
|
export interface SelectedServer {
|
|
15
12
|
url: string;
|
|
16
13
|
variables: Record<string, string>;
|
|
17
14
|
}
|
|
18
|
-
|
|
15
|
+
interface ApiContextType {
|
|
16
|
+
servers: ServerObject[];
|
|
17
|
+
shikiOptions: RenderContext['shikiOptions'];
|
|
18
|
+
mediaAdapters: Record<string, MediaAdapter>;
|
|
19
|
+
}
|
|
19
20
|
interface ServerSelectType {
|
|
20
21
|
server: SelectedServer | null;
|
|
21
22
|
setServer: (value: string) => void;
|
|
@@ -23,6 +24,6 @@ interface ServerSelectType {
|
|
|
23
24
|
}
|
|
24
25
|
export declare function useApiContext(): ApiContextType;
|
|
25
26
|
export declare function useServerSelectContext(): ServerSelectType;
|
|
26
|
-
export declare function ApiProvider({ defaultBaseUrl, children,
|
|
27
|
+
export declare function ApiProvider({ defaultBaseUrl, children, servers, mediaAdapters, shikiOptions, }: ApiProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
export {};
|
|
28
29
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/api.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/api.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC7C;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC7D;AAKD,wBAAgB,aAAa,IAAI,cAAc,CAK9C;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAKzD;AAED,wBAAgB,WAAW,CAAC,EAC1B,cAAc,EACd,QAAQ,EACR,OAAO,EACP,aAAa,EACb,YAAY,GACb,EAAE,gBAAgB,2CA2ElB"}
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useEffect, useMemo, useState, } from 'react';
|
|
4
|
+
import { defaultAdapters } from '../../media/adapter.js';
|
|
4
5
|
const ApiContext = createContext(null);
|
|
5
6
|
const ServerSelectContext = createContext(null);
|
|
6
7
|
export function useApiContext() {
|
|
@@ -15,11 +16,11 @@ export function useServerSelectContext() {
|
|
|
15
16
|
throw new Error('Component must be used under <ApiProvider />');
|
|
16
17
|
return ctx;
|
|
17
18
|
}
|
|
18
|
-
export function ApiProvider({ defaultBaseUrl, children,
|
|
19
|
+
export function ApiProvider({ defaultBaseUrl, children, servers, mediaAdapters, shikiOptions, }) {
|
|
19
20
|
const [server, setServer] = useState(() => {
|
|
20
21
|
const defaultItem = defaultBaseUrl
|
|
21
|
-
?
|
|
22
|
-
:
|
|
22
|
+
? servers.find((item) => item.url === defaultBaseUrl)
|
|
23
|
+
: null;
|
|
23
24
|
return defaultItem
|
|
24
25
|
? {
|
|
25
26
|
url: defaultItem.url,
|
|
@@ -41,7 +42,14 @@ export function ApiProvider({ defaultBaseUrl, children, ...props }) {
|
|
|
41
42
|
// ignore
|
|
42
43
|
}
|
|
43
44
|
}, []);
|
|
44
|
-
return (_jsx(ApiContext.Provider, { value:
|
|
45
|
+
return (_jsx(ApiContext.Provider, { value: useMemo(() => ({
|
|
46
|
+
shikiOptions,
|
|
47
|
+
mediaAdapters: {
|
|
48
|
+
...defaultAdapters,
|
|
49
|
+
...mediaAdapters,
|
|
50
|
+
},
|
|
51
|
+
servers,
|
|
52
|
+
}), [mediaAdapters, servers, shikiOptions]), children: _jsx(ServerSelectContext.Provider, { value: useMemo(() => ({
|
|
45
53
|
server,
|
|
46
54
|
setServerVariables(variables) {
|
|
47
55
|
setServer((prev) => {
|
|
@@ -53,7 +61,7 @@ export function ApiProvider({ defaultBaseUrl, children, ...props }) {
|
|
|
53
61
|
});
|
|
54
62
|
},
|
|
55
63
|
setServer(value) {
|
|
56
|
-
const obj =
|
|
64
|
+
const obj = servers.find((item) => item.url === value);
|
|
57
65
|
if (!obj)
|
|
58
66
|
return;
|
|
59
67
|
const result = {
|
|
@@ -63,7 +71,7 @@ export function ApiProvider({ defaultBaseUrl, children, ...props }) {
|
|
|
63
71
|
localStorage.setItem('apiBaseUrl', JSON.stringify(result));
|
|
64
72
|
setServer(result);
|
|
65
73
|
},
|
|
66
|
-
}), [server,
|
|
74
|
+
}), [server, servers]), children: children }) }));
|
|
67
75
|
}
|
|
68
76
|
function getDefaultValues(server) {
|
|
69
77
|
return Object.fromEntries(Object.entries(server.variables ?? {}).map(([k, v]) => [k, v.default]));
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAYlE,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,2CAyB5C;AAED,wBAAgB,OAAO,CAAC,EACtB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,cAAc,CAAC,2CAMhC;AAED,wBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC,2CAmBzE;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE,aAAa,2CAsBf;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,2CAY/D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAiBA;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/ui/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Badge } from '../ui/components/method-label.js';
|
|
3
3
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
|
|
4
4
|
import { ChevronDown } from '../icons.js';
|
|
5
|
-
import { ApiProvider } from '../ui/
|
|
5
|
+
import { ApiProvider } from '../ui/lazy.js';
|
|
6
6
|
import { cn } from 'fumadocs-ui/utils/cn';
|
|
7
7
|
import { buttonVariants } from 'fumadocs-ui/components/ui/button';
|
|
8
8
|
export function Root({ children, className, ctx, ...props }) {
|
|
9
|
-
return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className), ...props, children: _jsx(ApiProvider, { mediaAdapters: ctx.mediaAdapters, servers: ctx.servers, shikiOptions: ctx.shikiOptions, defaultBaseUrl: ctx.baseUrl, children: children }) }));
|
|
9
|
+
return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className), ...props, children: _jsx(ApiProvider, { mediaAdapters: Object.fromEntries(Object.entries(ctx.mediaAdapters).filter(([_, v]) => typeof v !== 'boolean')), servers: ctx.servers, shikiOptions: ctx.shikiOptions, defaultBaseUrl: ctx.baseUrl, children: children }) }));
|
|
10
10
|
}
|
|
11
11
|
export function APIInfo({ className, ...props }) {
|
|
12
12
|
return (_jsx("div", { className: cn('min-w-0 flex-1', className), ...props, children: props.children }));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CodeExampleProvider: import("react").ComponentType<{
|
|
2
|
+
route: string;
|
|
3
|
+
examples: {
|
|
4
|
+
key: string;
|
|
5
|
+
data: import("../requests/_shared.js").RequestData;
|
|
6
|
+
}[];
|
|
7
|
+
initialKey?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const CodeExample: import("react").ComponentType<import("../render/operation/index.js").CodeSample>;
|
|
11
|
+
export declare const CodeExampleSelector: import("react").ComponentType<import("../render/renderer.js").SamplesProps>;
|
|
12
|
+
export declare const ClientLazy: import("react").ComponentType<import("../playground/client.js").ClientProps>;
|
|
13
|
+
export declare const ApiProvider: import("react").ComponentType<import("./contexts/api.js").ApiProviderProps>;
|
|
14
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ui/lazy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB;;;;;;;;EAE/B,CAAC;AACF,eAAO,MAAM,WAAW,yEAEvB,CAAC;AACF,eAAO,MAAM,mBAAmB,0EAE/B,CAAC;AAEF,eAAO,MAAM,UAAU,0EAA+C,CAAC;AAEvE,eAAO,MAAM,WAAW,0EAEvB,CAAC"}
|
package/dist/ui/lazy.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import dynamic from 'next/dynamic';
|
|
3
|
+
export const CodeExampleProvider = dynamic(() => import('./contexts/code-example.js').then((mod) => mod.CodeExampleProvider));
|
|
4
|
+
export const CodeExample = dynamic(() => import('./contexts/code-example.js').then((mod) => mod.CodeExample));
|
|
5
|
+
export const CodeExampleSelector = dynamic(() => import('./contexts/code-example.js').then((mod) => mod.CodeExampleSelector));
|
|
6
|
+
export const ClientLazy = dynamic(() => import('../playground/client.js'));
|
|
7
|
+
export const ApiProvider = dynamic(() => import('./contexts/api.js').then((mod) => mod.ApiProvider));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/input-to-string.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"input-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/input-to-string.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAiB,EAClD,SAAS,GAAE,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAe,GAClE,MAAM,CAyCR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.7",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"remark-rehype": "^11.1.2",
|
|
64
64
|
"shiki": "^3.3.0",
|
|
65
65
|
"xml-js": "^1.6.11",
|
|
66
|
-
"fumadocs-core": "15.2.
|
|
67
|
-
"fumadocs-ui": "15.2.
|
|
66
|
+
"fumadocs-core": "15.2.15",
|
|
67
|
+
"fumadocs-ui": "15.2.15"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@scalar/api-client-react": "^1.2.31",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { MediaAdapter } from '../media/adapter.js';
|
|
2
|
-
export declare const json: MediaAdapter;
|
|
3
|
-
export declare const xml: MediaAdapter;
|
|
4
|
-
export declare const url: MediaAdapter;
|
|
5
|
-
export declare const formData: MediaAdapter;
|
|
6
|
-
export declare const ndJson: MediaAdapter;
|
|
7
|
-
export declare const octet: MediaAdapter;
|
|
8
|
-
//# sourceMappingURL=adapter.client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.client.d.ts","sourceRoot":"","sources":["../../src/media/adapter.client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AAElE,eAAO,MAAM,IAAI,EAAE,YAOlB,CAAC;AACF,eAAO,MAAM,GAAG,EAAE,YAYjB,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,YAqBjB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,YAyDtB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,YAUpB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,YAQnB,CAAC"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { inputToString } from '../utils/input-to-string.js';
|
|
3
|
-
export const json = {
|
|
4
|
-
encode(data) {
|
|
5
|
-
return JSON.stringify(data.body);
|
|
6
|
-
},
|
|
7
|
-
generateExample(data, ctx) {
|
|
8
|
-
return str(data.body, 'json', ctx);
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
export const xml = {
|
|
12
|
-
async encode(data) {
|
|
13
|
-
const { js2xml } = await import('xml-js');
|
|
14
|
-
return js2xml(data.body, {
|
|
15
|
-
compact: true,
|
|
16
|
-
spaces: 2,
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
generateExample(data, ctx) {
|
|
20
|
-
return str(data.body, 'xml', ctx);
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
export const url = {
|
|
24
|
-
encode(data) {
|
|
25
|
-
if (typeof data.body !== 'object')
|
|
26
|
-
throw new Error(`Input value must be object, received: ${typeof data.body}`);
|
|
27
|
-
const params = new URLSearchParams();
|
|
28
|
-
for (const key in data.body) {
|
|
29
|
-
params.set(key, String(data.body[key]));
|
|
30
|
-
}
|
|
31
|
-
return params;
|
|
32
|
-
},
|
|
33
|
-
generateExample(data, ctx) {
|
|
34
|
-
if (ctx.lang === 'js') {
|
|
35
|
-
return `const body = new URLSearchParams(${JSON.stringify(data.body, null, 2)})`;
|
|
36
|
-
}
|
|
37
|
-
return str(data.body, 'url', ctx);
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
export const formData = {
|
|
41
|
-
encode(data) {
|
|
42
|
-
const formData = new FormData();
|
|
43
|
-
const body = data.body;
|
|
44
|
-
if (typeof body !== 'object' || !body) {
|
|
45
|
-
throw new Error(`Unsupported body type: ${typeof body}, expected: object`);
|
|
46
|
-
}
|
|
47
|
-
for (const key in body) {
|
|
48
|
-
const prop = body[key];
|
|
49
|
-
if (typeof prop === 'object' && prop instanceof File) {
|
|
50
|
-
formData.set(key, prop);
|
|
51
|
-
}
|
|
52
|
-
if (Array.isArray(prop) && prop.every((item) => item instanceof File)) {
|
|
53
|
-
for (const item of prop) {
|
|
54
|
-
formData.append(key, item);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (prop && !(prop instanceof File)) {
|
|
58
|
-
formData.set(key, JSON.stringify(prop));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return formData;
|
|
62
|
-
},
|
|
63
|
-
generateExample(data, ctx) {
|
|
64
|
-
const s = [];
|
|
65
|
-
if (ctx.lang === 'js') {
|
|
66
|
-
s.push(`const body = new FormData();`);
|
|
67
|
-
for (const [key, value] of Object.entries(data.body)) {
|
|
68
|
-
s.push(`body.set(${key}, ${inputToString(value)})`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (ctx.lang === 'go' && 'addImport' in ctx) {
|
|
72
|
-
ctx.addImport('mime/multipart');
|
|
73
|
-
ctx.addImport('bytes');
|
|
74
|
-
s.push('body := new(bytes.Buffer)');
|
|
75
|
-
s.push('mp := multipart.NewWriter(payload)');
|
|
76
|
-
for (const [key, value] of Object.entries(data.body)) {
|
|
77
|
-
s.push(`mp.WriteField("${key}", ${inputToString(value, 'json', 'backtick')})`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (s.length > 0)
|
|
81
|
-
return s.join('\n');
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
export const ndJson = {
|
|
85
|
-
encode(data) {
|
|
86
|
-
if (Array.isArray(data.body)) {
|
|
87
|
-
return data.body.map((v) => JSON.stringify(v)).join('\n');
|
|
88
|
-
}
|
|
89
|
-
return JSON.stringify(data.body);
|
|
90
|
-
},
|
|
91
|
-
generateExample(data, ctx) {
|
|
92
|
-
return str(data.body, 'ndjson', ctx);
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
export const octet = {
|
|
96
|
-
encode(data) {
|
|
97
|
-
return data.body;
|
|
98
|
-
},
|
|
99
|
-
generateExample() {
|
|
100
|
-
// not supported
|
|
101
|
-
return undefined;
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
function str(init, format, ctx) {
|
|
105
|
-
if (ctx.lang === 'js') {
|
|
106
|
-
if (format === 'json') {
|
|
107
|
-
return `const body = JSON.stringify(${JSON.stringify(init, null, 2)})`;
|
|
108
|
-
}
|
|
109
|
-
return `const body = ${inputToString(init, format, 'backtick')}`;
|
|
110
|
-
}
|
|
111
|
-
if (ctx.lang === 'python') {
|
|
112
|
-
return `body = ${inputToString(init, format, 'python')}`;
|
|
113
|
-
}
|
|
114
|
-
if (ctx.lang === 'go' && 'addImport' in ctx) {
|
|
115
|
-
ctx.addImport('strings');
|
|
116
|
-
return `body := strings.NewReader(${inputToString(init, format, 'backtick')})`;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.lazy.d.ts","sourceRoot":"","sources":["../../src/playground/client.lazy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,+DAAoC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const CodeExampleProvider: import("react").ComponentType<{
|
|
2
|
-
route: string;
|
|
3
|
-
examples: {
|
|
4
|
-
key: string;
|
|
5
|
-
data: import("../../requests/_shared.js").RequestData;
|
|
6
|
-
}[];
|
|
7
|
-
initialKey?: string;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}>;
|
|
10
|
-
export declare const CodeExample: import("react").ComponentType<import("../../render/operation/index.js").CodeSample>;
|
|
11
|
-
export declare const CodeExampleSelector: import("react").ComponentType<import("../../render/renderer.js").SamplesProps>;
|
|
12
|
-
//# sourceMappingURL=code-example.lazy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-example.lazy.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/code-example.lazy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB;;;;;;;;EAE/B,CAAC;AACF,eAAO,MAAM,WAAW,4EAEvB,CAAC;AACF,eAAO,MAAM,mBAAmB,6EAE/B,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import dynamic from 'next/dynamic';
|
|
3
|
-
export const CodeExampleProvider = dynamic(() => import('./code-example.js').then((mod) => mod.CodeExampleProvider));
|
|
4
|
-
export const CodeExample = dynamic(() => import('./code-example.js').then((mod) => mod.CodeExample));
|
|
5
|
-
export const CodeExampleSelector = dynamic(() => import('./code-example.js').then((mod) => mod.CodeExampleSelector));
|