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.
- package/dist/media/adapter.d.ts +62 -0
- package/dist/media/adapter.d.ts.map +1 -0
- package/dist/media/adapter.js +126 -0
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +6 -3
- package/dist/playground/fetcher.d.ts +3 -6
- package/dist/playground/fetcher.d.ts.map +1 -1
- package/dist/playground/fetcher.js +17 -52
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +1 -3
- package/dist/playground/inputs.d.ts.map +1 -1
- package/dist/playground/inputs.js +1 -1
- package/dist/render/api-page.d.ts +1 -1
- package/dist/render/api-page.d.ts.map +1 -1
- package/dist/render/api-page.js +17 -6
- package/dist/render/operation/api-example.d.ts.map +1 -1
- package/dist/render/operation/api-example.js +1 -1
- package/dist/render/operation/index.d.ts +2 -2
- package/dist/render/operation/index.d.ts.map +1 -1
- package/dist/render/operation/index.js +1 -3
- package/dist/render/renderer.d.ts +3 -5
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +4 -4
- package/dist/requests/_shared.d.ts +5 -7
- package/dist/requests/_shared.d.ts.map +1 -1
- package/dist/requests/_shared.js +0 -11
- package/dist/requests/curl.d.ts +2 -2
- package/dist/requests/curl.d.ts.map +1 -1
- package/dist/requests/curl.js +16 -9
- package/dist/requests/go.d.ts +2 -2
- package/dist/requests/go.d.ts.map +1 -1
- package/dist/requests/go.js +13 -21
- package/dist/requests/index.js +4 -4
- package/dist/requests/javascript.d.ts +2 -2
- package/dist/requests/javascript.d.ts.map +1 -1
- package/dist/requests/javascript.js +20 -27
- package/dist/requests/python.d.ts +2 -2
- package/dist/requests/python.d.ts.map +1 -1
- package/dist/requests/python.js +18 -27
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/client.d.ts +0 -1
- package/dist/ui/client.d.ts.map +1 -1
- package/dist/ui/client.js +0 -1
- package/dist/ui/contexts/api.d.ts +8 -5
- package/dist/ui/contexts/api.d.ts.map +1 -1
- package/dist/ui/contexts/api.js +16 -8
- package/dist/ui/contexts/code-example.d.ts.map +1 -1
- package/dist/ui/contexts/code-example.js +5 -3
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/lazy.d.ts +14 -0
- package/dist/ui/lazy.d.ts.map +1 -0
- package/dist/ui/lazy.js +7 -0
- package/dist/utils/input-to-string.d.ts +1 -1
- package/dist/utils/input-to-string.d.ts.map +1 -1
- package/dist/utils/input-to-string.js +7 -1
- package/package.json +6 -6
- package/dist/playground/client.lazy.d.ts +0 -2
- package/dist/playground/client.lazy.d.ts.map +0 -1
- package/dist/playground/client.lazy.js +0 -3
- package/dist/ui/contexts/code-example.lazy.d.ts +0 -12
- package/dist/ui/contexts/code-example.lazy.d.ts.map +0 -1
- package/dist/ui/contexts/code-example.lazy.js +0 -5
package/dist/requests/_shared.js
CHANGED
|
@@ -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
|
}
|
package/dist/requests/curl.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare
|
|
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,
|
|
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"}
|
package/dist/requests/curl.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { inputToString } from '../utils/input-to-string.js';
|
|
3
|
-
import { getUrl, ident
|
|
4
|
-
|
|
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 (
|
|
17
|
-
|
|
18
|
-
|
|
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 &&
|
|
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
|
+
};
|
package/dist/requests/go.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
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":"
|
|
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"}
|
package/dist/requests/go.js
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
14
|
+
let body;
|
|
15
|
+
if (data.body && data.bodyMediaType && data.bodyMediaType in mediaAdapters) {
|
|
18
16
|
headers.set('Content-Type', `"${data.bodyMediaType}"`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
43
|
-
req, _ := http.NewRequest("${data.method}", url, ${
|
|
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
|
+
};
|
package/dist/requests/index.js
CHANGED
|
@@ -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.
|
|
8
|
+
source: CURL.generator,
|
|
9
9
|
lang: 'bash',
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
label: 'JavaScript',
|
|
13
|
-
source: JS.
|
|
13
|
+
source: JS.generator,
|
|
14
14
|
lang: 'js',
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
label: 'Go',
|
|
18
|
-
source: Go.
|
|
18
|
+
source: Go.generator,
|
|
19
19
|
lang: 'go',
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
label: 'Python',
|
|
23
|
-
source: Python.
|
|
23
|
+
source: Python.generator,
|
|
24
24
|
lang: 'python',
|
|
25
25
|
},
|
|
26
26
|
];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare
|
|
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":"
|
|
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
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
options.set('body',
|
|
24
|
+
if (body) {
|
|
25
|
+
s.push(body);
|
|
26
|
+
options.set('body', 'body');
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
export declare
|
|
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":"
|
|
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"}
|
package/dist/requests/python.js
CHANGED
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
20
|
+
params.push(`headers = ${JSON.stringify(headers, null, 2)}`);
|
|
23
21
|
}
|
|
24
22
|
if (Object.keys(data.cookie).length > 0) {
|
|
25
|
-
|
|
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
|
-
${
|
|
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
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
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,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AACrC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC;AACvE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;AACjD,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;AACvC,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,QAAQ,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,EAAE,CAAC;IAExB,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,iBAAiB,CAAC;IAE1B;;;;;;;OAOG;IACH,wBAAwB,CAAC,EACrB,CAAC,CACC,MAAM,EAAE,WAAW,CAAC,iBAAiB,CAAC,EACtC,UAAU,EAAE,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"}
|
package/dist/ui/client.d.ts
CHANGED
package/dist/ui/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAOA,
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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;
|
|
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;AAC3D,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAErE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,UAAU,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"}
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
const
|
|
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,
|
|
19
|
+
export function ApiProvider({ defaultBaseUrl, children, servers, mediaAdapters, shikiOptions, }) {
|
|
19
20
|
const [server, setServer] = useState(() => {
|
|
20
21
|
const defaultItem = defaultBaseUrl
|
|
21
|
-
?
|
|
22
|
-
:
|
|
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:
|
|
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 =
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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 }));
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -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,
|
|
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;
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAYlE,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,SAAS,EACT,GAAG,EACH,GAAG,KAAK,EACT,EAAE,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,2CAyB5C;AAED,wBAAgB,OAAO,CAAC,EACtB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,cAAc,CAAC,2CAMhC;AAED,wBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC,2CAmBzE;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,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/
|
|
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,
|
|
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"}
|
package/dist/ui/lazy.js
ADDED
|
@@ -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":"
|
|
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
|
-
|
|
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')
|