fumadocs-openapi 5.11.1 → 5.11.3
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 +4 -9
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.js +41 -24
- package/dist/ui/client-client-Co3JBILS.js +538 -0
- package/dist/ui/{fetcher-B7R5rjLv.js → fetcher-DLRl_kVF.js} +1 -1
- package/dist/ui/{index-client-B6op0H4J.js → index-client-cz-xNo9A.js} +61 -156
- package/dist/ui/index.d.ts +31 -19
- package/dist/ui/index.js +6 -8
- package/package.json +6 -6
- package/dist/ui/client-client-NS2E5Jdn.js +0 -312
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { forwardRef, useId, createContext, useContext, useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
|
5
4
|
import { FormProvider, Controller, useFormContext, useFieldArray, useForm, useWatch } from 'react-hook-form';
|
|
6
|
-
import {
|
|
5
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from 'fumadocs-ui/components/ui/collapsible';
|
|
7
6
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
8
|
-
import {
|
|
7
|
+
import { u as useSchemaContext, T as Trash2, I as Input, S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem, P as Plus, C as CircleCheck, e as CircleX, f as useApiContext, g as SchemaContext, h as ChevronDown, i as getUrl } from './client-client-Co3JBILS.js';
|
|
9
8
|
import { Slot } from '@radix-ui/react-slot';
|
|
10
9
|
import { cva } from 'class-variance-authority';
|
|
11
10
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
12
|
-
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
13
11
|
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
|
14
12
|
|
|
15
13
|
const Form = FormProvider;
|
|
@@ -56,7 +54,7 @@ const FormItem = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
|
|
|
56
54
|
});
|
|
57
55
|
});
|
|
58
56
|
FormItem.displayName = 'FormItem';
|
|
59
|
-
const labelVariants = cva('text-xs
|
|
57
|
+
const labelVariants = cva('font-mono text-xs text-fd-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
|
|
60
58
|
const FormLabel = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
|
|
61
59
|
const { isError, formItemId } = useFormField();
|
|
62
60
|
return /*#__PURE__*/ jsx("label", {
|
|
@@ -123,98 +121,6 @@ function getDefaultValues(field, context) {
|
|
|
123
121
|
]));
|
|
124
122
|
}
|
|
125
123
|
|
|
126
|
-
const Select = SelectPrimitive.Root;
|
|
127
|
-
const SelectValue = SelectPrimitive.Value;
|
|
128
|
-
const SelectTrigger = /*#__PURE__*/ forwardRef(({ className, children, ...props }, ref)=>/*#__PURE__*/ jsxs(SelectPrimitive.Trigger, {
|
|
129
|
-
ref: ref,
|
|
130
|
-
className: cn('flex h-10 items-center justify-between rounded-md border px-3 py-2 text-sm text-fd-foreground hover:bg-fd-accent focus:outline-none focus:ring-2 focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50', className),
|
|
131
|
-
...props,
|
|
132
|
-
children: [
|
|
133
|
-
children,
|
|
134
|
-
/*#__PURE__*/ jsx(SelectPrimitive.Icon, {
|
|
135
|
-
asChild: true,
|
|
136
|
-
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
137
|
-
className: "size-4 text-fd-muted-foreground"
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
]
|
|
141
|
-
}));
|
|
142
|
-
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
143
|
-
const SelectScrollUpButton = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectPrimitive.ScrollUpButton, {
|
|
144
|
-
ref: ref,
|
|
145
|
-
className: cn('flex items-center justify-center py-1', className),
|
|
146
|
-
...props,
|
|
147
|
-
children: /*#__PURE__*/ jsx(ChevronUp, {
|
|
148
|
-
className: "size-4"
|
|
149
|
-
})
|
|
150
|
-
}));
|
|
151
|
-
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
152
|
-
const SelectScrollDownButton = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectPrimitive.ScrollDownButton, {
|
|
153
|
-
ref: ref,
|
|
154
|
-
className: cn('flex items-center justify-center py-1', className),
|
|
155
|
-
...props,
|
|
156
|
-
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
157
|
-
className: "size-4"
|
|
158
|
-
})
|
|
159
|
-
}));
|
|
160
|
-
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
161
|
-
const SelectContent = /*#__PURE__*/ forwardRef(({ className, children, position = 'popper', ...props }, ref)=>/*#__PURE__*/ jsx(SelectPrimitive.Portal, {
|
|
162
|
-
children: /*#__PURE__*/ jsxs(SelectPrimitive.Content, {
|
|
163
|
-
ref: ref,
|
|
164
|
-
className: cn('z-50 overflow-hidden rounded-lg border bg-fd-popover text-fd-popover-foreground shadow-md data-[state=closed]:animate-fd-popover-out data-[state=open]:animate-fd-popover-in', className),
|
|
165
|
-
position: position,
|
|
166
|
-
...props,
|
|
167
|
-
children: [
|
|
168
|
-
/*#__PURE__*/ jsx(SelectScrollUpButton, {}),
|
|
169
|
-
/*#__PURE__*/ jsx(SelectPrimitive.Viewport, {
|
|
170
|
-
className: cn('p-1', position === 'popper' && 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'),
|
|
171
|
-
children: children
|
|
172
|
-
}),
|
|
173
|
-
/*#__PURE__*/ jsx(SelectScrollDownButton, {})
|
|
174
|
-
]
|
|
175
|
-
})
|
|
176
|
-
}));
|
|
177
|
-
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
178
|
-
const SelectLabel = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectPrimitive.Label, {
|
|
179
|
-
ref: ref,
|
|
180
|
-
className: cn('py-1.5 pe-2 ps-6 text-sm font-semibold', className),
|
|
181
|
-
...props
|
|
182
|
-
}));
|
|
183
|
-
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
184
|
-
const SelectItem = /*#__PURE__*/ forwardRef(({ className, children, ...props }, ref)=>/*#__PURE__*/ jsxs(SelectPrimitive.Item, {
|
|
185
|
-
ref: ref,
|
|
186
|
-
className: cn('flex select-none flex-row items-center rounded-md py-1.5 pe-2 ps-6 text-sm outline-none focus:bg-fd-accent focus:text-fd-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className),
|
|
187
|
-
...props,
|
|
188
|
-
children: [
|
|
189
|
-
/*#__PURE__*/ jsx(SelectPrimitive.ItemIndicator, {
|
|
190
|
-
className: "absolute start-2",
|
|
191
|
-
children: /*#__PURE__*/ jsx(Check, {
|
|
192
|
-
className: "size-4"
|
|
193
|
-
})
|
|
194
|
-
}),
|
|
195
|
-
/*#__PURE__*/ jsx(SelectPrimitive.ItemText, {
|
|
196
|
-
children: children
|
|
197
|
-
})
|
|
198
|
-
]
|
|
199
|
-
}));
|
|
200
|
-
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
201
|
-
const SelectSeparator = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SelectPrimitive.Separator, {
|
|
202
|
-
ref: ref,
|
|
203
|
-
className: cn('my-1 h-px bg-fd-muted', className),
|
|
204
|
-
...props
|
|
205
|
-
}));
|
|
206
|
-
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
207
|
-
|
|
208
|
-
const Input = /*#__PURE__*/ React.forwardRef(({ className, type, ...props }, ref)=>{
|
|
209
|
-
return /*#__PURE__*/ jsx("input", {
|
|
210
|
-
type: type,
|
|
211
|
-
className: cn('flex h-9 w-full rounded-md border bg-transparent px-2 py-1.5 text-sm text-fd-foreground transition-colors placeholder:text-fd-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50', className),
|
|
212
|
-
ref: ref,
|
|
213
|
-
...props
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
Input.displayName = 'Input';
|
|
217
|
-
|
|
218
124
|
function renderInner({ field, ...props }) {
|
|
219
125
|
if (field.type === 'object') return /*#__PURE__*/ jsx(ObjectInput, {
|
|
220
126
|
field: field,
|
|
@@ -240,7 +146,7 @@ function renderInner({ field, ...props }) {
|
|
|
240
146
|
function InputContainer({ toolbar, name, required, type, description, inline = false, ...props }) {
|
|
241
147
|
return /*#__PURE__*/ jsxs("div", {
|
|
242
148
|
...props,
|
|
243
|
-
className: cn('flex flex-col gap-
|
|
149
|
+
className: cn('flex flex-col gap-1', props.className),
|
|
244
150
|
children: [
|
|
245
151
|
/*#__PURE__*/ jsxs("div", {
|
|
246
152
|
className: cn(labelVariants(), 'inline-flex items-center gap-1'),
|
|
@@ -674,15 +580,6 @@ function ArrayInput({ fieldName, field, ...props }) {
|
|
|
674
580
|
});
|
|
675
581
|
}
|
|
676
582
|
|
|
677
|
-
function CodeBlock({ code, lang = 'json' }) {
|
|
678
|
-
const { shikiOptions } = useApiContext();
|
|
679
|
-
return /*#__PURE__*/ jsx(DynamicCodeBlock, {
|
|
680
|
-
lang: lang,
|
|
681
|
-
code: code,
|
|
682
|
-
options: shikiOptions
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
|
|
686
583
|
const statusMap = {
|
|
687
584
|
400: {
|
|
688
585
|
description: 'Bad Request',
|
|
@@ -735,8 +632,8 @@ function getStatusInfo(status) {
|
|
|
735
632
|
};
|
|
736
633
|
}
|
|
737
634
|
|
|
738
|
-
function APIPlayground({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl }) {
|
|
739
|
-
const {
|
|
635
|
+
function APIPlayground({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
|
|
636
|
+
const { serverRef } = useApiContext();
|
|
740
637
|
const dynamicRef = useRef(new Map());
|
|
741
638
|
const form = useForm({
|
|
742
639
|
defaultValues: {
|
|
@@ -748,14 +645,13 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
748
645
|
}
|
|
749
646
|
});
|
|
750
647
|
const testQuery = useQuery(async (input)=>{
|
|
751
|
-
const fetcher = await import('./fetcher-
|
|
752
|
-
const
|
|
753
|
-
let url
|
|
648
|
+
const fetcher = await import('./fetcher-DLRl_kVF.js').then((mod)=>mod.createBrowserFetcher(body, schemas));
|
|
649
|
+
const serverUrl = serverRef.current ? getUrl(serverRef.current.url, serverRef.current.variables) : window.location.origin;
|
|
650
|
+
let url = `${serverUrl}${createPathnameFromInput(route, input.path, input.query)}`;
|
|
754
651
|
if (proxyUrl) {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
url = new URL(targetUrl);
|
|
652
|
+
const updated = new URL(proxyUrl, window.location.origin);
|
|
653
|
+
updated.searchParams.append('url', url);
|
|
654
|
+
url = updated.toString();
|
|
759
655
|
}
|
|
760
656
|
const header = {
|
|
761
657
|
...input.header
|
|
@@ -808,7 +704,6 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
808
704
|
field: info
|
|
809
705
|
}, key);
|
|
810
706
|
}
|
|
811
|
-
const isParamEmpty = path.length === 0 && query.length === 0 && header.length === 0 && body === undefined;
|
|
812
707
|
return /*#__PURE__*/ jsx(Form, {
|
|
813
708
|
...form,
|
|
814
709
|
children: /*#__PURE__*/ jsx(SchemaContext.Provider, {
|
|
@@ -819,7 +714,8 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
819
714
|
schemas
|
|
820
715
|
]),
|
|
821
716
|
children: /*#__PURE__*/ jsxs("form", {
|
|
822
|
-
|
|
717
|
+
...props,
|
|
718
|
+
className: cn('not-prose flex flex-col gap-5 rounded-xl border bg-fd-card p-3', props.className),
|
|
823
719
|
onSubmit: onSubmit,
|
|
824
720
|
children: [
|
|
825
721
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -831,7 +727,7 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
831
727
|
/*#__PURE__*/ jsx("button", {
|
|
832
728
|
type: "submit",
|
|
833
729
|
className: cn(buttonVariants({
|
|
834
|
-
color: '
|
|
730
|
+
color: 'secondary'
|
|
835
731
|
})),
|
|
836
732
|
disabled: testQuery.isLoading,
|
|
837
733
|
children: "Send"
|
|
@@ -839,39 +735,24 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
839
735
|
]
|
|
840
736
|
}),
|
|
841
737
|
authorization ? renderCustomField('authorization', authorization, fields.auth) : null,
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
header.length > 0 ? /*#__PURE__*/ jsx(Accordion, {
|
|
861
|
-
title: "Headers",
|
|
862
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
863
|
-
className: "flex flex-col gap-4",
|
|
864
|
-
children: header.map((field)=>renderCustomField(`header.${field.name}`, field, fields.header, field.name))
|
|
865
|
-
})
|
|
866
|
-
}) : null,
|
|
867
|
-
body ? /*#__PURE__*/ jsx(Accordion, {
|
|
868
|
-
title: "Body",
|
|
869
|
-
children: body.type === 'object' && !fields.body ? /*#__PURE__*/ jsx(ObjectInput, {
|
|
870
|
-
field: body,
|
|
871
|
-
fieldName: "body"
|
|
872
|
-
}) : renderCustomField('body', body, fields.body)
|
|
873
|
-
}) : null
|
|
874
|
-
]
|
|
738
|
+
path.length > 0 ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
739
|
+
title: "Path",
|
|
740
|
+
children: path.map((field)=>renderCustomField(`path.${field.name}`, field, fields.path, field.name))
|
|
741
|
+
}) : null,
|
|
742
|
+
query.length > 0 ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
743
|
+
title: "Query",
|
|
744
|
+
children: query.map((field)=>renderCustomField(`query.${field.name}`, field, fields.query, field.name))
|
|
745
|
+
}) : null,
|
|
746
|
+
header.length > 0 ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
747
|
+
title: "Headers",
|
|
748
|
+
children: header.map((field)=>renderCustomField(`header.${field.name}`, field, fields.header, field.name))
|
|
749
|
+
}) : null,
|
|
750
|
+
body ? /*#__PURE__*/ jsx(CollapsiblePanel, {
|
|
751
|
+
title: "Body",
|
|
752
|
+
children: body.type === 'object' && !fields.body ? /*#__PURE__*/ jsx(ObjectInput, {
|
|
753
|
+
field: body,
|
|
754
|
+
fieldName: "body"
|
|
755
|
+
}) : renderCustomField('body', body, fields.body)
|
|
875
756
|
}) : null,
|
|
876
757
|
testQuery.data ? /*#__PURE__*/ jsx(ResultDisplay, {
|
|
877
758
|
data: testQuery.data
|
|
@@ -881,6 +762,28 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
881
762
|
})
|
|
882
763
|
});
|
|
883
764
|
}
|
|
765
|
+
function CollapsiblePanel({ title, children }) {
|
|
766
|
+
return /*#__PURE__*/ jsxs(Collapsible, {
|
|
767
|
+
className: "-m-2",
|
|
768
|
+
children: [
|
|
769
|
+
/*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
770
|
+
className: "group flex w-full flex-row items-center justify-between p-2 font-medium",
|
|
771
|
+
children: [
|
|
772
|
+
title,
|
|
773
|
+
/*#__PURE__*/ jsx(ChevronDown, {
|
|
774
|
+
className: "size-4 group-data-[state=open]:rotate-180"
|
|
775
|
+
})
|
|
776
|
+
]
|
|
777
|
+
}),
|
|
778
|
+
/*#__PURE__*/ jsx(CollapsibleContent, {
|
|
779
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
780
|
+
className: "flex flex-col gap-4 p-2",
|
|
781
|
+
children: children
|
|
782
|
+
})
|
|
783
|
+
})
|
|
784
|
+
]
|
|
785
|
+
});
|
|
786
|
+
}
|
|
884
787
|
function createPathnameFromInput(route, path, query) {
|
|
885
788
|
let pathname = route;
|
|
886
789
|
for (const key of Object.keys(path)){
|
|
@@ -907,14 +810,15 @@ function RouteDisplay({ route }) {
|
|
|
907
810
|
query
|
|
908
811
|
]);
|
|
909
812
|
return /*#__PURE__*/ jsx("code", {
|
|
910
|
-
className: "flex-1 overflow-auto text-nowrap rounded-lg border bg-fd-
|
|
813
|
+
className: "flex-1 overflow-auto text-nowrap rounded-lg border bg-fd-secondary px-2 py-1.5 text-sm text-fd-secondary-foreground",
|
|
911
814
|
children: pathname
|
|
912
815
|
});
|
|
913
816
|
}
|
|
914
|
-
function
|
|
817
|
+
function DefaultResultDisplay({ data }) {
|
|
915
818
|
const statusInfo = useMemo(()=>getStatusInfo(data.status), [
|
|
916
819
|
data.status
|
|
917
820
|
]);
|
|
821
|
+
const { shikiOptions } = useApiContext();
|
|
918
822
|
return /*#__PURE__*/ jsxs("div", {
|
|
919
823
|
className: "flex flex-col gap-3 rounded-lg border bg-fd-card p-4",
|
|
920
824
|
children: [
|
|
@@ -931,9 +835,10 @@ function ResultDisplay({ data }) {
|
|
|
931
835
|
className: "text-sm text-fd-muted-foreground",
|
|
932
836
|
children: data.status
|
|
933
837
|
}),
|
|
934
|
-
data.data ? /*#__PURE__*/ jsx(
|
|
838
|
+
data.data ? /*#__PURE__*/ jsx(DynamicCodeBlock, {
|
|
935
839
|
lang: typeof data.data === 'string' && data.data.length > 50000 ? 'text' : data.type,
|
|
936
|
-
code: typeof data.data === 'string' ? data.data : JSON.stringify(data.data, null, 2)
|
|
840
|
+
code: typeof data.data === 'string' ? data.data : JSON.stringify(data.data, null, 2),
|
|
841
|
+
...shikiOptions
|
|
937
842
|
}) : null
|
|
938
843
|
]
|
|
939
844
|
});
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ComponentType,
|
|
4
|
-
import { FieldPath, ControllerRenderProps, ControllerFieldState, UseFormStateReturn } from 'react-hook-form';
|
|
3
|
+
import { ReactNode, ComponentType, RefObject, ReactElement, HTMLAttributes } from 'react';
|
|
5
4
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
6
5
|
import Slugger from 'github-slugger';
|
|
7
6
|
import { CodeToHastOptionsCommon, CodeOptionsThemes, BuiltinTheme } from 'shiki';
|
|
7
|
+
import { FieldPath, ControllerRenderProps, ControllerFieldState, UseFormStateReturn } from 'react-hook-form';
|
|
8
8
|
|
|
9
9
|
type NoReference<T> = T extends (infer I)[] ? NoReference<I>[] : T extends ReferenceObject ? Exclude<T, ReferenceObject> : T extends object ? {
|
|
10
10
|
[K in keyof T]: NoReference<T[K]>;
|
|
@@ -48,6 +48,7 @@ interface CodeSample {
|
|
|
48
48
|
|
|
49
49
|
type Document = OpenAPIV3_1.Document;
|
|
50
50
|
type ReferenceObject = OpenAPIV3_1.ReferenceObject;
|
|
51
|
+
type ServerObject = NoReference<OpenAPIV3_1.ServerObject>;
|
|
51
52
|
type Awaitable<T> = T | Promise<T>;
|
|
52
53
|
/**
|
|
53
54
|
* Dereferenced value and its original `$ref` value
|
|
@@ -64,7 +65,7 @@ interface RenderContext {
|
|
|
64
65
|
*/
|
|
65
66
|
document: NoReference<Document>;
|
|
66
67
|
baseUrl: string;
|
|
67
|
-
|
|
68
|
+
servers: ServerObject[];
|
|
68
69
|
slugger: Slugger;
|
|
69
70
|
dereferenceMap: DereferenceMap;
|
|
70
71
|
/**
|
|
@@ -153,7 +154,6 @@ interface ResponseProps {
|
|
|
153
154
|
interface APIInfoProps {
|
|
154
155
|
method: string;
|
|
155
156
|
route: string;
|
|
156
|
-
baseUrls: string[];
|
|
157
157
|
head: ReactNode;
|
|
158
158
|
children: ReactNode;
|
|
159
159
|
}
|
|
@@ -180,6 +180,7 @@ interface ResponseTypeProps {
|
|
|
180
180
|
}
|
|
181
181
|
interface RootProps {
|
|
182
182
|
baseUrl?: string;
|
|
183
|
+
servers: ServerObject[];
|
|
183
184
|
children: ReactNode;
|
|
184
185
|
}
|
|
185
186
|
interface Renderer {
|
|
@@ -210,6 +211,25 @@ interface Renderer {
|
|
|
210
211
|
APIPlayground: ComponentType<APIPlaygroundProps>;
|
|
211
212
|
}
|
|
212
213
|
|
|
214
|
+
interface SchemaContextType {
|
|
215
|
+
references: Record<string, RequestSchema>;
|
|
216
|
+
dynamic: RefObject<Map<string, DynamicField>>;
|
|
217
|
+
}
|
|
218
|
+
type DynamicField = {
|
|
219
|
+
type: 'object';
|
|
220
|
+
properties: string[];
|
|
221
|
+
} | {
|
|
222
|
+
type: 'field';
|
|
223
|
+
schema: RequestSchema | ReferenceSchema;
|
|
224
|
+
};
|
|
225
|
+
declare function useSchemaContext(): SchemaContextType;
|
|
226
|
+
|
|
227
|
+
interface FetchResult {
|
|
228
|
+
status: number;
|
|
229
|
+
type: 'json' | 'html' | 'text';
|
|
230
|
+
data: unknown;
|
|
231
|
+
}
|
|
232
|
+
|
|
213
233
|
interface FormValues {
|
|
214
234
|
authorization: string;
|
|
215
235
|
path: Record<string, unknown>;
|
|
@@ -229,19 +249,6 @@ interface CustomField<TName extends FieldPath<FormValues>, Info> {
|
|
|
229
249
|
}) => ReactElement;
|
|
230
250
|
}
|
|
231
251
|
|
|
232
|
-
interface SchemaContextType {
|
|
233
|
-
references: Record<string, RequestSchema>;
|
|
234
|
-
dynamic: RefObject<Map<string, DynamicField>>;
|
|
235
|
-
}
|
|
236
|
-
type DynamicField = {
|
|
237
|
-
type: 'object';
|
|
238
|
-
properties: string[];
|
|
239
|
-
} | {
|
|
240
|
-
type: 'field';
|
|
241
|
-
schema: RequestSchema | ReferenceSchema;
|
|
242
|
-
};
|
|
243
|
-
declare function useSchemaContext(): SchemaContextType;
|
|
244
|
-
|
|
245
252
|
declare const APIPlayground: react.ComponentType<APIPlaygroundProps & {
|
|
246
253
|
fields?: {
|
|
247
254
|
auth?: CustomField<"authorization", PrimitiveRequestField>;
|
|
@@ -250,12 +257,17 @@ declare const APIPlayground: react.ComponentType<APIPlaygroundProps & {
|
|
|
250
257
|
header?: CustomField<`header.${string}`, PrimitiveRequestField>;
|
|
251
258
|
body?: CustomField<"body", RequestSchema>;
|
|
252
259
|
};
|
|
260
|
+
components?: Partial<{
|
|
261
|
+
ResultDisplay: react.FC<{
|
|
262
|
+
data: FetchResult;
|
|
263
|
+
}>;
|
|
264
|
+
}>;
|
|
253
265
|
} & HTMLAttributes<HTMLFormElement>>;
|
|
254
|
-
declare function Root({ children, baseUrl, className, shikiOptions, ...props }: RootProps & {
|
|
266
|
+
declare function Root({ children, baseUrl, className, shikiOptions, servers, ...props }: RootProps & {
|
|
255
267
|
shikiOptions: RenderContext['shikiOptions'];
|
|
256
268
|
} & HTMLAttributes<HTMLDivElement>): ReactNode;
|
|
257
269
|
|
|
258
|
-
declare function APIInfo({ className, route, badgeClassname,
|
|
270
|
+
declare function APIInfo({ className, route, badgeClassname, method, head, ...props }: APIInfoProps & HTMLAttributes<HTMLDivElement> & {
|
|
259
271
|
badgeClassname?: string;
|
|
260
272
|
}): react_jsx_runtime.JSX.Element;
|
|
261
273
|
declare function API({ children, ...props }: HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
package/dist/ui/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { cn } from 'fumadocs-ui/components/api';
|
|
|
3
3
|
import { Fragment } from 'react';
|
|
4
4
|
import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
5
5
|
import { cva } from 'class-variance-authority';
|
|
6
|
-
import {
|
|
7
|
-
export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-
|
|
6
|
+
import { j as CopyRouteButton, k as ServerSelect } from './client-client-Co3JBILS.js';
|
|
7
|
+
export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-Co3JBILS.js';
|
|
8
8
|
|
|
9
9
|
const badgeVariants = cva('rounded-xl border px-1.5 py-1 text-xs font-medium leading-[12px]', {
|
|
10
10
|
variants: {
|
|
@@ -53,17 +53,17 @@ function Route({ route }) {
|
|
|
53
53
|
}, index))
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
function APIInfo({ className, route, badgeClassname,
|
|
56
|
+
function APIInfo({ className, route, badgeClassname, method = 'GET', head, ...props }) {
|
|
57
57
|
return /*#__PURE__*/ jsxs("div", {
|
|
58
58
|
className: cn('min-w-0 flex-1', className),
|
|
59
59
|
...props,
|
|
60
60
|
children: [
|
|
61
61
|
head,
|
|
62
62
|
/*#__PURE__*/ jsxs("div", {
|
|
63
|
-
className: "
|
|
63
|
+
className: "not-prose mb-4 rounded-lg border bg-fd-card p-3 text-fd-card-foreground shadow-lg",
|
|
64
64
|
children: [
|
|
65
65
|
/*#__PURE__*/ jsxs("div", {
|
|
66
|
-
className: "flex flex-row items-center gap-1.5",
|
|
66
|
+
className: "-mx-1 flex flex-row items-center gap-1.5",
|
|
67
67
|
children: [
|
|
68
68
|
/*#__PURE__*/ jsx("span", {
|
|
69
69
|
className: cn(badgeVariants({
|
|
@@ -80,9 +80,7 @@ function APIInfo({ className, route, badgeClassname, baseUrls, method = 'GET', h
|
|
|
80
80
|
})
|
|
81
81
|
]
|
|
82
82
|
}),
|
|
83
|
-
/*#__PURE__*/ jsx(
|
|
84
|
-
baseUrls: baseUrls
|
|
85
|
-
})
|
|
83
|
+
/*#__PURE__*/ jsx(ServerSelect, {})
|
|
86
84
|
]
|
|
87
85
|
}),
|
|
88
86
|
/*#__PURE__*/ jsx("div", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.3",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@scalar/openapi-parser": "0.10.2",
|
|
38
38
|
"ajv-draft-04": "^1.0.0",
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
|
-
"fast-glob": "^3.3.
|
|
40
|
+
"fast-glob": "^3.3.3",
|
|
41
41
|
"github-slugger": "^2.0.0",
|
|
42
42
|
"hast-util-to-jsx-runtime": "^2.3.2",
|
|
43
43
|
"js-yaml": "^4.1.0",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"remark-rehype": "^11.1.1",
|
|
48
48
|
"shiki": "^1.26.1",
|
|
49
49
|
"xml-js": "^1.6.11",
|
|
50
|
-
"fumadocs-core": "14.7.
|
|
51
|
-
"fumadocs-ui": "14.7.
|
|
50
|
+
"fumadocs-core": "14.7.2",
|
|
51
|
+
"fumadocs-ui": "14.7.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/js-yaml": "^4.0.9",
|
|
55
55
|
"@types/node": "22.10.5",
|
|
56
56
|
"@types/openapi-sampler": "^1.0.3",
|
|
57
|
-
"@types/react": "^19.0.
|
|
57
|
+
"@types/react": "^19.0.4",
|
|
58
58
|
"bunchee": "^6.2.0",
|
|
59
59
|
"lucide-react": "^0.469.0",
|
|
60
|
-
"next": "15.1.
|
|
60
|
+
"next": "15.1.4",
|
|
61
61
|
"openapi-types": "^12.1.3",
|
|
62
62
|
"eslint-config-custom": "0.0.0",
|
|
63
63
|
"tsconfig": "0.0.0"
|