fumadocs-openapi 6.0.10 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/generate-file.d.ts.map +1 -1
  2. package/dist/generate-file.js +3 -0
  3. package/dist/{ui/playground/index.d.ts → playground/client.d.ts} +31 -9
  4. package/dist/playground/client.d.ts.map +1 -0
  5. package/dist/{ui/playground/index.js → playground/client.js} +18 -12
  6. package/dist/playground/client.lazy.d.ts +2 -0
  7. package/dist/playground/client.lazy.d.ts.map +1 -0
  8. package/dist/playground/client.lazy.js +3 -0
  9. package/dist/{ui/playground → playground}/fetcher.d.ts +2 -2
  10. package/dist/playground/fetcher.d.ts.map +1 -0
  11. package/dist/{ui/playground → playground}/fetcher.js +1 -1
  12. package/dist/{ui/playground → playground}/get-default-values.d.ts +1 -1
  13. package/dist/playground/get-default-values.d.ts.map +1 -0
  14. package/dist/{ui/playground → playground}/get-default-values.js +1 -1
  15. package/dist/{render/operation/playground.d.ts → playground/index.d.ts} +7 -19
  16. package/dist/playground/index.d.ts.map +1 -0
  17. package/dist/{render/operation/playground.js → playground/index.js} +6 -5
  18. package/dist/{ui/playground → playground}/inputs.d.ts +1 -1
  19. package/dist/playground/inputs.d.ts.map +1 -0
  20. package/dist/{ui/playground → playground}/inputs.js +6 -5
  21. package/dist/{ui/playground → playground}/resolve.d.ts +1 -1
  22. package/dist/playground/resolve.d.ts.map +1 -0
  23. package/dist/playground/status-info.d.ts.map +1 -0
  24. package/dist/render/operation/api-example.d.ts.map +1 -1
  25. package/dist/render/operation/api-example.js +21 -21
  26. package/dist/render/renderer.d.ts +5 -9
  27. package/dist/render/renderer.d.ts.map +1 -1
  28. package/dist/render/renderer.js +4 -4
  29. package/dist/ui/client.d.ts +0 -15
  30. package/dist/ui/client.d.ts.map +1 -1
  31. package/dist/ui/client.js +0 -2
  32. package/dist/ui/sample-select.js +1 -1
  33. package/dist/utils/generate-sample.d.ts +4 -4
  34. package/dist/utils/generate-sample.d.ts.map +1 -1
  35. package/dist/utils/generate-sample.js +7 -2
  36. package/package.json +13 -9
  37. package/dist/render/operation/playground.d.ts.map +0 -1
  38. package/dist/ui/contexts/schema.d.ts +0 -17
  39. package/dist/ui/contexts/schema.d.ts.map +0 -1
  40. package/dist/ui/contexts/schema.js +0 -8
  41. package/dist/ui/playground/fetcher.d.ts.map +0 -1
  42. package/dist/ui/playground/get-default-values.d.ts.map +0 -1
  43. package/dist/ui/playground/index.d.ts.map +0 -1
  44. package/dist/ui/playground/inputs.d.ts.map +0 -1
  45. package/dist/ui/playground/resolve.d.ts.map +0 -1
  46. package/dist/ui/playground/status-info.d.ts.map +0 -1
  47. /package/dist/{ui/playground → playground}/resolve.js +0 -0
  48. /package/dist/{ui/playground → playground}/status-info.d.ts +0 -0
  49. /package/dist/{ui/playground → playground}/status-info.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,MAAO,SAAQ,eAAe;IAC7C;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;IAEnC;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;CACpC;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4HlE"}
1
+ {"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,MAAO,SAAQ,eAAe;IAC7C;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;IAEnC;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;CACpC;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoIlE"}
@@ -20,6 +20,9 @@ export async function generateFiles(options) {
20
20
  ...(await fg.glob(fileInputs, { cwd, absolute: false })),
21
21
  ...urlInputs,
22
22
  ];
