fumadocs-openapi 5.1.0 → 5.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.
package/dist/index.d.ts CHANGED
@@ -155,7 +155,7 @@ interface ParameterSample {
155
155
  interface CodeSample {
156
156
  lang: string;
157
157
  label: string;
158
- source: string;
158
+ source?: string;
159
159
  }
160
160
 
161
161
  interface RouteInformation {
@@ -247,10 +247,10 @@ interface Config extends GenerateOptions {
247
247
  output: string;
248
248
  /**
249
249
  * tag: Generate a page for each tag
250
- *
251
250
  * file: Generate a page for each schema
251
+ * operation: Generate a page for each API endpoint/operation
252
252
  *
253
- * @defaultValue file
253
+ * @defaultValue 'operation'
254
254
  */
255
255
  per?: 'tag' | 'file' | 'operation';
256
256
  /**
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ function generateDocument(options) {
95
95
  if (imports) {
96
96
  out.push(imports);
97
97
  }
98
- out.push(pageContent(data, options.page));
98
+ out.push(pageContent(options.page));
99
99
  return out.join('\n\n');
100
100
  }
101
101
  function generateStaticData(dereferenced, props) {
@@ -131,26 +131,8 @@ function generateStaticData(dereferenced, props) {
131
131
  structuredData
132
132
  };
133
133
  }
134
- function pageContent(data, props) {
135
- // modify toc and structured data if possible
136
- // it may not be compatible with other content sources except Fumadocs MDX
137
- // TODO: Maybe add to frontmatter and let developers to handle them?
138
- return `<APIPage document={${JSON.stringify(props.document)}} operations={${JSON.stringify(props.operations)}} hasHead={${JSON.stringify(props.hasHead)}} />
139
-
140
- export function startup() {
141
- if (typeof toc !== 'undefined') {
142
- // toc might be immutable
143
- while (toc.length > 0) toc.pop()
144
- toc.push(...${JSON.stringify(data.toc)})
145
- }
146
-
147
- if (typeof structuredData !== 'undefined') {
148
- structuredData.headings = ${JSON.stringify(data.structuredData.headings)}
149
- structuredData.contents = ${JSON.stringify(data.structuredData.contents)}
150
- }
151
- }
152
-
153
- {startup()}`;
134
+ function pageContent(props) {
135
+ return `<APIPage document={${JSON.stringify(props.document)}} operations={${JSON.stringify(props.operations)}} hasHead={${JSON.stringify(props.hasHead)}} />`;
154
136
  }
155
137
 
156
138
  async function dereference(pathOrDocument, options) {
@@ -257,7 +239,7 @@ async function generateTags(pathOrDocument, options = {}) {
257
239
  }
258
240
 
259
241
  async function generateFiles(options) {
260
- const { input, output, name: nameFn, per = 'file', groupBy = 'none', cwd = process.cwd() } = options;
242
+ const { input, output, name: nameFn, per = 'operation', groupBy = 'none', cwd = process.cwd() } = options;
261
243
  const outputDir = join(cwd, output);
262
244
  const urlInputs = [];
263
245
  const fileInputs = [];
@@ -156,7 +156,7 @@ interface ParameterSample {
156
156
  interface CodeSample {
157
157
  lang: string;
158
158
  label: string;
159
- source: string;
159
+ source?: string;
160
160
  }
161
161
 
162
162
  type Awaitable<T> = T | Promise<T>;
@@ -765,7 +765,7 @@ async function APIExample({ method, endpoint, ctx }) {
765
765
  },
766
766
  ...ctx.generateCodeSamples ? await ctx.generateCodeSamples(endpoint) : [],
767
767
  ...method['x-codeSamples'] ?? []
768
- ]);
768
+ ]).filter((item)=>item.source !== undefined);
769
769
  children.push(/*#__PURE__*/ jsx(renderer.Requests, {
770
770
  items: samples.map((s)=>s.label),
771
771
  children: samples.map((s)=>/*#__PURE__*/ jsx(renderer.Request, {
@@ -1090,8 +1090,6 @@ function getBadgeColor(method) {
1090
1090
  if ('_openapi' in data && typeof data._openapi === 'object') {
1091
1091
  const meta = data._openapi;
1092
1092
  method = meta.method;
1093
- } else if ('method' in data && typeof data.method === 'string') {
1094
- method = data.method;
1095
1093
  }
1096
1094
  if (method) {
1097
1095
  const color = getBadgeColor(method);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "5.1.0",
3
+ "version": "5.2.1",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -54,18 +54,18 @@
54
54
  "github-slugger": "^2.0.0",
55
55
  "js-yaml": "^4.1.0",
56
56
  "json-schema-to-typescript": "^15.0.0",
57
- "lucide-react": "^0.427.0",
57
+ "lucide-react": "^0.428.0",
58
58
  "openapi-sampler": "^1.5.1",
59
59
  "react-hook-form": "^7.52.2",
60
60
  "remark": "^15.0.0",
61
- "shiki": "^1.12.1",
61
+ "shiki": "^1.13.0",
62
62
  "swr": "^2.2.5",
63
- "fumadocs-core": "13.2.1",
64
- "fumadocs-ui": "13.2.1"
63
+ "fumadocs-core": "13.3.0",
64
+ "fumadocs-ui": "13.3.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/js-yaml": "^4.0.9",
68
- "@types/node": "20.14.12",
68
+ "@types/node": "22.3.0",
69
69
  "@types/openapi-sampler": "^1.0.3",
70
70
  "@types/react": "^18.3.3",
71
71
  "bunchee": "^5.3.2",