fumadocs-openapi 9.0.18 → 9.1.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/media/adapter.d.ts +47 -16
- package/dist/media/adapter.d.ts.map +1 -1
- package/dist/media/adapter.js +3 -4
- package/dist/playground/client.d.ts +6 -4
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +46 -40
- package/dist/playground/fetcher.d.ts.map +1 -1
- package/dist/playground/fetcher.js +14 -24
- package/dist/playground/index.d.ts +3 -5
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +2 -7
- package/dist/playground/inputs.d.ts.map +1 -1
- package/dist/playground/inputs.js +5 -4
- package/dist/playground/schema.d.ts +5 -0
- package/dist/playground/schema.d.ts.map +1 -1
- package/dist/playground/schema.js +61 -32
- package/dist/render/api-page.d.ts.map +1 -1
- package/dist/render/api-page.js +2 -8
- package/dist/render/operation/api-example.d.ts +3 -2
- package/dist/render/operation/api-example.d.ts.map +1 -1
- package/dist/render/operation/api-example.js +8 -6
- package/dist/render/operation/get-request-data.d.ts +2 -2
- package/dist/render/operation/get-request-data.d.ts.map +1 -1
- package/dist/requests/_shared.d.ts +20 -4
- package/dist/requests/_shared.d.ts.map +1 -1
- package/dist/requests/_shared.js +113 -0
- package/dist/requests/csharp.d.ts.map +1 -1
- package/dist/requests/csharp.js +12 -8
- package/dist/requests/curl.d.ts.map +1 -1
- package/dist/requests/curl.js +5 -6
- package/dist/requests/go.d.ts +1 -1
- package/dist/requests/go.d.ts.map +1 -1
- package/dist/requests/go.js +6 -6
- package/dist/requests/java.d.ts.map +1 -1
- package/dist/requests/java.js +8 -8
- package/dist/requests/javascript.d.ts.map +1 -1
- package/dist/requests/javascript.js +9 -6
- package/dist/requests/python.d.ts.map +1 -1
- package/dist/requests/python.js +12 -5
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/contexts/api.d.ts +2 -1
- package/dist/ui/contexts/api.d.ts.map +1 -1
- package/dist/ui/contexts/code-example.d.ts +5 -4
- package/dist/ui/contexts/code-example.d.ts.map +1 -1
- package/dist/ui/contexts/code-example.js +14 -11
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +8 -2
- package/dist/ui/lazy.d.ts +2 -1
- package/dist/ui/lazy.d.ts.map +1 -1
- package/dist/utils/schema-to-string.d.ts.map +1 -1
- package/dist/utils/schema-to-string.js +30 -35
- package/dist/utils/url.js +10 -12
- package/package.json +3 -3
package/dist/ui/index.js
CHANGED
|
@@ -6,7 +6,13 @@ 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
|
-
|
|
9
|
+
const mediaAdapters = {};
|
|
10
|
+
for (const k in ctx.mediaAdapters) {
|
|
11
|
+
const adapter = ctx.mediaAdapters[k];
|
|
12
|
+
if (adapter.client)
|
|
13
|
+
mediaAdapters[k] = adapter.client;
|
|
14
|
+
}
|
|
15
|
+
return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm', className), ...props, children: _jsx(ApiProvider, { mediaAdapters: mediaAdapters, servers: ctx.servers, shikiOptions: ctx.shikiOptions, children: children }) }));
|
|
10
16
|
}
|
|
11
17
|
export function APIInfo({ className, ...props }) {
|
|
12
18
|
return (_jsx("div", { className: cn('min-w-0 flex-1', className), ...props, children: props.children }));
|
|
@@ -26,6 +32,6 @@ export function APIExample(props) {
|
|
|
26
32
|
return (_jsx("div", { ...props, className: cn('prose-no-margin md:sticky md:top-(--fd-api-info-top) xl:w-[400px]', props.className), children: props.children }));
|
|
27
33
|
}
|
|
28
34
|
export function ObjectCollapsible(props) {
|
|
29
|
-
return (_jsxs(Collapsible, { ...props, children: [_jsxs(CollapsibleTrigger, { className: cn(buttonVariants({ color: 'secondary', size: 'sm' }), 'group px-3 py-2 data-[state=open]:rounded-b-none'), children: [props.name, _jsx(ChevronDown, { className: "size-4 text-fd-muted-foreground group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { className: "-mt-px *:bg-fd-card", children: props.children })] }));
|
|
35
|
+
return (_jsxs(Collapsible, { className: "my-2", ...props, children: [_jsxs(CollapsibleTrigger, { className: cn(buttonVariants({ color: 'secondary', size: 'sm' }), 'group px-3 py-2 data-[state=open]:rounded-b-none'), children: [props.name, _jsx(ChevronDown, { className: "size-4 text-fd-muted-foreground group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { className: "-mt-px *:bg-fd-card", children: props.children })] }));
|
|
30
36
|
}
|
|
31
37
|
export { APIPage } from '../render/api-page.js';
|
package/dist/ui/lazy.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export declare const CodeExampleProvider: import("react").ComponentType<{
|
|
|
2
2
|
route: string;
|
|
3
3
|
examples: {
|
|
4
4
|
key: string;
|
|
5
|
-
data: import("../requests/_shared.js").
|
|
5
|
+
data: import("../requests/_shared.js").RawRequestData;
|
|
6
|
+
encoded: import("../requests/_shared.js").RequestData;
|
|
6
7
|
}[];
|
|
7
8
|
initialKey?: string;
|
|
8
9
|
children: import("react").ReactNode;
|
package/dist/ui/lazy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ui/lazy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB
|
|
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"}
|
|
@@ -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,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,wBAAgB,cAAc,CAC5B,KAAK,EAAE,cAAc,EACrB,GAAG,CAAC,EAAE,iBAAiB,GACtB,MAAM,CAmER"}
|
|
@@ -1,47 +1,52 @@
|
|
|
1
1
|
export function schemaToString(value, ctx) {
|
|
2
|
-
function
|
|
2
|
+
function union(union, sep) {
|
|
3
|
+
const members = new Set();
|
|
4
|
+
let nullable = false;
|
|
5
|
+
for (const item of union) {
|
|
6
|
+
const result = run(item);
|
|
7
|
+
if (result === 'null') {
|
|
8
|
+
nullable = true;
|
|
9
|
+
}
|
|
10
|
+
else if (result !== 'unknown') {
|
|
11
|
+
members.add(result);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const result = Array.from(members).join(sep);
|
|
15
|
+
return nullable ? `${result} | null` : result;
|
|
16
|
+
}
|
|
17
|
+
function run(schema) {
|
|
3
18
|
if (schema === true)
|
|
4
19
|
return 'any';
|
|
5
20
|
else if (schema === false)
|
|
6
21
|
return 'never';
|
|
7
|
-
if (isNullable(schema) && isRoot) {
|
|
8
|
-
const type = run(schema, false);
|
|
9
|
-
// null if schema only contains `nullable`
|
|
10
|
-
return type === 'unknown' ? 'null' : `${type} | null`;
|
|
11
|
-
}
|
|
12
22
|
if (schema.title)
|
|
13
23
|
return schema.title;
|
|
14
24
|
const referenceName = ctx?.dereferenceMap.get(schema);
|
|
15
25
|
if (referenceName)
|
|
16
26
|
return referenceName.split('/').at(-1);
|
|
17
27
|
if (Array.isArray(schema.type)) {
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
const members = new Set();
|
|
29
|
+
const types = schema.type;
|
|
30
|
+
for (const type of types) {
|
|
20
31
|
schema.type = type;
|
|
21
|
-
const str = run(schema
|
|
22
|
-
schema.type =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
const str = run(schema);
|
|
33
|
+
schema.type = types;
|
|
34
|
+
if (str !== 'unknown')
|
|
35
|
+
members.add(str);
|
|
36
|
+
}
|
|
37
|
+
return Array.from(members).join(' | ');
|
|
27
38
|
}
|
|
28
39
|
if (schema.type === 'array')
|
|
29
|
-
return `array<${schema.items ? run(schema.items
|
|
40
|
+
return `array<${schema.items ? run(schema.items) : 'unknown'}>`;
|
|
30
41
|
if (schema.oneOf) {
|
|
31
|
-
return schema.oneOf
|
|
32
|
-
.map((one) => run(one, false))
|
|
33
|
-
.filter((v) => v !== 'unknown' && v !== 'null')
|
|
34
|
-
.join(' | ');
|
|
42
|
+
return union(schema.oneOf, ' | ');
|
|
35
43
|
}
|
|
36
44
|
const combinedOf = schema.anyOf ?? schema.allOf;
|
|
37
45
|
if (combinedOf) {
|
|
38
|
-
return combinedOf
|
|
39
|
-
.map((one) => run(one, false))
|
|
40
|
-
.filter((v) => v !== 'unknown' && v !== 'null')
|
|
41
|
-
.join(' & ');
|
|
46
|
+
return union(combinedOf, ' & ');
|
|
42
47
|
}
|
|
43
48
|
if (schema.not)
|
|
44
|
-
return `not ${run(schema.not
|
|
49
|
+
return `not ${run(schema.not)}`;
|
|
45
50
|
if (schema.type === 'string' && schema.format === 'binary')
|
|
46
51
|
return 'file';
|
|
47
52
|
if (schema.type && Array.isArray(schema.type)) {
|
|
@@ -52,15 +57,5 @@ export function schemaToString(value, ctx) {
|
|
|
52
57
|
}
|
|
53
58
|
return 'unknown';
|
|
54
59
|
}
|
|
55
|
-
return run(value
|
|
56
|
-
}
|
|
57
|
-
function isNullable(schema) {
|
|
58
|
-
if (typeof schema === 'boolean')
|
|
59
|
-
return false;
|
|
60
|
-
if (Array.isArray(schema.type) && schema.type.includes('null'))
|
|
61
|
-
return true;
|
|
62
|
-
const combined = schema.anyOf ?? schema.oneOf ?? schema.allOf;
|
|
63
|
-
if (combined && combined.some(isNullable))
|
|
64
|
-
return true;
|
|
65
|
-
return schema.type === 'null';
|
|
60
|
+
return run(value);
|
|
66
61
|
}
|
package/dist/utils/url.js
CHANGED
|
@@ -26,26 +26,24 @@ export function resolveServerUrl(template, variables) {
|
|
|
26
26
|
}
|
|
27
27
|
export function resolveRequestData(pathname, { path, query }) {
|
|
28
28
|
for (const key in path) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
pathname = pathname.replace(`{${key}}`, path[key].join('/'));
|
|
29
|
+
const param = path[key];
|
|
30
|
+
if (Array.isArray(param.value)) {
|
|
31
|
+
pathname = pathname.replace(`{${key}}`, param.value.join('/'));
|
|
33
32
|
}
|
|
34
33
|
else {
|
|
35
|
-
pathname = pathname.replace(`{${key}}`,
|
|
34
|
+
pathname = pathname.replace(`{${key}}`, param.value);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
const searchParams = new URLSearchParams();
|
|
39
38
|
for (const key in query) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
searchParams.append(key, String(value));
|
|
39
|
+
const param = query[key];
|
|
40
|
+
if (Array.isArray(param.value)) {
|
|
41
|
+
for (const item of param.value) {
|
|
42
|
+
searchParams.append(key, item);
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
else
|
|
48
|
-
searchParams.
|
|
45
|
+
else {
|
|
46
|
+
searchParams.append(key, param.value);
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
return searchParams.size > 0 ? `${pathname}?${searchParams}` : pathname;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"shiki": "^3.7.0",
|
|
65
65
|
"tinyglobby": "^0.2.14",
|
|
66
66
|
"xml-js": "^1.6.11",
|
|
67
|
-
"fumadocs-core": "15.6.
|
|
68
|
-
"fumadocs-ui": "15.6.
|
|
67
|
+
"fumadocs-core": "15.6.3",
|
|
68
|
+
"fumadocs-ui": "15.6.3"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@scalar/api-client-react": "^1.3.18",
|