fumadocs-openapi 10.3.2 → 10.3.3

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.
@@ -25,10 +25,10 @@ async function generateFilesOnly(options) {
25
25
  if (entries.length === 0) throw new Error("No input files found.");
26
26
  const preset = createAutoPreset(options);
27
27
  for (const [id, schema] of entries) {
28
- const entries$1 = fromSchema(id, schema, preset);
28
+ const entries = fromSchema(id, schema, preset);
29
29
  const schemaFiles = generated[id] ??= [];
30
- generatedEntries[id] = entries$1;
31
- for (const entry of entries$1) {
30
+ generatedEntries[id] = entries;
31
+ for (const entry of entries) {
32
32
  const file = {
33
33
  path: entry.path,
34
34
  content: toText(entry, schema, options)
@@ -54,9 +54,9 @@ function writeIndexFiles(files, context, options) {
54
54
  const getUrl = createGetUrl(url.baseUrl);
55
55
  urlFn = (file) => getUrl(getSlugs(path.relative(url.contentDir, file)));
56
56
  } else urlFn = url;
57
- function findEntryByPath(path$1) {
57
+ function findEntryByPath(path) {
58
58
  for (const entries of Object.values(generatedEntries)) {
59
- const match = entries.find((entry) => entry.path === path$1);
59
+ const match = entries.find((entry) => entry.path === path);
60
60
  if (match) return match;
61
61
  }
62
62
  }
@@ -177,7 +177,7 @@ function FieldInput({ field, fieldName, isRequired, ...props }) {
177
177
  }
178
178
  if (field.type === "boolean") return /* @__PURE__ */ jsxs(Select, {
179
179
  value: String(value),
180
- onValueChange: (value$1) => setValue(value$1 === "undefined" ? void 0 : value$1 === "true"),
180
+ onValueChange: (value) => setValue(value === "undefined" ? void 0 : value === "true"),
181
181
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
182
182
  id,
183
183
  ...props,
@@ -74,11 +74,11 @@ function OauthDialog({ scheme, scopes, setToken, children, open, setOpen }) {
74
74
  const params = new URLSearchParams(window.location.hash.slice(1));
75
75
  const state = params.get("state");
76
76
  const token = params.get("access_token");
77
- const type$1 = params.get("token_type") ?? "Bearer";
77
+ const type = params.get("token_type") ?? "Bearer";
78
78
  if (state && token) {
79
79
  const parsedState = JSON.parse(state);
80
80
  form.setValue("clientId", parsedState.client_id);
81
- setToken(`${type$1} ${token}`);
81
+ setToken(`${type} ${token}`);
82
82
  window.history.replaceState(null, "", window.location.pathname);
83
83
  }
84
84
  }
@@ -101,10 +101,10 @@ function Field({ fieldName, variable }) {
101
101
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
102
102
  id: fieldName,
103
103
  children: /* @__PURE__ */ jsx(SelectValue, {})
104
- }), /* @__PURE__ */ jsx(SelectContent, { children: variable.enum.map((value$1) => /* @__PURE__ */ jsx(SelectItem, {
105
- value: value$1,
106
- children: value$1
107
- }, value$1)) })]
104
+ }), /* @__PURE__ */ jsx(SelectContent, { children: variable.enum.map((value) => /* @__PURE__ */ jsx(SelectItem, {
105
+ value,
106
+ children: value
107
+ }, value)) })]
108
108
  });
109
109
  return /* @__PURE__ */ jsx(Input, {
110
110
  id: fieldName,
@@ -1,7 +1,6 @@
1
1
  import "../requests/types.js";
2
2
 
3
3
  //#region src/playground/fetcher.d.ts
4
-
5
4
  interface FetchResult {
6
5
  status: number;
7
6
  type: 'json' | 'html' | 'text';
@@ -1,6 +1,6 @@
1
1
  import { NoReference, ParsedSchema } from "../utils/schema.js";
2
2
  import { MethodInformation, ParameterObject, RenderContext, SecuritySchemeObject } from "../types.js";
3
- import * as react0 from "react";
3
+ import * as react from "react";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
 
6
6
  //#region src/playground/index.d.ts
@@ -21,6 +21,6 @@ declare function APIPlayground({
21
21
  path,
22
22
  method,
23
23
  ctx
24
- }: APIPlaygroundProps): Promise<string | number | bigint | boolean | Iterable<react0.ReactNode> | react_jsx_runtime0.JSX.Element | null | undefined>;
24
+ }: APIPlaygroundProps): Promise<string | number | bigint | boolean | react_jsx_runtime0.JSX.Element | Iterable<react.ReactNode> | null | undefined>;
25
25
  //#endregion
26
26
  export { APIPlayground, APIPlaygroundProps, ParameterField, SecurityEntry };
@@ -5,7 +5,6 @@ import { Ajv2020 } from "ajv/dist/2020";
5
5
  import { FieldKey } from "@fumari/stf";
6
6
 
7
7
  //#region src/playground/schema.d.ts
8
-
9
8
  interface SchemaScope {
10
9
  /**
11
10
  * show write only fields
@@ -2,7 +2,6 @@ import { CreateAPIPageOptions } from "../ui/full.js";
2
2
  import "../ui/index.js";
3
3
 
4
4
  //#region src/scalar/index.d.ts
5
-
6
5
  /**
7
6
  * Enable Scalar for API playgrounds by wrapping your options inside.
8
7
  *
@@ -4,7 +4,6 @@ import { ProcessedDocument } from "../utils/process-document.js";
4
4
  import { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
5
5
 
6
6
  //#region src/server/create.d.ts
7
-
8
7
  /**
9
8
  * schema id -> file path, URL, or downloaded schema object
10
9
  */
@@ -19,8 +19,8 @@ function createOpenAPI(options = {}) {
19
19
  options,
20
20
  createProxy,
21
21
  async getSchema(document) {
22
- const schemas$1 = await this.getSchemas();
23
- if (document in schemas$1) return schemas$1[document];
22
+ const schemas = await this.getSchemas();
23
+ if (document in schemas) return schemas[document];
24
24
  console.warn(`[Fumadocs OpenAPI] the document "${document}" is not listed in the input array, this may not be expected.`);
25
25
  return processDocument(document);
26
26
  },
package/dist/ui/base.js CHANGED
@@ -49,12 +49,12 @@ function createAPIPage(server, options) {
49
49
  ...options.mediaAdapters
50
50
  },
51
51
  slugger,
52
- renderHeading(depth, text, props$1) {
52
+ renderHeading(depth, text, props) {
53
53
  const id = slugger.slug(text);
54
54
  return /* @__PURE__ */ jsx(Heading, {
55
55
  id,
56
56
  as: `h${depth}`,
57
- ...props$1,
57
+ ...props,
58
58
  children: text
59
59
  }, id);
60
60
  },
@@ -70,7 +70,7 @@ function createAPIPage(server, options) {
70
70
  lang,
71
71
  ...options.shikiOptions,
72
72
  config: options.shiki,
73
- components: { pre: (props$1) => /* @__PURE__ */ jsx(Pre, { ...props$1 }) }
73
+ components: { pre: (props) => /* @__PURE__ */ jsx(Pre, { ...props }) }
74
74
  })
75
75
  });
76
76
  }
package/dist/ui/full.d.ts CHANGED
@@ -2,10 +2,10 @@ import { OpenAPIServer } from "../server/create.js";
2
2
  import { ApiPageProps } from "./api-page.js";
3
3
  import "../server/index.js";
4
4
  import { CreateAPIPageOptions as CreateAPIPageOptions$1 } from "./base.js";
5
- import * as react_jsx_runtime2 from "react/jsx-runtime";
5
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
6
6
 
7
7
  //#region src/ui/full.d.ts
8
8
  type CreateAPIPageOptions = Partial<CreateAPIPageOptions$1>;
9
- declare function createAPIPage(server: OpenAPIServer, options?: CreateAPIPageOptions): (props: ApiPageProps) => react_jsx_runtime2.JSX.Element;
9
+ declare function createAPIPage(server: OpenAPIServer, options?: CreateAPIPageOptions): (props: ApiPageProps) => react_jsx_runtime0.JSX.Element;
10
10
  //#endregion
11
11
  export { CreateAPIPageOptions, createAPIPage };
@@ -58,10 +58,10 @@ async function Operation({ type = "operation", path, method, ctx, showTitle, sho
58
58
  })]
