fumadocs-openapi 7.0.0 → 7.0.2

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.
@@ -61,6 +61,6 @@ export type DynamicField = {
61
61
  schema: RequestSchema | ReferenceSchema;
62
62
  };
63
63
  export declare function useSchemaContext(): SchemaContextType;
64
- export declare function Client({ route, method, authorization, parameters, body, fields, references, proxyUrl, components: { ResultDisplay }, ...props }: ClientProps): import("react/jsx-runtime").JSX.Element;
64
+ export declare function Client({ route, method, authorization, parameters, body, fields, references, proxyUrl, components: { ResultDisplay }, ...rest }: ClientProps): import("react/jsx-runtime").JSX.Element;
65
65
  export {};
66
66
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/playground/client.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAInB,KAAK,EAAE,EAGP,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,aAAa,EACd,MAAM,oBAAoB,CAAC;AAa5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AASrD,UAAU,UAAU;IAClB,aAAa,EACT,MAAM,GACN;QACE,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACN,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA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;KAC3C,CAAC;IAEF,UAAU,CAAC,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,EAAE,CAAC;YAAE,IAAI,EAAE,WAAW,CAAA;SAAE,CAAC,CAAC;KAC1C,CAAC,CAAC;CACJ,CAAC;AAEF,UAAU,iBAAiB;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1C,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,aAAa,GAAG,eAAe,CAAC;CACzC,CAAC;AAIN,wBAAgB,gBAAgB,IAAI,iBAAiB,CAIpD;AAkBD,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,MAAc,EACd,aAAa,EACb,UAAU,EACV,IAAI,EACJ,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EAAE,EAAE,aAAoC,EAAO,EACzD,GAAG,IAAI,EACR,EAAE,WAAW,2CAuHb"}
@@ -12,7 +12,7 @@ import { MethodLabel } from '../ui/components/method-label.js';
12
12
  import { useQuery } from '../utils/use-query.js';
13
13
  import ServerSelect from '../ui/server-select.js';
14
14
  import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
15
- import { ChevronDown } from 'lucide-react';
15
+ import { ChevronDown, Loader2 } from 'lucide-react';
16
16
  import { OauthDialog, OauthDialogTrigger, } from '../playground/auth/oauth-dialog.js';
17
17
  import { useRequestData } from '../ui/contexts/code-example.js';
18
18
  import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
@@ -34,17 +34,8 @@ function toRequestData(method, mediaType, value) {
34
34
  query: value.query,
35
35
  };
36
36
  }
