fumadocs-openapi 9.3.7 → 9.3.9

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.
@@ -29,7 +29,7 @@ interface OperationConfig extends BaseConfig {
29
29
  /**
30
30
  * Specify name for output file
31
31
  */
32
- name?: ((output: GeneratePageOutput, document: ProcessedDocument['document']) => string) | BaseName;
32
+ name?: ((output: GeneratePageOutput, document: ProcessedDocument['dereferenced']) => string) | BaseName;
33
33
  }
34
34
  interface TagConfig extends BaseConfig {
35
35
  /**
@@ -39,7 +39,7 @@ interface TagConfig extends BaseConfig {
39
39
  /**
40
40
  * Specify name for output file
41
41
  */
42
- name?: ((output: GenerateTagOutput, document: ProcessedDocument['document']) => string) | BaseName;
42
+ name?: ((output: GenerateTagOutput, document: ProcessedDocument['dereferenced']) => string) | BaseName;
43
43
  }
44
44
  interface FileConfig extends BaseConfig {
45
45
  /**
@@ -49,7 +49,7 @@ interface FileConfig extends BaseConfig {
49
49
  /**
50
50
  * Specify name for output file
51
51
  */
52
- name?: ((output: GenerateFileOutput, document: ProcessedDocument['document']) => string) | BaseName;
52
+ name?: ((output: GenerateFileOutput, document: ProcessedDocument['dereferenced']) => string) | BaseName;
53
53
  }
54
54
  export type Config = FileConfig | TagConfig | OperationConfig;