59
59
  }),
60
60
  body.description && ctx.renderMarkdown(body.description),
61
- contentTypes.map(([type$1, content]) => {
62
- if (!isMediaTypeSupported(type$1, ctx.mediaAdapters)) throw new Error(`Media type ${type$1} is not supported (in ${path})`);
61
+ contentTypes.map(([type, content]) => {
62
+ if (!isMediaTypeSupported(type, ctx.mediaAdapters)) throw new Error(`Media type ${type} is not supported (in ${path})`);
63
63
  return /* @__PURE__ */ jsx(SelectTab, {
64
- value: type$1,
64
+ value: type,
65
65
  children: /* @__PURE__ */ jsx(Schema, {
66
66
  client: {
67
67
  name: "body",
@@ -73,7 +73,7 @@ async function Operation({ type = "operation", path, method, ctx, showTitle, sho
73
73
  writeOnly: method.method !== "GET",
74
74
  ctx
75
75
  })
76
- }, type$1);
76
+ }, type);
77
77
  })
78
78
  ]
79
79
  });
@@ -89,8 +89,8 @@ async function Operation({ type = "operation", path, method, ctx, showTitle, sho
89
89
  }, status))
90
90
  })] });
91
91
  }
92
- const parameterNode = Object.entries(ParamTypes).map(([type$1, title]) => {
93
- const params = method.parameters?.filter((param) => param.in === type$1);
92
+ const parameterNode = Object.entries(ParamTypes).map(([type, title]) => {
93
+ const params = method.parameters?.filter((param) => param.in === type);
94
94
  if (!params || params.length === 0) return;
95
95
  return /* @__PURE__ */ jsxs(Fragment, { children: [ctx.renderHeading(headingLevel, title), /* @__PURE__ */ jsx("div", {
96
96
  className: "flex flex-col",
@@ -108,7 +108,7 @@ async function Operation({ type = "operation", path, method, ctx, showTitle, sho
108
108
  writeOnly: method.method !== "GET",
109
109
  ctx
110
110
  }, param.name))
111
- })] }, type$1);
111
+ })] }, type);
112
112
  });
