fumadocs-openapi 9.0.16 → 9.0.17

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.
@@ -67,6 +67,12 @@ interface BaseConfig extends GenerateOptions {
67
67
  * Output directory
68
68
  */
69
69
  output: string;
70
+ /**
71
+ * Custom function to convert names into file names.
72
+ *
73
+ * By default, it only escapes whitespaces and upper case (English) characters
74
+ */
75
+ slugify?: (name: string) => string;
70
76
  }
71
77
  export declare function generateFiles(options: Config): Promise<void>;
72
78
  export {};
@@ -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;;OAEG;IACH,IAAI,CAAC,EACD,CAAC,CACC,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,KACpC,MAAM,CAAC,GACZ,QAAQ,CAAC;CACd;AAED,UAA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Q,CAAC;CACd;AAED,UAAU,SAAU,SAAQ,UAAU;IACpC;;OAEG;IACH,GAAG,EAAE,KAAK,CAAC;IAEX;;OAEG;IACH,IAAI,CAAC,EACD,CAAC,CACC,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,KACpC,MAAM,CAAC,GACZ,QAAQ,CAAC;CACd;AAED,UAAU,UAAW,SAAQ,UAAU;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;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,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,eAAe,CAAC;AAE9D,UAAU,QAAQ;IAChB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACzB;AAED,UAAU,UAAW,SAAQ,eAAe;IAC1C;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAEzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BlE"}
@@ -26,14 +26,14 @@ export async function generateFiles(options) {
26
26
  await Promise.all(resolvedInputs.map((input) => generateFromDocument(input, options)));
27
27
  }
28
28
  async function generateFromDocument(pathOrUrl, options) {
29
- const { output, cwd = process.cwd() } = options;
29
+ const { output, cwd = process.cwd(), slugify = defaultSlugify } = options;
30
30
  let nameFn;
31
31
  if (!options.name || typeof options.name !== 'function') {
32
32
  const { algorithm = 'v2' } = options.name ?? {};
33
33
  nameFn = (output, document) => {
34
34
  if (options.per === 'tag') {
35
35
  const result = output;
36
- return getFilename(result.tag);
36
+ return slugify(result.tag);
37
37
  }
38
38
  if (options.per === 'file') {
39
39
  return isUrl(pathOrUrl)
@@ -52,7 +52,7 @@ async function generateFromDocument(pathOrUrl, options) {
52
52
  if (algorithm === 'v2' && hook.operationId) {
53
53
  return hook.operationId;
54
54
  }
55
- return getFilename(result.item.name);
55
+ return slugify(result.item.name);
56
56
  };
57
57
  }
58
58
  else {
@@ -81,7 +81,7 @@ async function generateFromDocument(pathOrUrl, options) {
81
81
  console.warn('When `groupBy` is set to `tag`, make sure a `tags` is defined for every operation schema.');
82
82
  tags = ['unknown'];
83
83
  }
84
- return tags.map((tag) => path.join(getFilename(tag), `${file}.mdx`));
84
+ return tags.map((tag) => path.join(slugify(tag), `${file}.mdx`));
85
85
  }
86
86
  return [`${file}.mdx`];
87
87
  }
@@ -142,7 +142,7 @@ function getOutputPathFromRoute(path) {
142
142
  })
143
143
  .join('/') ?? '');
144
144
  }
145
- function getFilename(s) {
145
+ function defaultSlugify(s) {
146
146
  return s.replace(/\s+/g, '-').toLowerCase();
147
147
  }
148
148
  async function dereference(pathOrDocument, options) {
@@ -45,7 +45,7 @@ export function Schema({ name, schema, required = false, readOnly = false, write
45
45
  }
46
46
  function propertyInfo(schema) {
47
47
  const fields = [];
48
- if (schema.default) {
48
+ if (schema.default !== undefined) {
49
49
  fields.push({
50
50
  key: 'Default',
51
51
  value: JSON.stringify(schema.default),
@@ -195,17 +195,17 @@ function isComplexType(schema) {
195
195
  }
196
196
  function getRange(value, min, exclusiveMin, max, exclusiveMax) {
197
197
  const out = [];
198
- if (min) {
198
+ if (min !== undefined) {
199
199
  out.push(`${min} <=`);
200
200
  }
201
- else if (exclusiveMin) {
201
+ else if (exclusiveMin !== undefined) {
202
202
  out.push(`${exclusiveMin} <`);
203
203
  }
204
204
  out.push(value);
205
- if (max) {
205
+ if (max !== undefined) {
206
206
  out.push(`<= ${max}`);
207
207
  }
208
- else if (exclusiveMax) {
208
+ else if (exclusiveMax !== undefined) {
209
209
  out.push(`< ${exclusiveMax}`);
210
210
  }
211
211
  if (out.length > 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "9.0.16",
3
+ "version": "9.0.17",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -78,8 +78,8 @@
78
78
  "openapi-types": "^12.1.3",
79
79
  "tailwindcss": "^4.1.11",
80
80
  "tsc-alias": "^1.8.16",
81
- "eslint-config-custom": "0.0.0",
82
- "tsconfig": "0.0.0"
81
+ "tsconfig": "0.0.0",
82
+ "eslint-config-custom": "0.0.0"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@scalar/api-client-react": "*",