fumadocs-openapi 8.1.5 → 8.1.7

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 (65) hide show
  1. package/dist/media/adapter.d.ts +62 -0
  2. package/dist/media/adapter.d.ts.map +1 -0
  3. package/dist/media/adapter.js +126 -0
  4. package/dist/playground/client.d.ts.map +1 -1
  5. package/dist/playground/client.js +6 -3
  6. package/dist/playground/fetcher.d.ts +3 -6
  7. package/dist/playground/fetcher.d.ts.map +1 -1
  8. package/dist/playground/fetcher.js +17 -52
  9. package/dist/playground/index.d.ts.map +1 -1
  10. package/dist/playground/index.js +1 -3
  11. package/dist/playground/inputs.d.ts.map +1 -1
  12. package/dist/playground/inputs.js +1 -1
  13. package/dist/render/api-page.d.ts +1 -1
  14. package/dist/render/api-page.d.ts.map +1 -1
  15. package/dist/render/api-page.js +17 -6
  16. package/dist/render/operation/api-example.d.ts.map +1 -1
  17. package/dist/render/operation/api-example.js +1 -1
  18. package/dist/render/operation/index.d.ts +2 -2
  19. package/dist/render/operation/index.d.ts.map +1 -1
  20. package/dist/render/operation/index.js +1 -3
  21. package/dist/render/renderer.d.ts +3 -5
  22. package/dist/render/renderer.d.ts.map +1 -1
  23. package/dist/render/renderer.js +4 -4
  24. package/dist/requests/_shared.d.ts +5 -7
  25. package/dist/requests/_shared.d.ts.map +1 -1
  26. package/dist/requests/_shared.js +0 -11
  27. package/dist/requests/curl.d.ts +2 -2
  28. package/dist/requests/curl.d.ts.map +1 -1
  29. package/dist/requests/curl.js +16 -9
  30. package/dist/requests/go.d.ts +2 -2
  31. package/dist/requests/go.d.ts.map +1 -1
  32. package/dist/requests/go.js +13 -21
  33. package/dist/requests/index.js +4 -4
  34. package/dist/requests/javascript.d.ts +2 -2
  35. package/dist/requests/javascript.d.ts.map +1 -1
  36. package/dist/requests/javascript.js +20 -27
  37. package/dist/requests/python.d.ts +2 -2
  38. package/dist/requests/python.d.ts.map +1 -1
  39. package/dist/requests/python.js +18 -27
  40. package/dist/types.d.ts +2 -0
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/ui/client.d.ts +0 -1
  43. package/dist/ui/client.d.ts.map +1 -1
  44. package/dist/ui/client.js +0 -1
  45. package/dist/ui/contexts/api.d.ts +8 -5
  46. package/dist/ui/contexts/api.d.ts.map +1 -1
  47. package/dist/ui/contexts/api.js +16 -8
  48. package/dist/ui/contexts/code-example.d.ts.map +1 -1
  49. package/dist/ui/contexts/code-example.js +5 -3
  50. package/dist/ui/index.d.ts +1 -1
  51. package/dist/ui/index.d.ts.map +1 -1
  52. package/dist/ui/index.js +3 -3
  53. package/dist/ui/lazy.d.ts +14 -0
  54. package/dist/ui/lazy.d.ts.map +1 -0
  55. package/dist/ui/lazy.js +7 -0
  56. package/dist/utils/input-to-string.d.ts +1 -1
  57. package/dist/utils/input-to-string.d.ts.map +1 -1
  58. package/dist/utils/input-to-string.js +7 -1
  59. package/package.json +6 -6
  60. package/dist/playground/client.lazy.d.ts +0 -2
  61. package/dist/playground/client.lazy.d.ts.map +0 -1
  62. package/dist/playground/client.lazy.js +0 -3
  63. package/dist/ui/contexts/code-example.lazy.d.ts +0 -12
  64. package/dist/ui/contexts/code-example.lazy.d.ts.map +0 -1
  65. package/dist/ui/contexts/code-example.lazy.js +0 -5