113
113
  const securities = (method.security ?? dereferenced.security ?? []).filter((v) => Object.keys(v).length > 0);
114
114
  if (type === "operation" && securities.length > 0) {
@@ -14,13 +14,13 @@ function getExampleRequests(path, operation, ctx) {
14
14
  if (bodyOfType?.examples) {
15
15
  const result = [];
16
16
  for (const [key, value] of Object.entries(bodyOfType.examples)) {
17
- const data$1 = getRequestData(path, operation, key, ctx);
17
+ const data = getRequestData(path, operation, key, ctx);
18
18
  result.push({
19
19
  id: key,
20
20
  name: value.summary || key,
21
21
  description: value.description,
22
- data: data$1,
23
- encoded: encodeRequestData(data$1, ctx.mediaAdapters, operation.parameters ?? [])
22
+ data,
23
+ encoded: encodeRequestData(data, ctx.mediaAdapters, operation.parameters ?? [])
24
24
  });
25
25
  }
26
26
  if (result.length > 0) return result;
@@ -18,12 +18,12 @@ function ResponseTabs({ operation, ctx }) {
18
18
  };
19
19
  if (responseOfType?.examples) {
20
20
  tab.examples ??= [];
21
- for (const [key, sample$1] of Object.entries(responseOfType.examples)) {
22
- const title = sample$1?.summary || `Example ${key}`;
21
+ for (const [key, sample] of Object.entries(responseOfType.examples)) {
22
+ const title = sample?.summary || `Example ${key}`;
23
23
  tab.examples.push({
24
24
  label: title,
25
- sample: sample$1.value,
26
- description: sample$1?.description
25
+ sample: sample.value,
26
+ description: sample?.description
27
27
  });
28
28
  }
29
29
  } else if (responseOfType?.example || responseOfType?.schema) {
@@ -17,10 +17,10 @@ function UsageTabsProvider({ route, examples, defaultExampleId, children }) {
17
17
  example,
18
18
  route,
19
19
  setExample: (newKey) => {
20
- const example$1 = examples.find((example$2) => example$2.id === newKey);
21
- if (!example$1) return;
20
+ const example = examples.find((example) => example.id === newKey);
21
+ if (!example) return;
22
22
  setExample(newKey);
23
- for (const listener of listeners.current) listener(example$1.data, example$1.encoded);
23
+ for (const listener of listeners.current) listener(example.data, example.encoded);
24
24
  },
25
25
  examples,
26
26
  setExampleData(data, encoded) {
@@ -17,15 +17,15 @@ async function UsageTabs({ method, ctx }) {
17
17
  ]
18
18
  });
19
19
  };
20
- renderAPIExampleUsageTabs ??= (generators$1) => {
21
- if (generators$1.length === 0) return null;
20
+ renderAPIExampleUsageTabs ??= (generators) => {
21
+ if (generators.length === 0) return null;
22
22
  return /* @__PURE__ */ jsxs(CodeBlockTabs, {
23
23
  groupId: "fumadocs_openapi_requests",
24
- defaultValue: generators$1[0].id,
25
- children: [/* @__PURE__ */ jsx(CodeBlockTabsList, { children: generators$1.map((item) => /* @__PURE__ */ jsx(CodeBlockTabsTrigger, {
24
+ defaultValue: generators[0].id,
25
+ children: [/* @__PURE__ */ jsx(CodeBlockTabsList, { children: generators.map((item) => /* @__PURE__ */ jsx(CodeBlockTabsTrigger, {
26
26
  value: item.id,
27
27
  children: item.label ?? item.lang
28
- }, item.id)) }), generators$1.map((item) => /* @__PURE__ */ jsx(CodeBlockTab, {
28
+ }, item.id)) }), generators.map((item) => /* @__PURE__ */ jsx(CodeBlockTab, {
29
29
  value: item.id,
30
30
  children: /* @__PURE__ */ jsx(UsageTabLazy, { ...item })
31
31
  }, item.id))]
@@ -146,7 +146,7 @@ function SchemaUIPopover({ initialPath }) {
146
146
  }, [last?.$ref]);
147
147
  const context = useMemo(() => ({ renderTrigger: ({ $ref, pathName, children }) => /* @__PURE__ */ jsx("button", {
148
148
  className: cn(typeVariants({ variant: "trigger" })),
149
- onClick: () => setPath((path$1) => [...path$1, {
149
+ onClick: () => setPath((path) => [...path, {
150
150
  name: pathName,
151
151
  $ref
152
152
  }]),
@@ -158,7 +158,7 @@ function SchemaUIPopover({ initialPath }) {
158
158
  children: path.map((item, i) => {
159
159
  const className = cn(path.some((other, j) => j < i && other.$ref === item.$ref) && "text-orange-400", item.$ref && "hover:underline hover:text-fd-accent-foreground");
160
160
  const node = item.$ref ? /* @__PURE__ */ jsx("button", {
161
- onClick: () => setPath((path$1) => path$1.slice(0, i + 1)),
161
+ onClick: () => setPath((path) => path.slice(0, i + 1)),
162
162
  className,
163
163
  children: item.name
164
164
  }) : /* @__PURE__ */ jsx("span", {
@@ -1,25 +1,25 @@
1
1
  //#region src/utils/schema-to-string.ts
2
- let FormatFlags = /* @__PURE__ */ function(FormatFlags$1) {
3
- FormatFlags$1[FormatFlags$1["None"] = 0] = "None";
4
- FormatFlags$1[FormatFlags$1["UseAlias"] = 1] = "UseAlias";
5
- return FormatFlags$1;
2
+ let FormatFlags = /* @__PURE__ */ function(FormatFlags) {
3
+ FormatFlags[FormatFlags["None"] = 0] = "None";
4
+ FormatFlags[FormatFlags["UseAlias"] = 1] = "UseAlias";
5
+ return FormatFlags;
6
6
  }({});
7
7
  function schemaToString(value, ctx, flags = FormatFlags.None) {
8
- function union(union$1, sep, flags$1) {
8
+ function union(union, sep, flags) {
9
9
  const members = /* @__PURE__ */ new Set();
10
10
  let nullable = false;
11
- for (const item of union$1) {
12
- const result$1 = run(item, flags$1 | FormatFlags.UseAlias);
13
- if (result$1 === "null") nullable = true;
14
- else if (result$1 !== "unknown") members.add(result$1);
11
+ for (const item of union) {
12
+ const result = run(item, flags | FormatFlags.UseAlias);
13
+ if (result === "null") nullable = true;
14
+ else if (result !== "unknown") members.add(result);
15
15
  }
16
16
  const result = Array.from(members).join(sep);
17
17
  return nullable ? `${result} | null` : result;
18
18
  }
19
- function run(schema, flags$1) {
19
+ function run(schema, flags) {
20
20
  if (schema === true) return "any";
21
21
  else if (schema === false) return "never";
22
- if ((flags$1 & FormatFlags.UseAlias) === FormatFlags.UseAlias) {
22
+ if ((flags & FormatFlags.UseAlias) === FormatFlags.UseAlias) {
23
23
  if (schema.title) return schema.title;
24
24
  const ref = ctx?.getRawRef(schema)?.split("/");
25
25
  if (ref && ref.length > 0) return ref[ref.length - 1];
@@ -27,13 +27,13 @@ function schemaToString(value, ctx, flags = FormatFlags.None) {
27
27
  if (Array.isArray(schema.type)) return union(schema.type.map((type) => ({
28
28
  ...schema,
29
29
  type
30
- })), " | ", flags$1);
31
- if (schema.type === "array") return `array<${schema.items ? run(schema.items, flags$1 | FormatFlags.UseAlias) : "unknown"}>`;
30
+ })), " | ", flags);
31
+ if (schema.type === "array") return `array<${schema.items ? run(schema.items, flags | FormatFlags.UseAlias) : "unknown"}>`;
32
32
  const or = schema.oneOf ?? schema.anyOf;
33
- if (schema.oneOf && schema.anyOf) return `(${union(schema.oneOf, " | ", flags$1)}) & (${union(schema.anyOf, " | ", flags$1)})`;
34
- else if (or) return union(or, " | ", flags$1);
35
- if (schema.allOf) return union(schema.allOf, " & ", flags$1);
36
- if (schema.not) return `not ${run(schema.not, flags$1)}`;
33
+ if (schema.oneOf && schema.anyOf) return `(${union(schema.oneOf, " | ", flags)}) & (${union(schema.anyOf, " | ", flags)})`;
34
+ else if (or) return union(or, " | ", flags);
35
+ if (schema.allOf) return union(schema.allOf, " & ", flags);
36
+ if (schema.not) return `not ${run(schema.not, flags)}`;
37
37
  if (schema.type === "string" && schema.format === "binary") return "file";
38
38
  if (schema.type && Array.isArray(schema.type)) return schema.type.filter((v) => v !== "null").join(" | ");
39
39
  if (schema.type) return schema.type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "10.3.2",
3
+ "version": "10.3.3",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "Docs",
@@ -61,8 +61,8 @@
61
61
  "@radix-ui/react-dialog": "^1.1.15",
62
62
  "@radix-ui/react-select": "^2.2.6",
63
63
  "@radix-ui/react-slot": "^1.2.4",
64
- "@scalar/json-magic": "^0.9.4",
65
- "@scalar/openapi-parser": "0.24.5",
64
+ "@scalar/json-magic": "^0.10.0",
65
+ "@scalar/openapi-parser": "0.24.8",
66
66
  "ajv": "^8.17.1",
67
67
  "class-variance-authority": "^0.7.1",
68
68
  "github-slugger": "^2.0.0",
@@ -76,33 +76,41 @@
76
76
  "remark-rehype": "^11.1.2",
77
77
  "tailwind-merge": "^3.4.0",
78
78
  "xml-js": "^1.6.11",
79
- "@fumari/stf": "^0.0.1"
79
+ "@fumari/stf": "^0.0.2"
80
80
  },
81
81
  "devDependencies": {
82
- "@scalar/api-client-react": "^1.3.82",
82
+ "@scalar/api-client-react": "^1.3.91",
83
83
  "@types/js-yaml": "^4.0.9",
84
- "@types/node": "25.1.0",
84
+ "@types/node": "25.2.1",
85
85
  "@types/openapi-sampler": "^1.0.3",
86
- "@types/react": "^19.2.10",
86
+ "@types/react": "^19.2.13",
87
87
  "json-schema-typed": "^8.0.2",
88
88
  "openapi-types": "^12.1.3",
89
89
  "tailwindcss": "^4.1.18",
90
- "tsdown": "^0.19.0",
91
- "fumadocs-core": "16.5.1",
92
- "tsconfig": "0.0.0",
93
- "fumadocs-ui": "16.5.1",
94
- "@fumadocs/tailwind": "0.0.1",
95
- "eslint-config-custom": "0.0.0"
90
+ "tsdown": "^0.20.3",
91
+ "@fumadocs/tailwind": "0.0.2",
92
+ "eslint-config-custom": "0.0.0",
93
+ "fumadocs-core": "16.5.2",
94
+ "fumadocs-ui": "16.5.2",
95
+ "tsconfig": "0.0.0"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "@scalar/api-client-react": "*",
99
99
  "@types/react": "*",
100
100
  "fumadocs-core": "^16.5.0",
101
101
  "fumadocs-ui": "^16.5.0",
102
+ "json-schema-typed": "*",
103
+ "openapi-types": "*",
102
104
  "react": "^19.2.0",
103
105
  "react-dom": "^19.2.0"
104
106
  },
105
107
  "peerDependenciesMeta": {
108
+ "json-schema-typed": {
109
+ "optional": true
110
+ },
111
+ "openapi-types": {
112
+ "optional": true
113
+ },
106
114
  "@types/react": {
107
115
  "optional": true
108
116
  },