23
+ if (resolvedInputs.length === 0) {
24
+ throw new Error(`No input files found. Tried resolving: ${typeof input === 'string' ? input : input.join(', ')}`);
25
+ }
23
26
  function getOutputPaths(result) {
24
27
  let file;
25
28
  if (result.pathItem.summary) {
@@ -1,7 +1,8 @@
1
- import { type ReactElement, type HTMLAttributes, type FC, type ReactNode } from 'react';
1
+ import { type ReactElement, type HTMLAttributes, type FC, type RefObject } from 'react';
2
2
  import type { FieldPath, UseFormStateReturn, ControllerFieldState, ControllerRenderProps } from 'react-hook-form';
3
- import type { FetchResult } from '../../ui/playground/fetcher.js';
4
- import type { APIPlaygroundProps, PrimitiveRequestField, RequestSchema } from '../../render/operation/playground.js';
3
+ import type { FetchResult } from '../playground/fetcher.js';
4
+ import type { PrimitiveRequestField, ReferenceSchema, RequestSchema } from '../playground/index.js';
5
+ import type { Security } from '../utils/get-security.js';
5
6
  interface FormValues {
6
7
  authorization: string | {
7
8
  username: string;
@@ -23,7 +24,18 @@ export interface CustomField<TName extends FieldPath<FormValues>, Info> {
23
24
  formState: UseFormStateReturn<FormValues>;
24
25
  }) => ReactElement;
25
26
  }
26
- export declare function APIPlayground({ route, method, authorization, path, header, query, body, fields, schemas, proxyUrl, components: { ResultDisplay }, ...props }: APIPlaygroundProps & {
27
+ export type ClientProps = HTMLAttributes<HTMLFormElement> & {
28
+ route: string;
29
+ method: string;
30
+ authorization?: Security;
31
+ path?: PrimitiveRequestField[];
32
+ query?: PrimitiveRequestField[];
33
+ header?: PrimitiveRequestField[];
34
+ body?: RequestSchema & {
35
+ mediaType: string;
36
+ };
37
+ schemas: Record<string, RequestSchema>;
38
+ proxyUrl?: string;
27
39
  fields?: {
28
40
  auth?: CustomField<'authorization', RequestSchema>;
29
41
  path?: CustomField<`path.${string}`, PrimitiveRequestField>;
@@ -36,9 +48,19 @@ export declare function APIPlayground({ route, method, authorization, path, head
36
48
  data: FetchResult;
37
49
  }>;
38
50
  }>;
39
- } & HTMLAttributes<HTMLFormElement>): import("react/jsx-runtime").JSX.Element;
40
- export declare function CollapsiblePanel({ title, children, ...props }: HTMLAttributes<HTMLDivElement> & {
41
- title: ReactNode;
42
- }): import("react/jsx-runtime").JSX.Element;
51
+ };
52
+ interface SchemaContextType {
53
+ references: Record<string, RequestSchema>;
54
+ dynamic: RefObject<Map<string, DynamicField>>;
55
+ }
56
+ export type DynamicField = {
57
+ type: 'object';
58
+ properties: string[];
59
+ } | {
60
+ type: 'field';
61
+ schema: RequestSchema | ReferenceSchema;
62
+ };
63
+ export declare function useSchemaContext(): SchemaContextType;
64
+ export declare function Client({ route, method, authorization, path, header, query, body, fields, schemas, proxyUrl, components: { ResultDisplay }, ...props }: ClientProps): import("react/jsx-runtime").JSX.Element;
43
65
  export {};
44
- //# sourceMappingURL=index.d.ts.map
66
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +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,EAGf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,aAAa,EACd,MAAM,oBAAoB,CAAC;AAa5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,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,OAAO,CAAC,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,WAAW,CAAC,KAAK,SAAS,SAAS,CAAC,UAAU,CAAC,EAAE,IAAI;IACpE,MAAM,EAAE,CAAC,KAAK,EAAE;QACd;;WAEG;QACH,IAAI,EAAE,IAAI,CAAC;QACX,KAAK,EAAE,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAChD,UAAU,EAAE,oBAAoB,CAAC;QACjC,SAAS,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;KAC3C,KAAK,YAAY,CAAC;CACpB;AAED,MAAM,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,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;AAcD,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,MAAc,EACd,aAAa,EACb,IAAS,EACT,MAAW,EACX,KAAU,EACV,IAAI,EACJ,MAAW,EACX,OAAO,EACP,QAAQ,EACR,UAAU,EAAE,EAAE,aAAoC,EAAO,EACzD,GAAG,KAAK,EACT,EAAE,WAAW,2CA2Ob"}
@@ -1,20 +1,26 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useMemo, useRef, useEffect, Fragment, } from 'react';
3
+ import { useMemo, useRef, useEffect, Fragment, createContext, useContext, } from 'react';
4
4
  import { Controller, FormProvider, useForm } from 'react-hook-form';
5
5
  import { cn, buttonVariants } from 'fumadocs-ui/components/api';
6
- import { useApiContext } from '../../ui/contexts/api.js';
7
- import { getDefaultValue, getDefaultValues, } from '../../ui/playground/get-default-values.js';
8
- import { FieldSet, ObjectInput } from '../../ui/playground/inputs.js';
9
- import { SchemaContext } from '../contexts/schema.js';
10
- import { getStatusInfo } from '../../ui/playground/status-info.js';
11
- import { getUrl } from '../../utils/server-url.js';
6
+ import { useApiContext } from '../ui/contexts/api.js';
7
+ import { getDefaultValue, getDefaultValues } from './get-default-values.js';
8
+ import { FieldSet, ObjectInput } from './inputs.js';
9
+ import { getStatusInfo } from './status-info.js';
10
+ import { getUrl } from '../utils/server-url.js';
12
11
  import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
13
- import { MethodLabel } from '../../ui/components/method-label.js';
14
- import { useQuery } from '../../utils/use-query.js';
15
- import ServerSelect from '../../ui/server-select.js';
12
+ import { MethodLabel } from '../ui/components/method-label.js';
13
+ import { useQuery } from '../utils/use-query.js';
14
+ import ServerSelect from '../ui/server-select.js';
16
15
  import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
17
16
  import { ChevronDown } from 'lucide-react';
17
+ const SchemaContext = createContext(undefined);
18
+ export function useSchemaContext() {
19
+ const ctx = useContext(SchemaContext);
20
+ if (!ctx)
21
+ throw new Error('Missing provider');
22
+ return ctx;
23
+ }
18
24
  function defaultAuthValue(auth) {
19
25
  if (!auth || auth.type === 'apiKey')
20
26
  return '';
@@ -26,7 +32,7 @@ function defaultAuthValue(auth) {
26
32
  }
27
33
  return 'Bearer';
28
34
  }
29
- export function APIPlayground({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
35
+ export function Client({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
30
36
  const { serverRef, servers } = useApiContext();
31
37
  const dynamicRef = useRef(new Map());
32
38
  const form = useForm({
@@ -182,6 +188,6 @@ function DefaultResultDisplay({ data }) {
182
188
  ? data.data
183
189
  : JSON.stringify(data.data, null, 2), ...shikiOptions })) : null] }));
184
190
  }
185
- export function CollapsiblePanel({ title, children, ...props }) {
191
+ function CollapsiblePanel({ title, children, ...props }) {
186
192
  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 }) })] }));
