fumadocs-openapi 5.8.2 → 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 Parser from '@apidevtools/json-schema-ref-parser';
5
- import { upgrade } from '@scalar/openapi-parser';
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 dereferenced = await Parser.dereference(bundled, {
150
- mutateInputSchema: true,
151
- dereference: {
152
- onDereference ($ref, schema) {
153
- dereferenceMap.set(schema, $ref);
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 = {
@@ -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 Parser from '@apidevtools/json-schema-ref-parser';
18
- import { upgrade } from '@scalar/openapi-parser';
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 if (type !== 'null' && type !== 'object') {
440
- items[type] = {
441
- type: type === 'integer' ? 'number' : type,
442
- isRequired: required,
443
- defaultValue: schema.example ?? schema.default ?? ''
444
- };
440
+ } else {
441
+ items[type] = toSchema({
442
+ ...schema,
443
+ type
444
+ }, true, ctx);
445
445
  }
446
446
  }
447
447
  return {
@@ -1193,17 +1193,18 @@ const cache = new Map();
1193
1193
  */ async function processDocument(document, disableCache = false) {
1194
1194
  const cached = !disableCache && typeof document === 'string' ? cache.get(document) : null;
1195
1195
  if (cached) return cached;
1196
- let bundled = await Parser.bundle(document, {
1197
- mutateInputSchema: false
1198
- });
1199
- bundled = upgrade(bundled).specification;
1200
1196
  const dereferenceMap = new Map();
1201
- const dereferenced = await Parser.dereference(bundled, {
1202
- mutateInputSchema: true,
1203
- dereference: {
1204
- onDereference ($ref, schema) {
1205
- dereferenceMap.set(schema, $ref);
1206
- }
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);
1207
1208
  }
1208
1209
  });
1209
1210
  const processed = {
@@ -253,7 +253,7 @@ function useSchemaContext() {
253
253
  return ctx;
254
254
  }
255
255
 
256
- const APIPlayground = dynamic(()=>import('./playground-client-JckpOPq4.js').then((mod)=>mod.APIPlayground));
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-D5WUNeFS.js';
7
- export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-D5WUNeFS.js';
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-D5WUNeFS.js';
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') return getDefaultValue(resolve(Object.values(item.items)[0], references), references);
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.8.2",
3
+ "version": "5.9.0",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -31,32 +31,32 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@apidevtools/json-schema-ref-parser": "^11.7.3",
35
34
  "@fumari/json-schema-to-typescript": "^1.1.2",
36
- "@radix-ui/react-select": "^2.1.2",
37
- "@radix-ui/react-slot": "^1.1.0",
38
- "@scalar/openapi-parser": "^0.8.10",
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.54.0",
45
+ "react-hook-form": "^7.54.1",
46
46
  "remark": "^15.0.1",
47
47
  "remark-rehype": "^11.1.1",
48
48
  "shiki": "^1.24.2",
49
- "fumadocs-core": "14.6.0",
50
- "fumadocs-ui": "14.6.0"
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.1",
54
+ "@types/node": "22.10.2",
55
55
  "@types/openapi-sampler": "^1.0.3",
56
56
  "@types/react": "^19.0.1",
57
57
  "bunchee": "^6.0.3",
58
58
  "lucide-react": "^0.468.0",
59
- "next": "15.0.4",
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"