fumadocs-openapi 5.8.1 → 5.9.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/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { resolve, join, parse, dirname } from 'node:path';
|
|
2
2
|
import { dump } from 'js-yaml';
|
|
3
3
|
import Slugger from 'github-slugger';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
4
|
+
import { load, upgrade, dereference as dereference$1 } from '@scalar/openapi-parser';
|
|
5
|
+
import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls';
|
|
6
|
+
import { readFiles } from '@scalar/openapi-parser/plugins/read-files';
|
|
6
7
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
7
8
|
import fg from 'fast-glob';
|
|
8
9
|
|
|
@@ -141,17 +142,18 @@ const cache = new Map();
|
|
|
141
142
|
*/ async function processDocument(document, disableCache = false) {
|
|
142
143
|
const cached = !disableCache && typeof document === 'string' ? cache.get(document) : null;
|
|
143
144
|
if (cached) return cached;
|
|
144
|
-
let bundled = await Parser.bundle(document, {
|
|
145
|
-
mutateInputSchema: false
|
|
146
|
-
});
|
|
147
|
-
bundled = upgrade(bundled).specification;
|
|
148
145
|
const dereferenceMap = new Map();
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
const loaded = await load(document, {
|
|
147
|
+
plugins: [
|
|
148
|
+
readFiles(),
|
|
149
|
+
fetchUrls()
|
|
150
|
+
]
|
|
151
|
+
});
|
|
152
|
+
// upgrade
|
|
153
|
+
loaded.specification = upgrade(loaded.specification).specification;
|
|
154
|
+
const { schema: dereferenced } = await dereference$1(loaded.filesystem, {
|
|
155
|
+
onDereference ({ ref, schema }) {
|
|
156
|
+
dereferenceMap.set(schema, ref);
|
|
155
157
|
}
|
|
156
158
|
});
|
|
157
159
|
const processed = {
|
package/dist/server/index.js
CHANGED
|
@@ -14,8 +14,9 @@ import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
|
14
14
|
import * as Base from 'fumadocs-ui/components/codeblock';
|
|
15
15
|
import { highlight } from 'fumadocs-core/server';
|
|
16
16
|
import { Root, API, APIInfo, APIExample as APIExample$1, Property, ObjectCollapsible, APIPlayground } from '../ui/index.js';
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
17
|
+
import { load, upgrade, dereference } from '@scalar/openapi-parser';
|
|
18
|
+
import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls';
|
|
19
|
+
import { readFiles } from '@scalar/openapi-parser/plugins/read-files';
|
|
19
20
|
import { cva } from 'class-variance-authority';
|
|
20
21
|
|
|
21
22
|
function getPreferredType(body) {
|
|
@@ -384,7 +385,7 @@ function toSchema(schema, required, ctx) {
|
|
|
384
385
|
const additional = schema.additionalProperties;
|
|
385
386
|
let additionalProperties;
|
|
386
387
|
if (additional && typeof additional === 'object') {
|
|
387
|
-
if (!additional.type && !additional.anyOf && !additional.allOf && !additional.oneOf) {
|
|
388
|
+
if ((!additional.type || additional.type.length === 0) && !additional.anyOf && !additional.allOf && !additional.oneOf) {
|
|
388
389
|
additionalProperties = true;
|
|
389
390
|
} else {
|
|
390
391
|
additionalProperties = getIdFromSchema(additional, false, ctx);
|
|
@@ -436,12 +437,11 @@ function toSchema(schema, required, ctx) {
|
|
|
436
437
|
items: 'items' in schema && schema.items ? toSchema(schema.items, false, ctx) : toSchema({}, required, ctx),
|
|
437
438
|
isRequired: required
|
|
438
439
|
};
|
|
439
|
-
} else
|
|
440
|
-
items[type] = {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
};
|
|
440
|
+
} else {
|
|
441
|
+
items[type] = toSchema({
|
|
442
|
+
...schema,
|
|
443
|
+
type
|
|
444
|
+
}, true, ctx);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
447
|
return {
|
|
@@ -487,7 +487,6 @@ async function Markdown({ text }) {
|
|
|
487
487
|
jsx: jsx,
|
|
488
488
|
jsxs: jsxs,
|
|
489
489
|
Fragment,
|
|
490
|
-
// @ts-expect-error -- safe to use
|
|
491
490
|
components: defaultMdxComponents
|
|
492
491
|
});
|
|
493
492
|
}
|
|
@@ -1194,17 +1193,18 @@ const cache = new Map();
|
|
|
1194
1193
|
*/ async function processDocument(document, disableCache = false) {
|
|
1195
1194
|
const cached = !disableCache && typeof document === 'string' ? cache.get(document) : null;
|
|
1196
1195
|
if (cached) return cached;
|
|
1197
|
-
let bundled = await Parser.bundle(document, {
|
|
1198
|
-
mutateInputSchema: false
|
|
1199
|
-
});
|
|
1200
|
-
bundled = upgrade(bundled).specification;
|
|
1201
1196
|
const dereferenceMap = new Map();
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1197
|
+
const loaded = await load(document, {
|
|
1198
|
+
plugins: [
|
|
1199
|
+
readFiles(),
|
|
1200
|
+
fetchUrls()
|
|
1201
|
+
]
|
|
1202
|
+
});
|
|
1203
|
+
// upgrade
|
|
1204
|
+
loaded.specification = upgrade(loaded.specification).specification;
|
|
1205
|
+
const { schema: dereferenced } = await dereference(loaded.filesystem, {
|
|
1206
|
+
onDereference ({ ref, schema }) {
|
|
1207
|
+
dereferenceMap.set(schema, ref);
|
|
1208
1208
|
}
|
|
1209
1209
|
});
|
|
1210
1210
|
const processed = {
|
|
@@ -6,7 +6,7 @@ import dynamic from 'next/dynamic';
|
|
|
6
6
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @license lucide-react v0.
|
|
9
|
+
* @license lucide-react v0.468.0 - ISC
|
|
10
10
|
*
|
|
11
11
|
* This source code is licensed under the ISC license.
|
|
12
12
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -16,7 +16,7 @@ const mergeClasses = (...classes)=>classes.filter((className, index, array)=>{
|
|
|
16
16
|
}).join(" ").trim();
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @license lucide-react v0.
|
|
19
|
+
* @license lucide-react v0.468.0 - ISC
|
|
20
20
|
*
|
|
21
21
|
* This source code is licensed under the ISC license.
|
|
22
22
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -253,7 +253,7 @@ function useSchemaContext() {
|
|
|
253
253
|
return ctx;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
const APIPlayground = dynamic(()=>import('./playground-client-
|
|
256
|
+
const APIPlayground = dynamic(()=>import('./playground-client-HUgWUI95.js').then((mod)=>mod.APIPlayground));
|
|
257
257
|
function Root({ children, baseUrl, className, shikiOptions, ...props }) {
|
|
258
258
|
return /*#__PURE__*/ jsx("div", {
|
|
259
259
|
className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className),
|
package/dist/ui/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { cn } from 'fumadocs-ui/components/api';
|
|
|
3
3
|
import { Fragment } from 'react';
|
|
4
4
|
import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
5
5
|
import { cva } from 'class-variance-authority';
|
|
6
|
-
import { f as CopyRouteButton, B as BaseUrlSelect } from './client-client-
|
|
7
|
-
export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-
|
|
6
|
+
import { f as CopyRouteButton, B as BaseUrlSelect } from './client-client-DopF7PSu.js';
|
|
7
|
+
export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-DopF7PSu.js';
|
|
8
8
|
|
|
9
9
|
const badgeVariants = cva('rounded-xl border px-1.5 py-1 text-xs font-medium leading-[12px]', {
|
|
10
10
|
variants: {
|
|
@@ -5,7 +5,7 @@ import { forwardRef, useId, createContext, useContext, useState, useCallback, us
|
|
|
5
5
|
import { FormProvider, Controller, useFormContext, useFieldArray, useForm, useWatch } from 'react-hook-form';
|
|
6
6
|
import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
7
7
|
import { cn, buttonVariants } from 'fumadocs-ui/components/api';
|
|
8
|
-
import { C as CircleCheck, a as CircleX, b as ChevronDown, c as ChevronUp, d as Check, u as useSchemaContext, T as Trash2, P as Plus, e as useApiContext, S as SchemaContext } from './client-client-
|
|
8
|
+
import { C as CircleCheck, a as CircleX, b as ChevronDown, c as ChevronUp, d as Check, u as useSchemaContext, T as Trash2, P as Plus, e as useApiContext, S as SchemaContext } from './client-client-DopF7PSu.js';
|
|
9
9
|
import { Slot } from '@radix-ui/react-slot';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
import { useOnChange } from 'fumadocs-core/utils/use-on-change';
|
|
@@ -248,7 +248,11 @@ function getDefaultValue(item, references) {
|
|
|
248
248
|
]));
|
|
249
249
|
if (item.type === 'array') return [];
|
|
250
250
|
if (item.type === 'null') return null;
|
|
251
|
-
if (item.type === 'switcher')
|
|
251
|
+
if (item.type === 'switcher') {
|
|
252
|
+
const first = Object.values(item.items).at(0);
|
|
253
|
+
if (!first) return '';
|
|
254
|
+
return getDefaultValue(resolve(first, references), references);
|
|
255
|
+
}
|
|
252
256
|
if (item.type === 'file') return undefined;
|
|
253
257
|
return String(item.defaultValue);
|
|
254
258
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -31,40 +31,40 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@apidevtools/json-schema-ref-parser": "^11.7.2",
|
|
35
34
|
"@fumari/json-schema-to-typescript": "^1.1.2",
|
|
36
|
-
"@radix-ui/react-select": "^2.1.
|
|
37
|
-
"@radix-ui/react-slot": "^1.1.
|
|
38
|
-
"@scalar/openapi-parser": "
|
|
35
|
+
"@radix-ui/react-select": "^2.1.3",
|
|
36
|
+
"@radix-ui/react-slot": "^1.1.1",
|
|
37
|
+
"@scalar/openapi-parser": "0.10.0",
|
|
38
|
+
"ajv-draft-04": "^1.0.0",
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
40
|
"fast-glob": "^3.3.1",
|
|
41
41
|
"github-slugger": "^2.0.0",
|
|
42
42
|
"hast-util-to-jsx-runtime": "^2.3.2",
|
|
43
43
|
"js-yaml": "^4.1.0",
|
|
44
44
|
"openapi-sampler": "^1.6.1",
|
|
45
|
-
"react-hook-form": "^7.
|
|
45
|
+
"react-hook-form": "^7.54.1",
|
|
46
46
|
"remark": "^15.0.1",
|
|
47
47
|
"remark-rehype": "^11.1.1",
|
|
48
|
-
"shiki": "^1.24.
|
|
49
|
-
"fumadocs-
|
|
50
|
-
"fumadocs-
|
|
48
|
+
"shiki": "^1.24.2",
|
|
49
|
+
"fumadocs-ui": "14.6.1",
|
|
50
|
+
"fumadocs-core": "14.6.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/js-yaml": "^4.0.9",
|
|
54
|
-
"@types/node": "22.10.
|
|
54
|
+
"@types/node": "22.10.2",
|
|
55
55
|
"@types/openapi-sampler": "^1.0.3",
|
|
56
|
-
"@types/react": "^
|
|
57
|
-
"bunchee": "^6.0.
|
|
58
|
-
"lucide-react": "^0.
|
|
59
|
-
"next": "15.0
|
|
56
|
+
"@types/react": "^19.0.1",
|
|
57
|
+
"bunchee": "^6.0.3",
|
|
58
|
+
"lucide-react": "^0.468.0",
|
|
59
|
+
"next": "15.1.0",
|
|
60
60
|
"openapi-types": "^12.1.3",
|
|
61
61
|
"eslint-config-custom": "0.0.0",
|
|
62
62
|
"tsconfig": "0.0.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"next": "14.x.x || 15.x.x",
|
|
66
|
-
"react": "
|
|
67
|
-
"react-dom": "
|
|
66
|
+
"react": "18.x.x || 19.x.x",
|
|
67
|
+
"react-dom": "18.x.x || 19.x.x"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|