fumadocs-openapi 10.0.11 → 10.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.
- package/dist/generate-file.d.ts +6 -5
- package/dist/generate-file.d.ts.map +1 -1
- package/dist/generate-file.js +44 -37
- package/dist/playground/client.d.ts +9 -7
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +7 -7
- package/dist/playground/components/inputs.d.ts +6 -6
- package/dist/playground/components/inputs.d.ts.map +1 -1
- package/dist/playground/components/inputs.js +13 -12
- package/dist/playground/get-default-values.d.ts +2 -2
- package/dist/playground/get-default-values.d.ts.map +1 -1
- package/dist/playground/index.d.ts +1 -2
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +2 -0
- package/dist/playground/schema.d.ts +22 -8
- package/dist/playground/schema.d.ts.map +1 -1
- package/dist/playground/schema.js +29 -34
- package/dist/requests/generators/index.d.ts +1 -1
- package/dist/requests/generators/index.d.ts.map +1 -1
- package/dist/server/create.d.ts +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/source-api.d.ts +5 -3
- package/dist/server/source-api.d.ts.map +1 -1
- package/dist/server/source-api.js +13 -7
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/api-page.d.ts +16 -8
- package/dist/ui/api-page.d.ts.map +1 -1
- package/dist/ui/api-page.js +7 -7
- package/dist/ui/client/index.d.ts +2 -2
- package/dist/ui/client/index.d.ts.map +1 -1
- package/dist/ui/operation/index.d.ts +4 -3
- package/dist/ui/operation/index.d.ts.map +1 -1
- package/dist/ui/operation/index.js +37 -20
- package/dist/ui/operation/request-tabs.d.ts +18 -0
- package/dist/ui/operation/request-tabs.d.ts.map +1 -0
- package/dist/ui/operation/request-tabs.js +143 -0
- package/dist/ui/operation/response-tabs.d.ts +32 -0
- package/dist/ui/operation/response-tabs.d.ts.map +1 -0
- package/dist/ui/operation/response-tabs.js +59 -0
- package/dist/ui/operation/usage-tabs/client.d.ts +23 -0
- package/dist/ui/operation/usage-tabs/client.d.ts.map +1 -0
- package/dist/ui/operation/{example-panel → usage-tabs}/client.js +50 -6
- package/dist/ui/operation/usage-tabs/index.d.ts +26 -0
- package/dist/ui/operation/usage-tabs/index.d.ts.map +1 -0
- package/dist/ui/operation/usage-tabs/index.js +52 -0
- package/dist/ui/operation/usage-tabs/lazy.d.ts +4 -0
- package/dist/ui/operation/usage-tabs/lazy.d.ts.map +1 -0
- package/dist/ui/operation/usage-tabs/lazy.js +5 -0
- package/dist/ui/schema/client.d.ts +1 -3
- package/dist/ui/schema/client.d.ts.map +1 -1
- package/dist/ui/schema/client.js +13 -17
- package/dist/ui/schema/index.d.ts +19 -5
- package/dist/ui/schema/index.d.ts.map +1 -1
- package/dist/ui/schema/index.js +69 -29
- package/dist/utils/deep-equal.d.ts +2 -0
- package/dist/utils/deep-equal.d.ts.map +1 -0
- package/dist/utils/deep-equal.js +27 -0
- package/dist/utils/merge-schema.d.ts +7 -0
- package/dist/utils/merge-schema.d.ts.map +1 -0
- package/dist/utils/merge-schema.js +179 -0
- package/dist/utils/pages/to-body.d.ts.map +1 -1
- package/dist/utils/pages/to-body.js +2 -3
- package/dist/utils/pages/to-text.d.ts.map +1 -1
- package/dist/utils/pages/to-text.js +31 -16
- package/dist/utils/schema-to-string.d.ts.map +1 -1
- package/dist/utils/schema-to-string.js +8 -5
- package/dist/utils/use-query.d.ts +1 -0
- package/dist/utils/use-query.d.ts.map +1 -1
- package/dist/utils/use-query.js +5 -0
- package/package.json +8 -8
- package/dist/ui/contexts/operation.d.ts +0 -20
- package/dist/ui/contexts/operation.d.ts.map +0 -1
- package/dist/ui/contexts/operation.js +0 -48
- package/dist/ui/contexts/operation.lazy.d.ts +0 -2
- package/dist/ui/contexts/operation.lazy.d.ts.map +0 -1
- package/dist/ui/contexts/operation.lazy.js +0 -3
- package/dist/ui/operation/example-panel/client.d.ts +0 -4
- package/dist/ui/operation/example-panel/client.d.ts.map +0 -1
- package/dist/ui/operation/example-panel/index.d.ts +0 -58
- package/dist/ui/operation/example-panel/index.d.ts.map +0 -1
- package/dist/ui/operation/example-panel/index.js +0 -140
- package/dist/ui/operation/example-panel/lazy.d.ts +0 -3
- package/dist/ui/operation/example-panel/lazy.d.ts.map +0 -1
- package/dist/ui/operation/example-panel/lazy.js +0 -4
- package/dist/ui/operation/get-request-data.d.ts +0 -4
- package/dist/ui/operation/get-request-data.d.ts.map +0 -1
- package/dist/ui/operation/get-request-data.js +0 -70
- package/dist/utils/combine-schema.d.ts +0 -6
- package/dist/utils/combine-schema.d.ts.map +0 -1
- package/dist/utils/combine-schema.js +0 -51
package/dist/generate-file.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { type PagesToTextOptions } from './utils/pages/to-text.js';
|
|
|
2
2
|
import type { ProcessedDocument } from './utils/process-document.js';
|
|
3
3
|
import type { OpenAPIServer } from './server/index.js';
|
|
4
4
|
import { type SchemaToPagesOptions } from './utils/pages/preset-auto.js';
|
|
5
|
+
import { type OutputEntry } from './utils/pages/builder.js';
|
|
5
6
|
export interface OutputFile {
|
|
6
7
|
path: string;
|
|
7
8
|
content: string;
|
|
8
9
|
}
|
|
9
10
|
interface IndexConfig {
|
|
10
|
-
items: IndexItem[] | ((ctx:
|
|
11
|
+
items: IndexItem[] | ((ctx: BeforeWriteContext) => IndexItem[]);
|
|
11
12
|
/**
|
|
12
13
|
* Generate URLs for cards
|
|
13
14
|
*/
|
|
@@ -28,7 +29,7 @@ interface IndexItem {
|
|
|
28
29
|
* - items in `inputs` to include all generated pages of a specific schema.
|
|
29
30
|
* - specific Markdown/MDX files.
|
|
30
31
|
*/
|
|
31
|
-
only?:
|
|
32
|
+
only?: string[];
|
|
32
33
|
}
|
|
33
34
|
interface GenerateFilesConfig extends PagesToTextOptions {
|
|
34
35
|
/**
|
|
@@ -46,12 +47,12 @@ interface GenerateFilesConfig extends PagesToTextOptions {
|
|
|
46
47
|
/**
|
|
47
48
|
* Can add/change/remove output files before writing to file system
|
|
48
49
|
**/
|
|
49
|
-
beforeWrite?: (this:
|
|
50
|
+
beforeWrite?: (this: BeforeWriteContext, files: OutputFile[]) => void | Promise<void>;
|
|
50
51
|
}
|
|
51
52
|
export type Config = SchemaToPagesOptions & GenerateFilesConfig;
|
|
52
|
-
interface
|
|
53
|
-
files: OutputFile[];
|
|
53
|
+
interface BeforeWriteContext {
|
|
54
54
|
readonly generated: Record<string, OutputFile[]>;
|
|
55
|
+
readonly generatedEntries: Record<string, OutputEntry[]>;
|
|
55
56
|
readonly documents: Record<string, ProcessedDocument>;
|
|
56
57
|
}
|
|
57
58
|
export declare function generateFiles(options: Config): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,WAAW;IACnB,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,EAA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,EAAE,CAAC,CAwCvB"}
|
package/dist/generate-file.js
CHANGED
|
@@ -2,7 +2,6 @@ import { mkdir, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { generateDocument, toText, } from './utils/pages/to-text.js';
|
|
4
4
|
import { createGetUrl, getSlugs } from 'fumadocs-core/source';
|
|
5
|
-
import matter from 'gray-matter';
|
|
6
5
|
import { createAutoPreset, } from './utils/pages/preset-auto.js';
|
|
7
6
|
import { fromSchema } from './utils/pages/builder.js';
|
|
8
7
|
export async function generateFiles(options) {
|
|
@@ -16,36 +15,42 @@ export async function generateFiles(options) {
|
|
|
16
15
|
}));
|
|
17
16
|
}
|
|
18
17
|
export async function generateFilesOnly(options) {
|
|
19
|
-
const { beforeWrite } = options;
|
|
20
18
|
const schemas = await options.input.getSchemas();
|
|
21
|
-
const generated = {};
|
|
22
19
|
const files = [];
|
|
20
|
+
const generated = {};
|
|
21
|
+
const generatedEntries = {};
|
|
23
22
|
const entries = Object.entries(schemas);
|
|
24
23
|
if (entries.length === 0) {
|
|
25
24
|
throw new Error('No input files found.');
|
|
26
25
|
}
|
|
27
26
|
const preset = createAutoPreset(options);
|
|
28
27
|
for (const [id, schema] of entries) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const entries = fromSchema(id, schema, preset);
|
|
29
|
+
const schemaFiles = (generated[id] ?? (generated[id] = []));
|
|
30
|
+
generatedEntries[id] = entries;
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
const file = {
|
|
33
|
+
path: entry.path,
|
|
34
|
+
content: toText(entry, schema, options),
|
|
35
|
+
};
|
|
36
|
+
schemaFiles.push(file);
|
|
37
|
+
files.push(file);
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
const context = {
|
|
37
|
-
files,
|
|
38
41
|
generated,
|
|
42
|
+
generatedEntries,
|
|
39
43
|
documents: schemas,
|
|
40
44
|
};
|
|
41
45
|
if (options.index) {
|
|
42
|
-
writeIndexFiles(
|
|
46
|
+
writeIndexFiles(files, context, options);
|
|
43
47
|
}
|
|
44
|
-
await beforeWrite?.call(context,
|
|
45
|
-
return
|
|
48
|
+
await options.beforeWrite?.call(context, files);
|
|
49
|
+
return files;
|
|
46
50
|
}
|
|
47
|
-
function writeIndexFiles(context, options
|
|
48
|
-
const {
|
|
51
|
+
function writeIndexFiles(files, context, options) {
|
|
52
|
+
const { generatedEntries } = context;
|
|
53
|
+
const { items, url } = options.index;
|
|
49
54
|
let urlFn;
|
|
50
55
|
if (typeof url === 'object') {
|
|
51
56
|
const getUrl = createGetUrl(url.baseUrl);
|
|
@@ -54,44 +59,46 @@ function writeIndexFiles(context, options, generateOptions) {
|
|
|
54
59
|
else {
|
|
55
60
|
urlFn = url;
|
|
56
61
|
}
|
|
62
|
+
function findEntryByPath(path) {
|
|
63
|
+
for (const entries of Object.values(generatedEntries)) {
|
|
64
|
+
const match = entries.find((entry) => entry.path === path);
|
|
65
|
+
if (match)
|
|
66
|
+
return match;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
57
69
|
function fileContent(index) {
|
|
58
|
-
const generatedPages = context.generated;
|
|
59
70
|
const content = [];
|
|
60
71
|
content.push('<Cards>');
|
|
61
|
-
const
|
|
72
|
+
const pathToEntry = new Map();
|
|
62
73
|
const only = index.only ?? Object.keys(context.generated);
|
|
63
74
|
for (const item of only) {
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
if (generatedEntries[item]) {
|
|
76
|
+
for (const entry of generatedEntries[item]) {
|
|
77
|
+
pathToEntry.set(entry.path, entry);
|
|
78
|
+
}
|
|
67
79
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
else {
|
|
81
|
+
const match = findEntryByPath(item);
|
|
82
|
+
if (!match) {
|
|
83
|
+
throw new Error(`${item} does not exist on "input", available: ${Object.keys(generatedEntries).join(', ')}.`);
|
|
84
|
+
}
|
|
85
|
+
pathToEntry.set(match.path, match);
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
|
-
for (const file of
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
continue;
|
|
79
|
-
const { data } = matter(file.content);
|
|
80
|
-
if (typeof data.title !== 'string')
|
|
81
|
-
continue;
|
|
82
|
-
const descriptionAttr = data.description
|
|
83
|
-
? `description=${JSON.stringify(data.description)} `
|
|
88
|
+
for (const file of pathToEntry.values()) {
|
|
89
|
+
const descriptionAttr = file.info.description
|
|
90
|
+
? `description=${JSON.stringify(file.info.description)} `
|
|
84
91
|
: '';
|
|
85
|
-
content.push(`<Card href="${urlFn(file.path)}" title=${JSON.stringify(
|
|
92
|
+
content.push(`<Card href="${urlFn(file.path)}" title=${JSON.stringify(file.info.title)} ${descriptionAttr}/>`);
|
|
86
93
|
}
|
|
87
94
|
content.push('</Cards>');
|
|
88
95
|
return generateDocument({
|
|
89
96
|
title: index.title ?? 'Overview',
|
|
90
97
|
description: index.description,
|
|
91
|
-
}, content.join('\n'),
|
|
98
|
+
}, content.join('\n'), options);
|
|
92
99
|
}
|
|
93
100
|
for (const item of typeof items === 'function' ? items(context) : items) {
|
|
94
|
-
|
|
101
|
+
files.push({
|
|
95
102
|
path: path.extname(item.path).length === 0 ? `${item.path}.mdx` : item.path,
|
|
96
103
|
content: fileContent(item),
|
|
97
104
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type FC, type
|
|
1
|
+
import { type FC, type ReactNode, type ComponentProps } from 'react';
|
|
2
2
|
import type { FieldPath, UseControllerProps, UseControllerReturn } from 'react-hook-form';
|
|
3
3
|
import type { FetchResult } from '../playground/fetcher.js';
|
|
4
|
-
import type { ParameterField,
|
|
4
|
+
import type { ParameterField, SecurityEntry } from '../playground/index.js';
|
|
5
|
+
import { SchemaScope } from '../playground/schema.js';
|
|
6
|
+
import type { ParsedSchema } from '../utils/schema.js';
|
|
5
7
|
import type { RequestData } from '../requests/types.js';
|
|
6
8
|
export interface FormValues {
|
|
7
9
|
path: Record<string, unknown>;
|
|
@@ -14,19 +16,19 @@ export interface FormValues {
|
|
|
14
16
|
*/
|
|
15
17
|
_encoded?: RequestData;
|
|
16
18
|
}
|
|
17
|
-
export interface PlaygroundClientProps extends
|
|
19
|
+
export interface PlaygroundClientProps extends ComponentProps<'form'>, SchemaScope {
|
|
18
20
|
route: string;
|
|
19
21
|
method: string;
|
|
20
22
|
parameters?: ParameterField[];
|
|
21
23
|
securities: SecurityEntry[][];
|
|
22
24
|
body?: {
|
|
23
|
-
schema:
|
|
25
|
+
schema: ParsedSchema;
|
|
24
26
|
mediaType: string;
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
29
|
* Resolver for $ref schemas you've passed
|
|
28
30
|
*/
|
|
29
|
-
references: Record<string,
|
|
31
|
+
references: Record<string, ParsedSchema>;
|
|
30
32
|
proxyUrl?: string;
|
|
31
33
|
}
|
|
32
34
|
export interface PlaygroundClientOptions {
|
|
@@ -59,11 +61,11 @@ export interface PlaygroundClientOptions {
|
|
|
59
61
|
* @see renderParameterField for customisation tips
|
|
60
62
|
*/
|
|
61
63
|
renderBodyField?: (fieldName: 'body', info: {
|
|
62
|
-
schema:
|
|
64
|
+
schema: ParsedSchema;
|
|
63
65
|
mediaType: string;
|
|
64
66
|
}) => ReactNode;
|
|
65
67
|
}
|
|
66
|
-
export default function PlaygroundClient({ route, method, securities, parameters, body, references, proxyUrl, ...rest }: PlaygroundClientProps): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
export default function PlaygroundClient({ route, method, securities, parameters, body, references, proxyUrl, writeOnly, readOnly, ...rest }: PlaygroundClientProps): import("react/jsx-runtime").JSX.Element;
|
|
67
69
|
export interface AuthField {
|
|
68
70
|
fieldName: string;
|
|
69
71
|
defaultValue: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/playground/client.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kBAAkB,sBAEX,kBAAkB,CAAC,UAAU,EAAE,KAAK,EAAE,kBAAkB,CAAC,GAC/D,mBAAmB,CAAC,UAAU,EAAE,KAAK,CAAC;CAG1C,CAAC"}
|
|
@@ -10,24 +10,24 @@ import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
|
|
10
10
|
import { MethodLabel } from '../ui/components/method-label.js';
|
|
11
11
|
import { useQuery } from '../utils/use-query.js';
|
|
12
12
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
|
|
13
|
-
import { ChevronDown, LoaderCircle } from '../icons.js';
|
|
13
|
+
import { X, ChevronDown, LoaderCircle } from '../icons.js';
|
|
14
14
|
import { encodeRequestData } from '../requests/media/encode.js';
|
|
15
15
|
import { buttonVariants } from 'fumadocs-ui/components/ui/button';
|
|
16
16
|
import { cn } from 'fumadocs-ui/utils/cn';
|
|
17
17
|
import { SchemaProvider, useResolvedSchema, } from '../playground/schema.js';
|
|
18
|
-
import { useOperationContext } from '../ui/contexts/operation.js';
|
|
19
18
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
|
|
20
19
|
import { labelVariants } from '../ui/components/input.js';
|
|
21
20
|
import ServerSelect from './components/server-select.js';
|
|
22
21
|
import { useStorageKey } from '../ui/client/storage-key.js';
|
|
22
|
+
import { useExampleRequests } from '../ui/operation/usage-tabs/client.js';
|
|
23
23
|
const OauthDialog = lazy(() => import('./components/oauth-dialog.js').then((mod) => ({
|
|
24
24
|
default: mod.OauthDialog,
|
|
25
25
|
})));
|
|
26
26
|
const OauthDialogTrigger = lazy(() => import('./components/oauth-dialog.js').then((mod) => ({
|
|
27
27
|
default: mod.OauthDialogTrigger,
|
|
28
28
|
})));
|
|
29
|
-
export default function PlaygroundClient({ route, method = 'GET', securities, parameters = [], body, references, proxyUrl, ...rest }) {
|
|
30
|
-
const { example: exampleId, examples, setExampleData
|
|
29
|
+
export default function PlaygroundClient({ route, method = 'GET', securities, parameters = [], body, references, proxyUrl, writeOnly, readOnly, ...rest }) {
|
|
30
|
+
const { example: exampleId, examples, setExampleData } = useExampleRequests();
|
|
31
31
|
const storageKeys = useStorageKey();
|
|
32
32
|
const fieldInfoMap = useMemo(() => new Map(), []);
|
|
33
33
|
const { mediaAdapters, serverRef, client: { playground: { components: { ResultDisplay = DefaultResultDisplay } = {}, requestTimeout = 10, transformAuthInputs, } = {}, }, } = useApiContext();
|
|
@@ -109,7 +109,7 @@ export default function PlaygroundClient({ route, method = 'GET', securities, pa
|
|
|
109
109
|
const onSubmit = form.handleSubmit((value) => {
|
|
110
110
|
testQuery.start(mapInputs(value));
|
|
111
111
|
});
|
|
112
|
-
return (_jsx(FormProvider, { ...form, children: _jsx(SchemaProvider, { fieldInfoMap: fieldInfoMap, references: references, children: _jsxs("form", { ...rest, className: cn('not-prose flex flex-col rounded-xl border shadow-md overflow-hidden bg-fd-card text-fd-card-foreground', rest.className), onSubmit: onSubmit, children: [_jsx(ServerSelect, {}), _jsxs("div", { className: "flex flex-row items-center gap-2 text-sm p-3 not-last:pb-0", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), 'w-14 py-1.5'), disabled: testQuery.isLoading, children: testQuery.isLoading ? (_jsx(LoaderCircle, { className: "size-4 animate-spin" })) : ('Send') })] }), securities.length > 0 && (_jsx(SecurityTabs, { securities: securities, securityId: securityId, setSecurityId: setSecurityId, children: inputs.map((input) => (_jsx(Fragment, { children: input.children }, input.fieldName))) })), _jsx(FormBody, { body: body, parameters: parameters }), testQuery.data ? _jsx(ResultDisplay, { data: testQuery.data }) : null] }) }) }));
|
|
112
|
+
return (_jsx(FormProvider, { ...form, children: _jsx(SchemaProvider, { fieldInfoMap: fieldInfoMap, references: references, writeOnly: writeOnly, readOnly: readOnly, children: _jsxs("form", { ...rest, className: cn('not-prose flex flex-col rounded-xl border shadow-md overflow-hidden bg-fd-card text-fd-card-foreground', rest.className), onSubmit: onSubmit, children: [_jsx(ServerSelect, {}), _jsxs("div", { className: "flex flex-row items-center gap-2 text-sm p-3 not-last:pb-0", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), 'w-14 py-1.5'), disabled: testQuery.isLoading, children: testQuery.isLoading ? (_jsx(LoaderCircle, { className: "size-4 animate-spin" })) : ('Send') })] }), securities.length > 0 && (_jsx(SecurityTabs, { securities: securities, securityId: securityId, setSecurityId: setSecurityId, children: inputs.map((input) => (_jsx(Fragment, { children: input.children }, input.fieldName))) })), _jsx(FormBody, { body: body, parameters: parameters }), testQuery.data ? (_jsx(ResultDisplay, { data: testQuery.data, reset: testQuery.reset })) : null] }) }) }));
|
|
113
113
|
}
|
|
114
114
|
function SecurityTabs({ securities, setSecurityId, securityId, children, }) {
|
|
115
115
|
const [open, setOpen] = useState(false);
|
|
@@ -289,10 +289,10 @@ function useAuthInputs(securities, transform) {
|
|
|
289
289
|
function Route({ route, ...props }) {
|
|
290
290
|
return (_jsx("div", { ...props, className: cn('flex flex-row items-center gap-0.5 overflow-auto text-nowrap', props.className), children: route.split('/').map((part, index) => (_jsxs(Fragment, { children: [index > 0 && _jsx("span", { className: "text-fd-muted-foreground", children: "/" }), part.startsWith('{') && part.endsWith('}') ? (_jsx("code", { className: "bg-fd-primary/10 text-fd-primary", children: part })) : (_jsx("code", { className: "text-fd-foreground", children: part }))] }, index))) }));
|
|
291
291
|
}
|
|
292
|
-
function DefaultResultDisplay({ data }) {
|
|
292
|
+
function DefaultResultDisplay({ data, reset, }) {
|
|
293
293
|
const statusInfo = useMemo(() => getStatusInfo(data.status), [data.status]);
|
|
294
294
|
const { shikiOptions } = useApiContext();
|
|
295
|
-
return (_jsxs("div", { className: "flex flex-col gap-3 p-3", children: [_jsxs("div", { className: "inline-flex items-center gap-1.5 text-sm font-medium text-fd-foreground", children: [_jsx(statusInfo.icon, { className: cn('size-4', statusInfo.color) }), statusInfo.description] }), _jsx("p", { className: "text-sm text-fd-muted-foreground", children: data.status }), data.data !== undefined && (_jsx(DynamicCodeBlock, { lang: typeof data.data === 'string' && data.data.length > 50000
|
|
295
|
+
return (_jsxs("div", { className: "flex flex-col gap-3 p-3", children: [_jsxs("div", { className: "flex justify-between items-center", children: [_jsxs("div", { className: "inline-flex items-center gap-1.5 text-sm font-medium text-fd-foreground", children: [_jsx(statusInfo.icon, { className: cn('size-4', statusInfo.color) }), statusInfo.description] }), _jsx("button", { type: "button", className: cn(buttonVariants({ size: 'icon-xs' }), 'p-0 text-fd-muted-foreground hover:text-fd-accent-foreground [&_svg]:size-3.5'), onClick: () => reset(), "aria-label": "Dismiss response", children: _jsx(X, {}) })] }), _jsx("p", { className: "text-sm text-fd-muted-foreground", children: data.status }), data.data !== undefined && (_jsx(DynamicCodeBlock, { lang: typeof data.data === 'string' && data.data.length > 50000
|
|
296
296
|
? 'text'
|
|
297
297
|
: data.type, code: typeof data.data === 'string'
|
|
298
298
|
? data.data
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { type ComponentProps, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ParsedSchema } from '../../utils/schema.js';
|
|
3
3
|
export declare function ObjectInput({ field: _field, fieldName, ...props }: {
|
|
4
|
-
field: Exclude<
|
|
4
|
+
field: Exclude<ParsedSchema, boolean>;
|
|
5
5
|
fieldName: string;
|
|
6
|
-
} & ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element
|
|
6
|
+
} & ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare function JsonInput({ fieldName }: {
|
|
8
8
|
fieldName: string;
|
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare function FieldInput({ field, fieldName, isRequired, ...props }: HTMLAttributes<HTMLElement> & {
|
|
11
|
-
field: Exclude<
|
|
11
|
+
field: Exclude<ParsedSchema, boolean>;
|
|
12
12
|
isRequired?: boolean;
|
|
13
13
|
fieldName: string;
|
|
14
14
|
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
15
15
|
export declare function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth, slotType, collapsible, ...props }: HTMLAttributes<HTMLElement> & {
|
|
16
16
|
isRequired?: boolean;
|
|
17
17
|
name?: ReactNode;
|
|
18
|
-
field:
|
|
18
|
+
field: ParsedSchema;
|
|
19
19
|
fieldName: string;
|
|
20
20
|
depth?: number;
|
|
21
21
|
slotType?: ReactNode;
|
|
22
22
|
toolbar?: ReactNode;
|
|
23
23
|
collapsible?: boolean;
|
|
24
|
-
}): import("react/jsx-runtime").JSX.Element |
|
|
24
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
25
25
|
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/playground/components/inputs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/playground/components/inputs.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAqBf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuCnD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EAAE,MAAM,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IACD,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,KAAK,CAAC,2CAsCxB;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,2CA8B7D;AA6FD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,UAAU,EACV,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,uDA2GA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EAAE,MAAM,EACb,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,KAAS,EACT,QAAQ,EACR,WAAkB,EAClB,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,uDAuLA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useState, } from 'react';
|
|
4
4
|
import { ChevronDown, Plus, Trash2, X } from '../../icons.js';
|
|
5
5
|
import { useController, useFieldArray, useFormContext } from 'react-hook-form';
|
|
6
6
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
|
|
@@ -8,9 +8,8 @@ import { Input, labelVariants } from '../../ui/components/input.js';
|
|
|
8
8
|
import { getDefaultValue } from '../get-default-values.js';
|
|
9
9
|
import { cn } from 'fumadocs-ui/utils/cn';
|
|
10
10
|
import { buttonVariants } from 'fumadocs-ui/components/ui/button';
|
|
11
|
-
import { combineSchema } from '../../utils/combine-schema.js';
|
|
12
11
|
import { FormatFlags, schemaToString } from '../../utils/schema-to-string.js';
|
|
13
|
-
import { anyFields, useFieldInfo, useResolvedSchema, } from '../../playground/schema.js';
|
|
12
|
+
import { anyFields, useFieldInfo, useResolvedSchema, useSchemaScope, } from '../../playground/schema.js';
|
|
14
13
|
function FieldLabel(props) {
|
|
15
14
|
return (_jsx("label", { ...props, className: cn('w-full inline-flex items-center gap-0.5', props.className), children: props.children }));
|
|
16
15
|
}
|
|
@@ -21,10 +20,7 @@ function FieldLabelType(props) {
|
|
|
21
20
|
return (_jsx("code", { ...props, className: cn('text-xs text-fd-muted-foreground', props.className), children: props.children }));
|
|
22
21
|
}
|
|
23
22
|
export function ObjectInput({ field: _field, fieldName, ...props }) {
|
|
24
|
-
const
|
|
25
|
-
const field = useMemo(() => combineSchema([resolved]), [resolved]);
|
|
26
|
-
if (typeof field === 'boolean')
|
|
27
|
-
return;
|
|
23
|
+
const field = useResolvedSchema(_field);
|
|
28
24
|
return (_jsxs("div", { ...props, className: cn('grid grid-cols-1 gap-4 @md:grid-cols-2', props.className), children: [Object.entries(field.properties ?? {}).map(([key, child]) => (_jsx(FieldSet, { name: key, field: child, fieldName: `${fieldName}.${key}`, isRequired: field.required?.includes(key) }, key))), (field.additionalProperties || field.patternProperties) && (_jsx(DynamicProperties, { fieldName: fieldName, filterKey: (v) => !field.properties || !Object.keys(field.properties).includes(v), getType: (key) => {
|
|
29
25
|
for (const pattern in field.patternProperties) {
|
|
30
26
|
if (key.match(RegExp(pattern))) {
|
|
@@ -129,11 +125,16 @@ export function FieldInput({ field, fieldName, isRequired, ...props }) {
|
|
|
129
125
|
onClick: () => form.resetField(fieldName), className: "text-fd-muted-foreground", children: _jsx(X, { className: "size-4" }) }))] }));
|
|
130
126
|
}
|
|
131
127
|
export function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth = 0, slotType, collapsible = true, ...props }) {
|
|
128
|
+
const { readOnly, writeOnly } = useSchemaScope();
|
|
132
129
|
const field = useResolvedSchema(_field);
|
|
133
130
|
const [show, setShow] = useState(!collapsible);
|
|
134
131
|
const { info, updateInfo } = useFieldInfo(fieldName, field, depth);
|
|
135
132
|
if (_field === false)
|
|
136
|
-
return
|
|
133
|
+
return;
|
|
134
|
+
if (field.readOnly && !readOnly)
|
|
135
|
+
return;
|
|
136
|
+
if (field.writeOnly && !writeOnly)
|
|
137
|
+
return;
|
|
137
138
|
if (info.unionField) {
|
|
138
139
|
const union = field[info.unionField];
|
|
139
140
|
const showSelect = union.length > 1;
|
|
@@ -141,7 +142,7 @@ export function FieldSet({ field: _field, fieldName, toolbar, name, isRequired,
|
|
|
141
142
|
updateInfo({
|
|
142
143
|
oneOf: Number(e.target.value),
|
|
143
144
|
});
|
|
144
|
-
}, children: union.map((item, i) => (_jsx("option", { value: i, children: schemaToString(item, undefined, FormatFlags.UseAlias) }, i))) })), toolbar] }) }));
|
|
145
|
+
}, children: union.map((item, i) => (_jsx("option", { value: i, className: "bg-fd-popover text-fd-popover-foreground", children: schemaToString(item, undefined, FormatFlags.UseAlias) }, i))) })), toolbar] }) }));
|
|
145
146
|
}
|
|
146
147
|
if (Array.isArray(field.type)) {
|
|
147
148
|
const showSelect = field.type.length > 1;
|
|
@@ -152,15 +153,15 @@ export function FieldSet({ field: _field, fieldName, toolbar, name, isRequired,
|
|
|
152
153
|
updateInfo({
|
|
153
154
|
selectedType: e.target.value,
|
|
154
155
|
});
|
|
155
|
-
}, children: field.type.map((item) => (_jsx("option", { value: item, children: item }, item))) })), toolbar] }) }));
|
|
156
|
+
}, children: field.type.map((item) => (_jsx("option", { value: item, className: "bg-fd-popover text-fd-popover-foreground", children: item }, item))) })), toolbar] }) }));
|
|
156
157
|
}
|
|
157
158
|
const showBn = collapsible && (_jsx("button", { type: "button", onClick: () => setShow((prev) => !prev), className: cn(buttonVariants({
|
|
158
159
|
size: 'icon-xs',
|
|
159
160
|
color: 'ghost',
|
|
160
161
|
className: 'text-fd-muted-foreground -ms-1',
|
|
161
162
|
})), children: _jsx(ChevronDown, { className: cn(show && 'rotate-180') }) }));
|
|
162
|
-
if (field.type === 'object' ||
|
|
163
|
-
return (_jsxs("fieldset", { ...props, className: cn('flex flex-col gap-1.5 col-span-full @container', props.className), children: [_jsxs(FieldLabel, { htmlFor: fieldName, children: [showBn, _jsx(FieldLabelName, { required: isRequired, children: name }), slotType ?? _jsx(FieldLabelType, { children: schemaToString(field) }), toolbar] }), show && (_jsx(ObjectInput, { field: field, fieldName: fieldName, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-background/50 p-2 shadow-sm', props.className) }))] }));
|
|
163
|
+
if (field.type === 'object' || info.intersection) {
|
|
164
|
+
return (_jsxs("fieldset", { ...props, className: cn('flex flex-col gap-1.5 col-span-full @container', props.className), children: [_jsxs(FieldLabel, { htmlFor: fieldName, children: [showBn, _jsx(FieldLabelName, { required: isRequired, children: name }), slotType ?? _jsx(FieldLabelType, { children: schemaToString(field) }), toolbar] }), show && (_jsx(ObjectInput, { field: info.intersection?.merged ?? field, fieldName: fieldName, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-background/50 p-2 shadow-sm', props.className) }))] }));
|
|
164
165
|
}
|
|
165
166
|
if (field.type === 'array') {
|
|
166
167
|
return (_jsxs("fieldset", { ...props, className: cn('flex flex-col gap-1.5 col-span-full', props.className), children: [_jsxs(FieldLabel, { htmlFor: fieldName, children: [showBn, _jsx(FieldLabelName, { required: isRequired, children: name }), slotType ?? _jsx(FieldLabelType, { children: schemaToString(field) }), toolbar] }), show && (_jsx(ArrayInput, { fieldName: fieldName, items: field.items ?? anyFields, ...props, className: cn('rounded-lg border border-fd-primary/20 bg-fd-background/50 p-2 shadow-sm', props.className) }))] }));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function getDefaultValue(schema:
|
|
1
|
+
import type { ParsedSchema } from '../utils/schema.js';
|
|
2
|
+
export declare function getDefaultValue(schema: ParsedSchema): unknown;
|
|
3
3
|
//# sourceMappingURL=get-default-values.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-default-values.d.ts","sourceRoot":"","sources":["../../src/playground/get-default-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"get-default-values.d.ts","sourceRoot":"","sources":["../../src/playground/get-default-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CA2B7D"}
|
|
@@ -4,7 +4,6 @@ export type ParameterField = NoReference<ParameterObject> & {
|
|
|
4
4
|
schema: ParsedSchema;
|
|
5
5
|
in: 'cookie' | 'header' | 'query' | 'path';
|
|
6
6
|
};
|
|
7
|
-
export type RequestSchema = ParsedSchema;
|
|
8
7
|
export interface APIPlaygroundProps {
|
|
9
8
|
path: string;
|
|
10
9
|
method: MethodInformation;
|
|
@@ -14,5 +13,5 @@ export type SecurityEntry = SecuritySchemeObject & {
|
|
|
14
13
|
scopes: string[];
|
|
15
14
|
id: string;
|
|
16
15
|
};
|
|
17
|
-
export declare function APIPlayground({ path, method, ctx }: APIPlaygroundProps): Promise<string | number | bigint | boolean |
|
|
16
|
+
export declare function APIPlayground({ path, method, ctx }: APIPlaygroundProps): Promise<string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | null | undefined>;
|
|
18
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playground/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG;IAC1D,MAAM,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playground/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG;IAC1D,MAAM,EAAE,YAAY,CAAC;IACrB,EAAE,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CAC5C,CAAC;AAQF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG;IACjD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,kBAAkB,kJAuC5E"}
|
package/dist/playground/index.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Ajv2020 } from 'ajv/dist/2020';
|
|
2
|
-
import type { RequestSchema } from '../playground/index.js';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { ParsedSchema } from '../utils/schema.js';
|
|
4
|
+
interface SchemaContextType extends SchemaScope {
|
|
5
|
+
references: Record<string, ParsedSchema>;
|
|
6
6
|
fieldInfoMap: Map<string, FieldInfo>;
|
|
7
7
|
ajv: Ajv2020;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
export interface SchemaScope {
|
|
10
|
+
/**
|
|
11
|
+
* show write only fields
|
|
12
|
+
*/
|
|
13
|
+
writeOnly: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* show read only fields
|
|
16
|
+
*/
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
}
|
|
19
|
+
type UnionField = 'anyOf' | 'oneOf';
|
|
10
20
|
export interface FieldInfo {
|
|
11
21
|
selectedType?: string;
|
|
12
22
|
oneOf: number;
|
|
@@ -14,15 +24,19 @@ export interface FieldInfo {
|
|
|
14
24
|
* The actual field that represents union members.
|
|
15
25
|
*/
|
|
16
26
|
unionField?: UnionField;
|
|
27
|
+
intersection?: {
|
|
28
|
+
merged: Exclude<ParsedSchema, boolean>;
|
|
29
|
+
};
|
|
17
30
|
}
|
|
18
31
|
export declare const anyFields: {
|
|
19
32
|
type: string[];
|
|
20
33
|
items: true;
|
|
21
34
|
additionalProperties: true;
|
|
22
35
|
};
|
|
23
|
-
export declare function SchemaProvider({ references, fieldInfoMap, children, }: Omit<SchemaContextType, 'ajv'> & {
|
|
36
|
+
export declare function SchemaProvider({ references, fieldInfoMap, readOnly, writeOnly, children, }: Omit<SchemaContextType, 'ajv'> & {
|
|
24
37
|
children: ReactNode;
|
|
25
38
|
}): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function useSchemaScope(): SchemaScope;
|
|
26
40
|
/**
|
|
27
41
|
* A hook to store dynamic info of a field, such as selected schema of `oneOf`.
|
|
28
42
|
*
|
|
@@ -30,14 +44,14 @@ export declare function SchemaProvider({ references, fieldInfoMap, children, }:
|
|
|
30
44
|
* @param schema - The JSON Schema to generate initial values.
|
|
31
45
|
* @param depth - The depth to avoid duplicated field name with same schema (e.g. nested `oneOf`).
|
|
32
46
|
*/
|
|
33
|
-
export declare function useFieldInfo(fieldName: string, schema: Exclude<
|
|
47
|
+
export declare function useFieldInfo(fieldName: string, schema: Exclude<ParsedSchema, boolean>, depth: number): {
|
|
34
48
|
info: FieldInfo;
|
|
35
49
|
updateInfo: (value: Partial<FieldInfo>) => void;
|
|
36
50
|
};
|
|
37
51
|
/**
|
|
38
52
|
* Resolve `$ref` in the schema, **not recursive**.
|
|
39
53
|
*/
|
|
40
|
-
export declare function useResolvedSchema(schema:
|
|
41
|
-
export declare function fallbackAny(schema:
|
|
54
|
+
export declare function useResolvedSchema(schema: ParsedSchema): Exclude<ParsedSchema, boolean>;
|
|
55
|
+
export declare function fallbackAny(schema: ParsedSchema): Exclude<ParsedSchema, boolean>;
|
|
42
56
|
export {};
|
|
43
57
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/playground/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/playground/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAiB,SAAS,EAA0B,MAAM,OAAO,CAAC;AAGzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrC,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IAC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