fumadocs-openapi 9.1.13 → 9.2.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.
@@ -1,5 +1,6 @@
1
1
  import { type GenerateOptions, type GeneratePageOutput, type GenerateTagOutput } from './generate.js';
2
2
  import { type ProcessedDocument } from './utils/process-document.js';
3
+ import type { OpenAPIServer } from './server/index.js';
3
4
  interface GenerateFileOutput {
4
5
  /**
5
6
  * The original schema file path/url from `input`
@@ -60,9 +61,9 @@ interface BaseName {
60
61
  }
61
62
  interface BaseConfig extends GenerateOptions {
62
63
  /**
63
- * Schema files
64
+ * Schema files, or the OpenAPI server object
64
65
  */
65
- input: string[] | string;
66
+ input: string[] | string | OpenAPIServer;
66
67
  /**
67
68
  * Output directory
68
69
  */
@@ -1 +1 @@
1
- {"version":3,"file":"generate-file.d.ts","sourceRoot":"","sources":["../src/generate-file.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EAEvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAElC,UAAU,kBAAkB;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,eAAgB,SAAQ,UAAU;IAC1C;;OAEG;IACH,GAAG,CAAC,EAAE,WAAW,CAAC;IAElB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAEnC;;OAEG;IACH,IAAI,CAAC,EACD,CAAC,CACC,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,KACpC,MAAM,CAAC,GACZ,QAAQ,CAAC;CACd;AAED,UAAU,SAAU,SAAQ,UAAU;IACpC;;OAEG;IACH,GAAG,EAAE,KAAK,CAAC;IAEX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E"}
@@ -1,32 +1,39 @@
1
1
  import { mkdir, writeFile } from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
- import { resolve } from 'node:path';
4
3
  import { glob } from 'tinyglobby';
5
4
  import { generateAll, generatePages, generateTags, } from './generate.js';
6
5
  import { processDocument, } from './utils/process-document.js';
7
6
  export async function generateFiles(options) {
8
- const { input, cwd = process.cwd() } = options;
9
- const urlInputs = [];
10
- const fileInputs = [];
11
- for (const v of typeof input === 'string' ? [input] : input) {
12
- if (isUrl(v)) {
13
- urlInputs.push(v);
14
- }
15
- else {
16
- fileInputs.push(v);
7
+ const { cwd = process.cwd() } = options;
8
+ const input = typeof options.input === 'string' ? [options.input] : options.input;
9
+ let schemas = {};
10
+ if (Array.isArray(input)) {
11
+ const targets = [];
12
+ const patterns = [];
13
+ for (const item of input) {
14
+ if (isUrl(item))
15
+ targets.push(item);
16
+ else
17
+ patterns.push(item);
17
18
  }
19
+ if (patterns.length > 0)
20
+ targets.push(...(await glob(patterns, { cwd })));
21
+ await Promise.all(targets.map(async (item) => {
22
+ schemas[item] = await processDocument(path.join(cwd, item));
23
+ }));
24
+ }
25
+ else {
26
+ schemas = await input.getSchemas();
18
27
  }
19
- const resolvedInputs = [
20
- ...(await glob(fileInputs, { cwd, absolute: false })),
21
- ...urlInputs,
22
- ];
23
- if (resolvedInputs.length === 0) {
24
- throw new Error(`No input files found. Tried resolving: ${typeof input === 'string' ? input : input.join(', ')}`);
28
+ const resolvedSchemas = Object.entries(schemas);
29
+ if (resolvedSchemas.length === 0) {
30
+ throw new Error('No input files found.');
25
31
  }
26
- await Promise.all(resolvedInputs.map((input) => generateFromDocument(input, options)));
32
+ await Promise.all(resolvedSchemas.map(([id, document]) => generateFromDocument(id, document, options)));
27
33
  }
28
- async function generateFromDocument(pathOrUrl, options) {
34
+ async function generateFromDocument(schemaId, document, options) {
29
35
  const { output, cwd = process.cwd(), slugify = defaultSlugify } = options;
36
+ const outputDir = path.join(cwd, output);
30
37
  let nameFn;
31
38
  if (!options.name || typeof options.name !== 'function') {
32
39
  const { algorithm = 'v2' } = options.name ?? {};
@@ -36,9 +43,9 @@ async function generateFromDocument(pathOrUrl, options) {
36
43
  return slugify(result.tag);
37
44
  }
38
45
  if (options.per === 'file') {
39
- return isUrl(pathOrUrl)
46
+ return isUrl(schemaId)
40
47
  ? 'index'
41
- : path.basename(pathOrUrl, path.extname(pathOrUrl));
48
+ : path.basename(schemaId, path.extname(schemaId));
42
49
  }
43
50
  const result = output;
44
51
  if (result.type === 'operation') {
@@ -58,8 +65,6 @@ async function generateFromDocument(pathOrUrl, options) {
58
65
  else {
59
66
  nameFn = options.name;
60
67
  }
61
- const document = await dereference(pathOrUrl, options);
62
- const outputDir = path.join(cwd, output);
63
68
  async function write(file, content) {
64
69
  await mkdir(path.dirname(file), { recursive: true });
65
70
  await writeFile(file, content);
@@ -86,9 +91,9 @@ async function generateFromDocument(pathOrUrl, options) {
86
91
  return [`${file}.mdx`];
87
92
  }
88
93
  if (options.per === 'file') {
89
- const result = await generateAll(pathOrUrl, document, options);
94
+ const result = await generateAll(schemaId, document, options);
90
95
  const filename = nameFn({
91
- pathOrUrl,
96
+ pathOrUrl: schemaId,
92
97
  content: result,
93
98
  }, document.document);
94
99
  const outPath = path.join(outputDir, `${filename}.mdx`);
@@ -96,7 +101,7 @@ async function generateFromDocument(pathOrUrl, options) {
96
101
  console.log(`Generated: ${outPath}`);
97
102
  }
98
103
  else if (options.per === 'tag') {
99
- const results = await generateTags(pathOrUrl, document, options);
104
+ const results = await generateTags(schemaId, document, options);
100
105
  for (const result of results) {
101
106
  const filename = nameFn(result, document.document);
102
107
  const outPath = path.join(outputDir, `${filename}.mdx`);
@@ -105,7 +110,7 @@ async function generateFromDocument(pathOrUrl, options) {
105
110
  }
106
111
  }
107
112
  else {
108
- const results = await generatePages(pathOrUrl, document, options);
113
+ const results = await generatePages(schemaId, document, options);
109
114
  const mapping = new Map();
110
115
  for (const result of results) {
111
116
  for (const outputPath of getOutputPaths(options.groupBy, result)) {
@@ -145,12 +150,3 @@ function getOutputPathFromRoute(path) {
145
150
  function defaultSlugify(s) {
146
151
  return s.replace(/\s+/g, '-').toLowerCase();
147
152
  }
148
- async function dereference(pathOrDocument, options) {
149
- return processDocument(
150
- // resolve paths
151
- typeof pathOrDocument === 'string' &&
152
- !pathOrDocument.startsWith('http://') &&
153
- !pathOrDocument.startsWith('https://')
154
- ? resolve(options.cwd ?? process.cwd(), pathOrDocument)
155
- : pathOrDocument);
156
- }
@@ -1,6 +1,6 @@
1
1
  import { type DocumentContext } from './utils/generate-document.js';
2
2
  import type { OperationItem, WebhookItem } from './render/api-page.js';
3
- import type { DocumentInput, ProcessedDocument } from './utils/process-document.js';
3
+ import type { ProcessedDocument } from './utils/process-document.js';
4
4
  export interface GenerateOptions {
5
5
  /**
6
6
  * Additional imports of your MDX components.
@@ -36,6 +36,7 @@ export interface GenerateOptions {
36
36
  /**
37
37
  * Inline the entire OpenAPI document into the MDX file.
38
38
  *
39
+ * @deprecated Use the new `input` API on `createOpenAPI()` instead.
39
40
  * @defaultValue false
40
41
  */
41
42
  inlineDocument?: boolean;
@@ -53,7 +54,7 @@ export type GeneratePageOutput = {
53
54
  item: WebhookItem;
54
55
  content: string;
55
56
  };
56
- export declare function generateAll(input: DocumentInput, processed: ProcessedDocument, options?: GenerateOptions): Promise<string>;
57
- export declare function generatePages(input: DocumentInput, processed: ProcessedDocument, options?: GenerateOptions): Promise<GeneratePageOutput[]>;
58
- export declare function generateTags(input: DocumentInput, processed: ProcessedDocument, options?: GenerateOptions): Promise<GenerateTagOutput[]>;
57
+ export declare function generateAll(schemaId: string, processed: ProcessedDocument, options?: GenerateOptions): Promise<string>;
58
+ export declare function generatePages(schemaId: string, processed: ProcessedDocument, options?: GenerateOptions): Promise<GeneratePageOutput[]>;
59
+ export declare function generateTags(schemaId: string, processed: ProcessedDocument, options?: GenerateOptions): Promise<GenerateTagOutput[]>;
59
60
  //# sourceMappingURL=generate.d.ts.map
@@ -1 +1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B;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAiE/B;AAED,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAwC9B"}
package/dist/generate.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { getAPIPageItems } from './build-routes.js';
2
2
  import { generateDocument, } from './utils/generate-document.js';
3
3
  import { idToTitle } from './utils/id-to-title.js';
4
- export async function generateAll(input, processed, options = {}) {
4
+ export async function generateAll(schemaId, processed, options = {}) {
5
5
  const { document } = processed;
6
6
  const items = getAPIPageItems(document);
7
- return generateDocument(input, processed, {
7
+ return generateDocument(schemaId, processed, {
8
8
  operations: items.operations,
9
9
  webhooks: items.webhooks,
10
10
  hasHead: true,
@@ -16,7 +16,7 @@ export async function generateAll(input, processed, options = {}) {
16
16
  type: 'file',
17
17
  });
18
18
  }
19
- export async function generatePages(input, processed, options = {}) {
19
+ export async function generatePages(schemaId, processed, options = {}) {
20
20
  const { document } = processed;
21
21
  const items = getAPIPageItems(document);
22
22
  const result = [];
@@ -30,7 +30,7 @@ export async function generatePages(input, processed, options = {}) {
30
30
  result.push({
31
31
  type: 'operation',
32
32
  item,
33
- content: generateDocument(input, processed, {
33
+ content: generateDocument(schemaId, processed, {
34
34
  operations: [item],
35
35
  hasHead: false,
36
36
  }, {
@@ -54,7 +54,7 @@ export async function generatePages(input, processed, options = {}) {
54
54
  result.push({
55
55
  type: 'webhook',
56
56
  item,
57
- content: generateDocument(input, processed, {
57
+ content: generateDocument(schemaId, processed, {
58
58
  webhooks: [item],
59
59
  hasHead: false,
60
60
  }, {
@@ -68,7 +68,7 @@ export async function generatePages(input, processed, options = {}) {
68
68
  }
69
69
  return result;
70
70
  }
71
- export async function generateTags(input, processed, options = {}) {
71
+ export async function generateTags(schemaId, processed, options = {}) {
72
72
  const { document } = processed;
73
73
  if (!document.tags)
74
74
  return [];
@@ -81,7 +81,7 @@ export async function generateTags(input, processed, options = {}) {
81
81
  : idToTitle(tag.name);
82
82
  return {
83
83
  tag: tag.name,
84
- content: generateDocument(input, processed, {
84
+ content: generateDocument(schemaId, processed, {
85
85
  operations,
86
86
  webhooks,
87
87
  hasHead: true,
@@ -1,21 +1,15 @@
1
1
  import type { RenderContext } from '../types.js';
2
- import { type Renderer } from '../render/renderer.js';
3
2
  import type { OpenAPIV3_1 } from 'openapi-types';
4
- import { type DocumentInput, type ProcessedDocument } from '../utils/process-document.js';
5
- type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema' | 'disablePlayground' | 'mediaAdapters'>;
6
- export interface ApiPageProps extends ApiPageContextProps {
7
- document: DocumentInput;
3
+ import { type ProcessedDocument } from '../utils/process-document.js';
4
+ import type { SharedOpenAPIOptions } from '../server/index.js';
5
+ export interface ApiPageProps extends SharedOpenAPIOptions {
6
+ document: Promise<ProcessedDocument> | string | ProcessedDocument;
8
7
  hasHead: boolean;
9
- renderer?: Partial<Renderer>;
10
8
  /**
11
9
  * An array of operations
12
10
  */
13
11
  operations?: OperationItem[];
14
12
  webhooks?: WebhookItem[];
15
- /**
16
- * By default, it is disabled on dev mode
17
- */
18
- disableCache?: boolean;
19
13
  }
20
14
  export interface WebhookItem {
21
15
  name: string;
@@ -26,8 +20,5 @@ export interface OperationItem {
26
20
  method: OpenAPIV3_1.HttpMethods;
27
21
  }
28
22
  export declare function APIPage(props: ApiPageProps): Promise<import("react/jsx-runtime").JSX.Element>;
29
- export declare function getContext(schema: ProcessedDocument, options?: ApiPageContextProps & {
30
- renderer?: Partial<Renderer>;
31
- }): Promise<RenderContext>;
32
- export {};
23
+ export declare function getContext(schema: ProcessedDocument, options?: SharedOpenAPIOptions): Promise<RenderContext>;
33
24
  //# sourceMappingURL=api-page.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-page.d.ts","sourceRoot":"","sources":["../../src/render/api-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,KAAK,mBAAmB,GAAG,IAAI,CAC7B,OAAO,CAAC,aAAa,CAAC,EACpB,cAAc,GACd,0BAA0B,GAC1B,qBAAqB,GACrB,UAAU,GACV,oBAAoB,GACpB,mBAAmB,GACnB,eAAe,CAClB,CAAC;AAEF,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE7B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WA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D;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,aAAa,CAAC,CA0BxB"}
@@ -6,8 +6,10 @@ import { createRenders } from '../render/renderer.js';
6
6
  import { processDocument, } from '../utils/process-document.js';
7
7
  import { defaultAdapters } from '../media/adapter.js';
8
8
  export async function APIPage(props) {
9
- const { operations, hasHead = true, webhooks, disableCache = process.env.NODE_ENV === 'development', } = props;
10
- const processed = await processDocument(props.document, disableCache);
9
+ const { operations, hasHead = true, webhooks } = props;
10
+ const processed = typeof props.document === 'string'
11
+ ? await processDocument(props.document)
12
+ : await props.document;
11
13
  const ctx = await getContext(processed, props);
12
14
  const { document } = processed;
13
15
  return (_jsxs(ctx.renderer.Root, { ctx: ctx, children: [operations?.map((item) => {
@@ -1,11 +1,72 @@
1
1
  import type { ApiPageProps } from '../render/api-page.js';
2
2
  import { createProxy } from '../server/proxy.js';
3
3
  import type { CodeSample } from '../render/operation/index.js';
4
- export type OpenAPIOptions = Omit<Partial<ApiPageProps>, 'document'>;
4
+ import type { Renderer } from '../render/renderer.js';
5
+ import type { NoReference } from '../utils/schema.js';
6
+ import type { BuiltinTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from 'shiki';
7
+ import type { MediaAdapter } from '../media/adapter.js';
8
+ import type { MethodInformation } from '../types.js';
9
+ import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
10
+ import { type ProcessedDocument } from '../utils/process-document.js';
11
+ type Awaitable<T> = T | Promise<T>;
12
+ /**
13
+ * schema id -> downloaded schema object
14
+ */
15
+ type SchemaMap = Record<string, OpenAPIV3_1.Document | OpenAPIV3.Document>;
16
+ type ProcessedSchemaMap = Record<string, ProcessedDocument>;
17
+ export interface SharedOpenAPIOptions {
18
+ /**
19
+ * The url of proxy to avoid CORS issues
20
+ */
21
+ proxyUrl?: string;
22
+ renderer?: Partial<Renderer>;
23
+ /**
24
+ * Disable API Playground
25
+ *
26
+ * @defaultValue false
27
+ */
28
+ disablePlayground?: boolean;
29
+ /**
30
+ * Generate TypeScript definitions from response schema.
31
+ *
32
+ * Pass `false` to disable it.
33
+ *
34
+ * @param method - the operation object
35
+ * @param statusCode - status code
36
+ */
37
+ generateTypeScriptSchema?: ((method: NoReference<MethodInformation>, statusCode: string) => Awaitable<string>) | false;
38
+ /**
39
+ * Generate code samples for endpoint.
40
+ */
41
+ generateCodeSamples?: (method: MethodInformation) => Awaitable<CodeSample[]>;
42
+ shikiOptions?: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BuiltinTheme>;
43
+ /**
44
+ * Show full response schema instead of only example response & Typescript definitions
45
+ *
46
+ * @default true
47
+ */
48
+ showResponseSchema?: boolean;
49
+ mediaAdapters?: Record<string, MediaAdapter>;
50
+ }
51
+ export interface OpenAPIOptions extends SharedOpenAPIOptions {
52
+ /**
53
+ * Schema files, can be:
54
+ * - URL
55
+ * - file path
56
+ * - a function returning records of downloaded schemas.
57
+ */
58
+ input?: string[] | (() => Promise<SchemaMap>);
59
+ /**
60
+ * By default, it is disabled on dev mode
61
+ */
62
+ disableCache?: boolean;
63
+ }
5
64
  export interface OpenAPIServer {
6
65
  getAPIPageProps: (from: ApiPageProps) => ApiPageProps;
7
66
  createProxy: typeof createProxy;
67
+ getSchemas: () => Promise<ProcessedSchemaMap>;
8
68
  }
9
69
  export declare function createOpenAPI(options?: OpenAPIOptions): OpenAPIServer;
10
70
  export declare function createCodeSample<T>(options: CodeSample<T>): CodeSample;
71
+ export {};
11
72
  //# sourceMappingURL=create.d.ts.map
@@ -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;AA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wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAEtE"}
@@ -1,11 +1,36 @@
1
1
  import { createProxy } from '../server/proxy.js';
2
+ import { processDocument, } from '../utils/process-document.js';
2
3
  export function createOpenAPI(options = {}) {
4
+ const { input = [], disableCache = process.env.NODE_ENV === 'development', ...shared } = options;
5
+ let schemas;
6
+ async function getSchemas() {
7
+ const out = {};
8
+ if (Array.isArray(input)) {
9
+ await Promise.all(input.map(async (item) => {
10
+ out[item] = await processDocument(item, disableCache);
11
+ }));
12
+ }
13
+ else {
14
+ await Promise.all(Object.entries(await input()).map(async ([k, v]) => {
15
+ out[k] = await processDocument(v, disableCache);
16
+ }));
17
+ }
18
+ return out;
19
+ }
3
20
  return {
4
21
  createProxy,
5
- getAPIPageProps(props) {
22
+ async getSchemas() {
23
+ return (schemas ?? (schemas = getSchemas()));
24
+ },
25
+ getAPIPageProps({ document, ...props }) {
6
26
  return {
7
- ...options,
27
+ ...shared,
8
28
  ...props,
29
+ document: typeof document === 'string'
30
+ ? this.getSchemas().then((map) => {
31
+ return map[document] ?? processDocument(document, disableCache);
32
+ })
33
+ : document,
9
34
  };
10
35
  },
11
36
  };
@@ -1,9 +1,10 @@
1
1
  import type { PageTree } from 'fumadocs-core/server';
2
- import type { PageFile } from 'fumadocs-core/source';
2
+ import type { PageFile, PageTreeTransformer } from 'fumadocs-core/source';
3
3
  /**
4
4
  * Source API Integration
5
5
  *
6
6
  * Add this to page tree builder options
7
7
  */
8
8
  export declare const attachFile: (node: PageTree.Item, file: PageFile | undefined) => PageTree.Item;
9
+ export declare function transformerOpenAPI(): PageTreeTransformer;
9
10
  //# sourceMappingURL=source-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-api.d.ts","sourceRoot":"","sources":["../../src/server/source-api.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,QAAQ,CAAC,IAAI,EACnB,MAAM,QAAQ,GAAG,SAAS,KACzB,QAAQ,CAAC,IA4BX,CAAC"}
1
+ {"version":3,"file":"source-api.d.ts","sourceRoot":"","sources":["../../src/server/source-api.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,QAAQ,CAAC,IAAI,EACnB,MAAM,QAAQ,GAAG,SAAS,KACzB,QAAQ,CAAC,IA4BX,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,mBAAmB,CASxD"}
@@ -22,3 +22,13 @@ export const attachFile = (node, file) => {
22
22
  }
23
23
  return node;
24
24
  };
25
+ export function transformerOpenAPI() {
26
+ return {
27
+ file(node, file) {
28
+ if (!file)
29
+ return node;
30
+ const content = this.storage.read(file);
31
+ return attachFile(node, content?.format === 'page' ? content : undefined);
32
+ },
33
+ };
34
+ }
package/dist/types.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import type { OpenAPIV3_1 as V3_1 } from 'openapi-types';
2
2
  import type { default as Slugger } from 'github-slugger';
3
3
  import { type Renderer } from './render/renderer.js';
4
- import type { CodeSample } from './render/operation/index.js';
5
- import type { BuiltinTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from 'shiki';
6
4
  import type { NoReference } from './utils/schema.js';
7
5
  import type { ProcessedDocument } from './utils/process-document.js';
8
6
  import type { MediaAdapter } from './media/adapter.js';
7
+ import type { SharedOpenAPIOptions } from './server/index.js';
9
8
  export type Document = V3_1.Document;
10
9
  export type OperationObject = V3_1.OperationObject;
11
10
  export type ParameterObject = V3_1.ParameterObject;
@@ -20,48 +19,18 @@ export type ServerVariableObject = NoReference<V3_1.ServerVariableObject>;
20
19
  export type MethodInformation = NoReference<OperationObject> & {
21
20
  method: string;
22
21
  };
23
- type Awaitable<T> = T | Promise<T>;
24
22
  /**
25
23
  * Dereferenced value and its original `$ref` value
26
24
  */
27
25
  export type DereferenceMap = Map<unknown, string>;
28
- export interface RenderContext {
29
- /**
30
- * The url of proxy to avoid CORS issues
31
- */
32
- proxyUrl?: string;
26
+ export interface RenderContext extends SharedOpenAPIOptions {
33
27
  renderer: Renderer;
34
- /**
35
- * Disable API Playground
36
- */
37
- disablePlayground?: boolean;
38
28
  servers: ServerObject[];
39
29
  slugger: Slugger;
40
30
  /**
41
31
  * dereferenced schema
42
32
  */
43
33
  schema: ProcessedDocument;
44
- /**
45
- * Generate TypeScript definitions from response schema.
46
- *
47
- * Pass `false` to disable it.
48
- *
49
- * @param method - the operation object
50
- * @param statusCode - status code
51
- */
52
- generateTypeScriptSchema?: ((method: NoReference<MethodInformation>, statusCode: string) => Awaitable<string>) | false;
53
- /**
54
- * Generate code samples for endpoint.
55
- */
56
- generateCodeSamples?: (method: MethodInformation) => Awaitable<CodeSample[]>;
57
- shikiOptions?: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BuiltinTheme>;
58
- /**
59
- * Show full response schema instead of only example response & Typescript definitions
60
- *
61
- * @default true
62
- */
63
- showResponseSchema?: boolean;
64
34
  mediaAdapters: Record<string, MediaAdapter>;
65
35
  }
66
- export {};
67
36
  //# sourceMappingURL=types.d.ts.map
@@ -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,OAA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../generate.js';
3
3
  import type { TagObject } from '../types.js';
4
- import type { DocumentInput, ProcessedDocument } from '../utils/process-document.js';
4
+ import type { ProcessedDocument } from '../utils/process-document.js';
5
5
  export type DocumentContext = {
6
6
  type: 'tag';
7
7
  tag: TagObject | undefined;
@@ -10,7 +10,7 @@ export type DocumentContext = {
10
10
  } | {
11
11
  type: 'file';
12
12
  };
13
- export declare function generateDocument(input: DocumentInput, processed: ProcessedDocument, pageProps: Omit<ApiPageProps, 'document'>, options: GenerateOptions & {
13
+ export declare function generateDocument(schemaId: string, processed: ProcessedDocument, pageProps: Omit<ApiPageProps, 'document'>, options: GenerateOptions & {
14
14
  title: string;
15
15
  description?: string;
16
16
  }, context: DocumentContext): string;
@@ -1 +1 @@
1
- {"version":3,"file":"generate-document.d.ts","sourceRoot":"","sources":["../../src/utils/generate-document.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAOlC,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,SAAS,GAAG,SAAS,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EACzC,OAAO,EAAE,eAAe,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EACD,OAAO,EAAE,eAAe,GACvB,MAAM,CAkER"}
1
+ {"version":3,"file":"generate-document.d.ts","sourceRoot":"","sources":["../../src/utils/generate-document.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAOlE,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,SAAS,GAAG,SAAS,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EACzC,OAAO,EAAE,eAAe,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,EACD,OAAO,EAAE,eAAe,GACvB,MAAM,CAkER"}
@@ -1,13 +1,13 @@
1
1
  import { dump } from 'js-yaml';
2
2
  import Slugger from 'github-slugger';
3
3
  import { idToTitle } from '../utils/id-to-title.js';
4
- export function generateDocument(input, processed, pageProps, options, context) {
4
+ export function generateDocument(schemaId, processed, pageProps, options, context) {
5
5
  const { frontmatter, includeDescription = false, addGeneratedComment = true, } = options;
6
6
  const out = [];
7
7
  const extend = frontmatter?.(options.title, options.description, context);
8
8
  const page = {
9
9
  ...pageProps,
10
- document: options.inlineDocument ? processed.downloaded : input,
10
+ document: schemaId,
11
11
  };
12
12
  let meta;
13
13
  if (page.operations?.length === 1) {
@@ -1,7 +1,6 @@
1
1
  import type { DereferenceMap, Document } from '../types.js';
2
2
  import type { NoReference } from '../utils/schema.js';
3
3
  import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
4
- export type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
5
4
  export type ProcessedDocument = {
6
5
  document: NoReference<Document>;
7
6
  dereferenceMap: DereferenceMap;
@@ -10,5 +9,5 @@ export type ProcessedDocument = {
10
9
  /**
11
10
  * process & reference input document to a Fumadocs OpenAPI compatible format
12
11
  */
13
- export declare function processDocument(input: DocumentInput, disableCache?: boolean): Promise<ProcessedDocument>;
12
+ export declare function processDocument(input: string | OpenAPIV3_1.Document | OpenAPIV3.Document, disableCache?: boolean): Promise<ProcessedDocument>;
14
13
  //# sourceMappingURL=process-document.d.ts.map
@@ -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,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;AAE/E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC;CACtB,CAAC;AAIF;;GAEG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,aAAa,EACpB,YAAY,UAAQ,GACnB,OAAO,CAAC,iBAAiB,CAAC,CA+B5B"}
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,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,QAAQ,CAAC;CACtB,CAAC;AAIF;;GAEG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,EACzD,YAAY,UAAQ,GACnB,OAAO,CAAC,iBAAiB,CAAC,CA+B5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "9.1.13",
3
+ "version": "9.2.1",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -46,9 +46,9 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@fumari/json-schema-to-typescript": "^1.1.3",
49
- "@radix-ui/react-accordion": "^1.2.11",
50
- "@radix-ui/react-dialog": "^1.1.14",
51
- "@radix-ui/react-select": "^2.2.5",
49
+ "@radix-ui/react-accordion": "^1.2.12",
50
+ "@radix-ui/react-dialog": "^1.1.15",
51
+ "@radix-ui/react-select": "^2.2.6",
52
52
  "@radix-ui/react-slot": "^1.2.3",
53
53
  "@scalar/openapi-parser": "0.18.3",
54
54
  "ajv": "^8.17.1",
@@ -61,21 +61,21 @@
61
61
  "react-hook-form": "^7.62.0",
62
62
  "remark": "^15.0.1",
63
63
  "remark-rehype": "^11.1.2",
64
- "shiki": "^3.9.2",
64
+ "shiki": "^3.11.0",
65
65
  "tinyglobby": "^0.2.14",
66
66
  "xml-js": "^1.6.11",
67
- "fumadocs-ui": "15.6.11",
68
- "fumadocs-core": "15.6.11"
67
+ "fumadocs-core": "15.7.0",
68
+ "fumadocs-ui": "15.7.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@scalar/api-client-react": "^1.3.27",
72
72
  "@types/js-yaml": "^4.0.9",
73
- "@types/node": "24.2.1",
73
+ "@types/node": "24.3.0",
74
74
  "@types/openapi-sampler": "^1.0.3",
75
75
  "@types/react": "^19.1.10",
76
76
  "json-schema-typed": "^8.0.1",
77
77
  "openapi-types": "^12.1.3",
78
- "tailwindcss": "^4.1.11",
78
+ "tailwindcss": "^4.1.12",
79
79
  "tsc-alias": "^1.8.16",
80
80
  "eslint-config-custom": "0.0.0",
81
81
  "tsconfig": "0.0.0"