fumadocs-openapi 5.11.2 → 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/server/index.js +19 -2
- package/dist/ui/{client-client-Dxsry8Mu.js → client-client-Co3JBILS.js} +7 -7
- package/dist/ui/{fetcher-C0NHTJev.js → fetcher-DLRl_kVF.js} +1 -1
- package/dist/ui/{index-client-wsc_5cAY.js → index-client-cz-xNo9A.js} +45 -39
- package/dist/ui/index.js +2 -2
- package/package.json +4 -4
package/dist/server/index.js
CHANGED
|
@@ -1251,6 +1251,14 @@ const cache = new Map();
|
|
|
1251
1251
|
return processed;
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
1254
|
+
function getUrl(url, variables) {
|
|
1255
|
+
let out = url;
|
|
1256
|
+
for (const [key, value] of Object.entries(variables)){
|
|
1257
|
+
out = out.replaceAll(`{${key}}`, value);
|
|
1258
|
+
}
|
|
1259
|
+
return out;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1254
1262
|
async function APIPage(props) {
|
|
1255
1263
|
const { operations, hasHead = true, webhooks, disableCache = process.env.NODE_ENV === 'development' } = props;
|
|
1256
1264
|
const processed = await processDocument(props.document, disableCache);
|
|
@@ -1294,6 +1302,12 @@ async function APIPage(props) {
|
|
|
1294
1302
|
});
|
|
1295
1303
|
}
|
|
1296
1304
|
async function getContext({ document, dereferenceMap }, options = {}) {
|
|
1305
|
+
const servers = document.servers && document.servers.length > 0 ? document.servers : [
|
|
1306
|
+
{
|
|
1307
|
+
url: 'https://example.com'
|
|
1308
|
+
}
|
|
1309
|
+
];
|
|
1310
|
+
const server = servers[0];
|
|
1297
1311
|
return {
|
|
1298
1312
|
document: document,
|
|
1299
1313
|
dereferenceMap,
|
|
@@ -1305,8 +1319,11 @@ async function getContext({ document, dereferenceMap }, options = {}) {
|
|
|
1305
1319
|
shikiOptions: options.shikiOptions,
|
|
1306
1320
|
generateTypeScriptSchema: options.generateTypeScriptSchema,
|
|
1307
1321
|
generateCodeSamples: options.generateCodeSamples,
|
|
1308
|
-
baseUrl:
|
|
1309
|
-
|
|
1322
|
+
baseUrl: getUrl(server.url, server.variables ? Object.fromEntries(Object.entries(server.variables).map(([k, v])=>[
|
|
1323
|
+
k,
|
|
1324
|
+
v.default
|
|
1325
|
+
])) : {}),
|
|
1326
|
+
servers,
|
|
1310
1327
|
slugger: new Slugger()
|
|
1311
1328
|
};
|
|
1312
1329
|
}
|
|
@@ -314,14 +314,14 @@ const Select = SelectPrimitive.Root;
|
|
|
314
314
|
const SelectValue = SelectPrimitive.Value;
|
|
315
315
|
const SelectTrigger = /*#__PURE__*/ forwardRef(({ className, children, ...props }, ref)=>/*#__PURE__*/ jsxs(SelectPrimitive.Trigger, {
|
|
316
316
|
ref: ref,
|
|
317
|
-
className: cn('flex h-10 items-center
|
|
317
|
+
className: cn('flex h-10 items-center rounded-md border px-3 py-2 text-start 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),
|
|
318
318
|
...props,
|
|
319
319
|
children: [
|
|
320
320
|
children,
|
|
321
321
|
/*#__PURE__*/ jsx(SelectPrimitive.Icon, {
|
|
322
322
|
asChild: true,
|
|
323
323
|
children: /*#__PURE__*/ jsx(ChevronDown, {
|
|
324
|
-
className: "size-4 text-fd-muted-foreground"
|
|
324
|
+
className: "ms-auto size-4 text-fd-muted-foreground"
|
|
325
325
|
})
|
|
326
326
|
})
|
|
327
327
|
]
|
|
@@ -407,7 +407,7 @@ function useSchemaContext() {
|
|
|
407
407
|
return ctx;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
const APIPlayground = dynamic(()=>import('./index-client-
|
|
410
|
+
const APIPlayground = dynamic(()=>import('./index-client-cz-xNo9A.js').then(function (n) { return n.i; }).then((mod)=>mod.APIPlayground));
|
|
411
411
|
function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
|
|
412
412
|
return /*#__PURE__*/ jsx("div", {
|
|
413
413
|
className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className),
|
|
@@ -450,11 +450,11 @@ function ServerSelect() {
|
|
|
450
450
|
className: "-m-2 mt-2",
|
|
451
451
|
children: [
|
|
452
452
|
/*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
453
|
-
className: "flex w-full flex-row items-center justify-between p-2 text-xs font-medium",
|
|
453
|
+
className: "flex w-full flex-row items-center justify-between p-2 text-xs font-medium text-fd-muted-foreground",
|
|
454
454
|
children: [
|
|
455
455
|
"Configure Server",
|
|
456
456
|
/*#__PURE__*/ jsx(ChevronDown, {
|
|
457
|
-
className: "size-4
|
|
457
|
+
className: "size-4"
|
|
458
458
|
})
|
|
459
459
|
]
|
|
460
460
|
}),
|
|
@@ -467,7 +467,7 @@ function ServerSelect() {
|
|
|
467
467
|
onValueChange: setServer,
|
|
468
468
|
children: [
|
|
469
469
|
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
470
|
-
className: "h-auto",
|
|
470
|
+
className: "h-auto break-all",
|
|
471
471
|
children: /*#__PURE__*/ jsx(SelectValue, {})
|
|
472
472
|
}),
|
|
473
473
|
/*#__PURE__*/ jsx(SelectContent, {
|
|
@@ -535,4 +535,4 @@ function ServerSelect() {
|
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
export { APIPlayground as A, CircleCheck as C, Input as I, Plus as P, Root as R, Select as S, Trash2 as T, SelectTrigger as a, SelectValue as b, SelectContent as c, SelectItem as d, CircleX as e, useApiContext as f, SchemaContext as g,
|
|
538
|
+
export { APIPlayground as A, CircleCheck as C, Input as I, Plus as P, Root as R, Select as S, Trash2 as T, SelectTrigger as a, SelectValue as b, SelectContent as c, SelectItem as d, CircleX as e, useApiContext as f, SchemaContext as g, ChevronDown as h, getUrl as i, CopyRouteButton as j, ServerSelect as k, useSchemaContext as u };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef, useId, createContext, useContext, useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
|
4
4
|
import { FormProvider, Controller, useFormContext, useFieldArray, useForm, useWatch } from 'react-hook-form';
|
|
5
|
-
import {
|
|
5
|
+
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from 'fumadocs-ui/components/ui/collapsible';
|
|
6
6
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
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 getUrl } from './client-client-
|
|
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';
|
|
8
8
|
import { Slot } from '@radix-ui/react-slot';
|
|
9
9
|
import { cva } from 'class-variance-authority';
|
|
10
10
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
@@ -645,7 +645,7 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
645
645
|
}
|
|
646
646
|
});
|
|
647
647
|
const testQuery = useQuery(async (input)=>{
|
|
648
|
-
const fetcher = await import('./fetcher-
|
|
648
|
+
const fetcher = await import('./fetcher-DLRl_kVF.js').then((mod)=>mod.createBrowserFetcher(body, schemas));
|
|
649
649
|
const serverUrl = serverRef.current ? getUrl(serverRef.current.url, serverRef.current.variables) : window.location.origin;
|
|
650
650
|
let url = `${serverUrl}${createPathnameFromInput(route, input.path, input.query)}`;
|
|
651
651
|
if (proxyUrl) {
|
|
@@ -704,7 +704,6 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
704
704
|
field: info
|
|
705
705
|
}, key);
|
|
706
706
|
}
|
|
707
|
-
const isParamEmpty = path.length === 0 && query.length === 0 && header.length === 0 && body === undefined;
|
|
708
707
|
return /*#__PURE__*/ jsx(Form, {
|
|
709
708
|
...form,
|
|
710
709
|
children: /*#__PURE__*/ jsx(SchemaContext.Provider, {
|
|
@@ -728,7 +727,7 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
728
727
|
/*#__PURE__*/ jsx("button", {
|
|
729
728
|
type: "submit",
|
|
730
729
|
className: cn(buttonVariants({
|
|
731
|
-
color: '
|
|
730
|
+
color: 'secondary'
|
|
732
731
|
})),
|
|
733
732
|
disabled: testQuery.isLoading,
|
|
734
733
|
children: "Send"
|
|
@@ -736,39 +735,24 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
736
735
|
]
|
|
737
736
|
}),
|
|
738
737
|
authorization ? renderCustomField('authorization', authorization, fields.auth) : null,
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
header.length > 0 ? /*#__PURE__*/ jsx(Accordion, {
|
|
758
|
-
title: "Headers",
|
|
759
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
760
|
-
className: "flex flex-col gap-4",
|
|
761
|
-
children: header.map((field)=>renderCustomField(`header.${field.name}`, field, fields.header, field.name))
|
|
762
|
-
})
|
|
763
|
-
}) : null,
|
|
764
|
-
body ? /*#__PURE__*/ jsx(Accordion, {
|
|
765
|
-
title: "Body",
|
|
766
|
-
children: body.type === 'object' && !fields.body ? /*#__PURE__*/ jsx(ObjectInput, {
|
|
767
|
-
field: body,
|
|
768
|
-
fieldName: "body"
|
|
769
|
-
}) : renderCustomField('body', body, fields.body)
|
|
770
|
-
}) : null
|
|
771
|
-
]
|
|
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)
|
|
772
756
|
}) : null,
|
|
773
757
|
testQuery.data ? /*#__PURE__*/ jsx(ResultDisplay, {
|
|
774
758
|
data: testQuery.data
|
|
@@ -778,6 +762,28 @@ function APIPlayground({ route, method = 'GET', authorization, path = [], header
|
|
|
778
762
|
})
|
|
779
763
|
});
|
|
780
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
|
+
}
|
|
781
787
|
function createPathnameFromInput(route, path, query) {
|
|
782
788
|
let pathname = route;
|
|
783
789
|
for (const key of Object.keys(path)){
|
|
@@ -804,7 +810,7 @@ function RouteDisplay({ route }) {
|
|
|
804
810
|
query
|
|
805
811
|
]);
|
|
806
812
|
return /*#__PURE__*/ jsx("code", {
|
|
807
|
-
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",
|
|
808
814
|
children: pathname
|
|
809
815
|
});
|
|
810
816
|
}
|
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: {
|
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",
|
|
@@ -54,10 +54,10 @@
|
|
|
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"
|