fumadocs-openapi 9.0.4 → 9.0.6
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/playground/auth/oauth-dialog.d.ts +4 -2
- package/dist/playground/auth/oauth-dialog.d.ts.map +1 -1
- package/dist/playground/auth/oauth-dialog.js +113 -26
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +105 -69
- package/dist/playground/fetcher.d.ts +6 -1
- package/dist/playground/fetcher.d.ts.map +1 -1
- package/dist/playground/fetcher.js +2 -4
- package/dist/playground/index.js +26 -15
- package/dist/playground/inputs.d.ts +8 -2
- package/dist/playground/inputs.d.ts.map +1 -1
- package/dist/playground/inputs.js +32 -31
- package/dist/render/api-page.d.ts.map +1 -1
- package/dist/render/api-page.js +2 -10
- package/dist/render/heading.d.ts +1 -1
- package/dist/render/heading.d.ts.map +1 -1
- package/dist/render/heading.js +3 -3
- package/dist/render/markdown.d.ts +2 -2
- package/dist/render/markdown.d.ts.map +1 -1
- package/dist/render/markdown.js +4 -2
- package/dist/render/operation/index.d.ts.map +1 -1
- package/dist/render/operation/index.js +68 -58
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +3 -3
- package/dist/render/schema.d.ts.map +1 -1
- package/dist/render/schema.js +7 -8
- package/dist/requests/_shared.d.ts +0 -1
- package/dist/requests/_shared.d.ts.map +1 -1
- package/dist/requests/_shared.js +0 -4
- package/dist/requests/curl.d.ts.map +1 -1
- package/dist/requests/curl.js +3 -2
- package/dist/requests/go.d.ts.map +1 -1
- package/dist/requests/go.js +3 -2
- package/dist/requests/javascript.d.ts.map +1 -1
- package/dist/requests/javascript.js +3 -2
- package/dist/requests/python.d.ts.map +1 -1
- package/dist/requests/python.js +2 -2
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/components/accordion.d.ts +8 -0
- package/dist/ui/components/accordion.d.ts.map +1 -0
- package/dist/ui/components/accordion.js +20 -0
- package/dist/ui/components/input.js +1 -1
- package/dist/ui/components/select.js +1 -1
- package/dist/ui/contexts/api.js +1 -1
- package/dist/ui/contexts/code-example.d.ts.map +1 -1
- package/dist/ui/contexts/code-example.js +4 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +5 -3
- package/dist/ui/select-tabs.d.ts +13 -0
- package/dist/ui/select-tabs.d.ts.map +1 -0
- package/dist/ui/select-tabs.js +20 -0
- package/dist/ui/server-select.d.ts.map +1 -1
- package/dist/ui/server-select.js +24 -19
- package/dist/utils/schema-to-string.d.ts.map +1 -1
- package/dist/utils/schema-to-string.js +10 -1
- package/dist/utils/schema.d.ts +0 -1
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +0 -10
- package/dist/utils/url.d.ts +10 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +51 -0
- package/package.json +10 -9
- package/dist/utils/get-pathname-from-input.d.ts +0 -2
- package/dist/utils/get-pathname-from-input.d.ts.map +0 -1
- package/dist/utils/get-pathname-from-input.js +0 -27
- package/dist/utils/server-url.d.ts +0 -2
- package/dist/utils/server-url.d.ts.map +0 -1
- package/dist/utils/server-url.js +0 -7
package/dist/requests/curl.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { inputToString } from '../utils/input-to-string.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ident } from '../requests/_shared.js';
|
|
4
|
+
import { resolveRequestData } from '../utils/url.js';
|
|
4
5
|
const MediaTypeFormatMap = {
|
|
5
6
|
'application/json': 'json',
|
|
6
7
|
'application/xml': 'xml',
|
|
@@ -8,7 +9,7 @@ const MediaTypeFormatMap = {
|
|
|
8
9
|
};
|
|
9
10
|
export const generator = (url, data) => {
|
|
10
11
|
const s = [];
|
|
11
|
-
s.push(`curl -X ${data.method} "${
|
|
12
|
+
s.push(`curl -X ${data.method} "${resolveRequestData(url, data)}"`);
|
|
12
13
|
for (const header in data.header) {
|
|
13
14
|
const value = `${header}: ${data.header[header]}`;
|
|
14
15
|
s.push(`-H "${value}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/requests/go.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/requests/go.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG5D,eAAO,MAAM,SAAS,EAAE,eAqDvB,CAAC"}
|
package/dist/requests/go.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { ident } from '../requests/_shared.js';
|
|
3
|
+
import { resolveRequestData } from '../utils/url.js';
|
|
3
4
|
export const generator = (url, data, { mediaAdapters }) => {
|
|
4
5
|
const imports = ['fmt', 'net/http', 'io/ioutil'];
|
|
5
6
|
const headers = new Map();
|
|
6
7
|
const variables = new Map();
|
|
7
|
-
variables.set('url', JSON.stringify(
|
|
8
|
+
variables.set('url', JSON.stringify(resolveRequestData(url, data)));
|
|
8
9
|
for (const header in data.header) {
|
|
9
10
|
headers.set(header, JSON.stringify(data.header[header]));
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/requests/javascript.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/requests/javascript.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGjE,eAAO,MAAM,SAAS,EAAE,eA0CvB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { ident } from '../requests/_shared.js';
|
|
3
|
+
import { resolveRequestData } from '../utils/url.js';
|
|
3
4
|
export const generator = (url, data, { mediaAdapters }) => {
|
|
4
5
|
const s = [];
|
|
5
6
|
const options = new Map();
|
|
@@ -25,7 +26,7 @@ export const generator = (url, data, { mediaAdapters }) => {
|
|
|
25
26
|
s.push(body);
|
|
26
27
|
options.set('body', 'body');
|
|
27
28
|
}
|
|
28
|
-
const params = [JSON.stringify(
|
|
29
|
+
const params = [JSON.stringify(resolveRequestData(url, data))];
|
|
29
30
|
if (options.size > 0) {
|
|
30
31
|
const str = Array.from(options.entries())
|
|
31
32
|
.map(([k, v]) => ident(k === v ? k : `${k}: ${v}`))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,eAAO,MAAM,SAAS,EAAE,eAkCvB,CAAC"}
|
package/dist/requests/python.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveRequestData } from '../utils/url.js';
|
|
3
3
|
export const generator = (url, data, { mediaAdapters }) => {
|
|
4
4
|
const headers = { ...data.header };
|
|
5
5
|
const params = [`"${data.method}"`, 'url'];
|
|
@@ -24,7 +24,7 @@ export const generator = (url, data, { mediaAdapters }) => {
|
|
|
24
24
|
}
|
|
25
25
|
return `import requests
|
|
26
26
|
|
|
27
|
-
url = ${JSON.stringify(
|
|
27
|
+
url = ${JSON.stringify(resolveRequestData(url, data))}
|
|
28
28
|
${body ?? ''}
|
|
29
29
|
response = requests.request(${params.join(', ')})
|
|
30
30
|
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","s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C,EAAE,OAAO,CAAC;IAE7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Primitive from '@radix-ui/react-accordion';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
export declare function Accordions(props: ComponentProps<typeof Primitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function AccordionItem(props: ComponentProps<typeof Primitive.Item>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function AccordionContent(props: ComponentProps<typeof Primitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function AccordionHeader(props: ComponentProps<typeof Primitive.Header>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function AccordionTrigger(props: ComponentProps<typeof Primitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../src/ui/components/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,2CAUtE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,2CAMzE;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,2CAahD;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,2CAa/C;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,cAAc,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,2CAchD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as Primitive from '@radix-ui/react-accordion';
|
|
4
|
+
import { ChevronRight } from '../../icons.js';
|
|
5
|
+
import { cn } from 'fumadocs-ui/utils/cn';
|
|
6
|
+
export function Accordions(props) {
|
|
7
|
+
return (_jsx(Primitive.Root, { ...props, className: cn('divide-y divide-fd-border overflow-hidden', props.className) }));
|
|
8
|
+
}
|
|
9
|
+
export function AccordionItem(props) {
|
|
10
|
+
return (_jsx(Primitive.Item, { ...props, className: cn('scroll-m-20', props.className), children: props.children }));
|
|
11
|
+
}
|
|
12
|
+
export function AccordionContent(props) {
|
|
13
|
+
return (_jsx(Primitive.Content, { ...props, className: cn('overflow-hidden px-1 data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down', props.className), children: props.children }));
|
|
14
|
+
}
|
|
15
|
+
export function AccordionHeader(props) {
|
|
16
|
+
return (_jsx(Primitive.Header, { ...props, className: cn('not-prose flex py-2 text-fd-foreground font-medium', props.className), children: props.children }));
|
|
17
|
+
}
|
|
18
|
+
export function AccordionTrigger(props) {
|
|
19
|
+
return (_jsxs(Primitive.Trigger, { ...props, className: cn('flex flex-1 items-center gap-1 text-start group/accordion focus-visible:outline-none', props.className), children: [_jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-data-[state=open]/accordion:rotate-90" }), props.children] }));
|
|
20
|
+
}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { cn } from 'fumadocs-ui/utils/cn';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
|
-
export const labelVariants = cva('text-xs font-medium text-fd-foreground
|
|
5
|
+
export const labelVariants = cva('text-xs font-medium text-fd-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
|
|
6
6
|
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
7
7
|
return (_jsx("input", { type: type, className: cn('flex h-9 w-full rounded-md border bg-fd-secondary px-2 py-1.5 text-[13px] text-fd-secondary-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), ref: ref, ...props }));
|
|
8
8
|
});
|
|
@@ -6,7 +6,7 @@ import { cn } from 'fumadocs-ui/utils/cn';
|
|
|
6
6
|
const Select = SelectPrimitive.Root;
|
|
7
7
|
const SelectGroup = SelectPrimitive.Group;
|
|
8
8
|
const SelectValue = SelectPrimitive.Value;
|
|
9
|
-
const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex
|
|
9
|
+
const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex items-center w-full rounded-md border p-2 gap-2 text-start text-[13px] text-fd-secondary-foreground bg-fd-secondary hover:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50', className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "ms-auto size-3.5 text-fd-muted-foreground" }) })] })));
|
|
10
10
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
11
11
|
const SelectScrollUpButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn('flex items-center justify-center py-1', className), ...props, children: _jsx(ChevronUp, { className: "size-4" }) })));
|
|
12
12
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -20,7 +20,7 @@ export function ApiProvider({ defaultBaseUrl, children, servers, mediaAdapters,
|
|
|
20
20
|
const [server, setServer] = useState(() => {
|
|
21
21
|
const defaultItem = defaultBaseUrl
|
|
22
22
|
? servers.find((item) => item.url === defaultBaseUrl)
|
|
23
|
-
:
|
|
23
|
+
: servers.at(0);
|
|
24
24
|
return defaultItem
|
|
25
25
|
? {
|
|
26
26
|
url: defaultItem.url,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-example.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/code-example.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAqBtD,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,WAAW,CAAC;KACnB,EAAE,CAAC;IACJ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAwDA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"code-example.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/code-example.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAqBtD,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,WAAW,CAAC;KACnB,EAAE,CAAC;IACJ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAwDA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,kDAgD5C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY,2CAoB1D;AAgBD,wBAAgB,qBAAqB,gBAOpC;AAED,wBAAgB,qBAAqB;oBA5KnB,WAAW,KAAK,IAAI;EA+KrC"}
|
|
@@ -5,7 +5,7 @@ import { useApiContext, useServerSelectContext } from '../../ui/contexts/api.js'
|
|
|
5
5
|
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
|
6
6
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
|
|
7
7
|
import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
|
|
8
|
-
import {
|
|
8
|
+
import { joinURL, resolveServerUrl, withBase } from '../../utils/url.js';
|
|
9
9
|
import { defaultSamples } from '../../requests/index.js';
|
|
10
10
|
const CodeExampleContext = createContext(null);
|
|
11
11
|
export function CodeExampleProvider({ route, examples, initialKey, children, }) {
|
|
@@ -72,7 +72,9 @@ export function CodeExample(props) {
|
|
|
72
72
|
return;
|
|
73
73
|
if (typeof sample.source === 'string')
|
|
74
74
|
return sample.source;
|
|
75
|
-
return sample.source(
|
|
75
|
+
return sample.source(joinURL(withBase(server ? resolveServerUrl(server.url, server.variables) : '/', typeof window !== 'undefined'
|
|
76
|
+
? window.location.origin
|
|
77
|
+
: 'https://loading'), route), data, {
|
|
76
78
|
mediaAdapters,
|
|
77
79
|
});
|
|
78
80
|
}, [mediaAdapters, sample, server, route, data]);
|
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;AAYlE,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,SAAS,GAAG,cAAc,CAAC,cAAc,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,2CAkB5C;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,MAAM,EACN,GAAG,KAAK,EACT,EAAE,aAAa,2CA+Bf;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
|
@@ -6,7 +6,7 @@ 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', className), ...props, children: _jsx(ApiProvider, { mediaAdapters: Object.fromEntries(Object.entries(ctx.mediaAdapters).filter(([_, v]) => typeof v !== 'boolean')), servers: ctx.servers, shikiOptions: ctx.shikiOptions,
|
|
9
|
+
return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm', className), ...props, children: _jsx(ApiProvider, { mediaAdapters: Object.fromEntries(Object.entries(ctx.mediaAdapters).filter(([_, v]) => typeof v !== 'boolean')), servers: ctx.servers, shikiOptions: ctx.shikiOptions, 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 }));
|
|
@@ -18,12 +18,14 @@ export function API({ children, ...props }) {
|
|
|
18
18
|
}, children: children }));
|
|
19
19
|
}
|
|
20
20
|
export function Property({ name, type, required, deprecated, nested, ...props }) {
|
|
21
|
-
return (_jsxs("div", { className: cn('
|
|
21
|
+
return (_jsxs("div", { className: cn('text-sm border-t', nested
|
|
22
|
+
? 'p-3 border-x bg-fd-card last:rounded-b-xl first:rounded-tr-xl last:border-b'
|
|
23
|
+
: 'py-4 first:border-t-0'), children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2 not-prose", children: [_jsxs("span", { className: "font-medium font-mono text-fd-primary", children: [name, required === false && (_jsx("span", { className: "text-fd-muted-foreground", children: "?" }))] }), _jsx("span", { className: "me-auto text-xs font-mono text-fd-muted-foreground", children: type }), deprecated && (_jsx(Badge, { color: "yellow", className: "text-xs", children: "Deprecated" }))] }), _jsx("div", { className: "prose-no-margin pt-2.5 empty:hidden", children: props.children })] }));
|
|
22
24
|
}
|
|
23
25
|
export function APIExample(props) {
|
|
24
26
|
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 }));
|
|
25
27
|
}
|
|
26
28
|
export function ObjectCollapsible(props) {
|
|
27
|
-
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
|
|
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 })] }));
|
|
28
30
|
}
|
|
29
31
|
export { APIPage } from '../render/api-page.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { SelectTrigger } from '../ui/components/select.js';
|
|
3
|
+
export declare function SelectTabs({ defaultValue, children, }: {
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function SelectTab({ value, ...props }: ComponentProps<'div'> & {
|
|
8
|
+
value: string;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
10
|
+
export declare function SelectTabTrigger({ items, ...props }: ComponentProps<typeof SelectTrigger> & {
|
|
11
|
+
items: string[];
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=select-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-tabs.d.ts","sourceRoot":"","sources":["../../src/ui/select-tabs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAQhC,wBAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAQA;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;CACf,uDAKA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,2CAoB5D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, use, useMemo, useState, } from 'react';
|
|
4
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
|
|
5
|
+
import { cn } from 'fumadocs-ui/utils/cn';
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
export function SelectTabs({ defaultValue, children, }) {
|
|
8
|
+
const [type, setType] = useState(defaultValue ?? null);
|
|
9
|
+
return (_jsx(Context, { value: useMemo(() => ({ type, setType }), [type]), children: children }));
|
|
10
|
+
}
|
|
11
|
+
export function SelectTab({ value, ...props }) {
|
|
12
|
+
const { type } = use(Context);
|
|
13
|
+
if (value !== type)
|
|
14
|
+
return;
|
|
15
|
+
return _jsx("div", { ...props, children: props.children });
|
|
16
|
+
}
|
|
17
|
+
export function SelectTabTrigger({ items, ...props }) {
|
|
18
|
+
const { type, setType } = use(Context);
|
|
19
|
+
return (_jsxs(Select, { value: type ?? '', onValueChange: setType, children: [_jsx(SelectTrigger, { ...props, className: cn('not-prose w-fit', props.className), children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: items.map((type) => (_jsx(SelectItem, { value: type, children: type }, type))) })] }));
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-select.d.ts","sourceRoot":"","sources":["../../src/ui/server-select.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAejE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"server-select.d.ts","sourceRoot":"","sources":["../../src/ui/server-select.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAejE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,uDAgDzE"}
|
package/dist/ui/server-select.js
CHANGED
|
@@ -6,9 +6,9 @@ import { Input, labelVariants } from '../ui/components/input.js';
|
|
|
6
6
|
import { useEffect, useState } from 'react';
|
|
7
7
|
import { cn } from 'fumadocs-ui/utils/cn';
|
|
8
8
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from '../ui/components/dialog.js';
|
|
9
|
-
import {
|
|
9
|
+
import { resolveServerUrl, withBase } from '../utils/url.js';
|
|
10
10
|
import { FormProvider, useController, useForm } from 'react-hook-form';
|
|
11
|
-
import {
|
|
11
|
+
import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
|
|
12
12
|
export default function ServerSelect(props) {
|
|
13
13
|
const { servers } = useApiContext();
|
|
14
14
|
const { server, setServer } = useServerSelectContext();
|
|
@@ -20,33 +20,38 @@ export default function ServerSelect(props) {
|
|
|
20
20
|
if (servers.length <= 0)
|
|
21
21
|
return;
|
|
22
22
|
return (_jsxs(Dialog, { open: open, onOpenChange: setOpen, children: [_jsx(DialogTrigger, { className: "text-xs p-3 py-2 bg-fd-muted text-fd-muted-foreground transition-colors truncate hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:outline-none", children: isMounted
|
|
23
|
-
? server
|
|
24
|
-
|
|
25
|
-
: window.location.origin
|
|
26
|
-
: 'loading...' }), _jsxs(DialogContent, { ...props, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Server URL" }), _jsx(DialogDescription, { children: "The base URL of your API endpoint." })] }), _jsxs(Select, { value: server?.url, onValueChange: setServer, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: servers.map((item) => (_jsxs(SelectItem, { value: item.url, children: [item.url, _jsx("p", { className: "text-start text-fd-muted-foreground", children: item.description })] }, item.url))) })] }), server && (_jsx(ServerSelectContent, { server: server, onClose: () => setOpen(false) }, server.url))] })] }));
|
|
23
|
+
? withBase(server ? resolveServerUrl(server.url, server.variables) : '/', window.location.origin)
|
|
24
|
+
: 'loading...' }), _jsxs(DialogContent, { ...props, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Server URL" }), _jsx(DialogDescription, { children: "The base URL of your API endpoint." })] }), _jsxs(Select, { value: server?.url, onValueChange: setServer, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: servers.map((item) => (_jsxs(SelectItem, { value: item.url, children: [_jsx("code", { className: "text-[13px]", children: item.url }), _jsx("p", { className: "text-fd-muted-foreground", children: item.description })] }, item.url))) })] }), server && server.variables && (_jsx(ServerSelectContent, { server: server }, server.url))] })] }));
|
|
27
25
|
}
|
|
28
|
-
function ServerSelectContent({ server
|
|
26
|
+
function ServerSelectContent({ server }) {
|
|
29
27
|
const { servers } = useApiContext();
|
|
30
28
|
const { setServerVariables } = useServerSelectContext();
|
|
31
29
|
const schema = servers.find((item) => item.url === server.url);
|
|
32
30
|
const form = useForm({
|
|
33
31
|
defaultValues: server.variables,
|
|
34
32
|
});
|
|
35
|
-
const
|
|
36
|
-
setServerVariables(
|
|
37
|
-
onClose();
|
|
33
|
+
const onChangeDebounced = useEffectEvent((values) => {
|
|
34
|
+
setServerVariables(values);
|
|
38
35
|
});
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
let timer = null;
|
|
38
|
+
return form.subscribe({
|
|
39
|
+
formState: {
|
|
40
|
+
values: true,
|
|
41
|
+
},
|
|
42
|
+
callback({ values }) {
|
|
43
|
+
if (timer !== null)
|
|
44
|
+
window.clearTimeout(timer);
|
|
45
|
+
timer = window.setTimeout(() => onChangeDebounced(values), 500);
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `form` shouldn't be included
|
|
49
|
+
}, []);
|
|
39
50
|
if (!schema?.variables)
|
|
40
51
|
return;
|
|
41
|
-
return (_jsx(FormProvider, { ...form, children:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, children: [Object.entries(schema.variables).map(([key, variable]) => {
|
|
45
|
-
return (_jsxs("fieldset", { className: "flex flex-col gap-1", children: [_jsx("label", { className: cn(labelVariants()), htmlFor: key, children: key }), _jsx("p", { className: "text-xs text-fd-muted-foreground empty:hidden", children: variable.description }), _jsx(Field, { fieldName: key, variable: variable })] }, key));
|
|
46
|
-
}), _jsx("button", { type: "submit", className: cn(buttonVariants({
|
|
47
|
-
color: 'primary',
|
|
48
|
-
className: 'mt-2',
|
|
49
|
-
})), children: "Save" })] }) }));
|
|
52
|
+
return (_jsx(FormProvider, { ...form, children: _jsx("div", { className: "flex flex-col gap-4", children: Object.entries(schema.variables).map(([key, variable]) => {
|
|
53
|
+
return (_jsxs("fieldset", { className: "flex flex-col gap-1", children: [_jsx("label", { className: cn(labelVariants()), htmlFor: key, children: key }), _jsx("p", { className: "text-xs text-fd-muted-foreground empty:hidden", children: variable.description }), _jsx(Field, { fieldName: key, variable: variable })] }, key));
|
|
54
|
+
}) }) }));
|
|
50
55
|
}
|
|
51
56
|
function Field({ fieldName, variable, }) {
|
|
52
57
|
const { field } = useController({
|
|
@@ -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,EAAqB,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExE,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,UAAO,GAAG,MAAM,CA0D5E"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isNullable } from '../utils/schema.js';
|
|
2
1
|
export function schemaToString(schema, isRoot = true) {
|
|
3
2
|
if (schema === true)
|
|
4
3
|
return 'any';
|
|
@@ -47,3 +46,13 @@ export function schemaToString(schema, isRoot = true) {
|
|
|
47
46
|
}
|
|
48
47
|
return 'unknown';
|
|
49
48
|
}
|
|
49
|
+
function isNullable(schema) {
|
|
50
|
+
if (typeof schema === 'boolean')
|
|
51
|
+
return false;
|
|
52
|
+
if (Array.isArray(schema.type) && schema.type.includes('null'))
|
|
53
|
+
return true;
|
|
54
|
+
const combined = schema.anyOf ?? schema.oneOf ?? schema.allOf;
|
|
55
|
+
if (combined && combined.some(isNullable))
|
|
56
|
+
return true;
|
|
57
|
+
return schema.type === 'null';
|
|
58
|
+
}
|
package/dist/utils/schema.d.ts
CHANGED
|
@@ -9,6 +9,5 @@ type NoReferenceJSONSchema<T> = T extends (infer I)[] ? NoReference<I>[] : T ext
|
|
|
9
9
|
export type ParsedSchema = JSONSchema;
|
|
10
10
|
export type ResolvedSchema = NoReferenceJSONSchema<ParsedSchema>;
|
|
11
11
|
export declare function getPreferredType<B extends Record<string, unknown>>(body: B): keyof B | undefined;
|
|
12
|
-
export declare function isNullable(schema: ParsedSchema): boolean;
|
|
13
12
|
export {};
|
|
14
13
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,eAAe,GACvB,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAC3B,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,GACD,CAAC,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACjD,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GACf,CAAC,CAAC;AAER,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAEjE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,IAAI,EAAE,CAAC,GACN,MAAM,CAAC,GAAG,SAAS,CAIrB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,eAAe,GACvB,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAC3B,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,GACD,CAAC,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACjD,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GACf,CAAC,CAAC;AAER,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAEjE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,IAAI,EAAE,CAAC,GACN,MAAM,CAAC,GAAG,SAAS,CAIrB"}
|
package/dist/utils/schema.js
CHANGED
|
@@ -3,13 +3,3 @@ export function getPreferredType(body) {
|
|
|
3
3
|
return 'application/json';
|
|
4
4
|
return Object.keys(body)[0];
|
|
5
5
|
}
|
|
6
|
-
export function isNullable(schema) {
|
|
7
|
-
if (typeof schema === 'boolean')
|
|
8
|
-
return false;
|
|
9
|
-
if (Array.isArray(schema.type) && schema.type.includes('null'))
|
|
10
|
-
return true;
|
|
11
|
-
const combined = schema.anyOf ?? schema.oneOf ?? schema.allOf;
|
|
12
|
-
if (combined && combined.some(isNullable))
|
|
13
|
-
return true;
|
|
14
|
-
return schema.type === 'null';
|
|
15
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RequestData } from '../requests/_shared.js';
|
|
2
|
+
export declare function joinURL(base: string, pathname: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* @param url - URL (can be relative)
|
|
5
|
+
* @param base - the base URL (must be absolute)
|
|
6
|
+
*/
|
|
7
|
+
export declare function withBase(url: string, base: string): string;
|
|
8
|
+
export declare function resolveServerUrl(template: string, variables: Record<string, string>): string;
|
|
9
|
+
export declare function resolveRequestData(pathname: string, { path, query }: RequestData): string;
|
|
10
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ9D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAMR;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,WAAW,GAC3B,MAAM,CAyBR"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function joinURL(base, pathname) {
|
|
2
|
+
pathname = pathname
|
|
3
|
+
.split('/')
|
|
4
|
+
.filter((v) => v.length > 0)
|
|
5
|
+
.join('/');
|
|
6
|
+
if (!base.endsWith('/') && pathname.length > 0)
|
|
7
|
+
base += '/';
|
|
8
|
+
return base + pathname;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @param url - URL (can be relative)
|
|
12
|
+
* @param base - the base URL (must be absolute)
|
|
13
|
+
*/
|
|
14
|
+
export function withBase(url, base) {
|
|
15
|
+
if (!url.startsWith('https://') && !url.startsWith('http://')) {
|
|
16
|
+
return joinURL(base, url);
|
|
17
|
+
}
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
export function resolveServerUrl(template, variables) {
|
|
21
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
22
|
+
template = template.replaceAll(`{${key}}`, value);
|
|
23
|
+
}
|
|
24
|
+
return template;
|
|
25
|
+
}
|
|
26
|
+
export function resolveRequestData(pathname, { path, query }) {
|
|
27
|
+
for (const key in path) {
|
|
28
|
+
if (path[key] === '')
|
|
29
|
+
continue;
|
|
30
|
+
if (Array.isArray(path[key])) {
|
|
31
|
+
pathname = pathname.replace(`{${key}}`, path[key].join('/'));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
pathname = pathname.replace(`{${key}}`, String(path[key]));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const searchParams = new URLSearchParams();
|
|
38
|
+
for (const key in query) {
|
|
39
|
+
if (Array.isArray(query[key])) {
|
|
40
|
+
for (const value of query[key]) {
|
|
41
|
+
if (!query[key])
|
|
42
|
+
continue;
|
|
43
|
+
searchParams.append(key, String(value));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (query[key] && query[key] !== '') {
|
|
47
|
+
searchParams.set(key, String(query[key]));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return searchParams.size > 0 ? `${pathname}?${searchParams}` : pathname;
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.6",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -46,10 +46,11 @@
|
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@fumari/json-schema-to-typescript": "^1.1.3",
|
|
49
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
49
50
|
"@radix-ui/react-dialog": "^1.1.14",
|
|
50
51
|
"@radix-ui/react-select": "^2.2.5",
|
|
51
52
|
"@radix-ui/react-slot": "^1.2.3",
|
|
52
|
-
"@scalar/openapi-parser": "0.
|
|
53
|
+
"@scalar/openapi-parser": "0.13.0",
|
|
53
54
|
"ajv": "^8.17.1",
|
|
54
55
|
"class-variance-authority": "^0.7.1",
|
|
55
56
|
"github-slugger": "^2.0.0",
|
|
@@ -63,19 +64,19 @@
|
|
|
63
64
|
"shiki": "^3.4.2",
|
|
64
65
|
"tinyglobby": "^0.2.14",
|
|
65
66
|
"xml-js": "^1.6.11",
|
|
66
|
-
"fumadocs-core": "15.
|
|
67
|
-
"fumadocs-ui": "15.
|
|
67
|
+
"fumadocs-core": "15.5.1",
|
|
68
|
+
"fumadocs-ui": "15.5.1"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@scalar/api-client-react": "^1.3.
|
|
71
|
+
"@scalar/api-client-react": "^1.3.5",
|
|
71
72
|
"@types/js-yaml": "^4.0.9",
|
|
72
|
-
"@types/node": "22.15.
|
|
73
|
+
"@types/node": "22.15.28",
|
|
73
74
|
"@types/openapi-sampler": "^1.0.3",
|
|
74
|
-
"@types/react": "^19.1.
|
|
75
|
+
"@types/react": "^19.1.6",
|
|
75
76
|
"json-schema-typed": "^8.0.1",
|
|
76
|
-
"next": "15.3.
|
|
77
|
+
"next": "15.3.3",
|
|
77
78
|
"openapi-types": "^12.1.3",
|
|
78
|
-
"tailwindcss": "^4.1.
|
|
79
|
+
"tailwindcss": "^4.1.8",
|
|
79
80
|
"tsc-alias": "^1.8.16",
|
|
80
81
|
"eslint-config-custom": "0.0.0",
|
|
81
82
|
"tsconfig": "0.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-pathname-from-input.d.ts","sourceRoot":"","sources":["../../src/utils/get-pathname-from-input.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CA0BR"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function getPathnameFromInput(url, path, query) {
|
|
2
|
-
let pathname = url;
|
|
3
|
-
for (const key in path) {
|
|
4
|
-
if (path[key] === '')
|
|
5
|
-
continue;
|
|
6
|
-
if (Array.isArray(path[key])) {
|
|
7
|
-
pathname = pathname.replace(`{${key}}`, path[key].join('/'));
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
pathname = pathname.replace(`{${key}}`, String(path[key]));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const searchParams = new URLSearchParams();
|
|
14
|
-
for (const key in query) {
|
|
15
|
-
if (query[key] === '')
|
|
16
|
-
continue;
|
|
17
|
-
if (Array.isArray(query[key])) {
|
|
18
|
-
for (const value of query[key]) {
|
|
19
|
-
searchParams.append(key, String(value));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
searchParams.set(key, String(query[key]));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return searchParams.size > 0 ? `${pathname}?${searchParams}` : pathname;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-url.d.ts","sourceRoot":"","sources":["../../src/utils/server-url.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAQ7E"}
|