fumadocs-openapi 8.1.3 → 8.1.4
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 +40 -23
- package/dist/playground/client.d.ts +5 -16
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +39 -44
- package/dist/playground/get-default-values.d.ts +2 -2
- package/dist/playground/get-default-values.d.ts.map +1 -1
- package/dist/playground/get-default-values.js +21 -22
- package/dist/playground/index.d.ts +4 -38
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +43 -139
- package/dist/playground/inputs.d.ts +11 -13
- package/dist/playground/inputs.d.ts.map +1 -1
- package/dist/playground/inputs.js +72 -129
- package/dist/playground/schema.d.ts +38 -0
- package/dist/playground/schema.d.ts.map +1 -0
- package/dist/playground/schema.js +93 -0
- package/dist/render/operation/get-request-data.d.ts +1 -2
- package/dist/render/operation/get-request-data.d.ts.map +1 -1
- package/dist/render/operation/get-request-data.js +2 -2
- package/dist/render/operation/index.d.ts.map +1 -1
- package/dist/render/operation/index.js +5 -5
- package/dist/render/schema.d.ts +3 -3
- package/dist/render/schema.d.ts.map +1 -1
- package/dist/render/schema.js +70 -100
- package/dist/ui/client.d.ts +3 -0
- package/dist/ui/client.d.ts.map +1 -1
- package/dist/ui/client.js +15 -0
- package/dist/ui/components/dialog.d.ts.map +1 -1
- package/dist/ui/components/dialog.js +4 -3
- package/dist/ui/components/select.js +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/server-select.d.ts +2 -7
- package/dist/ui/server-select.d.ts.map +1 -1
- package/dist/ui/server-select.js +52 -19
- package/dist/utils/combine-schema.d.ts.map +1 -1
- package/dist/utils/combine-schema.js +12 -2
- package/dist/utils/schema-to-string.d.ts +3 -0
- package/dist/utils/schema-to-string.d.ts.map +1 -0
- package/dist/utils/schema-to-string.js +62 -0
- package/dist/utils/schema.d.ts +9 -4
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +2 -0
- package/package.json +6 -5
- package/dist/playground/resolve.d.ts +0 -6
- package/dist/playground/resolve.d.ts.map +0 -1
- package/dist/playground/resolve.js +0 -14
|
@@ -2,17 +2,23 @@
|
|
|
2
2
|
* Combine multiple object schemas into one
|
|
3
3
|
*/
|
|
4
4
|
export function combineSchema(schema) {
|
|
5
|
-
|
|
5
|
+
let result = {
|
|
6
6
|
type: undefined,
|
|
7
7
|
};
|
|
8
8
|
function add(s) {
|
|
9
|
+
if (typeof s === 'boolean') {
|
|
10
|
+
result = s;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (typeof result === 'boolean')
|
|
14
|
+
return;
|
|
9
15
|
if (s.type) {
|
|
10
16
|
result.type ?? (result.type = []);
|
|
11
17
|
if (!Array.isArray(result.type)) {
|
|
12
18
|
result.type = [result.type];
|
|
13
19
|
}
|
|
14
20
|
for (const v of Array.isArray(s.type) ? s.type : [s.type]) {
|
|
15
|
-
if (!result.type.includes(v)) {
|
|
21
|
+
if (Array.isArray(result.type) && !result.type.includes(v)) {
|
|
16
22
|
result.type.push(v);
|
|
17
23
|
}
|
|
18
24
|
}
|
|
@@ -21,6 +27,10 @@ export function combineSchema(schema) {
|
|
|
21
27
|
result.properties ?? (result.properties = {});
|
|
22
28
|
Object.assign(result.properties, s.properties);
|
|
23
29
|
}
|
|
30
|
+
if (s.patternProperties) {
|
|
31
|
+
result.patternProperties ?? (result.patternProperties = {});
|
|
32
|
+
Object.assign(result.patternProperties, s.patternProperties);
|
|
33
|
+
}
|
|
24
34
|
if (s.additionalProperties === true) {
|
|
25
35
|
result.additionalProperties = true;
|
|
26
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-to-string.d.ts","sourceRoot":"","sources":["../../src/utils/schema-to-string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,UAAO,GAAG,MAAM,CAuE5E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isNullable } from '../utils/schema.js';
|
|
2
|
+
export function schemaToString(schema, isRoot = true) {
|
|
3
|
+
if (schema === true)
|
|
4
|
+
return 'any';
|
|
5
|
+
else if (schema === false)
|
|
6
|
+
return 'never';
|
|
7
|
+
if (isNullable(schema) && isRoot) {
|
|
8
|
+
const type = schemaToString(schema, false);
|
|
9
|
+
// null if schema only contains `nullable`
|
|
10
|
+
return type === 'unknown' ? 'null' : `${type} | null`;
|
|
11
|
+
}
|
|
12
|
+
if (schema.title)
|
|
13
|
+
return schema.title;
|
|
14
|
+
if (Array.isArray(schema.type)) {
|
|
15
|
+
return schema.type
|
|
16
|
+
.map((type) => schemaToString({
|
|
17
|
+
...schema,
|
|
18
|
+
type,
|
|
19
|
+
}, false))
|
|
20
|
+
.join(' | ');
|
|
21
|
+
}
|
|
22
|
+
if (schema.type === 'array')
|
|
23
|
+
return `array<${schema.items ? schemaToString(schema.items) : 'unknown'}>`;
|
|
24
|
+
if (schema.oneOf) {
|
|
25
|
+
return schema.oneOf
|
|
26
|
+
.map((one) => schemaToString(one, false))
|
|
27
|
+
.filter((v) => v !== 'unknown')
|
|
28
|
+
.join(' | ');
|
|
29
|
+
}
|
|
30
|
+
if (schema.allOf) {
|
|
31
|
+
return schema.allOf
|
|
32
|
+
.map((one) => schemaToString(one, false))
|
|
33
|
+
.filter((v) => v !== 'unknown')
|
|
34
|
+
.join(' & ');
|
|
35
|
+
}
|
|
36
|
+
if (schema.not)
|
|
37
|
+
return `not ${schemaToString(schema.not, false)}`;
|
|
38
|
+
if (schema.anyOf) {
|
|
39
|
+
const union = schema.anyOf
|
|
40
|
+
.map((one) => schemaToString(one, false))
|
|
41
|
+
.filter((v) => v !== 'unknown');
|
|
42
|
+
if (union.length > 1) {
|
|
43
|
+
return `Any properties in ${union.join(',')}`;
|
|
44
|
+
}
|
|
45
|
+
else if (union.length === 1) {
|
|
46
|
+
return union[0];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (schema.type === 'string' && schema.format === 'binary')
|
|
50
|
+
return 'file';
|
|
51
|
+
if (schema.type && Array.isArray(schema.type)) {
|
|
52
|
+
const nonNullTypes = schema.type.filter((v) => v !== 'null');
|
|
53
|
+
if (nonNullTypes.length > 0)
|
|
54
|
+
return nonNullTypes.join(' | ');
|
|
55
|
+
}
|
|
56
|
+
else if (schema.type && schema.type !== 'null') {
|
|
57
|
+
return schema.type;
|
|
58
|
+
}
|
|
59
|
+
if (typeof schema.type === 'string')
|
|
60
|
+
return schema.type;
|
|
61
|
+
return 'unknown';
|
|
62
|
+
}
|
package/dist/utils/schema.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
1
|
+
import { type JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
2
|
+
import { ReferenceObject } from '../types.js';
|
|
3
3
|
export type NoReference<T> = T extends (infer I)[] ? NoReference<I>[] : T extends ReferenceObject ? Exclude<T, ReferenceObject> : T extends object ? {
|
|
4
4
|
[K in keyof T]: NoReference<T[K]>;
|
|
5
5
|
} : T;
|
|
6
|
-
|
|
6
|
+
type NoReferenceJSONSchema<T> = T extends (infer I)[] ? NoReference<I>[] : T extends {
|
|
7
|
+
$ref?: string;
|
|
8
|
+
} ? Omit<T, '$ref'> : T;
|
|
9
|
+
export type ParsedSchema = JSONSchema;
|
|
10
|
+
export type ResolvedSchema = NoReferenceJSONSchema<ParsedSchema>;
|
|
7
11
|
export declare function getPreferredType<B extends Record<string, unknown>>(body: B): keyof B | undefined;
|
|
8
|
-
export declare function isNullable(schema:
|
|
12
|
+
export declare function isNullable(schema: ParsedSchema, includeOneOf?: boolean): boolean;
|
|
13
|
+
export {};
|
|
9
14
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC9C,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS,eAAe,GACvB,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAC3B,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,GACD,CAAC,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACjD,WAAW,CAAC,CAAC,CAAC,EAAE,GAChB,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACzB,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,GACf,CAAC,CAAC;AAER,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC;AACtC,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAEjE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,IAAI,EAAE,CAAC,GACN,MAAM,CAAC,GAAG,SAAS,CAIrB;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,UAAO,GAAG,OAAO,CAU7E"}
|
package/dist/utils/schema.js
CHANGED
|
@@ -4,6 +4,8 @@ export function getPreferredType(body) {
|
|
|
4
4
|
return Object.keys(body)[0];
|
|
5
5
|
}
|
|
6
6
|
export function isNullable(schema, includeOneOf = true) {
|
|
7
|
+
if (typeof schema === 'boolean')
|
|
8
|
+
return false;
|
|
7
9
|
if (Array.isArray(schema.type) && schema.type.includes('null'))
|
|
8
10
|
return true;
|
|
9
11
|
if (includeOneOf && (schema.anyOf || schema.oneOf)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.4",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@radix-ui/react-select": "^2.2.2",
|
|
51
51
|
"@radix-ui/react-slot": "^1.2.0",
|
|
52
52
|
"@scalar/openapi-parser": "0.10.16",
|
|
53
|
-
"ajv
|
|
53
|
+
"ajv": "^8.17.1",
|
|
54
54
|
"class-variance-authority": "^0.7.1",
|
|
55
55
|
"fast-glob": "^3.3.3",
|
|
56
56
|
"github-slugger": "^2.0.0",
|
|
@@ -67,14 +67,15 @@
|
|
|
67
67
|
"fumadocs-ui": "15.2.12"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@scalar/api-client-react": "^1.2.
|
|
70
|
+
"@scalar/api-client-react": "^1.2.28",
|
|
71
71
|
"@types/js-yaml": "^4.0.9",
|
|
72
|
-
"@types/node": "22.15.
|
|
72
|
+
"@types/node": "22.15.3",
|
|
73
73
|
"@types/openapi-sampler": "^1.0.3",
|
|
74
74
|
"@types/react": "^19.1.2",
|
|
75
|
+
"json-schema-typed": "^8.0.1",
|
|
75
76
|
"next": "15.3.1",
|
|
76
77
|
"openapi-types": "^12.1.3",
|
|
77
|
-
"tailwindcss": "^4.1.
|
|
78
|
+
"tailwindcss": "^4.1.5",
|
|
78
79
|
"tsc-alias": "^1.8.15",
|
|
79
80
|
"eslint-config-custom": "0.0.0",
|
|
80
81
|
"tsconfig": "0.0.0"
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type ReferenceSchema, type RequestSchema } from '../playground/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve reference
|
|
4
|
-
*/
|
|
5
|
-
export declare function resolve(schema: RequestSchema | ReferenceSchema | string, references: Record<string, RequestSchema>): RequestSchema;
|
|
6
|
-
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/playground/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE9E;;GAEG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,GAAG,eAAe,GAAG,MAAM,EAChD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,aAAa,CASf"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve reference
|
|
3
|
-
*/
|
|
4
|
-
export function resolve(schema, references) {
|
|
5
|
-
if (typeof schema === 'string')
|
|
6
|
-
return references[schema];
|
|
7
|
-
if (schema.type !== 'ref')
|
|
8
|
-
return schema;
|
|
9
|
-
return {
|
|
10
|
-
...references[schema.schema],
|
|
11
|
-
description: schema.description,
|
|
12
|
-
isRequired: schema.isRequired,
|
|
13
|
-
};
|
|
14
|
-
}
|