187
193
  }
@@ -0,0 +1,2 @@
1
+ export declare const ClientLazy: import("react").ComponentType<import("./client.js").ClientProps>;
2
+ //# sourceMappingURL=client.lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.lazy.d.ts","sourceRoot":"","sources":["../../src/playground/client.lazy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,+DAEtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ import dynamic from 'next/dynamic';
3
+ export const ClientLazy = dynamic(() => import('./client.js').then((mod) => mod.Client));
@@ -1,5 +1,5 @@
1
- import { type RequestSchema } from '../../render/operation/playground.js';
2
- import { type DynamicField } from '../../ui/contexts/schema.js';
1
+ import { type RequestSchema } from '../playground/index.js';
2
+ import type { DynamicField } from '../playground/client.js';
3
3
  export interface FetchOptions {
4
4
  url: string;
5
5
  method: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/playground/fetcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC,IAAI,CAAC,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACxD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,aAAa,GAAG,SAAS,EACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,OAAO,CAyDT;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GACvC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CA2C5B"}
@@ -1,4 +1,4 @@
1
- import { resolve } from '../../ui/playground/resolve.js';
1
+ import { resolve } from '../playground/resolve.js';
2
2
  /**
3
3
  * @param bodySchema - schema of body
4
4
  * @param references - defined references of schemas, needed for resolve cyclic references
@@ -1,4 +1,4 @@
1
- import type { PrimitiveRequestField, RequestSchema } from '../../render/operation/playground.js';
1
+ import type { PrimitiveRequestField, RequestSchema } from '../playground/index.js';
2
2
  export declare function getDefaultValue(item: RequestSchema, references: Record<string, RequestSchema>): unknown;
3
3
  export declare function getDefaultValues(field: PrimitiveRequestField[], context: Record<string, RequestSchema>): Record<string, unknown>;
4
4
  //# sourceMappingURL=get-default-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-default-values.d.ts","sourceRoot":"","sources":["../../src/playground/get-default-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG/E,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,OAAO,CAwBT;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB"}
@@ -1,4 +1,4 @@
1
- import { resolve } from '../../ui/playground/resolve.js';
1
+ import { resolve } from '../playground/resolve.js';
2
2
  export function getDefaultValue(item, references) {
3
3
  if (item.type === 'object')
4
4
  return Object.fromEntries(Object.entries(item.properties).map(([key, prop]) => [
@@ -1,6 +1,5 @@
1
- import type { ReactNode } from 'react';
2
- import type { MethodInformation, RenderContext } from '../../types.js';
3
- import { type Security } from '../../utils/get-security.js';
1
+ import type { MethodInformation, RenderContext } from '../types.js';
2
+ import { type ClientProps } from './client.js';
4
3
  interface BaseRequestField {
5
4
  name: string;
6
5
  description?: string;
@@ -45,22 +44,11 @@ interface NullSchema extends BaseSchema {
45
44
  }
46
45
  export type RequestSchema = PrimitiveSchema | ArraySchema | ObjectSchema | SwitcherSchema | NullSchema | FileSchema;
47
46
  export interface APIPlaygroundProps {
48
- route: string;
49
- method: string;
50
- authorization?: Security;
51
- path?: PrimitiveRequestField[];
52
- query?: PrimitiveRequestField[];
53
- header?: PrimitiveRequestField[];
54
- body?: RequestSchema & {
55
- mediaType: string;
56
- };
57
- schemas: Record<string, RequestSchema>;
58
- proxyUrl?: string;
59
- }
60
- export declare function Playground({ path, method, ctx, }: {
61
47
  path: string;
62
48
  method: MethodInformation;
63
49
  ctx: RenderContext;
64
- }): ReactNode;
65
- export {};
66
- //# sourceMappingURL=playground.d.ts.map
50
+ client?: Partial<ClientProps>;
51
+ }
52
+ export type { ClientProps, CustomField } from './client.js';
53
+ export declare function APIPlayground({ path, method, ctx, client, }: APIPlaygroundProps): Promise<import("react/jsx-runtime").JSX.Element>;
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playground/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,aAAa,EACd,MAAM,SAAS,CAAC;AAOjB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAA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,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;IAEnB,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B;AAED,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,wBAAsB,aAAa,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,GACP,EAAE,kBAAkB,oDA+CpB"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getPreferredType, } from '../../utils/schema.js';
3
- import { getSecurities } from '../../utils/get-security.js';
4
- import { APIPlayground } from '../../ui/client.js';
5
- export function Playground({ path, method, ctx, }) {
2
+ import { getPreferredType, } from '../utils/schema.js';
3
+ import { getSecurities } from '../utils/get-security.js';
4
+ export async function APIPlayground({ path, method, ctx, client, }) {
5
+ const { ClientLazy } = await import('./client.lazy.js');
6
6
  let currentId = 0;
7
7
  const bodyContent = method.requestBody?.content;
8
8
  const mediaType = bodyContent ? getPreferredType(bodyContent) : undefined;
@@ -39,8 +39,9 @@ export function Playground({ path, method, ctx, }) {
39
39
  : undefined,
40
40
  schemas: context.references,
41
41
  proxyUrl: ctx.proxyUrl,
42
+ ...client,
42
43
  };
43
- return _jsx(APIPlayground, { ...props });
44
+ return _jsx(ClientLazy, { ...props });
44
45
  }
45
46
  function getAuthorizationField(method, { schema: { document } }) {
46
47
  const security = method.security ?? document.security ?? [];
@@ -1,5 +1,5 @@
1
1
  import { type HTMLAttributes, type ReactNode } from 'react';
2
- import type { RequestSchema } from '../../render/operation/playground.js';
2
+ import type { RequestSchema } from '../playground/index.js';
3
3
  type FieldOfType<Type> = Extract<RequestSchema, {
4
4
  type: Type;
5
5
  }>;
@@ -0,0 +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;AAoJD,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,kDAuFA;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,kDA8EA"}
@@ -1,13 +1,14 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  import { useState, } from 'react';
3
4
  import { Plus, Trash2 } from 'lucide-react';
4
5
  import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
5
6
  import { cn, buttonVariants } from 'fumadocs-ui/components/api';
6
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
7
- import { resolve } from '../../ui/playground/resolve.js';
8
- import { Input, labelVariants } from '../../ui/components/input.js';
9
- import { getDefaultValue } from '../../ui/playground/get-default-values.js';
10
- import { useSchemaContext } from '../../ui/contexts/schema.js';
7
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
8
+ import { resolve } from '../playground/resolve.js';
9
+ import { Input, labelVariants } from '../ui/components/input.js';
10
+ import { getDefaultValue } from './get-default-values.js';
11
+ import { useSchemaContext } from './client.js';
11
12
  function FieldHeader({ name, required = false, type, ...props }) {
12
13
  return (_jsxs("label", { ...props, className: cn('w-full inline-flex items-center gap-1', props.className), children: [_jsx("span", { className: cn(labelVariants()), children: name }), required ? _jsx("span", { className: "text-red-500", children: "*" }) : null, _jsx("div", { className: "flex-1" }), type ? (_jsx("code", { className: "text-xs text-fd-muted-foreground", children: type })) : null, props.children] }));
13
14
  }
@@ -1,4 +1,4 @@
1
- import { type ReferenceSchema, type RequestSchema } from '../../render/operation/playground.js';
1
+ import { type ReferenceSchema, type RequestSchema } from '../playground/index.js';
2
2
  /**
3
3
  * Resolve reference
4
4
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/playground/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;GAEG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,GAAG,eAAe,GAAG,MAAM,EAChD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,aAAa,CASf"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-info.d.ts","sourceRoot":"","sources":["../../src/playground/status-info.tsx"],"names":[],"mappings":"AAEA,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC;CACzB;AAsBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAsBxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"api-example.d.ts","sourceRoot":"","sources":["../../../src/render/operation/api-example.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA2BrD,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAcD,wBAAsB,UAAU,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;IAC3C,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,aAAa,CAAC;CACpB,oDA2FA"}
1
+ {"version":3,"file":"api-example.d.ts","sourceRoot":"","sources":["../../../src/render/operation/api-example.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA2BrD,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAcD,wBAAsB,UAAU,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;IAC3C,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,aAAa,CAAC;CACpB,oDAyFA"}
@@ -5,6 +5,7 @@ import * as Go from '../../requests/go.js';
5
5
  import * as Python from '../../requests/python.js';
6
6
  import { Markdown } from '../../render/markdown.js';
7
7
  import { getTypescriptSchema } from '../../utils/get-typescript-schema.js';
8
+ import { CodeBlock } from '../../render/codeblock.js';
8
9
  const defaultSamples = [
9
10
  {
10
11
  label: 'cURL',
@@ -62,12 +63,12 @@ export async function APIExample({ method, endpoint, ctx, }) {
62
63
  function renderRequest(sample) {
63
64
  return (_jsx(renderer.Requests, { items: sample.samples.map((s) => s.label), children: sample.samples.map((s) => (_jsx(renderer.Request, { name: s.label, code: s.source, language: s.lang }, s.label))) }));
64
65
  }
66
+ const exclusiveCodeSamples = method['x-exclusiveCodeSample'];
65
67
  if ((samples.size === 1 && samples.has('_default')) ||
66
- (method['x-exclusiveCodeSample'] &&
67
- samples.has(method['x-exclusiveCodeSample']))) {
68
+ (exclusiveCodeSamples && samples.has(exclusiveCodeSamples))) {
68
69
  // if exclusiveSampleKey is present, we don't use tabs
69
70
  // if only the fallback or non described openapi legacy example is present, we don't use tabs
70
- children = renderRequest(samples.get(method['x-exclusiveCodeSample'] ?? '_default'));
71
+ children = renderRequest(samples.get(exclusiveCodeSamples ?? '_default'));
71
72
  }
72
73
  else if (samples.size > 0) {
73
74
  const entries = Array.from(samples.entries());
@@ -75,7 +76,7 @@ export async function APIExample({ method, endpoint, ctx, }) {
75
76
  title: sample.title,
76
77
  description: sample.description ? (_jsx(Markdown, { text: sample.description })) : null,
77
78
  value: key,
78
- })), defaultValue: method['x-selectedCodeSample'], children: entries.map(([key, sample]) => (_jsx(renderer.Sample, { value: key, children: renderRequest(sample) }, key))) }));
79
+ })), defaultValue: exclusiveCodeSamples, children: entries.map(([key, sample]) => (_jsx(renderer.Sample, { value: key, children: renderRequest(sample) }, key))) }));
79
80
  }
80
81
  return (_jsxs(renderer.APIExample, { children: [children, _jsx(ResponseTabs, { operation: method, ctx: ctx, endpoint: endpoint })] }));
81
82
  }
@@ -97,17 +98,10 @@ function ResponseTabs({ endpoint, operation, ctx: { renderer, generateTypeScript
97
98
  if (!operation.responses)
98
99
  return null;
99
100
  async function renderResponse(code) {
100
- const types = [];
101
- let description = operation.responses?.[code].description;
102
- if (!description && code in endpoint.responses)
103
- description = endpoint.responses[code].schema.description ?? '';
104
- if (code in endpoint.responses) {
105
- types.push({
106
- lang: 'json',
107
- label: 'Response',
108
- code: JSON.stringify(endpoint.responses[code].sample, null, 2),
109
- });
110
- }
101
+ const response = code in endpoint.responses ? endpoint.responses[code] : null;
102
+ const description = operation.responses?.[code].description ??
103
+ response?.schema.description ??
104
+ '';
111
105
  let ts;
112
106
  if (generateTypeScriptSchema) {
113
107
  ts = await generateTypeScriptSchema(endpoint, code);
@@ -115,14 +109,20 @@ function ResponseTabs({ endpoint, operation, ctx: { renderer, generateTypeScript
115
109
  else if (generateTypeScriptSchema === undefined) {
116
110
  ts = await getTypescriptSchema(endpoint, code, schema.dereferenceMap);
117
111
  }
118
- if (ts) {
119
- types.push({
120
- code: ts,
121
- lang: 'ts',
122
- label: 'TypeScript',
112
+ const values = [];
113
+ let exampleSlot;
114
+ if (response?.samples._default) {
115
+ values.push('Response');
116
+ exampleSlot = (_jsx(renderer.ResponseType, { label: "Response", children: _jsx(CodeBlock, { lang: "json", code: JSON.stringify(endpoint.responses[code].samples._default, null, 2) }) }));
117
+ }
118
+ else if (response) {
119
+ exampleSlot = Object.entries(response.samples).map(([key, sample], i) => {
120
+ const title = sample?.summary ?? `Example ${i + 1}`;
121
+ values.push(title);
122
+ return (_jsxs(renderer.ResponseType, { label: title, children: [sample?.description ? (_jsx(Markdown, { text: sample.description })) : null, _jsx(CodeBlock, { lang: "json", code: JSON.stringify(sample, null, 2) })] }, key));
123
123
  });
124
124
  }
125
- return (_jsxs(renderer.Response, { value: code, children: [description ? _jsx(Markdown, { text: description }) : null, types.length > 0 ? (_jsx(renderer.ResponseTypes, { children: types.map((type) => (_jsx(renderer.ResponseType, { ...type }, type.lang))) })) : null] }));
125
+ return (_jsxs(renderer.Response, { value: code, children: [description ? _jsx(Markdown, { text: description }) : null, response && (_jsxs(renderer.ResponseTypes, { defaultValue: values[0], children: [exampleSlot, ts ? (_jsx(renderer.ResponseType, { label: "TypeScript", children: _jsx(CodeBlock, { code: ts, lang: "ts" }) })) : null] }))] }));
126
126
  }
127
127
  const codes = Object.keys(operation.responses);
128
128
  if (codes.length === 0)
@@ -1,5 +1,6 @@
1
1
  import type { ComponentType, ReactNode } from 'react';
2
- import type { MethodInformation, RenderContext, ServerObject } from '../types.js';
2
+ import type { RenderContext, ServerObject } from '../types.js';
3
+ import { type APIPlaygroundProps } from '../playground/index.js';
3
4
  export interface ResponsesProps {
4
5
  items: string[];
5
6
  children: ReactNode;
@@ -44,9 +45,8 @@ export interface SamplesProps {
44
45
  defaultValue?: string;
45
46
  }
46
47
  export interface ResponseTypeProps {
47
- lang: string;
48
- code: string;
49
48
  label: string;
49
+ children: ReactNode;
50
50
  }
51
51
  export interface RootProps {
52
52
  baseUrl?: string;
@@ -73,6 +73,7 @@ export interface Renderer {
73
73
  }>;
74
74
  Request: ComponentType<RequestProps>;
75
75
  ResponseTypes: ComponentType<{
76
+ defaultValue?: string;
76
77
  children: ReactNode;
77
78
  }>;
78
79
  ResponseType: ComponentType<ResponseTypeProps>;
@@ -81,12 +82,7 @@ export interface Renderer {
81
82
  */
82
83
  ObjectCollapsible: ComponentType<ObjectCollapsibleProps>;
83
84
  Property: ComponentType<PropertyProps>;
84
- APIPlayground: ComponentType<{
85
- path: string;
86
- method: MethodInformation;
87
- ctx: RenderContext;
88
- }>;
85
+ APIPlayground: ComponentType<APIPlaygroundProps>;
89
86
  }
