fumadocs-openapi 5.12.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -68
- package/dist/scalar/client-client-DgnHaOQ3.js +93 -0
- package/dist/scalar/index.d.ts +176 -0
- package/dist/scalar/index.js +13 -0
- package/dist/server/index.d.ts +14 -69
- package/dist/server/index.js +164 -180
- package/dist/ui/client-client-CpwKrzlY.js +107 -0
- package/dist/ui/{fetcher-BHk80ZFu.js → fetcher-Cey1qI8X.js} +1 -1
- package/dist/ui/{index-client-XPLtFTfD.js → index-client-CehDtJk-.js} +285 -81
- package/dist/ui/index.d.ts +22 -17
- package/dist/ui/index.js +2 -2
- package/dist/ui/{server-select-client-D4GEjFgD.js → server-select-client-CbFencmM.js} +2 -2
- package/package.json +13 -9
- package/dist/ui/client-client-Die8irpf.js +0 -315
|
@@ -1,18 +1,214 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
2
|
import * as React from 'react';
|
|
4
|
-
import { forwardRef, useState, useMemo, useRef, useEffect, Fragment as Fragment$1 } from 'react';
|
|
3
|
+
import { forwardRef, createElement, useState, useMemo, useRef, useEffect, Fragment as Fragment$1 } from 'react';
|
|
4
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { useFormContext, Controller, useFieldArray, useForm, FormProvider } from 'react-hook-form';
|
|
6
6
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
7
|
-
import {
|
|
7
|
+
import { u as useSchemaContext, a as useApiContext, S as SchemaContext } from './client-client-CpwKrzlY.js';
|
|
8
8
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
9
9
|
import { cva } from 'class-variance-authority';
|
|
10
10
|
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
|
11
|
-
import { S as ServerSelect } from './server-select-client-
|
|
11
|
+
import { S as ServerSelect } from './server-select-client-CbFencmM.js';
|
|
12
12
|
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from 'fumadocs-ui/components/ui/collapsible';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @license lucide-react v0.474.0 - ISC
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the ISC license.
|
|
18
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/ const toKebabCase = (string)=>string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
20
|
+
const mergeClasses = (...classes)=>classes.filter((className, index, array)=>{
|
|
21
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
22
|
+
}).join(" ").trim();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @license lucide-react v0.474.0 - ISC
|
|
26
|
+
*
|
|
27
|
+
* This source code is licensed under the ISC license.
|
|
28
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
29
|
+
*/ var defaultAttributes = {
|
|
30
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
31
|
+
width: 24,
|
|
32
|
+
height: 24,
|
|
33
|
+
viewBox: "0 0 24 24",
|
|
34
|
+
fill: "none",
|
|
35
|
+
stroke: "currentColor",
|
|
36
|
+
strokeWidth: 2,
|
|
37
|
+
strokeLinecap: "round",
|
|
38
|
+
strokeLinejoin: "round"
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const Icon = /*#__PURE__*/ forwardRef(({ color = "currentColor", size = 24, strokeWidth = 2, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref)=>{
|
|
42
|
+
return /*#__PURE__*/ createElement("svg", {
|
|
43
|
+
ref,
|
|
44
|
+
...defaultAttributes,
|
|
45
|
+
width: size,
|
|
46
|
+
height: size,
|
|
47
|
+
stroke: color,
|
|
48
|
+
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
49
|
+
className: mergeClasses("lucide", className),
|
|
50
|
+
...rest
|
|
51
|
+
}, [
|
|
52
|
+
...iconNode.map(([tag, attrs])=>/*#__PURE__*/ createElement(tag, attrs)),
|
|
53
|
+
...Array.isArray(children) ? children : [
|
|
54
|
+
children
|
|
55
|
+
]
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const createLucideIcon = (iconName, iconNode)=>{
|
|
60
|
+
const Component = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ createElement(Icon, {
|
|
61
|
+
ref,
|
|
62
|
+
iconNode,
|
|
63
|
+
className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
|
|
64
|
+
...props
|
|
65
|
+
}));
|
|
66
|
+
Component.displayName = `${iconName}`;
|
|
67
|
+
return Component;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const __iconNode$6 = [
|
|
71
|
+
[
|
|
72
|
+
"path",
|
|
73
|
+
{
|
|
74
|
+
d: "M20 6 9 17l-5-5",
|
|
75
|
+
key: "1gmf2c"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
];
|
|
79
|
+
const Check = createLucideIcon("Check", __iconNode$6);
|
|
80
|
+
|
|
81
|
+
const __iconNode$5 = [
|
|
82
|
+
[
|
|
83
|
+
"path",
|
|
84
|
+
{
|
|
85
|
+
d: "m6 9 6 6 6-6",
|
|
86
|
+
key: "qrunsl"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
];
|
|
90
|
+
const ChevronDown = createLucideIcon("ChevronDown", __iconNode$5);
|
|
91
|
+
|
|
92
|
+
const __iconNode$4 = [
|
|
93
|
+
[
|
|
94
|
+
"path",
|
|
95
|
+
{
|
|
96
|
+
d: "m18 15-6-6-6 6",
|
|
97
|
+
key: "153udz"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
];
|
|
101
|
+
const ChevronUp = createLucideIcon("ChevronUp", __iconNode$4);
|
|
102
|
+
|
|
103
|
+
const __iconNode$3 = [
|
|
104
|
+
[
|
|
105
|
+
"circle",
|
|
106
|
+
{
|
|
107
|
+
cx: "12",
|
|
108
|
+
cy: "12",
|
|
109
|
+
r: "10",
|
|
110
|
+
key: "1mglay"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"path",
|
|
115
|
+
{
|
|
116
|
+
d: "m9 12 2 2 4-4",
|
|
117
|
+
key: "dzmm74"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
];
|
|
121
|
+
const CircleCheck = createLucideIcon("CircleCheck", __iconNode$3);
|
|
122
|
+
|
|
123
|
+
const __iconNode$2 = [
|
|
124
|
+
[
|
|
125
|
+
"circle",
|
|
126
|
+
{
|
|
127
|
+
cx: "12",
|
|
128
|
+
cy: "12",
|
|
129
|
+
r: "10",
|
|
130
|
+
key: "1mglay"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
"path",
|
|
135
|
+
{
|
|
136
|
+
d: "m15 9-6 6",
|
|
137
|
+
key: "1uzhvr"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
"path",
|
|
142
|
+
{
|
|
143
|
+
d: "m9 9 6 6",
|
|
144
|
+
key: "z0biqf"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
];
|
|
148
|
+
const CircleX = createLucideIcon("CircleX", __iconNode$2);
|
|
149
|
+
|
|
150
|
+
const __iconNode$1 = [
|
|
151
|
+
[
|
|
152
|
+
"path",
|
|
153
|
+
{
|
|
154
|
+
d: "M5 12h14",
|
|
155
|
+
key: "1ays0h"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
"path",
|
|
160
|
+
{
|
|
161
|
+
d: "M12 5v14",
|
|
162
|
+
key: "s699le"
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
];
|
|
166
|
+
const Plus = createLucideIcon("Plus", __iconNode$1);
|
|
167
|
+
|
|
168
|
+
const __iconNode = [
|
|
169
|
+
[
|
|
170
|
+
"path",
|
|
171
|
+
{
|
|
172
|
+
d: "M3 6h18",
|
|
173
|
+
key: "d0wm0j"
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
"path",
|
|
178
|
+
{
|
|
179
|
+
d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",
|
|
180
|
+
key: "4alrt4"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
"path",
|
|
185
|
+
{
|
|
186
|
+
d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",
|
|
187
|
+
key: "v07s0e"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
"line",
|
|
192
|
+
{
|
|
193
|
+
x1: "10",
|
|
194
|
+
x2: "10",
|
|
195
|
+
y1: "11",
|
|
196
|
+
y2: "17",
|
|
197
|
+
key: "1uufr5"
|
|
198
|
+
}
|
|
199
|
+
],
|
|
200
|
+
[
|
|
201
|
+
"line",
|
|
202
|
+
{
|
|
203
|
+
x1: "14",
|
|
204
|
+
x2: "14",
|
|
205
|
+
y1: "11",
|
|
206
|
+
y2: "17",
|
|
207
|
+
key: "xtxkd"
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
];
|
|
211
|
+
const Trash2 = createLucideIcon("Trash2", __iconNode);
|
|
16
212
|
|
|
17
213
|
/**
|
|
18
214
|
* Resolve reference
|
|
@@ -555,6 +751,14 @@ function getStatusInfo(status) {
|
|
|
555
751
|
};
|
|
556
752
|
}
|
|
557
753
|
|
|
754
|
+
function getUrl(url, variables) {
|
|
755
|
+
let out = url;
|
|
756
|
+
for (const [key, value] of Object.entries(variables)){
|
|
757
|
+
out = out.replaceAll(`{${key}}`, value);
|
|
758
|
+
}
|
|
759
|
+
return out;
|
|
760
|
+
}
|
|
761
|
+
|
|
558
762
|
const variants = cva('font-mono font-medium', {
|
|
559
763
|
variants: {
|
|
560
764
|
color: {
|
|
@@ -613,12 +817,22 @@ function useQuery(fn) {
|
|
|
613
817
|
]);
|
|
614
818
|
}
|
|
615
819
|
|
|
820
|
+
function defaultAuthValue(auth) {
|
|
821
|
+
if (!auth || auth.type === 'apiKey') return '';
|
|
822
|
+
if (auth.type === 'http' && auth.scheme === 'basic') {
|
|
823
|
+
return {
|
|
824
|
+
username: '',
|
|
825
|
+
password: ''
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
return 'Bearer';
|
|
829
|
+
}
|
|
616
830
|
function APIPlayground({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
|
|
617
831
|
const { serverRef } = useApiContext();
|
|
618
832
|
const dynamicRef = useRef(new Map());
|
|
619
833
|
const form = useForm({
|
|
620
834
|
defaultValues: {
|
|
621
|
-
authorization: authorization
|
|
835
|
+
authorization: defaultAuthValue(authorization),
|
|
622
836
|
path: getDefaultValues(path, schemas),
|
|
623
837
|
query: getDefaultValues(query, schemas),
|
|
624
838
|
header: getDefaultValues(header, schemas),
|
|
@@ -626,20 +840,42 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
626
840
|
}
|
|
627
841
|
});
|
|
628
842
|
const testQuery = useQuery(async (input)=>{
|
|
629
|
-
const fetcher = await import('./fetcher-
|
|
843
|
+
const fetcher = await import('./fetcher-Cey1qI8X.js').then((mod)=>mod.createBrowserFetcher(body, schemas));
|
|
844
|
+
const query = {
|
|
845
|
+
...input.query
|
|
846
|
+
};
|
|
847
|
+
const header = {
|
|
848
|
+
...input.header
|
|
849
|
+
};
|
|
850
|
+
if (input.authorization && authorization) {
|
|
851
|
+
if (authorization.type === 'apiKey') {
|
|
852
|
+
if (authorization.in === 'header') {
|
|
853
|
+
header[authorization.name] = input.authorization;
|
|
854
|
+
} else if (authorization.in === 'query') {
|
|
855
|
+
query[authorization.name] = input.authorization;
|
|
856
|
+
} else {
|
|
857
|
+
if ('cookie' in header) {
|
|
858
|
+
header.Cookie = header.cookie;
|
|
859
|
+
delete header.cookie;
|
|
860
|
+
}
|
|
861
|
+
header.Cookie = [
|
|
862
|
+
header.Cookie,
|
|
863
|
+
`${authorization.name}=${input.authorization}`
|
|
864
|
+
].filter((s)=>s.length > 0).join('; ');
|
|
865
|
+
}
|
|
866
|
+
} else if (authorization.type === 'http' && authorization.scheme === 'basic') {
|
|
867
|
+
if (typeof input.authorization === 'object') header.Authorization = `Basic ${btoa(`${input.authorization.username}:${input.authorization.password}`)}`;
|
|
868
|
+
} else {
|
|
869
|
+
header.Authorization = input.authorization;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
630
872
|
const serverUrl = serverRef.current ? getUrl(serverRef.current.url, serverRef.current.variables) : window.location.origin;
|
|
631
|
-
let url = `${serverUrl}${createPathnameFromInput(route, input.path,
|
|
873
|
+
let url = `${serverUrl}${createPathnameFromInput(route, input.path, query)}`;
|
|
632
874
|
if (proxyUrl) {
|
|
633
875
|
const updated = new URL(proxyUrl, window.location.origin);
|
|
634
876
|
updated.searchParams.append('url', url);
|
|
635
877
|
url = updated.toString();
|
|
636
878
|
}
|
|
637
|
-
const header = {
|
|
638
|
-
...input.header
|
|
639
|
-
};
|
|
640
|
-
if (input.authorization && authorization) {
|
|
641
|
-
header[authorization.name] = input.authorization;
|
|
642
|
-
}
|
|
643
879
|
return fetcher.fetch({
|
|
644
880
|
url: url.toString(),
|
|
645
881
|
header,
|
|
@@ -653,12 +889,12 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
653
889
|
});
|
|
654
890
|
useEffect(()=>{
|
|
655
891
|
if (!authorization) return;
|
|
656
|
-
const key = `
|
|
892
|
+
const key = `__fumadocs_auth_${JSON.stringify(authorization)}`;
|
|
657
893
|
const cached = localStorage.getItem(key);
|
|
658
|
-
if (cached) form.setValue('authorization', cached);
|
|
894
|
+
if (cached) form.setValue('authorization', JSON.parse(cached));
|
|
659
895
|
const subscription = form.watch((value, { name })=>{
|
|
660
|
-
if (name
|
|
661
|
-
localStorage.setItem(key, value.authorization);
|
|
896
|
+
if (!name || !name.startsWith('authorization') || !value.authorization) return;
|
|
897
|
+
localStorage.setItem(key, JSON.stringify(value.authorization));
|
|
662
898
|
});
|
|
663
899
|
return ()=>{
|
|
664
900
|
subscription.unsubscribe();
|
|
@@ -708,9 +944,34 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
708
944
|
title: "Server URL",
|
|
709
945
|
children: /*#__PURE__*/ jsx(ServerSelect, {})
|
|
710
946
|
}),
|
|
711
|
-
authorization ? /*#__PURE__*/
|
|
947
|
+
header.length > 0 || authorization ? /*#__PURE__*/ jsxs(CollapsiblePanel, {
|
|
712
948
|
title: "Headers",
|
|
713
|
-
children:
|
|
949
|
+
children: [
|
|
950
|
+
authorization?.type === 'http' && authorization.scheme === 'basic' ? renderCustomField('authorization', {
|
|
951
|
+
name: 'Authorization',
|
|
952
|
+
type: 'object',
|
|
953
|
+
isRequired: true,
|
|
954
|
+
properties: {
|
|
955
|
+
username: {
|
|
956
|
+
type: 'string',
|
|
957
|
+
isRequired: true,
|
|
958
|
+
defaultValue: ''
|
|
959
|
+
},
|
|
960
|
+
password: {
|
|
961
|
+
type: 'string',
|
|
962
|
+
isRequired: true,
|
|
963
|
+
defaultValue: ''
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}, fields.auth) : authorization ? renderCustomField('authorization', {
|
|
967
|
+
name: 'Authorization',
|
|
968
|
+
type: 'string',
|
|
969
|
+
isRequired: true,
|
|
970
|
+
description: 'The Authorization access token',
|
|
971
|
+
defaultValue: ''
|
|
972
|
+
}, fields.auth) : null,
|
|
973
|
+
header.map((field)=>renderCustomField(`header.${field.name}`, field, fields.header, field.name))
|
|
974
|
+
]
|
|
714
975
|
}) : null,
|
|
715
976
|
path.length > 0 ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
716
977
|
title: "Path",
|
|
@@ -720,10 +981,6 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
720
981
|
title: "Query",
|
|
721
982
|
children: query.map((field)=>renderCustomField(`query.${field.name}`, field, fields.query, field.name))
|
|
722
983
|
}) : null,
|
|
723
|
-
header.length > 0 ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
724
|
-
title: "Headers",
|
|
725
|
-
children: header.map((field)=>renderCustomField(`header.${field.name}`, field, fields.header, field.name))
|
|
726
|
-
}) : null,
|
|
727
984
|
body ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
728
985
|
title: "Body",
|
|
729
986
|
children: body.type === 'object' && !fields.body ? /*#__PURE__*/ jsx(ObjectInput, {
|
|
@@ -850,63 +1107,10 @@ function CollapsiblePanel({ title, children, ...props }) {
|
|
|
850
1107
|
});
|
|
851
1108
|
}
|
|
852
1109
|
|
|
853
|
-
var index
|
|
1110
|
+
var index = {
|
|
854
1111
|
__proto__: null,
|
|
855
1112
|
APIPlayground: APIPlayground,
|
|
856
1113
|
CollapsiblePanel: CollapsiblePanel
|
|
857
1114
|
};
|
|
858
1115
|
|
|
859
|
-
|
|
860
|
-
const { resolvedTheme } = useTheme();
|
|
861
|
-
const [mounted, setMounted] = useState(false);
|
|
862
|
-
useEffect(()=>{
|
|
863
|
-
setMounted(true);
|
|
864
|
-
}, []);
|
|
865
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
866
|
-
className: cn('flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose', mounted ? `${resolvedTheme}-mode` : null),
|
|
867
|
-
children: [
|
|
868
|
-
/*#__PURE__*/ jsx(MethodLabel, {
|
|
869
|
-
className: "text-xs",
|
|
870
|
-
children: method
|
|
871
|
-
}),
|
|
872
|
-
/*#__PURE__*/ jsx("code", {
|
|
873
|
-
className: "flex-1 overflow-auto text-nowrap text-[13px] text-fd-muted-foreground",
|
|
874
|
-
children: path
|
|
875
|
-
}),
|
|
876
|
-
/*#__PURE__*/ jsx(ApiClientModalProvider, {
|
|
877
|
-
configuration: {
|
|
878
|
-
themeId: 'moon',
|
|
879
|
-
spec: {
|
|
880
|
-
content: spec
|
|
881
|
-
}
|
|
882
|
-
},
|
|
883
|
-
children: /*#__PURE__*/ jsx(Trigger, {
|
|
884
|
-
path: path,
|
|
885
|
-
method: method
|
|
886
|
-
})
|
|
887
|
-
})
|
|
888
|
-
]
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
function Trigger({ path, method }) {
|
|
892
|
-
const client = useApiClientModal();
|
|
893
|
-
return /*#__PURE__*/ jsx("button", {
|
|
894
|
-
type: "submit",
|
|
895
|
-
className: cn(buttonVariants$1({
|
|
896
|
-
color: 'primary',
|
|
897
|
-
size: 'sm'
|
|
898
|
-
}), 'px-3 py-1.5'),
|
|
899
|
-
onClick: ()=>client?.open({
|
|
900
|
-
path,
|
|
901
|
-
method
|
|
902
|
-
}),
|
|
903
|
-
children: "Test"
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
var index = {
|
|
908
|
-
__proto__: null,
|
|
909
|
-
default: ScalarPlayground
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
export { Input as I, Select as S, SelectTrigger as a, SelectValue as b, SelectContent as c, SelectItem as d, index as e, index$1 as i, labelVariants as l, resolve as r };
|
|
1116
|
+
export { ChevronDown as C, Input as I, Select as S, SelectTrigger as a, SelectValue as b, SelectContent as c, SelectItem as d, index as i, labelVariants as l, resolve as r };
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -53,18 +53,19 @@ type ProcessedDocument = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
type Document = OpenAPIV3_1.Document;
|
|
56
|
+
type OperationObject = OpenAPIV3_1.OperationObject;
|
|
57
|
+
type SecuritySchemeObject = OpenAPIV3_1.SecuritySchemeObject;
|
|
56
58
|
type ReferenceObject = OpenAPIV3_1.ReferenceObject;
|
|
57
59
|
type ServerObject = NoReference<OpenAPIV3_1.ServerObject>;
|
|
60
|
+
type MethodInformation = NoReference<OperationObject> & {
|
|
61
|
+
method: string;
|
|
62
|
+
};
|
|
58
63
|
type Awaitable<T> = T | Promise<T>;
|
|
59
64
|
/**
|
|
60
65
|
* Dereferenced value and its original `$ref` value
|
|
61
66
|
*/
|
|
62
67
|
type DereferenceMap = Map<unknown, string>;
|
|
63
68
|
interface RenderContext {
|
|
64
|
-
/**
|
|
65
|
-
* Use Scalar for API Playground
|
|
66
|
-
*/
|
|
67
|
-
useScalar: boolean;
|
|
68
69
|
/**
|
|
69
70
|
* The url of proxy to avoid CORS issues
|
|
70
71
|
*/
|
|
@@ -97,6 +98,10 @@ interface RenderContext {
|
|
|
97
98
|
showResponseSchema?: boolean;
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
type Security = SecuritySchemeObject & {
|
|
102
|
+
scopes: string[];
|
|
103
|
+
};
|
|
104
|
+
|
|
100
105
|
interface BaseRequestField {
|
|
101
106
|
name: string;
|
|
102
107
|
description?: string;
|
|
@@ -126,7 +131,7 @@ interface FileSchema extends BaseSchema {
|
|
|
126
131
|
}
|
|
127
132
|
interface ObjectSchema extends BaseSchema {
|
|
128
133
|
type: 'object';
|
|
129
|
-
properties: Record<string, ReferenceSchema>;
|
|
134
|
+
properties: Record<string, RequestSchema | ReferenceSchema>;
|
|
130
135
|
/**
|
|
131
136
|
* Reference to schema, or true if it's `any`
|
|
132
137
|
*/
|
|
@@ -143,9 +148,7 @@ type RequestSchema = PrimitiveSchema | ArraySchema | ObjectSchema | SwitcherSche
|
|
|
143
148
|
interface APIPlaygroundProps {
|
|
144
149
|
route: string;
|
|
145
150
|
method: string;
|
|
146
|
-
authorization?:
|
|
147
|
-
authType: string;
|
|
148
|
-
};
|
|
151
|
+
authorization?: Security;
|
|
149
152
|
path?: PrimitiveRequestField[];
|
|
150
153
|
query?: PrimitiveRequestField[];
|
|
151
154
|
header?: PrimitiveRequestField[];
|
|
@@ -221,7 +224,11 @@ interface Renderer {
|
|
|
221
224
|
*/
|
|
222
225
|
ObjectCollapsible: ComponentType<ObjectCollapsibleProps>;
|
|
223
226
|
Property: ComponentType<PropertyProps>;
|
|
224
|
-
APIPlayground: ComponentType<
|
|
227
|
+
APIPlayground: ComponentType<{
|
|
228
|
+
path: string;
|
|
229
|
+
method: MethodInformation;
|
|
230
|
+
ctx: RenderContext;
|
|
231
|
+
}>;
|
|
225
232
|
}
|
|
226
233
|
|
|
227
234
|
interface SchemaContextType {
|
|
@@ -244,7 +251,10 @@ interface FetchResult {
|
|
|
244
251
|
}
|
|
245
252
|
|
|
246
253
|
interface FormValues {
|
|
247
|
-
authorization: string
|
|
254
|
+
authorization: string | {
|
|
255
|
+
username: string;
|
|
256
|
+
password: string;
|
|
257
|
+
};
|
|
248
258
|
path: Record<string, unknown>;
|
|
249
259
|
query: Record<string, unknown>;
|
|
250
260
|
header: Record<string, unknown>;
|
|
@@ -264,7 +274,7 @@ interface CustomField<TName extends FieldPath<FormValues>, Info> {
|
|
|
264
274
|
|
|
265
275
|
declare const APIPlayground: react.ComponentType<APIPlaygroundProps & {
|
|
266
276
|
fields?: {
|
|
267
|
-
auth?: CustomField<"authorization",
|
|
277
|
+
auth?: CustomField<"authorization", RequestSchema>;
|
|
268
278
|
path?: CustomField<`path.${string}`, PrimitiveRequestField>;
|
|
269
279
|
query?: CustomField<`query.${string}`, PrimitiveRequestField>;
|
|
270
280
|
header?: CustomField<`header.${string}`, PrimitiveRequestField>;
|
|
@@ -276,11 +286,6 @@ declare const APIPlayground: react.ComponentType<APIPlaygroundProps & {
|
|
|
276
286
|
}>;
|
|
277
287
|
}>;
|
|
278
288
|
} & HTMLAttributes<HTMLFormElement>>;
|
|
279
|
-
declare const ScalarPlayground: react.ComponentType<{
|
|
280
|
-
spec: object;
|
|
281
|
-
path: string;
|
|
282
|
-
method: string;
|
|
283
|
-
}>;
|
|
284
289
|
declare function Root({ children, baseUrl, className, shikiOptions, servers, ...props }: RootProps & {
|
|
285
290
|
shikiOptions: RenderContext['shikiOptions'];
|
|
286
291
|
} & HTMLAttributes<HTMLDivElement>): ReactNode;
|
|
@@ -294,4 +299,4 @@ declare function ObjectCollapsible(props: {
|
|
|
294
299
|
children: ReactNode;
|
|
295
300
|
}): react_jsx_runtime.JSX.Element;
|
|
296
301
|
|
|
297
|
-
export { API, APIExample, APIInfo, APIPlayground, ObjectCollapsible, Property, Root,
|
|
302
|
+
export { API, APIExample, APIInfo, APIPlayground, ObjectCollapsible, Property, Root, useSchemaContext };
|
package/dist/ui/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from 'fumadocs-ui/components/ui/collapsible';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-CpwKrzlY.js';
|
|
6
|
+
import { C as ChevronDown } from './index-client-CehDtJk-.js';
|
|
7
7
|
|
|
8
8
|
const badgeVariants = cva('rounded-xl border px-1.5 py-1 text-xs font-medium leading-[12px]', {
|
|
9
9
|
variants: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
4
|
-
import { S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem, l as labelVariants, I as Input } from './index-client-
|
|
3
|
+
import { a as useApiContext, b as useServerSelectContext } from './client-client-CpwKrzlY.js';
|
|
4
|
+
import { S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem, l as labelVariants, I as Input } from './index-client-CehDtJk-.js';
|
|
5
5
|
import { cn } from 'fumadocs-ui/components/api';
|
|
6
6
|
|
|
7
7
|
function ServerSelect(props) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"import": "./dist/ui/index.js",
|
|
21
21
|
"types": "./dist/ui/index.d.ts"
|
|
22
22
|
},
|
|
23
|
+
"./scalar": {
|
|
24
|
+
"import": "./dist/scalar/index.js",
|
|
25
|
+
"types": "./dist/scalar/index.d.ts"
|
|
26
|
+
},
|
|
23
27
|
"./server": {
|
|
24
28
|
"import": "./dist/server/index.js",
|
|
25
29
|
"types": "./dist/server/index.d.ts"
|
|
@@ -46,24 +50,24 @@
|
|
|
46
50
|
"react-hook-form": "^7.54.2",
|
|
47
51
|
"remark": "^15.0.1",
|
|
48
52
|
"remark-rehype": "^11.1.1",
|
|
49
|
-
"shiki": "^2.
|
|
53
|
+
"shiki": "^2.2.0",
|
|
50
54
|
"xml-js": "^1.6.11",
|
|
51
55
|
"fumadocs-core": "15.0.0",
|
|
52
56
|
"fumadocs-ui": "15.0.0"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
|
-
"@scalar/api-client-react": "^1.1.
|
|
59
|
+
"@scalar/api-client-react": "^1.1.22",
|
|
56
60
|
"@types/js-yaml": "^4.0.9",
|
|
57
|
-
"@types/node": "22.
|
|
61
|
+
"@types/node": "22.13.0",
|
|
58
62
|
"@types/openapi-sampler": "^1.0.3",
|
|
59
|
-
"@types/react": "^19.0.
|
|
63
|
+
"@types/react": "^19.0.8",
|
|
60
64
|
"bunchee": "^6.3.2",
|
|
61
|
-
"lucide-react": "^0.
|
|
65
|
+
"lucide-react": "^0.474.0",
|
|
62
66
|
"next": "15.1.6",
|
|
63
67
|
"openapi-types": "^12.1.3",
|
|
64
|
-
"tailwindcss": "^4.0.
|
|
65
|
-
"
|
|
66
|
-
"
|
|
68
|
+
"tailwindcss": "^4.0.2",
|
|
69
|
+
"tsconfig": "0.0.0",
|
|
70
|
+
"eslint-config-custom": "0.0.0"
|
|
67
71
|
},
|
|
68
72
|
"peerDependencies": {
|
|
69
73
|
"@scalar/api-client-react": "*",
|