fumadocs-openapi 8.1.0 → 8.1.1
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.map +1 -1
- package/dist/generate-file.js +3 -9
- package/dist/generate.d.ts +3 -1
- package/dist/generate.d.ts.map +1 -1
- package/dist/render/operation/index.d.ts.map +1 -1
- package/dist/render/operation/index.js +3 -8
- package/dist/render/schema.d.ts +7 -13
- package/dist/render/schema.d.ts.map +1 -1
- package/dist/render/schema.js +14 -19
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,MAAO,SAAQ,eAAe;IAC7C;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,WAAW,CAAC;IAEnC;;OAEG;IACH,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;CACpC;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+HlE"}
|
package/dist/generate-file.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join, parse } from 'node:path';
|
|
3
3
|
import fg from 'fast-glob';
|
|
4
|
-
import { generatePages, } from './generate.js';
|
|
5
|
-
import { generateAll, generateTags } from './generate.js';
|
|
4
|
+
import { generateAll, generatePages, generateTags, } from './generate.js';
|
|
6
5
|
export async function generateFiles(options) {
|
|
7
6
|
const { input, output, name: nameFn, per = 'operation', groupBy = 'none', cwd = process.cwd(), } = options;
|
|
8
7
|
const outputDir = join(cwd, output);
|
|
@@ -29,9 +28,7 @@ export async function generateFiles(options) {
|
|
|
29
28
|
file = getFilename(result.pathItem.summary);
|
|
30
29
|
}
|
|
31
30
|
else if (result.type === 'operation') {
|
|
32
|
-
file = result.
|
|
33
|
-
? getFilename(result.operation.operationId)
|
|
34
|
-
: join(getOutputPathFromRoute(result.item.path), result.item.method.toLowerCase());
|
|
31
|
+
file = join(getOutputPathFromRoute(result.item.path), result.item.method.toLowerCase());
|
|
35
32
|
}
|
|
36
33
|
else {
|
|
37
34
|
file = getFilename(result.item.name);
|
|
@@ -109,10 +106,7 @@ function getOutputPathFromRoute(path) {
|
|
|
109
106
|
.at(-1) ?? '');
|
|
110
107
|
}
|
|
111
108
|
function getFilename(s) {
|
|
112
|
-
return s
|
|
113
|
-
.replace(/[A-Z]/g, (match, idx) => idx === 0 ? match : `-${match.toLowerCase()}`)
|
|
114
|
-
.replace(/\s+/g, '-')
|
|
115
|
-
.toLowerCase();
|
|
109
|
+
return s.replace(/\s+/g, '-').toLowerCase();
|
|
116
110
|
}
|
|
117
111
|
async function write(path, content) {
|
|
118
112
|
await mkdir(dirname(path), { recursive: true });
|
package/dist/generate.d.ts
CHANGED
|
@@ -18,7 +18,9 @@ export interface GenerateOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
frontmatter?: (title: string, description: string | undefined, context: DocumentContext) => Record<string, unknown>;
|
|
20
20
|
/**
|
|
21
|
-
* Add description to document body
|
|
21
|
+
* Add description to document body.
|
|
22
|
+
*
|
|
23
|
+
* We recommend but don't enable it by default because some OpenAPI schemas have invalid description that breaks MDX syntax.
|
|
22
24
|
*
|
|
23
25
|
* @defaultValue false
|
|
24
26
|
*/
|
package/dist/generate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAE/E,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IAEJ;;;;OAIG;IACH,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,eAAe,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7B
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAE/E,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IAEJ;;;;OAIG;IACH,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,eAAe,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAEvC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,kBAAkB,GAC1B;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IACtC,SAAS,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAExC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC;IACtC,SAAS,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAExC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAgBN,wBAAsB,WAAW,CAC/B,cAAc,EAAE,aAAa,EAC7B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED,wBAAsB,aAAa,CACjC,cAAc,EAAE,aAAa,EAC7B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAiE/B;AAED,wBAAsB,YAAY,CAChC,cAAc,EAAE,aAAa,EAC7B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAsC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/operation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAEV,iBAAiB,EAEjB,aAAa,EAEd,MAAM,SAAS,CAAC;AAejB,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,oBAAoB,CAAC;AAK3E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EACH,MAAM,GACN,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,MAAM,GAAG,SAAS,CAAC,GACxD,KAAK,CAAC;CACX;AASD,wBAAgB,SAAS,CAAC,EACxB,IAAkB,EAClB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,YAAgB,GACjB,EAAE;IACD,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;IAEnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/render/operation/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,KAAK,EAEV,iBAAiB,EAEjB,aAAa,EAEd,MAAM,SAAS,CAAC;AAejB,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,oBAAoB,CAAC;AAK3E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EACH,MAAM,GACN,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,MAAM,GAAG,SAAS,CAAC,GACxD,KAAK,CAAC;CACX;AASD,wBAAgB,SAAS,CAAC,EACxB,IAAkB,EAClB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,YAAgB,GACjB,EAAE;IACD,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;IAEnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,YAAY,CAgLf"}
|
|
@@ -37,12 +37,10 @@ export function Operation({ type = 'operation', path, method, ctx, hasHead, head
|
|
|
37
37
|
if (!type ||
|
|
38
38
|
!supportedMediaTypes.includes(String(type)))
|
|
39
39
|
throw new Error(`No supported media type for body content: ${path}, received: ${type}`);
|
|
40
|
-
bodyNode = (_jsxs(_Fragment, { children: [heading(headingLevel, 'Request Body', ctx), _jsxs("div", { className: "mb-8 flex flex-row items-center justify-between gap-2", children: [_jsx("code", { children: type }), _jsx("span", { children: body.required ? 'Required' : 'Optional' })] }), body.description ? _jsx(Markdown, { text: body.description }) : null, _jsx(Schema, { name: "body", schema: body.content[type].schema ?? {}, ctx: {
|
|
40
|
+
bodyNode = (_jsxs(_Fragment, { children: [heading(headingLevel, 'Request Body', ctx), _jsxs("div", { className: "mb-8 flex flex-row items-center justify-between gap-2", children: [_jsx("code", { children: type }), _jsx("span", { children: body.required ? 'Required' : 'Optional' })] }), body.description ? _jsx(Markdown, { text: body.description }) : null, _jsx(Schema, { name: "body", schema: body.content[type].schema ?? {}, required: body.required, ctx: {
|
|
41
41
|
readOnly: method.method === 'GET',
|
|
42
42
|
writeOnly: method.method !== 'GET',
|
|
43
|
-
required: body.required ?? false,
|
|
44
43
|
render: ctx,
|
|
45
|
-
allowFile: type === 'multipart/form-data',
|
|
46
44
|
} })] }));
|
|
47
45
|
}
|
|
48
46
|
if (method.responses && ctx.showResponseSchema !== false) {
|
|
@@ -58,11 +56,9 @@ export function Operation({ type = 'operation', path, method, ctx, hasHead, head
|
|
|
58
56
|
description: param.description ?? param.schema?.description,
|
|
59
57
|
deprecated: (param.deprecated ?? false) ||
|
|
60
58
|
(param.schema?.deprecated ?? false),
|
|
61
|
-
}, ctx: {
|
|
62
|
-
parseObject: false,
|
|
59
|
+
}, parseObject: false, required: param.required, ctx: {
|
|
63
60
|
readOnly: method.method === 'GET',
|
|
64
61
|
writeOnly: method.method !== 'GET',
|
|
65
|
-
required: param.required ?? false,
|
|
66
62
|
render: ctx,
|
|
67
63
|
} }, param.name))) })] }, type));
|
|
68
64
|
});
|
|
@@ -96,11 +92,10 @@ async function ResponseTab({ status, operation, ctx, }) {
|
|
|
96
92
|
else if (generateTypeScriptSchema === undefined && responseOfType?.schema) {
|
|
97
93
|
ts = await getTypescriptSchema(responseOfType?.schema, schema.dereferenceMap);
|
|
98
94
|
}
|
|
99
|
-
return (_jsxs(Tab, { value: status, children: [_jsx(Markdown, { text: description }), responseOfType?.schema && (_jsx(Schema, { name: "response", schema: responseOfType.schema, ctx: {
|
|
95
|
+
return (_jsxs(Tab, { value: status, children: [_jsx(Markdown, { text: description }), responseOfType?.schema && (_jsx(Schema, { name: "response", schema: responseOfType.schema, required: true, ctx: {
|
|
100
96
|
render: ctx,
|
|
101
97
|
writeOnly: false,
|
|
102
98
|
readOnly: true,
|
|
103
|
-
required: true,
|
|
104
99
|
} })), ts && _jsx(CodeBlock, { lang: "ts", code: ts, ctx: ctx, className: "mt-4" })] }));
|
|
105
100
|
}
|
|
106
101
|
function WebhookCallback({ callback, ctx, headingLevel, }) {
|
package/dist/render/schema.d.ts
CHANGED
|
@@ -4,25 +4,19 @@ import type { RenderContext } from '../types.js';
|
|
|
4
4
|
interface Context {
|
|
5
5
|
readOnly: boolean;
|
|
6
6
|
writeOnly: boolean;
|
|
7
|
-
|
|
7
|
+
stack?: ParsedSchema[];
|
|
8
|
+
render: RenderContext;
|
|
9
|
+
}
|
|
10
|
+
export declare function Schema({ name, schema, required, parseObject, ctx, }: {
|
|
11
|
+
name: string;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
schema: NoReference<ParsedSchema>;
|
|
8
14
|
/**
|
|
9
15
|
* Render the full object
|
|
10
16
|
*
|
|
11
17
|
* @defaultValue true
|
|
12
18
|
* */
|
|
13
19
|
parseObject?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Parse binary format string to be files
|
|
16
|
-
*
|
|
17
|
-
* @defaultValue false
|
|
18
|
-
*/
|
|
19
|
-
allowFile?: boolean;
|
|
20
|
-
stack?: ParsedSchema[];
|
|
21
|
-
render: RenderContext;
|
|
22
|
-
}
|
|
23
|
-
export declare function Schema({ name, schema, ctx, }: {
|
|
24
|
-
name: string;
|
|
25
|
-
schema: NoReference<ParsedSchema>;
|
|
26
20
|
ctx: Context;
|
|
27
21
|
}): ReactNode;
|
|
28
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/render/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAc,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAgB7C,UAAU,OAAO;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/render/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAc,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAgB7C,UAAU,OAAO;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IAEvB,MAAM,EAAE,aAAa,CAAC;CACvB;AAUD,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,MAAM,EACN,QAAgB,EAChB,WAAkB,EAClB,GAAG,GACJ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IAElC;;;;SAIK;IACL,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,GAAG,EAAE,OAAO,CAAC;CACd,GAAG,SAAS,CAmKZ"}
|
package/dist/render/schema.js
CHANGED
|
@@ -16,13 +16,11 @@ function isObject(schema) {
|
|
|
16
16
|
schema.properties !== undefined ||
|
|
17
17
|
schema.additionalProperties !== undefined);
|
|
18
18
|
}
|
|
19
|
-
export function Schema({ name, schema, ctx, }) {
|
|
19
|
+
export function Schema({ name, schema, required = false, parseObject = true, ctx, }) {
|
|
20
20
|
if ((schema.readOnly === true && !ctx.readOnly) ||
|
|
21
21
|
(schema.writeOnly === true && !ctx.writeOnly))
|
|
22
22
|
return null;
|
|
23
|
-
const
|
|
24
|
-
const stack = ctx.stack ?? [];
|
|
25
|
-
const { renderer } = ctx.render;
|
|
23
|
+
const { render: { renderer }, stack = [], } = ctx;
|
|
26
24
|
// object type
|
|
27
25
|
if (isObject(schema) &&
|
|
28
26
|
parseObject &&
|
|
@@ -34,25 +32,26 @@ export function Schema({ name, schema, ctx, }) {
|
|
|
34
32
|
footer = _jsx(renderer.Property, { name: "[key: string]", type: "any" });
|
|
35
33
|
}
|
|
36
34
|
else if (additionalProperties) {
|
|
37
|
-
footer = (_jsx(Schema, { name: "[key: string]", schema: additionalProperties, ctx: {
|
|
35
|
+
footer = (_jsx(Schema, { name: "[key: string]", schema: additionalProperties, parseObject: false, ctx: {
|
|
38
36
|
...ctx,
|
|
39
|
-
|
|
40
|
-
parseObject: false,
|
|
37
|
+
stack: [schema, ...stack],
|
|
41
38
|
} }));
|
|
42
39
|
}
|
|
43
40
|
if (properties) {
|
|
44
41
|
body = Object.entries(properties).map(([key, value]) => {
|
|
45
|
-
return (_jsx(Schema, { name: key, schema: value, ctx: {
|
|
42
|
+
return (_jsx(Schema, { name: key, schema: value, parseObject: false, required: schema.required?.includes(key) ?? false, ctx: {
|
|
46
43
|
...ctx,
|
|
47
|
-
|
|
48
|
-
parseObject: false,
|
|
44
|
+
stack: [schema, ...stack],
|
|
49
45
|
} }, key));
|
|
50
46
|
});
|
|
51
47
|
}
|
|
52
48
|
return (_jsxs("div", { className: "flex flex-col gap-4", children: [body, footer] }));
|
|
53
49
|
}
|
|
54
50
|
if (schema.allOf && parseObject) {
|
|
55
|
-
return (_jsx(Schema, { name: name, schema: combineSchema(schema.allOf), ctx:
|
|
51
|
+
return (_jsx(Schema, { name: name, schema: combineSchema(schema.allOf), ctx: {
|
|
52
|
+
...ctx,
|
|
53
|
+
stack: [schema, ...stack],
|
|
54
|
+
} }));
|
|
56
55
|
}
|
|
57
56
|
let footer;
|
|
58
57
|
const fields = [];
|
|
@@ -73,8 +72,6 @@ export function Schema({ name, schema, ctx, }) {
|
|
|
73
72
|
if (isObject(schema) && !parseObject && !stack.includes(schema)) {
|
|
74
73
|
footer = (_jsx(renderer.ObjectCollapsible, { name: "Show Attributes", children: _jsx(Schema, { name: name, schema: schema, ctx: {
|
|
75
74
|
...ctx,
|
|
76
|
-
parseObject: true,
|
|
77
|
-
required: false,
|
|
78
75
|
stack: [schema, ...stack],
|
|
79
76
|
} }) }));
|
|
80
77
|
}
|
|
@@ -82,7 +79,7 @@ export function Schema({ name, schema, ctx, }) {
|
|
|
82
79
|
const mentionedObjectTypes = [
|
|
83
80
|
...(schema.anyOf ?? schema.oneOf ?? []),
|
|
84
81
|
...(schema.not ? [schema.not] : []),
|
|
85
|
-
...(schema.type === 'array' ? [schema.items] : []),
|
|
82
|
+
...(schema.type === 'array' && schema.items ? [schema.items] : []),
|
|
86
83
|
].filter((s) => isComplexType(s) && !stack.includes(s));
|
|
87
84
|
footer = mentionedObjectTypes.map((s, idx) => {
|
|
88
85
|
return (_jsx(renderer.ObjectCollapsible, { name: s.title ??
|
|
@@ -91,12 +88,10 @@ export function Schema({ name, schema, ctx, }) {
|
|
|
91
88
|
: `Object ${idx + 1}`), children: _jsx(Schema, { name: "element", schema: s, ctx: {
|
|
92
89
|
...ctx,
|
|
93
90
|
stack: [schema, ...stack],
|
|
94
|
-
parseObject: true,
|
|
95
|
-
required: false,
|
|
96
91
|
} }) }, idx));
|
|
97
92
|
});
|
|
98
93
|
}
|
|
99
|
-
return (_jsxs(renderer.Property, { name: name, type: getSchemaType(schema, ctx), required:
|
|
94
|
+
return (_jsxs(renderer.Property, { name: name, type: getSchemaType(schema, ctx), required: required, deprecated: schema.deprecated, children: [schema.description ? _jsx(Markdown, { text: schema.description }) : null, fields.length > 0 ? (_jsx("div", { className: "flex flex-col gap-2", children: fields.map((field) => (_jsxs("span", { children: [field.key, ": ", _jsx("code", { children: field.value })] }, field.key))) })) : null, footer] }));
|
|
100
95
|
}
|
|
101
96
|
/**
|
|
102
97
|
* Check if the schema needs another collapsible to explain
|
|
@@ -115,7 +110,7 @@ function getSchemaType(schema, ctx, isRoot = true) {
|
|
|
115
110
|
if (schema.title)
|
|
116
111
|
return schema.title;
|
|
117
112
|
if (schema.type === 'array')
|
|
118
|
-
return `array<${getSchemaType(schema.items, ctx)}>`;
|
|
113
|
+
return `array<${schema.items ? getSchemaType(schema.items, ctx) : 'unknown'}>`;
|
|
119
114
|
if (schema.oneOf)
|
|
120
115
|
return schema.oneOf
|
|
121
116
|
.map((one) => getSchemaType(one, ctx, false))
|
|
@@ -141,7 +136,7 @@ function getSchemaType(schema, ctx, isRoot = true) {
|
|
|
141
136
|
}
|
|
142
137
|
// otherwise unknown
|
|
143
138
|
}
|
|
144
|
-
if (schema.type === 'string' && schema.format === 'binary'
|
|
139
|
+
if (schema.type === 'string' && schema.format === 'binary')
|
|
145
140
|
return 'file';
|
|
146
141
|
if (schema.type && Array.isArray(schema.type)) {
|
|
147
142
|
const nonNullTypes = schema.type.filter((v) => v !== 'null');
|