@@ -1,15 +1,4 @@
1
1
  import { getPathnameFromInput } from '../utils/get-pathname-from-input.js';
2
- export const supportedMediaTypes = [
3
- 'multipart/form-data',
4
- 'application/json',
5
- 'application/xml',
6
- 'application/x-www-form-urlencoded',
7
- ];
8
- export const MediaTypeFormatMap = {
9
- 'application/json': 'json',
10
- 'application/xml': 'xml',
11
- 'application/x-www-form-urlencoded': 'url',
12
- };
13
2
  export function getUrl(url, data) {
14
3
  return getPathnameFromInput(url, data.path, data.query);
15
4
  }
@@ -1,3 +1,3 @@
1
- import { type RequestData } from '../requests/_shared.js';
2
- export declare function getSampleRequest(url: string, data: RequestData): string;
1
+ import { type SampleGenerator } from '../requests/_shared.js';
2
+ export declare const generator: SampleGenerator;
3
3
  //# sourceMappingURL=curl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/requests/curl.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAmCvE"}
1
+ {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/requests/curl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAQzE,eAAO,MAAM,SAAS,EAAE,eA0CvB,CAAC"}
@@ -1,7 +1,12 @@
1
1
  'use client';
2
2
  import { inputToString } from '../utils/input-to-string.js';
3
- import { getUrl, ident, MediaTypeFormatMap, } from '../requests/_shared.js';
4
- export function getSampleRequest(url, data) {
3
+ import { getUrl, ident } from '../requests/_shared.js';
4
+ const MediaTypeFormatMap = {
5
+ 'application/json': 'json',
6
+ 'application/xml': 'xml',
7
+ 'application/x-www-form-urlencoded': 'url',
8
+ };
9
+ export const generator = (url, data) => {
5
10
  const s = [];
6
11
  s.push(`curl -X ${data.method} "${getUrl(url, data)}"`);
7
12
  for (const header in data.header) {
@@ -12,16 +17,18 @@ export function getSampleRequest(url, data) {
12
17
  const value = JSON.stringify(`${cookie}=${data.cookie[cookie]}`);
13
18
  s.push(`--cookie ${value}`);
14
19
  }
15
- if (data.bodyMediaType === 'multipart/form-data') {
16
- if (data.body && typeof data.body === 'object') {
17
- for (const [key, value] of Object.entries(data.body)) {
18
- s.push(`-F ${key}=${inputToString(value)}`);
19
- }
20
+ if (data.body && data.bodyMediaType === 'multipart/form-data') {
21
+ if (typeof data.body !== 'object')
22
+ throw new Error('[CURL] request body must be an object.');
23
+ for (const [key, value] of Object.entries(data.body)) {
24
+ s.push(`-F ${key}=${inputToString(value)}`);
20
25
  }
21
26
  }
22
- else if (data.body && data.bodyMediaType) {
27
+ else if (data.body &&
28
+ data.bodyMediaType &&
29
+ data.bodyMediaType in MediaTypeFormatMap) {
23
30
  s.push(`-H "Content-Type: ${data.bodyMediaType}"`);
24
31
  s.push(`-d ${inputToString(data.body, MediaTypeFormatMap[data.bodyMediaType], 'single-quote')}`);
25
32
  }
26
33
  return s.flatMap((v, i) => ident(v, i > 0 ? 1 : 0)).join(' \\\n');
27
- }
34
+ };
@@ -1,3 +1,3 @@
1
- import { type RequestData } from '../requests/_shared.js';
2
- export declare function getSampleRequest(url: string, data: RequestData): string;
1
+ import { SampleGenerator } from '../requests/_shared.js';
2
+ export declare const generator: SampleGenerator;
3
3
  //# sourceMappingURL=go.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/requests/go.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAuEvE"}
1
+ {"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/requests/go.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEpE,eAAO,MAAM,SAAS,EAAE,eAqDvB,CAAC"}
@@ -1,33 +1,25 @@
1
1
  'use client';
2
- import { inputToString } from '../utils/input-to-string.js';
3
- import { getUrl, ident, MediaTypeFormatMap, } from '../requests/_shared.js';
4
- export function getSampleRequest(url, data) {
2
+ import { getUrl, ident } from '../requests/_shared.js';
3
+ export const generator = (url, data, { mediaAdapters }) => {
5
4
  const imports = ['fmt', 'net/http', 'io/ioutil'];
6
5
  const headers = new Map();
7
6
  const variables = new Map();
8
7
  variables.set('url', JSON.stringify(getUrl(url, data)));
9
- // additional lines before initializing request
10
- const additional = [];
11
8
  for (const header in data.header) {
12
9
  headers.set(header, JSON.stringify(data.header[header]));
13
10
  }
14
11
  const cookies = Object.keys(data.cookie);
15
12
  if (cookies.length > 0)
16
13
  headers.set('Cookie', JSON.stringify(cookies.map((p) => `${p}=${data.cookie[p]}`).join('; ')));
17
- if (data.body && data.bodyMediaType) {
14
+ let body;
15
+ if (data.body && data.bodyMediaType && data.bodyMediaType in mediaAdapters) {
18
16
  headers.set('Content-Type', `"${data.bodyMediaType}"`);
19
- if (data.bodyMediaType === 'multipart/form-data') {
20
- imports.push('mime/multipart', 'bytes');
21
- variables.set('payload', `new(bytes.Buffer)`);
22
- variables.set('mp', 'multipart.NewWriter(payload)');
23
- for (const [key, value] of Object.entries(data.body)) {
24
- additional.push(`mp.WriteField("${key}", ${inputToString(value, 'json', 'backtick')})`);
25
- }
26
- }
27
- else {
28
- imports.push('strings');
29
- variables.set('payload', `strings.NewReader(${inputToString(data.body, MediaTypeFormatMap[data.bodyMediaType], 'backtick')})`);
30
- }
17
+ body = mediaAdapters[data.bodyMediaType].generateExample(data, {
18
+ lang: 'go',
19
+ addImport(from) {
20
+ imports.push(from);
21
+ },
22
+ });
31
23
  }
32
24
  return `package main
33
25
 
@@ -39,8 +31,8 @@ func main() {
39
31
  ${Array.from(variables.entries())
40
32
  .map(([k, v]) => ident(`${k} := ${v}`))
41
33
  .join('\n')}
42
- ${ident(additional.join('\n'))}
43
- req, _ := http.NewRequest("${data.method}", url, ${variables.has('payload') ? 'payload' : 'nil'})
34
+ ${body ? ident(body) : ''}
35
+ req, _ := http.NewRequest("${data.method}", url, ${body ? 'body' : 'nil'})
44
36
  ${ident(Array.from(headers.entries())
45
37
  .map(([key, value]) => `req.Header.Add("${key}", ${value})`)
46
38
  .join('\n'))}
@@ -51,4 +43,4 @@ ${ident(Array.from(headers.entries())
51
43
  fmt.Println(res)
52
44
  fmt.Println(string(body))
53
45
  }`;
54
- }
46
+ };
@@ -5,22 +5,22 @@ import * as Python from '../requests/python.js';
5
5
  export const defaultSamples = [
6
6
  {
7
7
  label: 'cURL',
8
- source: CURL.getSampleRequest,
8
+ source: CURL.generator,
9
9
  lang: 'bash',
10
10
  },
11
11
  {
12
12
  label: 'JavaScript',
13
- source: JS.getSampleRequest,
13
+ source: JS.generator,
14
14
  lang: 'js',
15
15
  },
16
16
  {
17
17
  label: 'Go',
18
- source: Go.getSampleRequest,
18
+ source: Go.generator,
19
19
  lang: 'go',
20
20
  },
21
21
  {
22
22
  label: 'Python',
23
- source: Python.getSampleRequest,
23
+ source: Python.generator,
24
24
  lang: 'python',
25
25
  },
26
26
  ];
@@ -1,3 +1,3 @@
1
- import { type RequestData } from '../requests/_shared.js';
2
- export declare function getSampleRequest(url: string, data: RequestData): string;
1
+ import { type SampleGenerator } from '../requests/_shared.js';
2
+ export declare const generator: SampleGenerator;
3
3
  //# sourceMappingURL=javascript.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/requests/javascript.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAErE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAoDvE"}
1
+ {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/requests/javascript.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEzE,eAAO,MAAM,SAAS,EAAE,eA0CvB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  'use client';
2
- import { inputToString } from '../utils/input-to-string.js';
3
2
  import { getUrl, ident } from '../requests/_shared.js';
4
- export function getSampleRequest(url, data) {
3
+ export const generator = (url, data, { mediaAdapters }) => {
5
4
  const s = [];
6
5
  const options = new Map();
7
6
  const headers = { ...data.header };
@@ -13,32 +12,26 @@ export function getSampleRequest(url, data) {
13
12
  if (Object.keys(headers).length > 0) {
14
13
  options.set('headers', JSON.stringify(headers, null, 2));
15
14
  }
16
- if (data.bodyMediaType === 'multipart/form-data' && data.body) {
17
- s.push(`const formData = new FormData();`);
18
- for (const [key, value] of Object.entries(data.body))
19
- s.push(`formData.set(${key}, ${inputToString(value)})`);
20
- options.set('body', 'formData');
15
+ let body;
16
+ if (data.body && data.bodyMediaType && data.bodyMediaType in mediaAdapters) {
17
+ body = mediaAdapters[data.bodyMediaType].generateExample(data, {
18
+ lang: 'js',
19
+ addImport(from, name) {
20
+ s.unshift(`import { ${name} } from "${from}"`);
21
+ },
22
+ });
21
23
  }
22
- else if (data.body &&
23
- data.bodyMediaType === 'application/x-www-form-urlencoded') {
24
- options.set('body', `new URLSearchParams(${JSON.stringify(data.body, null, 2)})`);
24
+ if (body) {
25
+ s.push(body);
26
+ options.set('body', 'body');
25
27
  }
26
- else if (data.body) {
27
- let code;
28
- if (data.bodyMediaType === 'application/json') {
29
- code =
30
- typeof data.body === 'string'
31
- ? inputToString(data.body, 'json', 'backtick')
32
- : `JSON.stringify(${JSON.stringify(data.body, null, 2)})`;
33
- }
34
- else {
35
- code = inputToString(data.body, 'xml', 'backtick');
36
- }
37
- options.set('body', code);
28
+ const params = [JSON.stringify(getUrl(url, data))];
29
+ if (options.size > 0) {
30
+ const str = Array.from(options.entries())
31
+ .map(([k, v]) => ident(k === v ? k : `${k}: ${v}`))
32
+ .join(',\n');
33
+ params.push(`{\n${str}\n}`);
38
34
  }
39
- const optionsStr = Array.from(options.entries())
40
- .map(([k, v]) => ident(`${k}: ${v}`))
41
- .join(',\n');
42
- s.push(`fetch(${JSON.stringify(getUrl(url, data))}, {\n${optionsStr}\n});`);
35
+ s.push(`fetch(${params.join(', ')})`);
43
36
  return s.join('\n\n');
44
- }
37
+ };
@@ -1,3 +1,3 @@
1
- import { type RequestData } from '../requests/_shared.js';
2
- export declare function getSampleRequest(url: string, data: RequestData): string;
1
+ import { type SampleGenerator } from '../requests/_shared.js';
2
+ export declare const generator: SampleGenerator;
3
3
  //# sourceMappingURL=python.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAkDvE"}
1
+ {"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,eAAO,MAAM,SAAS,EAAE,eAkCvB,CAAC"}
@@ -1,41 +1,32 @@
1
1
  'use client';
2
- import { inputToString } from '../utils/input-to-string.js';
3
- import { getUrl, MediaTypeFormatMap, } from '../requests/_shared.js';
4
- export function getSampleRequest(url, data) {
5
- const variables = new Map();
2
+ import { getUrl } from '../requests/_shared.js';
3
+ export const generator = (url, data, { mediaAdapters }) => {
6
4
  const headers = { ...data.header };
7
- if (data.body && data.bodyMediaType) {
8
- switch (data.bodyMediaType) {
9
- case 'application/json':
10
- variables.set('json', JSON.stringify(data.body, null, 2));
11
- break;
12
- case 'multipart/form-data':
13
- headers['Content-Type'] = data.bodyMediaType;
14
- variables.set('data', JSON.stringify(data.body, null, 2));
15
- break;
16
- default:
17
- headers['Content-Type'] = data.bodyMediaType;
18
- variables.set('data', inputToString(data.body, MediaTypeFormatMap[data.bodyMediaType], 'python'));
5
+ const params = [`"${data.method}"`, 'url'];
6
+ let body;
7
+ if (data.body && data.bodyMediaType && data.bodyMediaType in mediaAdapters) {
8
+ headers['Content-Type'] = data.bodyMediaType;
9
+ body = mediaAdapters[data.bodyMediaType].generateExample(data, {
10
+ lang: 'python',
11
+ });
12
+ if (body && data.bodyMediaType === 'application/json') {
13
+ params.push('json = body');
14
+ }
15
+ else if (body) {
16
+ params.push('data = body');
19
17
  }
20
18
  }
21
19
  if (Object.keys(headers).length > 0) {
22
- variables.set('headers', JSON.stringify(headers, null, 2));
20
+ params.push(`headers = ${JSON.stringify(headers, null, 2)}`);
23
21
  }
24
22
  if (Object.keys(data.cookie).length > 0) {
25
- variables.set('cookies', JSON.stringify(data.cookie, null, 2));
23
+ params.push(`cookies = ${JSON.stringify(data.cookie, null, 2)}`);
26
24
  }
27
- const params = [
28
- `"${data.method}"`,
29
- 'url',
30
- ...Array.from(variables.keys()).map((k) => `${k}=${k}`),
31
- ];
32
25
  return `import requests
33
26
 
34
27
  url = ${JSON.stringify(getUrl(url, data))}
35
- ${Array.from(variables.entries())
36
- .map(([k, v]) => `${k} = ${v}`)
37
- .join('\n')}
28
+ ${body ?? ''}
38
29
  response = requests.request(${params.join(', ')})
39
30
 
40
31
  print(response.text)`;
41
- }
32
+ };
package/dist/types.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { CodeSample } from './render/operation/index.js';
5
5
  import type { BuiltinTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from 'shiki';
6
6
  import type { NoReference } from './utils/schema.js';
7
7
  import type { ProcessedDocument } from './utils/process-document.js';
8
+ import type { MediaAdapter } from './media/adapter.js';
8
9
  export type Document = V3_1.Document;
9
10
  export type OperationObject = V3_1.OperationObject;
10
11
  export type ParameterObject = V3_1.ParameterObject;
@@ -60,6 +61,7 @@ export interface RenderContext {
60
61
  * @default true
61
62
  */
62
63
  showResponseSchema?: boolean;
64
+ mediaAdapters: Record<string, MediaAdapter | true>;
63
65
  }
64
66
  export {};
65
67
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO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MAAM,KACf,SAAS,CAAC,MAAM,CAAC,CAAC,GACvB,KAAK,CAAC;IAEV;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;IAE7E,YAAY,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAC,GAClD,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAElC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC,CAAC;CACpD"}
@@ -1,4 +1,3 @@
1
- export { ClientLazy as APIPlayground } from '../playground/client.lazy.js';
2
1
  export declare function CopyResponseTypeScript({ code }: {
3
2
  code: string;
4
3
  }): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvE,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CAgChE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,2CAgChE"}
package/dist/ui/client.js CHANGED
@@ -4,7 +4,6 @@ import { useCopyButton } from 'fumadocs-ui/utils/use-copy-button';
4
4
  import { buttonVariants } from 'fumadocs-ui/components/ui/button';
5
5
  import { cn } from 'fumadocs-ui/utils/cn';
6
6
  import { Check, Copy } from '../icons.js';
7
- export { ClientLazy as APIPlayground } from '../playground/client.lazy.js';
8
7
  export function CopyResponseTypeScript({ code }) {
9
8
  const [isChecked, onCopy] = useCopyButton(() => {
10
9
  void navigator.clipboard.writeText(code);
@@ -1,19 +1,22 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import type { RenderContext, ServerObject } from '../../types.js';
3
- export interface ApiProviderProps {
3
+ import { type MediaAdapter } from '../../media/adapter.js';
4
+ export interface ApiProviderProps extends ApiContextType {
4
5
  /**
5
6
  * Base URL for API requests
6
7
  */
7
8
  defaultBaseUrl?: string;
8
- servers: ServerObject[];
9
- shikiOptions: RenderContext['shikiOptions'];
10
9
  children?: ReactNode;
11
10
  }
12
11
  export interface SelectedServer {
13
12
  url: string;
14
13
  variables: Record<string, string>;
15
14
  }
16
- type ApiContextType = Omit<ApiProviderProps, 'children' | 'defaultBaseUrl'>;
15
+ interface ApiContextType {
16
+ servers: ServerObject[];
17
+ shikiOptions: RenderContext['shikiOptions'];
18
+ mediaAdapters: Record<string, MediaAdapter>;
19
+ }
17
20
  interface ServerSelectType {
18
21
  server: SelectedServer | null;
19
22
  setServer: (value: string) => void;
@@ -21,6 +24,6 @@ interface ServerSelectType {
21
24
  }
22
25
  export declare function useApiContext(): ApiContextType;
23
26
  export declare function useServerSelectContext(): ServerSelectType;
24
- export declare function ApiProvider({ defaultBaseUrl, children, ...props }: ApiProviderProps): import("react/jsx-runtime").JSX.Element;
27
+ export declare function ApiProvider({ defaultBaseUrl, children, servers, mediaAdapters, shikiOptions, }: ApiProviderProps): import("react/jsx-runtime").JSX.Element;
25
28
  export {};
26
29
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/api.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,OAAO,EAAE,YAA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cAAc;IACtB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC7C;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC7D;AAKD,wBAAgB,aAAa,IAAI,cAAc,CAK9C;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAKzD;AAED,wBAAgB,WAAW,CAAC,EAC1B,cAAc,EACd,QAAQ,EACR,OAAO,EACP,aAAa,EACb,YAAY,GACb,EAAE,gBAAgB,2CA2ElB"}
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { createContext, useContext, useEffect, useMemo, useState, } from 'react';
4
- const ApiContext = createContext(undefined);
5
- const ServerSelectContext = createContext(undefined);
4
+ import { defaultAdapters } from '../../media/adapter.js';
5
+ const ApiContext = createContext(null);
6
+ const ServerSelectContext = createContext(null);
6
7
  export function useApiContext() {
7
8
  const ctx = useContext(ApiContext);
8
9
  if (!ctx)
@@ -15,11 +16,11 @@ export function useServerSelectContext() {
15
16
  throw new Error('Component must be used under <ApiProvider />');
16
17
  return ctx;
17
18
  }
18
- export function ApiProvider({ defaultBaseUrl, children, ...props }) {
19
+ export function ApiProvider({ defaultBaseUrl, children, servers, mediaAdapters, shikiOptions, }) {
19
20
  const [server, setServer] = useState(() => {
20
21
  const defaultItem = defaultBaseUrl
21
- ? props.servers.find((item) => item.url === defaultBaseUrl)
22
- : undefined;
22
+ ? servers.find((item) => item.url === defaultBaseUrl)
23
+ : null;
23
24
  return defaultItem
24
25
  ? {
25
26
  url: defaultItem.url,
@@ -41,7 +42,14 @@ export function ApiProvider({ defaultBaseUrl, children, ...props }) {
41
42
  // ignore
42
43
  }
43
44
  }, []);
44
- return (_jsx(ApiContext.Provider, { value: props, children: _jsx(ServerSelectContext.Provider, { value: useMemo(() => ({
45
+ return (_jsx(ApiContext.Provider, { value: useMemo(() => ({
46
+ shikiOptions,
47
+ mediaAdapters: {
48
+ ...defaultAdapters,
49
+ ...mediaAdapters,
50
+ },
51
+ servers,
52
+ }), [mediaAdapters, servers, shikiOptions]), children: _jsx(ServerSelectContext.Provider, { value: useMemo(() => ({
45
53
  server,
46
54
  setServerVariables(variables) {
47
55
  setServer((prev) => {
@@ -53,7 +61,7 @@ export function ApiProvider({ defaultBaseUrl, children, ...props }) {
53
61
  });
54
62
  },
55
63
  setServer(value) {
56
- const obj = props.servers.find((item) => item.url === value);
64
+ const obj = servers.find((item) => item.url === value);
57
65
  if (!obj)
58
66
  return;
59
67
  const result = {
@@ -63,7 +71,7 @@ export function ApiProvider({ defaultBaseUrl, children, ...props }) {
63
71
  localStorage.setItem('apiBaseUrl', JSON.stringify(result));
64
72
  setServer(result);
65
73
  },
66
- }), [server, props.servers]), children: children }) }));
74
+ }), [server, servers]), children: children }) }));
67
75
  }
68
76
  function getDefaultValues(server) {
69
77
  return Object.fromEntries(Object.entries(server.variables ?? {}).map(([k, v]) => [k, v.default]));
@@ -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,2CAqDA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,kDAqC5C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY,2CAoB1D;AAgBD,wBAAgB,cAAc;IAUxB;;OAEG;;IAEH;;OAEG;qBArKS,WAAW,KAAK,IAAI;EA0KrC"}
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,2CAqDA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,kDAwC5C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY,2CAoB1D;AAgBD,wBAAgB,cAAc;IAUxB;;OAEG;;IAEH;;OAEG;qBAxKS,WAAW,KAAK,IAAI;EA6KrC"}
@@ -48,7 +48,7 @@ export function CodeExampleProvider({ route, examples, initialKey, children, })
48
48
  }), [addListener, examples, key, removeListener, route, setData, updateKey]), children: children }));
49
49
  }
50
50
  export function CodeExample(props) {
51
- const { shikiOptions } = useApiContext();
51
+ const { shikiOptions, mediaAdapters } = useApiContext();
52
52
  const { examples, key, route, addListener, removeListener } = useContext(CodeExampleContext);
53
53
  const { server } = useServerSelectContext();
54
54
  const [data, setData] = useState(() => {
@@ -69,8 +69,10 @@ export function CodeExample(props) {
69
69
  return;
70
70
  if (typeof sample.source === 'string')
71
71
  return sample.source;
72
- return sample.source(`${server ? getUrl(server.url, server.variables) : '/'}${route}`, data);
73
- }, [sample, server, route, data]);
72
+ return sample.source(`${server ? getUrl(server.url, server.variables) : '/'}${route}`, data, {
73
+ mediaAdapters,
74
+ });
75
+ }, [mediaAdapters, sample, server, route, data]);
74
76
  if (!code || !sample)
75
77
  return null;
76
78
  return (_jsx(DynamicCodeBlock, { lang: sample.lang, code: code, options: shikiOptions }));
@@ -1,6 +1,6 @@
1
1
  import { type HTMLAttributes, type ReactNode } from 'react';
2
2
  import type { PropertyProps, RootProps } from '../render/renderer.js';
3
- export declare function Root({ children, baseUrl, className, shikiOptions, servers, ...props }: RootProps & HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Root({ children, className, ctx, ...props }: RootProps & HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
4
4
  export declare function APIInfo({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
5
5
  export declare function API({ children, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
6
6
  export declare function Property({ name, type, required, deprecated, children, }: PropertyProps): import("react/jsx-runtime").JSX.Element;
@@ -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,aA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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,QAAQ,GACT,EAAE,aAAa,2CAsBf;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
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Badge } from '../ui/components/method-label.js';
3
3
  import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
4
4
  import { ChevronDown } from '../icons.js';
5
- import { ApiProvider } from '../ui/contexts/api.js';
5
+ 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
- export function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
9
- return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className), ...props, children: _jsx(ApiProvider, { servers: servers, shikiOptions: shikiOptions, defaultBaseUrl: baseUrl, children: children }) }));
8
+ export function Root({ children, className, ctx, ...props }) {
9
+ return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className), ...props, children: _jsx(ApiProvider, { mediaAdapters: Object.fromEntries(Object.entries(ctx.mediaAdapters).filter(([_, v]) => typeof v !== 'boolean')), servers: ctx.servers, shikiOptions: ctx.shikiOptions, defaultBaseUrl: ctx.baseUrl, 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 }));
@@ -0,0 +1,14 @@
1
+ export declare const CodeExampleProvider: import("react").ComponentType<{
2
+ route: string;
3
+ examples: {
4
+ key: string;
5
+ data: import("../requests/_shared.js").RequestData;
6
+ }[];
7
+ initialKey?: string;
8
+ children: React.ReactNode;
9
+ }>;
10
+ export declare const CodeExample: import("react").ComponentType<import("../render/operation/index.js").CodeSample>;
11
+ export declare const CodeExampleSelector: import("react").ComponentType<import("../render/renderer.js").SamplesProps>;
12
+ export declare const ClientLazy: import("react").ComponentType<import("../playground/client.js").ClientProps>;
13
+ export declare const ApiProvider: import("react").ComponentType<import("./contexts/api.js").ApiProviderProps>;
14
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/ui/lazy.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB;;;;;;;;EAE/B,CAAC;AACF,eAAO,MAAM,WAAW,yEAEvB,CAAC;AACF,eAAO,MAAM,mBAAmB,0EAE/B,CAAC;AAEF,eAAO,MAAM,UAAU,0EAA+C,CAAC;AAEvE,eAAO,MAAM,WAAW,0EAEvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import dynamic from 'next/dynamic';
3
+ export const CodeExampleProvider = dynamic(() => import('./contexts/code-example.js').then((mod) => mod.CodeExampleProvider));
4
+ export const CodeExample = dynamic(() => import('./contexts/code-example.js').then((mod) => mod.CodeExample));
5
+ export const CodeExampleSelector = dynamic(() => import('./contexts/code-example.js').then((mod) => mod.CodeExampleSelector));
6
+ export const ClientLazy = dynamic(() => import('../playground/client.js'));
7
+ export const ApiProvider = dynamic(() => import('./contexts/api.js').then((mod) => mod.ApiProvider));
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Convert input value to hardcoded string (with quotes)
3
3
  */
4
- export declare function inputToString(value: unknown, format?: 'xml' | 'json' | 'url', multiLine?: 'single-quote' | 'backtick' | 'python' | 'none'): string;
4
+ export declare function inputToString(value: unknown, format?: 'xml' | 'json' | 'url' | 'ndjson', multiLine?: 'single-quote' | 'backtick' | 'python' | 'none'): string;
5
5
  //# sourceMappingURL=input-to-string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/input-to-string.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAc,EACvC,SAAS,GAAE,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAe,GAClE,MAAM,CAiCR"}
1
+ {"version":3,"file":"input-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/input-to-string.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAiB,EAClD,SAAS,GAAE,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAe,GAClE,MAAM,CAyCR"}
@@ -1,4 +1,5 @@
1
- import { js2xml } from 'xml-js';
1
+ // @ts-expect-error -- nothing
2
+ import js2xml from 'xml-js/lib/js2xml';
2
3
  /**
3
4
  * Convert input value to hardcoded string (with quotes)
4
5
  */
@@ -14,6 +15,11 @@ export function inputToString(value, format = 'json', multiLine = 'none') {
14
15
  if (format === 'json') {
15
16
  return getStr(JSON.stringify(value, null, 2));
16
17
  }
18
+ if (format === 'ndjson') {
19
+ return getStr(Array.isArray(value)
20
+ ? value.map((v) => JSON.stringify(v)).join('\n')
21
+ : JSON.stringify(value, null, 2));
22
+ }
17
23
  if (format === 'url') {
18
24
  const params = new URLSearchParams();
19
25
  if (typeof value !== 'object')