55
55
  interface BaseName {
@@ -1 +1 @@
1
- {"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EAEvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAI9C,UAAU,kBAAkB;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WA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AU,EAAE,CAAC,CA2DvB"}
@@ -66,7 +66,7 @@ export async function generateFilesOnly(options) {
66
66
  }
67
67
  function generateFromDocument(schemaId, processed, options) {
68
68
  const files = [];
69
- const { document } = processed;
69
+ const { dereferenced } = processed;
70
70
  const { output, cwd = process.cwd(), slugify = defaultSlugify } = options;
71
71
  const outputDir = path.join(cwd, output);
72
72
  let nameFn;
@@ -83,11 +83,11 @@ function generateFromDocument(schemaId, processed, options) {
83
83
  path.join(getOutputPathFromRoute(result.type === 'operation' ? result.item.path : result.item.name), `${result.item.method.toLowerCase()}.mdx`),
84
84
  ];
85
85
  }
86
- const file = nameFn(result, document);
86
+ const file = nameFn(result, dereferenced);
87
87
  if (groupBy === 'tag') {
88
88
  let tags = result.type === 'operation'
89
- ? document.paths[result.item.path][result.item.method].tags
90
- : document.webhooks[result.item.name][result.item.method].tags;
89
+ ? dereferenced.paths[result.item.path][result.item.method].tags
90
+ : dereferenced.webhooks[result.item.name][result.item.method].tags;
91
91
  if (!tags || tags.length === 0) {
92
92
  console.warn('When `groupBy` is set to `tag`, make sure a `tags` is defined for every operation schema.');
93
93
  tags = ['unknown'];
@@ -101,7 +101,7 @@ function generateFromDocument(schemaId, processed, options) {
101
101
  const filename = nameFn({
102
102
  pathOrUrl: schemaId,
103
103
  content: result,
104
- }, document);
104
+ }, dereferenced);
105
105
  files.push({
106
106
  path: path.join(outputDir, `${filename}.mdx`),
107
107
  content: result,
@@ -111,7 +111,7 @@ function generateFromDocument(schemaId, processed, options) {
111
111
  if (options.per === 'tag') {
112
112
  const results = generateTags(schemaId, processed, options);
113
113
  for (const result of results) {
114
- const filename = nameFn(result, document);
114
+ const filename = nameFn(result, dereferenced);
115
115
  files.push({
116
116
  path: path.join(outputDir, `${filename}.mdx`),
117
117
  content: result.content,
package/dist/generate.js CHANGED
@@ -4,26 +4,26 @@ import { dump } from 'js-yaml';
4
4
  import Slugger from 'github-slugger';
5
5
  import { removeUndefined } from './utils/remove-undefined.js';
6
6
  export function generateAll(schemaId, processed, options = {}) {
7
- const { document } = processed;
8
- const items = getAPIPageItems(document);
7
+ const { dereferenced } = processed;
8
+ const items = getAPIPageItems(dereferenced);
9
9
  return generatePage(schemaId, processed, {
10
10
  operations: items.operations,
11
11
  webhooks: items.webhooks,
12
12
  hasHead: true,
13
13
  }, {
14
14
  ...options,
15
- title: document.info.title,
16
- description: document.info.description,
15
+ title: dereferenced.info.title,
16
+ description: dereferenced.info.description,
17
17
  }, {
18
18
  type: 'file',
19
19
  });
20
20
  }
21
21
  export function generatePages(schemaId, processed, options = {}) {
22
- const { document } = processed;
23
- const items = getAPIPageItems(document);
22
+ const { dereferenced } = processed;
23
+ const items = getAPIPageItems(dereferenced);
24
24
  const result = [];
25
25
  for (const item of items.operations) {
26
- const pathItem = document.paths?.[item.path];
26
+ const pathItem = dereferenced.paths?.[item.path];
27
27
  if (!pathItem)
28
28
  continue;
29
29
  const operation = pathItem[item.method];
@@ -47,7 +47,7 @@ export function generatePages(schemaId, processed, options = {}) {
47
47
  });
48
48
  }
49
49
  for (const item of items.webhooks) {
50
- const pathItem = document.webhooks?.[item.name];
50
+ const pathItem = dereferenced.webhooks?.[item.name];
51
51
  if (!pathItem)
52
52
  continue;
53
53
  const operation = pathItem[item.method];
@@ -71,11 +71,11 @@ export function generatePages(schemaId, processed, options = {}) {
71
71
  return result;
72
72
  }
73
73
  export function generateTags(schemaId, processed, options = {}) {
74
- const { document } = processed;
75
- if (!document.tags)
74
+ const { dereferenced } = processed;
75
+ if (!dereferenced.tags)
76
76
  return [];
77
- const items = getAPIPageItems(document);
78
- return document.tags.map((tag) => {
77
+ const items = getAPIPageItems(dereferenced);
78
+ return dereferenced.tags.map((tag) => {
79
79
  const webhooks = items.webhooks.filter((v) => v.tags && v.tags.includes(tag.name));
80
80
  const operations = items.operations.filter((v) => v.tags && v.tags.includes(tag.name));
81
81
  const displayName = tag && 'x-displayName' in tag && typeof tag['x-displayName'] === 'string'
@@ -135,7 +135,7 @@ function generatePage(schemaId, processed, pageProps, options, context) {
135
135
  route: operation.path,
136
136
  };
137
137
  }
138
- const data = generateStaticData(processed.document, page);
138
+ const data = generateStaticData(processed.dereferenced, page);
139
139
  const content = [];
140
140
  if (options.description && includeDescription)
141
141
  content.push(options.description);
@@ -315,8 +315,7 @@ function renderCustomField(fieldName, info, field, key) {
315
315
  render: (props) => field.render({ ...props, info }), name: fieldName }, key));
316
316
  }
317
317
  function Route({ route, ...props }) {
318
- const segments = route.split('/').filter((part) => part.length > 0);
319
- return (_jsx("div", { ...props, className: cn('flex flex-row items-center gap-0.5 overflow-auto text-nowrap', props.className), children: segments.map((part, index) => (_jsxs(Fragment, { children: [_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))) }));
318
+ 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))) }));
320
319
  }
321
320
  function DefaultResultDisplay({ data }) {
322
321
  const statusInfo = useMemo(() => getStatusInfo(data.status), [data.status]);
@@ -67,15 +67,15 @@ function writeReferences(schema, ctx, stack = new WeakMap()) {
67
67
  }
68
68
  return output;
69
69
  }
70
- function parseSecurities(method, { schema: { document } }) {
70
+ function parseSecurities(method, { schema: { dereferenced } }) {
71
71
  const result = [];
72
- const security = method.security ?? document.security ?? [];
72
+ const security = method.security ?? dereferenced.security ?? [];
73
73
  if (security.length === 0)
74
74
  return result;
75
75
  for (const map of security) {
76
76
  const list = [];
77
77
  for (const [key, scopes] of Object.entries(map)) {
78
- const scheme = document.components?.securitySchemes?.[key];
78
+ const scheme = dereferenced.components?.securitySchemes?.[key];
79
79
  if (!scheme)
80
80
  continue;
81
81
  list.push({
@@ -11,9 +11,9 @@ export async function APIPage(props) {
11
11
  ? await processDocumentCached(props.document)
12
12
  : await props.document;
13
13
  const ctx = await getContext(processed, props);
14
- const { document } = processed;
14
+ const { dereferenced } = processed;
15
15
  return (_jsxs(ctx.renderer.Root, { ctx: ctx, children: [operations?.map((item) => {
16
- const pathItem = document.paths?.[item.path];
16
+ const pathItem = dereferenced.paths?.[item.path];
17
17
  if (!pathItem)
18
18
  throw new Error(`[Fumadocs OpenAPI] Path not found in OpenAPI schema: ${item.path}`);
19
19
  const operation = pathItem[item.method];
@@ -22,7 +22,7 @@ export async function APIPage(props) {
22
22
  const method = createMethod(item.method, pathItem, operation);
23
23
  return (_jsx(Operation, { method: method, path: item.path, ctx: ctx, hasHead: hasHead }, `${item.path}:${item.method}`));
24
24
  }), webhooks?.map((item) => {
25
- const webhook = document.webhooks?.[item.name];
25
+ const webhook = dereferenced.webhooks?.[item.name];
26
26
  if (!webhook)
27
27
  throw new Error(`[Fumadocs OpenAPI] Webhook not found in OpenAPI schema: ${item.name}`);
28
28
  const hook = webhook[item.method];
@@ -33,7 +33,7 @@ export async function APIPage(props) {
33
33
  })] }));
34
34
  }
35
35
  export async function getContext(schema, options = {}) {
36
- const document = schema.document;
36
+ const document = schema.dereferenced;
37
37
  const servers = document.servers && document.servers.length > 0
38
38
  ? document.servers
39
39
  : [{ url: '/' }];
@@ -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,EACjB,aAAa,EAEd,MAAM,SAAS,CAAC;AAcjB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAY1D,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,O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AW,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,CAiNf"}
@@ -19,6 +19,7 @@ const ParamTypes = {
19
19
  cookie: 'Cookie Parameters',
20
20
  };
21
21
  export function Operation({ type = 'operation', path, method, ctx, hasHead, headingLevel = 2, }) {
22
+ const { schema: { dereferenced }, } = ctx;
22
23
  const body = method.requestBody;
23
24
  let headNode = null;
24
25
  let bodyNode = null;
@@ -55,11 +56,9 @@ export function Operation({ type = 'operation', path, method, ctx, hasHead, head
55
56
  (param.schema?.deprecated ?? false),
56
57
  }, required: param.required, readOnly: method.method === 'GET', writeOnly: method.method !== 'GET', ctx: ctx }, param.name))) })] }, type));
57
58
  });
58
- const securities = (method.security ??
59
- ctx.schema.document.security ??
60
- []).filter((v) => Object.keys(v).length > 0);
59
+ const securities = (method.security ?? dereferenced.security ?? []).filter((v) => Object.keys(v).length > 0);
61
60
  if (type === 'operation' && securities.length > 0) {
62
- const securitySchemes = ctx.schema.document.components?.securitySchemes;
61
+ const securitySchemes = dereferenced.components?.securitySchemes;
63
62
  const names = securities.map((security) => Object.keys(security).join(' & '));
64
63
  authNode = (_jsxs(SelectTabs, { defaultValue: names[0], children: [_jsxs("div", { className: "flex items-end justify-between gap-2", children: [heading(headingLevel, 'Authorization', ctx), _jsx(SelectTabTrigger, { items: names, className: "mb-4" })] }), securities.map((security, i) => (_jsx(SelectTab, { value: names[i], children: Object.entries(security).map(([key, scopes]) => {
65
64
  const scheme = securitySchemes?.[key];
@@ -83,7 +82,7 @@ export function Operation({ type = 'operation', path, method, ctx, hasHead, head
83
82
  }
84
83
  async function ResponseAccordion({ status, operation, ctx, }) {
85
84
  const response = operation.responses[status];
86
- const { generateTypeScriptSchema, schema: { dereferenceMap }, } = ctx;
85
+ const { generateTypeScriptSchema } = ctx;
87
86
  const contentTypes = response.content
88
87
  ? Object.entries(response.content)
89
88
  : null;
@@ -94,7 +93,7 @@ async function ResponseAccordion({ status, operation, ctx, }) {
94
93
  ts = await generateTypeScriptSchema(operation, status);
95
94
  }
96
95
  else if (generateTypeScriptSchema === undefined && schema) {
97
- ts = await getTypescriptSchema(schema, dereferenceMap);
96
+ ts = await getTypescriptSchema(ctx.schema);
98
97
  }
99
98
  return (_jsxs(SelectTab, { value: type, className: "my-2", children: [ts && _jsx(CopyResponseTypeScript, { code: ts }), schema && (_jsx("div", { className: "border px-3 py-2 rounded-lg overflow-auto max-h-[400px]", children: _jsx(Schema, { name: "response", schema: schema, as: "body", readOnly: true, ctx: ctx }) }))] }, type));
100
99
  })] })] }));
@@ -165,7 +165,9 @@ function schemaStack(renderContext, parent) {
165
165
  function getId(schema) {
166
166
  if (typeof schema !== 'object')
167
167
  return;
168
- return schema.title ?? renderContext.schema.dereferenceMap.get(schema);
168
+ if (schema.title)
169
+ return schema.title;
170
+ return renderContext.schema.getRawRef(schema);
169
171
  }
170
172
  return {
171
173
  history: parent ? [...parent.history] : [],
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { lazy } from 'react';
3
3
  const Client = lazy(() => import('./client.js'));
4
4
  export function APIPlayground({ path, method, ctx, }) {
5
- return (_jsx(Client, { method: method.method, path: path, spec: ctx.schema.downloaded }));
5
+ return (_jsx(Client, { method: method.method, path: path, spec: ctx.schema.bundled }));
6
6
  }
@@ -3,7 +3,7 @@ import { createProxy } from '../server/proxy.js';
3
3
  import type { CodeSample } from '../render/operation/index.js';
4
4
  import type { Renderer } from '../render/renderer.js';
5
5
  import type { NoReference } from '../utils/schema.js';
6
- import type { BuiltinTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from 'shiki';
6
+ import type { HighlightOptionsCommon, HighlightOptionsThemes } from 'fumadocs-core/highlight';
7
7
  import type { MediaAdapter } from '../media/adapter.js';
8
8
  import type { MethodInformation } from '../types.js';
9
9
  import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
@@ -39,7 +39,7 @@ export interface SharedOpenAPIOptions {
39
39
  * Generate code samples for endpoint.
40
40
  */
41
41
  generateCodeSamples?: (method: MethodInformation) => Awaitable<CodeSample[]>;
42
- shikiOptions?: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BuiltinTheme>;
42
+ shikiOptions?: Omit<HighlightOptionsCommon, 'lang' | 'components'> & HighlightOptionsThemes;
43
43
  /**
44
44
  * Show full response schema instead of only example response & Typescript definitions
45
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/server/create.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAElC,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACnC;;GAEG;AACH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,GAAG,SAAS,CA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ACH,wBAAwB,CAAC,EACrB,CAAC,CACC,MAAM,EAAE,WAAW,CAAC,iBAAiB,CAAC,EACtC,UAAU,EAAE,MAAM,KACf,SAAS,CAAC,MAAM,CAAC,CAAC,GACvB,KAAK,CAAC;IAEV;;OAEG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;IAE7E,YAAY,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,YAAY,CAAC,GAChE,sBAAsB,CAAC;IAEzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,cAAe,SAAQ,oBAAoB;IAC1D;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAE9C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,YAAY,CAAC;IACtD,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,UAAU,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC/C;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB,GAAG,aAAa,CA4CzE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAEtE"}
package/dist/types.d.ts CHANGED
@@ -19,10 +19,6 @@ export type ServerVariableObject = NoReference<V3_1.ServerVariableObject>;
19
19
  export type MethodInformation = NoReference<OperationObject> & {
20
20
  method: string;
21
21
  };
22
- /**
23
- * Dereferenced value and its original `$ref` value
24
- */
25
- export type DereferenceMap = Map<unknown, string>;
26
22
  export interface RenderContext extends SharedOpenAPIOptions {
27
23
  renderer: Renderer;
28
24
  servers: ServerObject[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAErD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;AACrC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC;AACvE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;AACjD,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;AACvC,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC9D,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAE1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Ae,GAAG,IAAI,CAAC,eAAe,CAAC;AACnD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;AACjD,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;AACvC,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC9D,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAE1E,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,aAAc,SAAQ,oBAAoB;IACzD,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,iBAAiB,CAAC;IAE1B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC7C"}
@@ -1,3 +1,3 @@
1
- import type { DereferenceMap } from '../types.js';
2
- export declare function getTypescriptSchema(schema: object, dereferenceMap: DereferenceMap): Promise<string | undefined>;
1
+ import type { ProcessedDocument } from '../utils/process-document.js';
2
+ export declare function getTypescriptSchema(processed: ProcessedDocument): Promise<string | undefined>;
3
3
  //# sourceMappingURL=get-typescript-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-typescript-schema.d.ts","sourceRoot":"","sources":["../../src/utils/get-typescript-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAa7B"}
1
+ {"version":3,"file":"get-typescript-schema.d.ts","sourceRoot":"","sources":["../../src/utils/get-typescript-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAY7B"}
@@ -1,10 +1,9 @@
1
1
  import { compile } from '@fumari/json-schema-to-typescript';
2
- export async function getTypescriptSchema(schema, dereferenceMap) {
2
+ export async function getTypescriptSchema(processed) {
3
3
  try {
4
- const cloned = structuredClone({ schema, dereferenceMap });
5
- return await compile(cloned.schema, 'Response', {
4
+ const cloned = structuredClone(processed.bundled);
5
+ return await compile(cloned, 'Response', {
6
6
  $refOptions: false,
7
- schemaToId: cloned.dereferenceMap,
8
7
  bannerComment: '',
9
8
  additionalProperties: false,
10
9
  enableConstEnums: false,
@@ -1,10 +1,16 @@
1
- import type { DereferenceMap, Document } from '../types.js';
1
+ import type { Document } from '../types.js';
2
2
  import type { NoReference } from '../utils/schema.js';
3
3
  import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
4
4
  export type ProcessedDocument = {
5
- document: NoReference<Document>;
6
- dereferenceMap: DereferenceMap;
7
- downloaded: Document;
5
+ /**
6
+ * dereferenced document
7
+ */
8
+ dereferenced: NoReference<Document>;
9
+ /**
10
+ * Get raw object from dereference object
11
+ */
12
+ getRawRef: (obj: object) => string | undefined;
13
+ bundled: Document;
8
14
  };
9
15
  export declare function processDocumentCached(input: string | OpenAPIV3_1.Document | OpenAPIV3.Document): Promise<ProcessedDocument>;
10
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"process-document.d.ts","sourceRoot":"","sources":["../../src/utils/process-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,g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S,CAAC,QAAQ,GACxD,OAAO,CAAC,iBAAiB,CAAC,CA+B5B"}
@@ -1,5 +1,6 @@
1
- import { bundle, dereference, upgrade } from '@scalar/openapi-parser';
2
- import { fetchUrls, readFiles } from '@scalar/openapi-parser/plugins';
1
+ import { dereference, upgrade } from '@scalar/openapi-parser';
2
+ import { bundle } from '@scalar/json-magic/bundle';
3
+ import { fetchUrls, readFiles } from '@scalar/json-magic/bundle/plugins/node';
3
4
  const cache = new Map();
4
5
  export async function processDocumentCached(input) {
5
6
  if (typeof input !== 'string')
@@ -15,21 +16,30 @@ export async function processDocumentCached(input) {
15
16
  * process & reference input document to a Fumadocs OpenAPI compatible format
16
17
  */
17
18
  export async function processDocument(input) {
18
- const dereferenceMap = new Map();
19
- let document = await bundle(input, {
19
+ const document = await bundle(input, {
20
20
  plugins: [fetchUrls(), readFiles()],
21
- treeShake: false,
22
- });
23
- // upgrade
24
- document = upgrade(document).specification;
25
- const { schema: dereferenced } = await dereference(document, {
26
- onDereference({ ref, schema }) {
27
- dereferenceMap.set(schema, ref);
21
+ treeShake: true,
22
+ urlMap: true,
23
+ hooks: {
24
+ onResolveError(node) {
25
+ throw new Error(`Failed to resolve ${node.$ref}`);
26
+ },
28
27
  },
29
- });
28
+ }).then((v) => upgrade(v).specification);
29
+ /**
30
+ * Dereferenced value and its original `$ref` value
31
+ */
32
+ const dereferenceMap = new WeakMap();
30
33
  return {
31
- document: dereferenced,
32
- dereferenceMap,
33
- downloaded: document,
34
+ dereferenced: (await dereference(document, {
35
+ throwOnError: true,
36
+ onDereference({ schema, ref }) {
37
+ dereferenceMap.set(schema, ref);
38
+ },
39
+ })).schema,
40
+ getRawRef(obj) {
41
+ return dereferenceMap.get(obj);
42
+ },
43
+ bundled: document,
34
44
  };
35
45
  }
@@ -21,9 +21,9 @@ export function schemaToString(value, ctx) {
21
21
  return 'never';
22
22
  if (schema.title)
23
23
  return schema.title;
24
- const referenceName = ctx?.dereferenceMap.get(schema);
25
- if (referenceName)
26
- return referenceName.split('/').at(-1);
24
+ const rawRef = ctx?.getRawRef(schema);
25
+ if (rawRef)
26
+ return rawRef.split('/').at(-1);
27
27
  if (Array.isArray(schema.type)) {
28
28
  const members = new Set();
29
29
  const types = schema.type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "9.3.7",
3
+ "version": "9.3.9",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -50,7 +50,8 @@
50
50
  "@radix-ui/react-dialog": "^1.1.15",
51
51
  "@radix-ui/react-select": "^2.2.6",
52
52
  "@radix-ui/react-slot": "^1.2.3",
53
- "@scalar/openapi-parser": "0.18.3",
53
+ "@scalar/json-magic": "^0.4.2",
54
+ "@scalar/openapi-parser": "0.20.5",
54
55
  "ajv": "^8.17.1",
55
56
  "class-variance-authority": "^0.7.1",
56
57
  "github-slugger": "^2.0.0",
@@ -62,18 +63,17 @@
62
63
  "react-hook-form": "^7.62.0",
63
64
  "remark": "^15.0.1",
64
65
  "remark-rehype": "^11.1.2",
65
- "shiki": "^3.12.2",
66
- "tinyglobby": "^0.2.14",
66
+ "tinyglobby": "^0.2.15",
67
67
  "xml-js": "^1.6.11",
68
- "fumadocs-core": "15.7.10",
69
- "fumadocs-ui": "15.7.10"
68
+ "fumadocs-core": "15.7.12",
69
+ "fumadocs-ui": "15.7.12"
70
70
  },
71
71
  "devDependencies": {
72
- "@scalar/api-client-react": "^1.3.31",
72
+ "@scalar/api-client-react": "^1.3.37",
73
73
  "@types/js-yaml": "^4.0.9",
74
- "@types/node": "24.3.1",
74
+ "@types/node": "24.3.3",
75
75
  "@types/openapi-sampler": "^1.0.3",
76
- "@types/react": "^19.1.12",
76
+ "@types/react": "^19.1.13",
77
77
  "json-schema-typed": "^8.0.1",
78
78
  "openapi-types": "^12.1.3",
79
79
  "tailwindcss": "^4.1.13",