37
- export function Client({ route, method = 'GET', authorization, parameters = [], body, fields = {}, references, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
38
- const { servers } = useApiContext();
39
- const { server, setServer, setServerVariables } = useServerSelectContext();
40
- const params = useMemo(() => {
41
- return {
42
- headers: parameters.filter((v) => v.in === 'header'),
43
- cookies: parameters.filter((v) => v.in === 'cookie'),
44
- queries: parameters.filter((v) => v.in === 'query'),
45
- paths: parameters.filter((v) => v.in === 'path'),
46
- };
47
- }, [parameters]);
37
+ export function Client({ route, method = 'GET', authorization, parameters, body, fields, references, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...rest }) {
38
+ const { server } = useServerSelectContext();
48
39
  const dynamicRef = useRef(new Map());
49
40
  const requestData = useRequestData();
50
41
  const authInfo = usePersistentAuthInfo(authorization);
@@ -90,13 +81,34 @@ export function Client({ route, method = 'GET', authorization, parameters = [],
90
81
  const onSubmit = form.handleSubmit((value) => {
91
82
  testQuery.start(value);
92
83
  });
93
- function renderCustomField(fieldName, info, field, key) {
94
- if (field) {
95
- return (_jsx(Controller, { control: form.control, render: (props) => field.render({ ...props, info }), name: fieldName }, key));
96
- }
97
- return (_jsx(FieldSet, { name: info.name, fieldName: fieldName, field: info }, key));
98
- }
99
- return (_jsx(FormProvider, { ...form, children: _jsx(SchemaContext.Provider, { value: useMemo(() => ({ references: references, dynamic: dynamicRef }), [references]), children: _jsx(AuthProvider, { authorization: authorization, children: _jsxs("form", { ...props, className: cn('not-prose flex flex-col gap-2 rounded-xl border p-3 shadow-md', props.className), onSubmit: onSubmit, children: [_jsx(FormHeader, { method: method, route: route, isLoading: testQuery.isLoading }), servers.length > 1 ? (_jsx(CollapsiblePanel, { title: "Server URL", children: _jsx(ServerSelect, { server: server, onServerChanged: setServer, onVariablesChanged: setServerVariables }) })) : null, params.headers.length > 0 || authorization ? (_jsxs(CollapsiblePanel, { title: "Headers", children: [authorization ? (_jsx(AuthField, { authorization: authorization })) : null, params.headers.map((field) => renderCustomField(`header.${field.name}`, field, fields.parameter, field.name))] })) : null, params.paths.length > 0 ? (_jsx(CollapsiblePanel, { title: "Path", children: params.paths.map((field) => renderCustomField(`path.${field.name}`, field, fields.parameter, field.name)) })) : null, params.queries.length > 0 ? (_jsx(CollapsiblePanel, { title: "Query", children: params.queries.map((field) => renderCustomField(`query.${field.name}`, field, fields.parameter, field.name)) })) : null, params.cookies.length > 0 ? (_jsx(CollapsiblePanel, { title: "Cookies", children: params.cookies.map((field) => renderCustomField(`cookie.${field.name}`, field, fields.parameter, field.name)) })) : null, body ? (_jsx(CollapsiblePanel, { title: "Body", children: body.type === 'object' && !fields.body ? (_jsx(ObjectInput, { field: body, fieldName: "body" })) : (renderCustomField('body', body, fields.body)) })) : null, testQuery.data ? _jsx(ResultDisplay, { data: testQuery.data }) : null] }) }) }) }));
84
+ return (_jsx(FormProvider, { ...form, children: _jsx(SchemaContext.Provider, { value: useMemo(() => ({ references: references, dynamic: dynamicRef }), [references]), children: _jsx(AuthProvider, { authorization: authorization, children: _jsxs("form", { ...rest, className: cn('not-prose flex flex-col rounded-xl border p-3 gap-3 shadow-md overflow-hidden', rest.className), onSubmit: onSubmit, children: [_jsxs("div", { className: "flex flex-row items-center gap-2 text-sm", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), 'px-3 py-1.5'), disabled: testQuery.isLoading, children: testQuery.isLoading ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : ('Send') })] }), _jsx(FormBody, { body: body, fields: fields, parameters: parameters, authorization: authorization }), testQuery.data ? _jsx(ResultDisplay, { data: testQuery.data }) : null] }) }) }) }));
85
+ }
86
+ const paramNames = ['Headers', 'Cookies', 'Query', 'Path'];
87
+ const paramTypes = ['header', 'cookie', 'query', 'path'];
88
+ function FormBody({ authorization, parameters = [], body, fields = {}, }) {
89
+ const { servers } = useApiContext();
90
+ const { server, setServer, setServerVariables } = useServerSelectContext();
91
+ const params = useMemo(() => {
92
+ return paramTypes.map((param) => parameters.filter((v) => v.in === param));
93
+ }, [parameters]);
94
+ return (_jsxs(_Fragment, { children: [servers.length > 1 ? (_jsx(CollapsiblePanel, { title: "Server URL", children: _jsx(ServerSelect, { server: server, onServerChanged: setServer, onVariablesChanged: setServerVariables }) })) : null, params.map((param, i) => {
95
+ const name = paramNames[i];
96
+ const type = paramTypes[i];
97
+ if ((param.length === 0 && type !== 'header') || !authorization)
98
+ return;
99
+ return (_jsxs(CollapsiblePanel, { title: name, children: [type === 'header' && authorization ? (_jsx(AuthField, { authorization: authorization })) : null, param.map((field) => {
100
+ const fieldName = `${type}.${field.name}`;
101
+ if (!fields?.parameter) {
102
+ return (_jsx(FieldSet, { name: field.name, fieldName: fieldName, field: field }, fieldName));
103
+ }
104
+ return renderCustomField(fieldName, field, fields.parameter, field.name);
105
+ })] }, name));
106
+ }), body ? (_jsx(CollapsiblePanel, { title: "Body", children: fields.body ? (renderCustomField('body', body, fields.body)) : body.type === 'object' ? (_jsx(ObjectInput, { field: body, fieldName: "body" })) : (_jsx(FieldSet, { field: body, fieldName: "body" })) })) : null] }));
107
+ }
108
+ function renderCustomField(fieldName, info, field, key) {
109
+ return (_jsx(Controller, {
110
+ // @ts-expect-error we use string here
111
+ render: (props) => field.render({ ...props, info }), name: fieldName }, key));
100
112
  }