90
- export type { APIPlaygroundProps, RequestSchema, PrimitiveRequestField, ReferenceSchema, } from '../render/operation/playground.js';
91
87
  export declare function createRenders(shikiOptions: RenderContext['shikiOptions']): Renderer;
92
88
  //# sourceMappingURL=renderer.d.ts.map
@@ -1 +1 @@
1
- {"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K,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IAClE,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACrC,aAAa,EAAE,aAAa,CAAC;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IAC7E,YAAY,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAE/C;;OAEG;IACH,iBAAiB,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;IACzD,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CAClD;AAED,wBAAgB,aAAa,CAC3B,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,GAC1C,QAAQ,CAgDV"}
@@ -3,7 +3,7 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
3
3
  import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
4
4
  import { CodeBlock } from '../render/codeblock.js';
5
5
  import { API, Root, APIInfo, APIExample, Property, ObjectCollapsible, } from '../ui/index.js';
6
- import { Playground } from '../render/operation/playground.js';
6
+ import { APIPlayground } from '../playground/index.js';
7
7
  import { Sample, Samples } from '../ui/client.js';
8
8
  export function createRenders(shikiOptions) {
9
9
  return {
@@ -13,14 +13,14 @@ export function createRenders(shikiOptions) {
13
13
  APIExample,
14
14
  Responses: Tabs,
15
15
  Response: Tab,
16
- ResponseTypes: (props) => (_jsx(Accordions, { type: "single", className: "!-m-4 border-none pt-2", defaultValue: "Response", children: props.children })),
17
- ResponseType: (props) => (_jsx(Accordion, { title: props.label, children: _jsx(CodeBlock, { code: props.code, lang: props.lang, options: shikiOptions }) })),
16
+ ResponseTypes: (props) => (_jsx(Accordions, { type: "single", className: "!-m-4 border-none pt-2", defaultValue: props.defaultValue, children: props.children })),
17
+ ResponseType: (props) => (_jsx(Accordion, { title: props.label, children: props.children })),
18
18
  Property,
19
19
  ObjectCollapsible,
20
20
  Requests: (props) => (_jsx(Tabs, { groupId: "fumadocs_openapi_requests", ...props })),
21
21
  Samples,
22
22
  Sample,
23
23
  Request: (props) => (_jsx(Tab, { value: props.name, children: _jsx(CodeBlock, { lang: props.language, code: props.code, options: shikiOptions }) })),
24
- APIPlayground: Playground,
24
+ APIPlayground,
25
25
  };
26
26
  }
@@ -1,18 +1,3 @@
1
- export declare const APIPlayground: import("react").ComponentType<import("../render/renderer.js").APIPlaygroundProps & {
2
- fields?: {
3
- auth?: import("./playground/index.js").CustomField<"authorization", import("../render/renderer.js").RequestSchema>;
4
- path?: import("./playground/index.js").CustomField<`path.${string}`, import("../render/renderer.js").PrimitiveRequestField>;
5
- query?: import("./playground/index.js").CustomField<`query.${string}`, import("../render/renderer.js").PrimitiveRequestField>;
6
- header?: import("./playground/index.js").CustomField<`header.${string}`, import("../render/renderer.js").PrimitiveRequestField>;
7
- body?: import("./playground/index.js").CustomField<"body", import("../render/renderer.js").RequestSchema>;
8
- };
9
- components?: Partial<{
10
- ResultDisplay: import("react").FC<{
11
- data: import("./playground/fetcher.js").FetchResult;
12
- }>;
13
- }>;
14
- } & import("react").HTMLAttributes<HTMLFormElement>>;
15
1
  export declare const Samples: import("react").ComponentType<import("../render/renderer.js").SamplesProps>;
16
2
  export declare const Sample: import("react").ComponentType<import("../render/renderer.js").SampleProps>;
17
- export { useSchemaContext } from './contexts/schema.js';
18
3
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;YAaw/D,CAAC;YAAuD,CAAC;aAAiE,CAAC;cAAmE,CAAC;YAAkE,CAAC;;;;;;;oDAXnxE,CAAC;AAEF,eAAO,MAAM,OAAO,0EAEnB,CAAC;AAEF,eAAO,MAAM,MAAM,yEAElB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,0EAEnB,CAAC;AAEF,eAAO,MAAM,MAAM,yEAElB,CAAC"}
package/dist/ui/client.js CHANGED
@@ -1,6 +1,4 @@
1
1
  'use client';
2
2
  import dynamic from 'next/dynamic';
3
- export const APIPlayground = dynamic(() => import('./playground/index.js').then((mod) => mod.APIPlayground));
4
3
  export const Samples = dynamic(() => import('./sample-select.js').then((mod) => mod.Samples));
5
4
  export const Sample = dynamic(() => import('./sample-select.js').then((mod) => mod.Sample));
6
- export { useSchemaContext } from './contexts/schema.js';
@@ -6,7 +6,7 @@ export function Samples({ items, defaultValue = items[0].value, children, }) {
6
6
  const [value, setValue] = useState('');
7
7
  const active = value === '' ? defaultValue : value;
8
8
  const defaultItem = items.find((item) => item.value === defaultValue);
9
- return (_jsxs(_Fragment, { children: [_jsxs(Select, { value: value, onValueChange: setValue, children: [_jsx(SelectTrigger, { className: "not-prose", children: _jsx(SelectValue, { placeholder: defaultItem ? _jsx(SelectDisplay, { ...defaultItem }) : null }) }), _jsx(SelectContent, { children: items.map((item) => (_jsx(SelectItem, { value: item.value, children: _jsx(SelectDisplay, { ...item }) }, item.value))) })] }), _jsx(ActiveSampleContext, { value: active, children: children })] }));
9
+ return (_jsxs(_Fragment, { children: [_jsxs(Select, { value: value, onValueChange: setValue, children: [_jsx(SelectTrigger, { className: "not-prose mb-2", children: _jsx(SelectValue, { placeholder: defaultItem ? _jsx(SelectDisplay, { ...defaultItem }) : null }) }), _jsx(SelectContent, { children: items.map((item) => (_jsx(SelectItem, { value: item.value, children: _jsx(SelectDisplay, { ...item }) }, item.value))) })] }), _jsx(ActiveSampleContext, { value: active, children: children })] }));
10
10
  }
11
11
  function SelectDisplay(item) {
12
12
  return (_jsxs(_Fragment, { children: [_jsx("span", { className: "font-medium text-sm", children: item.title }), _jsx("span", { className: "text-fd-muted-foreground", children: item.description })] }));
@@ -1,14 +1,14 @@
1
1
  import type { MethodInformation, RenderContext } from '../types.js';
2
2
  import { type ParsedSchema, type NoReference } from '../utils/schema.js';
3
3
  import type { OpenAPIV3_1 } from 'openapi-types';
4
- export interface Samples {
5
- [key: string]: {
4
+ export type Samples = {
5
+ [key in '_default' | (string & {})]?: {
6
6
  value?: unknown;
7
7
  description?: string;
8
8
  summary?: string;
9
9
  externalValue?: string;
10
10
  };
11
- }
11
+ };
12
12
  /**
13
13
  * Sample info of endpoint
14
14
  */
@@ -28,7 +28,7 @@ export interface EndpointSample {
28
28
  }
29
29
  interface ResponseSample {
30
30
  mediaType: string;
31
- sample: unknown;
31
+ samples: Samples;
32
32
  schema: ParsedSchema;
33
33
  }
34
34
  interface ParameterSample extends NoReference<OpenAPIV3_1.ParameterObject> {
@@ -1 +1 @@
1
- {"version":3,"file":"generate-sample.d.ts","sourceRoot":"","sources":["../../src/utils/generate-sample.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AACD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,YAAY,CAAC;QACrB,SAAS,EAAE,MAAM,CA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AAE;QACL,MAAM,EAAE,YAAY,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,UAAU,eAAgB,SAAQ,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC;IACxE,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,GAC/C,cAAc,CA0HhB"}
@@ -71,10 +71,15 @@ export function generateSample(path, method, { baseUrl, schema: { document } })
71
71
  const responseSchema = content[mediaType].schema;
72
72
  if (!responseSchema)
73
73
  continue;
74
+ const examples = content[mediaType].examples ?? content.examples;
75
+ const example = content[mediaType].example ?? content.example;
74
76
  responses[code] = {
75
77
  mediaType,
76
- sample: content[mediaType].example ??
77
- generateBody(method.method, responseSchema),
78
+ samples: examples
79
+ ? examples
80
+ : {
81
+ _default: example ?? generateBody(method.method, responseSchema),
82
+ },
78
83
  schema: responseSchema,
79
84
  };
80
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "6.0.10",
3
+ "version": "6.1.0",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -24,6 +24,10 @@
24
24
  "import": "./dist/ui/client.js",
25
25
  "types": "./dist/ui/client.d.ts"
26
26
  },
27
+ "./playground": {
28
+ "import": "./dist/playground/index.js",
29
+ "types": "./dist/playground/index.d.ts"
30
+ },
27
31
  "./scalar": {
28
32
  "import": "./dist/scalar/index.js",
29
33
  "types": "./dist/scalar/index.d.ts"
@@ -42,12 +46,12 @@
42
46
  "@fumari/json-schema-to-typescript": "^1.1.2",
43
47
  "@radix-ui/react-select": "^2.1.6",
44
48
  "@radix-ui/react-slot": "^1.1.2",
45
- "@scalar/openapi-parser": "0.10.6",
49
+ "@scalar/openapi-parser": "0.10.8",
46
50
  "ajv-draft-04": "^1.0.0",
47
51
  "class-variance-authority": "^0.7.1",
48
52
  "fast-glob": "^3.3.3",
49
53
  "github-slugger": "^2.0.0",
50
- "hast-util-to-jsx-runtime": "^2.3.2",
54
+ "hast-util-to-jsx-runtime": "^2.3.3",
51
55
  "js-yaml": "^4.1.0",
52
56
  "lucide-react": "^0.475.0",
53
57
  "next-themes": "^0.4.4",
@@ -55,20 +59,20 @@
55
59
  "react-hook-form": "^7.54.2",
56
60
  "remark": "^15.0.1",
57
61
  "remark-rehype": "^11.1.1",
58
- "shiki": "^2.4.1",
62
+ "shiki": "^3.0.0",
59
63
  "xml-js": "^1.6.11",
60
- "fumadocs-core": "15.0.9",
61
- "fumadocs-ui": "15.0.9"
64
+ "fumadocs-core": "15.0.11",
65
+ "fumadocs-ui": "15.0.11"
62
66
  },
63
67
  "devDependencies": {
64
- "@scalar/api-client-react": "^1.1.27",
68
+ "@scalar/api-client-react": "^1.1.31",
65
69
  "@types/js-yaml": "^4.0.9",
66
70
  "@types/node": "22.13.4",
67
71
  "@types/openapi-sampler": "^1.0.3",
68
- "@types/react": "^19.0.9",
72
+ "@types/react": "^19.0.10",
69
73
  "next": "15.1.7",
70
74
  "openapi-types": "^12.1.3",
71
- "tailwindcss": "^4.0.6",
75
+ "tailwindcss": "^4.0.7",
72
76
  "tsc-alias": "^1.8.10",
73
77
  "eslint-config-custom": "0.0.0",
74
78
  "tsconfig": "0.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"file":"playground.d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;AAED,UAAU,UAAW,SAAQ,UAAU;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,cAAc,GACd,UAAU,GACV,UAAU,CAAC;AAUf,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,QAAQ,CAAC;IACzB,IAAI,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAChC,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,aAAa,GAAG;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;CACpB,GAAG,SAAS,CA6CZ"}
@@ -1,17 +0,0 @@
1
- import { type RefObject } from 'react';
2
- import { type ReferenceSchema, type RequestSchema } from '../../render/operation/playground.js';
3
- interface SchemaContextType {
4
- references: Record<string, RequestSchema>;
5
- dynamic: RefObject<Map<string, DynamicField>>;
6
- }
7
- export type DynamicField = {
8
- type: 'object';
9
- properties: string[];
10
- } | {
11
- type: 'field';
12
- schema: RequestSchema | ReferenceSchema;
13
- };
14
- export declare const SchemaContext: import("react").Context<SchemaContextType | undefined>;
15
- export declare function useSchemaContext(): SchemaContextType;
16
- export {};
17
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AAEvC,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;AAEN,eAAO,MAAM,aAAa,wDAEzB,CAAC;AAEF,wBAAgB,gBAAgB,IAAI,iBAAiB,CAIpD"}
@@ -1,8 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- export const SchemaContext = createContext(undefined);
3
- export function useSchemaContext() {
4
- const ctx = useContext(SchemaContext);
5
- if (!ctx)
6
- throw new Error('Missing provider');
7
- return ctx;
8
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/fetcher.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC,IAAI,CAAC,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACxD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,aAAa,GAAG,SAAS,EACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,OAAO,CAyDT;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GACvC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CA2C5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-default-values.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/get-default-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACd,MAAM,+BAA+B,CAAC;AAGvC,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,OAAO,CAwBT;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/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,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,cAAc,CAAC,2CAqBjC;AAoJD,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,kDAuFA;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,kDA8EA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,GAAG,eAAe,GAAG,MAAM,EAChD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,aAAa,CASf"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"status-info.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/status-info.tsx"],"names":[],"mappings":"AAEA,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC;CACzB;AAsBD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAsBxD"}
File without changes