101
113
  function AuthProvider({ authorization, children, }) {
102
114
  const form = useFormContext();
@@ -134,9 +146,6 @@ function Route({ route, ...props }) {
134
146
  const segments = route.split('/').filter((part) => part.length > 0);
135
147
  return (_jsx("div", { ...props, className: cn('flex flex-row items-center gap-0.5 overflow-auto text-nowrap', props.className), children: segments.map((part, index) => (_jsxs(Fragment, { children: [_jsx("span", { className: "text-fd-muted-foreground", children: "/" }), part.startsWith('{') && part.endsWith('}') ? (_jsx("code", { className: "bg-fd-primary/10 text-fd-primary", children: part })) : (_jsx("code", { className: "text-fd-foreground", children: part }))] }, index))) }));
136
148
  }
137
- function FormHeader({ route, method, isLoading, }) {
138
- return (_jsxs("div", { className: "flex flex-row items-center gap-2 text-sm", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), 'px-3 py-1.5'), disabled: isLoading, children: "Send" })] }));
139
- }
140
149
  function DefaultResultDisplay({ data }) {
141
150
  const statusInfo = useMemo(() => getStatusInfo(data.status), [data.status]);
142
151
  const { shikiOptions } = useApiContext();
@@ -144,7 +153,7 @@ function DefaultResultDisplay({ data }) {
144
153
  ? 'text'
145
154
  : data.type, code: typeof data.data === 'string'
146
155
  ? data.data
147
- : JSON.stringify(data.data, null, 2), ...shikiOptions })) : null] }));
156
+ : JSON.stringify(data.data, null, 2), options: shikiOptions })) : null] }));
148
157
  }
149
158
  function usePersistentAuthInfo(authorization) {
150
159
  const key = authorization
@@ -179,7 +188,7 @@ function usePersistentAuthInfo(authorization) {
179
188
  };
180
189
  }
181
190
  function CollapsiblePanel({ title, children, ...props }) {
182
- return (_jsxs(Collapsible, { ...props, className: "border rounded-xl bg-fd-card text-fd-card-foreground overflow-hidden", children: [_jsxs(CollapsibleTrigger, { className: "group w-full inline-flex items-center gap-2 justify-between p-3 text-sm font-medium hover:bg-fd-accent", children: [title, _jsx(ChevronDown, { className: "size-4 group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { children: _jsx("div", { className: "flex flex-col gap-4 p-3", children: children }) })] }));
191
+ return (_jsxs(Collapsible, { ...props, className: "rounded-xl bg-fd-card border text-fd-card-foreground", children: [_jsxs(CollapsibleTrigger, { className: "group w-full inline-flex items-center gap-2 p-3 text-sm font-medium", children: [title, _jsx(ChevronDown, { className: "ms-auto size-4 text-fd-muted-foreground group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { children: _jsx("div", { className: "flex flex-col gap-3 p-3", children: children }) })] }));
183
192
  }
184
193
  function writeAuthHeader(authorization, input, header, query, cookie) {
185
194
  if (authorization.type === 'apiKey') {
@@ -14,7 +14,7 @@ export declare function FieldInput({ field, fieldName, ...props }: HTMLAttribute
14
14
  fieldName: string;
15
15
  }): import("react/jsx-runtime").JSX.Element | null;
16
16
  export declare function FieldSet({ field, fieldName, toolbar, name, ...props }: HTMLAttributes<HTMLElement> & {
17
- name?: string;
17
+ name?: ReactNode;
18
18
  field: RequestSchema;
19
19
  fieldName: string;
20
20
  toolbar?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/playground/inputs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,KAAK,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AA6BhE,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IACD,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,cAAc,CAAC,2CAqBjC;AA+ID,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB,kDAmGA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,kDAgGA"}
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/playground/inputs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,KAAK,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AA6BhE,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IACD,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,cAAc,CAAC,2CAqBjC;AA+ID,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB,kDAmGA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,kDAgGA"}
@@ -102,10 +102,10 @@ export function FieldInput({ field, fieldName, ...props }) {
102
102
  if (field.type === 'null')
103
103
  return null;
104
104
  if (field.type === 'object') {
105
- return (_jsx(ObjectInput, { field: field, fieldName: fieldName, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-card p-3 shadow-sm', props.className) }));
105
+ return (_jsx(ObjectInput, { field: field, fieldName: fieldName, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-background/50 p-3 shadow-sm', props.className) }));
106
106
  }
107
107
  if (field.type === 'array') {
108
- return (_jsx(ArrayInput, { fieldName: fieldName, field: field, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-background p-3 shadow-sm', props.className) }));
108
+ return (_jsx(ArrayInput, { fieldName: fieldName, field: field, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-background/50 p-3 shadow-sm', props.className) }));
109
109
  }
110
110
  if (field.type === 'file') {
111
111
  return (_jsx(Controller, { control: control, name: fieldName, render: ({ field: { value: _, onChange, ...restField } }) => (_jsx("input", { id: fieldName, type: "file", multiple: false, onChange: (e) => {
@@ -172,7 +172,7 @@ function ArrayInput({ fieldName, field, ...props }) {
172
172
  const { fields, append, remove } = useFieldArray({
173
173
  name: fieldName,
174
174
  });
175
- return (_jsxs("div", { ...props, className: cn('flex flex-col gap-2', props.className), children: [fields.map((item, index) => (_jsx(FieldSet, { name: `${fieldName.split('.').at(-1)}[${index}]`, field: items, fieldName: `${fieldName}.${index}`, toolbar: _jsx("button", { type: "button", "aria-label": "Remove Item", className: cn(buttonVariants({
175
+ return (_jsxs("div", { ...props, className: cn('flex flex-col gap-2', props.className), children: [fields.map((item, index) => (_jsx(FieldSet, { name: _jsxs("span", { className: "text-fd-muted-foreground", children: [fieldName.split('.').at(-1), "[", index, "]"] }), field: items, fieldName: `${fieldName}.${index}`, toolbar: _jsx("button", { type: "button", "aria-label": "Remove Item", className: cn(buttonVariants({
176
176
  color: 'secondary',
177
177
  size: 'sm',
178
178
  })), onClick: () => {
@@ -3,7 +3,7 @@ import type { RenderContext } from '../types.js';
3
3
  export type CodeBlockProps = HTMLAttributes<HTMLPreElement> & {
4
4
  code: string;
5
5
  lang: string;
6
- options?: RenderContext['shikiOptions'];
6
+ ctx: RenderContext;
7
7
  };
8
- export declare function CodeBlock({ code, lang, options, ...rest }: CodeBlockProps): Promise<React.ReactElement>;
8
+ export declare function CodeBlock({ code, lang, ctx, ...rest }: CodeBlockProps): Promise<React.ReactElement>;
9
9
  //# sourceMappingURL=codeblock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/render/codeblock.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACzC,CAAC;AAEF,wBAAsB,SAAS,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,GAAG,IAAI,EACR,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAU9C"}
1
+ {"version":3,"file":"codeblock.d.ts","sourceRoot":"","sources":["../../src/render/codeblock.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,aAAa,CAAC;CACpB,CAAC;AAEF,wBAAsB,SAAS,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,GAAG,IAAI,EACR,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAU9C"}
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as Base from 'fumadocs-ui/components/codeblock';
3
3
  import { highlight } from 'fumadocs-core/highlight';
4
- export async function CodeBlock({ code, lang, options, ...rest }) {
4
+ export async function CodeBlock({ code, lang, ctx, ...rest }) {
5
5
  const rendered = await highlight(code, {
6
6
  lang,
7
- ...options,
7
+ ...ctx.shikiOptions,
8
8
  components: {
9
9
  pre: (props) => _jsx(Base.Pre, { ...props, ...rest }),
10
10
  },
@@ -85,7 +85,8 @@ function dedupe(samples) {
85
85
  }
86
86
  return out;
87
87
  }
88
- function ResponseTabs({ operation, ctx: { renderer, generateTypeScriptSchema, schema }, }) {
88
+ function ResponseTabs({ operation, ctx, }) {
89
+ const { renderer, generateTypeScriptSchema, schema } = ctx;
89
90
  if (!operation.responses)
90
91
  return null;
91
92
  async function renderResponse(code) {
@@ -111,14 +112,14 @@ function ResponseTabs({ operation, ctx: { renderer, generateTypeScriptSchema, sc
111
112
  exampleSlot = Object.entries(responseOfType.examples).map(([key, sample], i) => {
112
113
  const title = sample?.summary ?? `Example ${i + 1}`;
113
114
  values.push(title);
114
- return (_jsxs(renderer.ResponseType, { label: title, children: [sample?.description ? (_jsx(Markdown, { text: sample.description })) : null, _jsx(CodeBlock, { lang: "json", code: JSON.stringify(sample.value, null, 2) })] }, key));
115
+ return (_jsxs(renderer.ResponseType, { label: title, children: [sample?.description ? (_jsx(Markdown, { text: sample.description })) : null, _jsx(CodeBlock, { lang: "json", code: JSON.stringify(sample.value, null, 2), ctx: ctx })] }, key));
115
116
  });
116
117
  }
117
118
  else if (responseOfType?.example || responseOfType?.schema) {
118
119
  values.push('Response');
119
- exampleSlot = (_jsx(renderer.ResponseType, { label: "Response", children: _jsx(CodeBlock, { lang: "json", code: JSON.stringify(responseOfType.example ?? sample(responseOfType.schema), null, 2) }) }));
120
+ exampleSlot = (_jsx(renderer.ResponseType, { label: "Response", children: _jsx(CodeBlock, { lang: "json", code: JSON.stringify(responseOfType.example ?? sample(responseOfType.schema), null, 2), ctx: ctx }) }));
120
121
  }
121
- return (_jsxs(renderer.Response, { value: code, children: [description ? _jsx(Markdown, { text: description }) : null, exampleSlot ? (_jsxs(renderer.ResponseTypes, { defaultValue: values[0], children: [exampleSlot, ts ? (_jsx(renderer.ResponseType, { label: "TypeScript", children: _jsx(CodeBlock, { code: ts, lang: "ts" }) })) : null] })) : null] }));
122
+ return (_jsxs(renderer.Response, { value: code, children: [description ? _jsx(Markdown, { text: description }) : null, exampleSlot ? (_jsxs(renderer.ResponseTypes, { defaultValue: values[0], children: [exampleSlot, ts ? (_jsx(renderer.ResponseType, { label: "TypeScript", children: _jsx(CodeBlock, { lang: "ts", code: ts, ctx: ctx }) })) : null] })) : null] }));
122
123
  }
123
124
  const codes = Object.keys(operation.responses);
124
125
  if (codes.length === 0)
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { cn } from 'fumadocs-ui/components/api';
4
4
  import { cva } from 'class-variance-authority';
5
- export const labelVariants = cva('text-[13px] font-medium text-fd-card-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
5
+ export const labelVariants = cva('text-[13px] text-fd-card-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
6
6
  const Input = React.forwardRef(({ className, type, ...props }, ref) => {
7
- return (_jsx("input", { type: type, className: cn('flex h-9 w-full rounded-md border bg-transparent px-2 py-1.5 text-[13px] 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), ref: ref, ...props }));
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
  });
9
9
  Input.displayName = 'Input';
10
10
  export { Input };
@@ -6,7 +6,7 @@ import { cn } from 'fumadocs-ui/components/api';
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 min-h-10 items-center w-full rounded-md border px-3 py-2 text-start text-[13px] 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), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "ms-auto size-4 text-fd-muted-foreground" }) })] })));
9
+ const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex min-h-10 items-center w-full rounded-md border px-3 py-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-4 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;
@@ -11,7 +11,7 @@ export default function ServerSelect({ server, onServerChanged, onVariablesChang
11
11
  const schema = server
12
12
  ? servers.find((item) => item.url === server.url)
13
13
  : null;
14
- return (_jsxs("div", { ...props, className: cn('flex flex-col gap-4', props.className), children: [_jsxs(Select, { value: server?.url, onValueChange: onServerChanged, children: [_jsx(SelectTrigger, { className: "h-auto break-all", 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))) })] }), Object.entries(schema?.variables ?? {}).map(([key, variable]) => {
14
+ return (_jsxs("div", { ...props, className: cn('flex flex-col gap-4', props.className), children: [_jsxs(Select, { value: server?.url, onValueChange: onServerChanged, children: [_jsx(SelectTrigger, { className: "break-all", 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))) })] }), Object.entries(schema?.variables ?? {}).map(([key, variable]) => {
15
15
  if (!server)
16
16
  return;
17
17
  const id = `fd_server_select_${key}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -47,7 +47,7 @@
47
47
  "@radix-ui/react-dialog": "^1.1.6",
48
48
  "@radix-ui/react-select": "^2.1.6",
49
49
  "@radix-ui/react-slot": "^1.1.2",
50
- "@scalar/openapi-parser": "0.10.9",
50
+ "@scalar/openapi-parser": "0.10.10",
51
51
  "ajv-draft-04": "^1.0.0",
52
52
  "class-variance-authority": "^0.7.1",
53
53
  "fast-glob": "^3.3.3",
@@ -55,25 +55,25 @@
55
55
  "hast-util-to-jsx-runtime": "^2.3.6",
56
56
  "js-yaml": "^4.1.0",
57
57
  "lucide-react": "^0.479.0",
58
- "next-themes": "^0.4.4",
58
+ "next-themes": "^0.4.6",
59
59
  "openapi-sampler": "^1.6.1",
60
60
  "react-hook-form": "^7.54.2",
61
61
  "remark": "^15.0.1",
62
62
  "remark-rehype": "^11.1.1",
63
- "shiki": "^3.1.0",
63
+ "shiki": "^3.2.1",
64
64
  "xml-js": "^1.6.11",
65
- "fumadocs-core": "15.0.16",
66
- "fumadocs-ui": "15.0.16"
65
+ "fumadocs-core": "15.0.18",
66
+ "fumadocs-ui": "15.0.18"
67
67
  },
68
68
  "devDependencies": {
69
- "@scalar/api-client-react": "^1.1.42",
69
+ "@scalar/api-client-react": "^1.2.1",
70
70
  "@types/js-yaml": "^4.0.9",
71
71
  "@types/node": "22.13.10",
72
72
  "@types/openapi-sampler": "^1.0.3",
73
73
  "@types/react": "^19.0.10",
74
- "next": "15.2.1",
74
+ "next": "15.2.2",
75
75
  "openapi-types": "^12.1.3",
76
- "tailwindcss": "^4.0.12",
76
+ "tailwindcss": "^4.0.14",
77
77
  "tsc-alias": "^1.8.11",
78
78
  "eslint-config-custom": "0.0.0",
79
79
  "tsconfig": "0.0.0"