fumadocs-openapi 12.6.10 → 12.6.11

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.
Files changed (72) hide show
  1. package/css/generated/shared.css +1 -1
  2. package/dist/_virtual/_rolldown/runtime.js +8 -6
  3. package/dist/generate-file.js +9 -25
  4. package/dist/i18n.d.ts +1 -1
  5. package/dist/index.browser.d.ts +1 -1
  6. package/dist/index.browser.js +1 -1
  7. package/dist/operation.d.ts +1 -1
  8. package/dist/operation.js +4 -4
  9. package/dist/packages/shared-api/dist/auto-anchor/index.js +1 -1
  10. package/dist/packages/shared-api/dist/components/badge.js +1 -1
  11. package/dist/packages/shared-api/dist/components/collapsible.js +1 -1
  12. package/dist/packages/shared-api/dist/components/copy-typescript.js +3 -3
  13. package/dist/packages/shared-api/dist/components/defaults.d.ts +1 -1
  14. package/dist/packages/shared-api/dist/components/defaults.js +1 -1
  15. package/dist/packages/shared-api/dist/components/dialog.js +4 -4
  16. package/dist/packages/shared-api/dist/components/example.js +4 -4
  17. package/dist/packages/shared-api/dist/components/playground/fields.js +11 -11
  18. package/dist/packages/shared-api/dist/components/playground/json-editor.js +1 -1
  19. package/dist/packages/shared-api/dist/components/playground/panels.js +6 -6
  20. package/dist/packages/shared-api/dist/components/playground/param-input.js +1 -1
  21. package/dist/packages/shared-api/dist/components/playground/result.js +3 -3
  22. package/dist/packages/shared-api/dist/components/playground/schema.js +1 -1
  23. package/dist/packages/shared-api/dist/components/playground/server-select.js +5 -5
  24. package/dist/packages/shared-api/dist/components/schema/client.js +6 -6
  25. package/dist/packages/shared-api/dist/components/schema/index.js +2 -2
  26. package/dist/packages/shared-api/dist/components/segmented.js +1 -1
  27. package/dist/packages/shared-api/dist/components/select-tab.js +1 -1
  28. package/dist/packages/shared-api/dist/components/select.js +3 -3
  29. package/dist/packages/shared-api/dist/components/spinner.js +1 -1
  30. package/dist/packages/shared-api/dist/source.js +40 -24
  31. package/dist/packages/shared-api/dist/utils/use-server-store.js +1 -1
  32. package/dist/playground/auth.d.ts +3 -3
  33. package/dist/playground/auth.js +3 -3
  34. package/dist/playground/use-playground.d.ts +2 -2
  35. package/dist/playground/use-playground.js +2 -2
  36. package/dist/press.d.ts +2 -2
  37. package/dist/requests/generators/csharp.js +2 -1
  38. package/dist/requests/generators/curl.js +2 -1
  39. package/dist/requests/media/adapter.d.ts +2 -0
  40. package/dist/requests/media/adapter.js +5 -3
  41. package/dist/requests/media/encode.js +4 -11
  42. package/dist/requests/string-utils.js +1 -1
  43. package/dist/server/index.d.ts +3 -3
  44. package/dist/server/index.js +37 -32
  45. package/dist/ui/base.d.ts +1 -1
  46. package/dist/ui/components/schema.js +1 -1
  47. package/dist/ui/index.d.ts +1 -1
  48. package/dist/ui/index.js +1 -1
  49. package/dist/ui/operation/index.js +6 -6
  50. package/dist/ui/operation/usage-tabs.js +4 -4
  51. package/dist/ui/playground/client.d.ts +2 -2
  52. package/dist/ui/playground/client.js +7 -7
  53. package/dist/ui/playground/components/auth.js +6 -6
  54. package/dist/ui/playground/components/request-panel.d.ts +2 -2
  55. package/dist/ui/playground/components/request-panel.js +4 -4
  56. package/dist/ui/playground/components/response-panel.js +3 -3
  57. package/dist/ui/playground/components/result-display.d.ts +1 -1
  58. package/dist/ui/playground/components/result-display.js +3 -3
  59. package/dist/ui/playground/components/server-select.js +1 -1
  60. package/dist/ui/scalar/client.js +5 -5
  61. package/dist/utils/create-page.d.ts +3 -3
  62. package/dist/utils/create-page.js +3 -3
  63. package/dist/utils/get-example-requests.js +1 -1
  64. package/dist/utils/pages/builder.js +1 -1
  65. package/dist/utils/pages/preset-auto.js +2 -2
  66. package/dist/utils/pages/to-static-data.d.ts +1 -1
  67. package/dist/utils/pages/to-static-data.js +2 -2
  68. package/dist/utils/pages/to-text.js +1 -1
  69. package/dist/utils/schema.js +1 -1
  70. package/dist/utils/use-server.d.ts +1 -1
  71. package/dist/utils/use-server.js +1 -1
  72. package/package.json +13 -13
@@ -1,14 +1,13 @@
1
1
  import * as path from "node:path";
2
2
  import { PathUtils } from "fumadocs-core/source";
3
3
  // ../shared-api/dist/source.js
4
- /** convert output entries into virtual files for `loader()` */
5
- function toVirtualFiles(entries, { baseDir = "", meta = false }, toPage) {
6
- const { folderStyle = "folder" } = typeof meta === "object" ? meta : {};
4
+ /** convert output entries into pages for `loader()` */
5
+ function toVirtualFiles(entries, { baseDir = "" }, toPage) {
7
6
  const files = [];
8
- function scan(entries, parent) {
7
+ function scan(entries) {
9
8
  for (const entry of entries) {
10
9
  if (entry.type === "group") {
11
- scan(entry.entries, entry);
10
+ scan(entry.entries);
12
11
  continue;
13
12
  }
14
13
  files.push({
@@ -18,32 +17,49 @@ function toVirtualFiles(entries, { baseDir = "", meta = false }, toPage) {
18
17
  locale: "$"
19
18
  });
20
19
  }
21
- if (!meta) return;
22
- const pages = getMetaPages(entries, parent, folderStyle);
23
- if (pages.length === 0) return;
20
+ }
21
+ scan(entries);
22
+ return files;
23
+ }
24
+ /** the `meta.json` of each folder, from the output entries of each schema */
25
+ function toMetaFiles(schemas, { baseDir = "", meta = false }) {
26
+ if (!meta) return [];
27
+ const { folderStyle = "folder" } = typeof meta === "object" ? meta : {};
28
+ const folders = /* @__PURE__ */ new Map();
29
+ function scan(entries, group) {
30
+ const dir = group?.path ?? "";
31
+ let folder = folders.get(dir);
32
+ if (!folder) folders.set(dir, folder = {
33
+ group,
34
+ entries: /* @__PURE__ */ new Map()
35
+ });
36
+ for (const entry of entries) {
37
+ if (!folder.entries.has(entry.path)) folder.entries.set(entry.path, entry);
38
+ if (entry.type === "group") scan(entry.entries, entry);
39
+ }
40
+ }
41
+ for (const entries of schemas) scan(entries);
42
+ const files = [];
43
+ for (const [dir, { group, entries }] of folders) {
44
+ const pages = [];
45
+ for (const entry of entries.values()) {
46
+ const relativePath = PathUtils.slash(dir ? path.relative(dir, entry.path) : entry.path);
47
+ if (entry.type !== "group") pages.push(relativePath.slice(0, -path.extname(entry.path).length));
48
+ else if (folderStyle === "folder") pages.push(relativePath);
49
+ else pages.push(`---${entry.info.title}---`, `...${relativePath}`);
50
+ }
51
+ if (pages.length === 0) continue;
24
52
  files.push({
25
53
  type: "meta",
26
- path: path.join(baseDir, parent?.path ?? "", "meta.json"),
54
+ path: path.join(baseDir, dir, "meta.json"),
27
55
  data: {
28
- title: parent?.info.title,
29
- description: parent?.info.description,
56
+ title: group?.info.title,
57
+ description: group?.info.description,
30
58
  pages
31
59
  },
32
60
  locale: "$"
33
61
  });
34
62
  }
35
- scan(entries);
36
63
  return files;
37
64
  }
38
- /** the `pages` of `meta.json` in the folder of `parent`, for its entries */
39
- function getMetaPages(entries, parent, folderStyle) {
40
- const pages = [];
41
- for (const entry of entries) {
42
- const relativePath = PathUtils.slash(parent ? path.relative(parent.path, entry.path) : entry.path);
43
- if (entry.type !== "group") pages.push(relativePath.slice(0, -path.extname(entry.path).length));
44
- else if (folderStyle === "folder") pages.push(relativePath);
45
- else pages.push(`---${entry.info.title}---`, `...${relativePath}`);
46
- }
47
- return pages;
48
- }
49
- export { getMetaPages, toVirtualFiles };
65
+ export { toMetaFiles, toVirtualFiles };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { isPlainObject } from "./is-plain-object.js";
3
2
  import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { isPlainObject } from "./is-plain-object.js";
4
4
  // ../shared-api/dist/utils/use-server-store.js
5
5
  /**
6
6
  * The selected server of an API page, persisted in `localStorage`.
@@ -1,9 +1,9 @@
1
1
  import "../utils/create-page.js";
2
- import { OAuthFlows, OperationObject, SecuritySchemeObject } from "../types.js";
3
- import { RawRequestData } from "../requests/types.js";
4
2
  import { FC, ReactNode } from "react";
5
- import { JsonSchema } from "@fumadocs/json-schema";
6
3
  import { DataEngine, FieldKey, Stf } from "@fumari/stf";
4
+ import { JsonSchema } from "@fumadocs/json-schema";
5
+ import { OAuthFlows, OperationObject, SecuritySchemeObject } from "../types.js";
6
+ import { RawRequestData } from "../requests/types.js";
7
7
  /** how token requests authenticate the client */
8
8
  interface OAuthClient {
9
9
  client_id: string;
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import { useOpenAPI } from "../utils/create-page.js";
3
3
  import { useServer } from "../utils/use-server.js";
4
- import { useOperation } from "../operation.js";
5
- import { proxied } from "./fetcher.js";
6
4
  import { use, useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
7
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
5
  import { DataEngine, useListener } from "@fumari/stf";
9
6
  import { arrayStartsWith, objectGet } from "@fumari/stf/lib/utils";
7
+ import { useOperation } from "../operation.js";
8
+ import { proxied } from "./fetcher.js";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  // src/playground/auth.tsx
11
11
  const pendingFlowKey = "fumadocs-openapi-flow";
12
12
  function leavePage(url, flow, redirectUrl) {
@@ -1,7 +1,7 @@
1
+ import { Stf } from "@fumari/stf";
2
+ import { JsonSchema } from "@fumadocs/json-schema";
1
3
  import { AuthField, AuthProvider, AuthRequirement, OAuthFlowInput, OAuthFlowType } from "./auth.js";
2
4
  import { BrowserFetcherOptions, FetchResult } from "./fetcher.js";
3
- import { JsonSchema } from "@fumadocs/json-schema";
4
- import { Stf } from "@fumari/stf";
5
5
  export interface PlaygroundOptions {
6
6
  /** handle security schemes, before the built-in providers */
7
7
  authProviders?: AuthProvider[];
@@ -1,4 +1,6 @@
1
1
  "use client";
2
+ import { useEffect, useEffectEvent, useMemo, useState } from "react";
3
+ import { DataEngine } from "@fumari/stf";
2
4
  import { useExampleRequests, useOperation } from "../operation.js";
3
5
  import { pathnameFromRequest } from "../requests/generators/index.js";
4
6
  import { encodeRequestData } from "../requests/media/encode.js";
@@ -7,8 +9,6 @@ import { getPreferredType } from "../utils/schema.js";
7
9
  import { useServer } from "../utils/use-server.js";
8
10
  import { requestOAuthToken, useAuthFields, usePlaygroundAuth } from "./auth.js";
9
11
  import { createBrowserFetcher } from "./fetcher.js";
10
- import { useEffect, useEffectEvent, useMemo, useState } from "react";
11
- import { DataEngine } from "@fumari/stf";
12
12
  // src/playground/use-playground.tsx
13
13
  /** the form of a playground, its `auth` is the auth values of page */
14
14
  var PlaygroundForm = class extends DataEngine {
package/dist/press.d.ts CHANGED
@@ -1,9 +1,9 @@
1
+ import { Plugin } from "fumadocs-core/framework/plugin";
2
+ import { ComponentType } from "react";
1
3
  import { OpenAPIServer } from "./server/index.js";
2
4
  import { Awaitable } from "./types.js";
3
5
  import { CreateProxyOptions, Proxy } from "./server/proxy.js";
4
6
  import { OpenAPIPageProps } from "./utils/pages/builder.js";
5
- import { ComponentType } from "react";
6
- import { Plugin } from "fumadocs-core/framework/plugin";
7
7
  export interface OpenAPIPluginOptions {
8
8
  /** created with `createOpenAPI()` */
9
9
  server: OpenAPIServer;
@@ -12,7 +12,8 @@ const csharp = {
12
12
  ]);
13
13
  const body = generateBodyExample(data, mediaAdapters, {
14
14
  lang: "csharp",
15
- addImport: (name) => imports.add(name)
15
+ addImport: (name) => imports.add(name),
16
+ bodyMediaType: data.bodyMediaType
16
17
  });
17
18
  const s = Array.from(imports, (name) => `using ${name};`);
18
19
  s.push("");
@@ -7,7 +7,8 @@ const curl = {
7
7
  lang: "bash",
8
8
  generate(data, { mediaAdapters }) {
9
9
  const s = [];
10
- s.push(`curl -X ${data.method.toUpperCase()} ${shellQuote(data.url)}`);
10
+ const method = data.method.toUpperCase();
11
+ s.push(`curl ${method === "HEAD" ? "--head" : `-X ${method}`} ${shellQuote(data.url)}`);
11
12
  for (const header in data.header) s.push(`-H ${shellQuote(`${header}: ${data.header[header].value}`)}`);
12
13
  for (const k in data.cookie) s.push(`--cookie ${shellQuote(`${k}=${data.cookie[k].value}`)}`);
13
14
  const type = data.bodyMediaType && resolveMediaType(data.bodyMediaType, mediaAdapters);
@@ -19,6 +19,8 @@ interface JavaContext extends BaseContext {
19
19
  interface CSharpContext extends BaseContext {
20
20
  lang: 'csharp';
21
21
  addImport: (specifier: string) => void;
22
+ /** the declared media type, like `application/merge-patch+json` */
23
+ bodyMediaType: string;
22
24
  }
23
25
  export type MediaContext = JavaContext | GoContext | JavaScriptContext | CSharpContext | (BaseContext & {
24
26
  lang: string;
@@ -27,8 +27,7 @@ const defaultAdapters = {
27
27
  },
28
28
  "application/x-ndjson": {
29
29
  encode(data) {
30
- if (Array.isArray(data.body)) return data.body.map((v) => JSON.stringify(v)).join("\n");
31
- return JSON.stringify(data.body);
30
+ return inputToString(data.body, "application/x-ndjson");
32
31
  },
33
32
  generateExample(data, ctx) {
34
33
  return str(data.body, "application/x-ndjson", ctx);
@@ -132,7 +131,10 @@ function str(init, mediaType, ctx) {
132
131
  case "java":
133
132
  ctx.addImport("java.net.http.HttpRequest.BodyPublishers");
134
133
  return `var body = BodyPublishers.ofString(${javaTextBlock(text)});`;
135
- case "csharp": return `var body = new StringContent(${csharpRawString(text)}, Encoding.UTF8, "${mediaType}");`;
134
+ case "csharp": {
135
+ const [type] = ctx.bodyMediaType.split(";", 1);
136
+ return `var body = new StringContent(${csharpRawString(text)}, Encoding.UTF8, "${type.trim()}");`;
137
+ }
136
138
  case "rust": return `let body = ${rustString(text)};`;
137
139
  case "ruby": return `body = ${rubyString(text)}`;
138
140
  }
@@ -96,21 +96,14 @@ function serializePathParameter(field, value, output) {
96
96
  }
97
97
  }
98
98
  function serializeQueryParameter(field, value, output) {
99
- const { style, explode = true } = field;
100
- if (style === "spaceDelimited" && !explode && Array.isArray(value)) {
101
- output[field.name] = { values: [value.join(" ")] };
102
- return;
103
- }
104
- if (style === "pipeDelimited" && !explode && Array.isArray(value)) {
105
- output[field.name] = { values: [value.join("|")] };
106
- return;
107
- }
99
+ const { style = "form", explode = style === "form" } = field;
100
+ const delimiter = style === "pipeDelimited" ? "|" : style === "spaceDelimited" ? " " : ",";
108
101
  if (style === "deepObject" && !Array.isArray(value) && typeof value === "object") {
109
102
  for (const [k, v] of Object.entries(value)) output[`${field.name}[${k}]`] = { values: Array.isArray(v) ? v : [String(v)] };
110
103
  return;
111
104
  }
112
105
  if (Array.isArray(value)) {
113
- output[field.name] = { values: explode ? value : [value.join(",")] };
106
+ output[field.name] = { values: explode ? value : [value.join(delimiter)] };
114
107
  return;
115
108
  }
116
109
  if (typeof value === "object" && explode) {
@@ -118,7 +111,7 @@ function serializeQueryParameter(field, value, output) {
118
111
  return;
119
112
  }
120
113
  if (typeof value === "object") {
121
- output[field.name] = { values: [Object.entries(value).flat().join(",")] };
114
+ output[field.name] = { values: [Object.entries(value).flat().join(delimiter)] };
122
115
  return;
123
116
  }
124
117
  output[field.name] = { values: [String(value)] };
@@ -7,7 +7,7 @@ var import_js2xml = /* @__PURE__ */ __toESM(require_js2xml(), 1);
7
7
  */
8
8
  function inputToString(value, format = "application/json") {
9
9
  if (typeof value === "string" && format !== "application/json") return value;
10
- if (format === "application/x-ndjson") return Array.isArray(value) ? value.map((v) => JSON.stringify(v)).join("\n") : JSON.stringify(value, null, 2);
10
+ if (format === "application/x-ndjson") return Array.isArray(value) ? value.map((v) => JSON.stringify(v)).join("\n") : JSON.stringify(value);
11
11
  if (format === "application/x-www-form-urlencoded") return toSearchParams(value).toString();
12
12
  if (format === "application/xml") return (0, import_js2xml.default)(value, {
13
13
  compact: true,
@@ -2,13 +2,13 @@ import { CreateProxyOptions, Proxy, createProxy } from "./proxy.js";
2
2
  import { OpenAPIPageProps_Preloaded, OpenAPIPageProps_Spec } from "../utils/pages/builder.js";
3
3
  import { OAuthHandlerOptions, createOAuthHandler } from "./oauth.js";
4
4
  import { Awaitable, Document } from "../types.js";
5
+ import { DynamicSource, LoaderPlugin, MetaData, Page, PageData, Source } from "fumadocs-core/source";
5
6
  import { InternalOpenAPIMeta } from "../utils/pages/to-static-data.js";
6
7
  import { SourceOptions } from "../packages/shared-api/dist/source.js";
7
8
  import "../ui/index.js";
8
- import { SchemaToPagesOptions } from "../utils/pages/preset-auto.js";
9
- import { DynamicSource, LoaderPlugin, MetaData, Page, PageData, Source } from "fumadocs-core/source";
10
- import { TOCItemType } from "fumadocs-core/toc";
11
9
  import { StructuredData } from "fumadocs-core/mdx-plugins/remark-structure";
10
+ import { TOCItemType } from "fumadocs-core/toc";
11
+ import { SchemaToPagesOptions } from "../utils/pages/preset-auto.js";
12
12
  /**
13
13
  * schema ID -> file path, URL, downloaded schema object, or a function returning them
14
14
  */
@@ -3,7 +3,7 @@ import { createOAuthHandler } from "./oauth.js";
3
3
  import { loadDocument } from "../utils/document/load.js";
4
4
  import { fromSchema, getPageProps } from "../utils/pages/builder.js";
5
5
  import { toStaticData } from "../utils/pages/to-static-data.js";
6
- import { toVirtualFiles } from "../packages/shared-api/dist/source.js";
6
+ import { toMetaFiles, toVirtualFiles } from "../packages/shared-api/dist/source.js";
7
7
  import { createAutoPreset } from "../utils/pages/preset-auto.js";
8
8
  import { MethodLabel } from "../ui/components/method-label.js";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -30,44 +30,49 @@ function createOpenAPI(options = {}) {
30
30
  return Object.fromEntries(entries);
31
31
  }
32
32
  async function getVirtualFiles(server, options, docFilesCache) {
33
+ const entries = [];
33
34
  const files = [];
34
35
  for (const [id, schema] of Object.entries(await server.getSchemas())) {
35
- const cachedDocFiles = docFilesCache?.get(schema);
36
- if (cachedDocFiles) {
37
- files.push(...cachedDocFiles);
38
- continue;
39
- }
40
- const entries = toVirtualFiles(fromSchema(id, schema.bundled, createAutoPreset(options)), options, (entry) => {
41
- const props = getPageProps(entry);
42
- return {
43
- ...entry.info,
44
- full: true,
45
- getOpenAPIPageProps() {
36
+ let output = docFilesCache?.get(schema);
37
+ if (!output) {
38
+ const docEntries = fromSchema(id, schema.bundled, createAutoPreset(options));
39
+ output = {
40
+ entries: docEntries,
41
+ files: toVirtualFiles(docEntries, options, (entry) => {
42
+ const props = getPageProps(entry);
46
43
  return {
47
- payload: {
48
- ...includeDocument && { bundled: schema.bundled },
49
- proxyUrl: server.options.proxyUrl
44
+ ...entry.info,
45
+ full: true,
46
+ getOpenAPIPageProps() {
47
+ return {
48
+ payload: {
49
+ ...includeDocument && { bundled: schema.bundled },
50
+ proxyUrl: server.options.proxyUrl
51
+ },
52
+ ...props
53
+ };
50
54
  },
51
- ...props
52
- };
53
- },
54
- getSchema() {
55
- return {
56
- id,
57
- bundled: schema.bundled
55
+ getSchema() {
56
+ return {
57
+ id,
58
+ bundled: schema.bundled
59
+ };
60
+ },
61
+ ...toStaticData(props, schema.bundled),
62
+ _openapi: {
63
+ method: entry.type === "operation" || entry.type === "webhook" ? entry.item.method : void 0,
64
+ webhook: entry.type === "webhook",
65
+ deprecated: entry.info.deprecated
66
+ }
58
67
  };
59
- },
60
- ...toStaticData(props, schema.bundled),
61
- _openapi: {
62
- method: entry.type === "operation" || entry.type === "webhook" ? entry.item.method : void 0,
63
- webhook: entry.type === "webhook",
64
- deprecated: entry.info.deprecated
65
- }
68
+ })
66
69
  };
67
- });
68
- docFilesCache?.set(schema, entries);
69
- files.push(...entries);
70
+ docFilesCache?.set(schema, output);
71
+ }
72
+ entries.push(output.entries);
73
+ files.push(...output.files);
70
74
  }
75
+ files.push(...toMetaFiles(entries, options));
71
76
  return files;
72
77
  }
73
78
  return {
package/dist/ui/base.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OpenAPIPageProps } from "../utils/pages/builder.js";
2
- import { CreateOpenAPIPageOptions } from "./index.js";
3
2
  import { FC } from "react";
3
+ import { CreateOpenAPIPageOptions } from "./index.js";
4
4
  /**
5
5
  * Create `<OpenAPIPage />` (a client component) without the full Shiki bundle.
6
6
  */
@@ -1,7 +1,7 @@
1
1
  "use client";
2
+ import { useMemo } from "react";
2
3
  import { useAnchorId } from "../../packages/shared-api/dist/auto-anchor/index.js";
3
4
  import { useComponents, useRenderContext } from "../../utils/create-page.js";
4
- import { useMemo } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  // src/ui/components/schema.tsx
7
7
  /**
@@ -1,6 +1,6 @@
1
+ import { FC } from "react";
1
2
  import { CreateOpenAPIRendererOptions } from "../utils/create-page.js";
2
3
  import { OpenAPIPageProps, OpenAPIPageProps_Preloaded, OpenAPIPageProps_Spec } from "../utils/pages/builder.js";
3
- import { FC } from "react";
4
4
  export interface CreateOpenAPIPageOptions extends Omit<CreateOpenAPIRendererOptions, 'components'> {
5
5
  /**
6
6
  * Replace parts of the UI, e.g. the ones installed with Fumadocs CLI.
package/dist/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { createOpenAPIPageBase } from "./base.js";
3
2
  import { defaultShikiFactory } from "fumadocs-core/highlight/shiki/full";
3
+ import { createOpenAPIPageBase } from "./base.js";
4
4
  // src/ui/index.tsx
5
5
  /**
6
6
  * Create `<OpenAPIPage />` (a client component).
@@ -1,26 +1,26 @@
1
1
  "use client";
2
+ import { Fragment, Suspense, lazy, useState } from "react";
3
+ import { Dialog } from "@base-ui/react/dialog";
2
4
  import { RequestTabs, UsageTabs } from "./usage-tabs.js";
3
5
  import { MethodLabel } from "../components/method-label.js";
4
6
  import { SchemaUI } from "../components/schema.js";
5
7
  import { Badge } from "../../packages/shared-api/dist/components/badge.js";
6
8
  import { useOpenAPI, useRenderContext } from "../../utils/create-page.js";
7
9
  import { OperationProvider, useOperation } from "../../operation.js";
10
+ import { useTranslations } from "@fuma-translate/react";
8
11
  import { cn } from "../../utils/cn.js";
9
12
  import { SelectTab, SelectTabTrigger, SelectTabs } from "../../packages/shared-api/dist/components/select-tab.js";
13
+ import { Callout } from "fumadocs-ui/components/callout";
10
14
  import { AnchorSection, useAnchorLink } from "../../packages/shared-api/dist/auto-anchor/index.js";
11
15
  import { Heading } from "../components/heading.js";
12
16
  import { Markdown } from "../components/markdown.js";
17
+ import { buttonVariants } from "fumadocs-ui/components/ui/button";
18
+ import { ChevronRight, Plus, X } from "lucide-react";
13
19
  import { CopyTypeScript } from "../../packages/shared-api/dist/components/copy-typescript.js";
14
20
  import { EndpointBar } from "../components/endpoint.js";
15
21
  import { Segmented, SegmentedList, SegmentedPanel } from "../../packages/shared-api/dist/components/segmented.js";
16
22
  import { DialogPopup } from "../../packages/shared-api/dist/components/dialog.js";
17
- import { Fragment, Suspense, lazy, useState } from "react";
18
23
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
- import { useTranslations } from "@fuma-translate/react";
20
- import { ChevronRight, Plus, X } from "lucide-react";
21
- import { buttonVariants } from "fumadocs-ui/components/ui/button";
22
- import { Dialog } from "@base-ui/react/dialog";
23
- import { Callout } from "fumadocs-ui/components/callout";
24
24
  // src/ui/operation/index.tsx
25
25
  const PlaygroundClient = lazy(() => import("../playground/client.js"));
26
26
  function Operation({ type, path, method, operation, pathItem, ...props }) {
@@ -1,4 +1,8 @@
1
1
  "use client";
2
+ import { useState } from "react";
3
+ import { Switch } from "@base-ui/react/switch";
4
+ import { getRaw } from "@scalar/json-magic/magic-proxy";
5
+ import { useTranslations } from "@fuma-translate/react";
2
6
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../packages/shared-api/dist/components/select.js";
3
7
  import { ExampleHeader, ExampleSelect, captionCodeBlock, cardCodeBlock, exampleActions, exampleCardClassName, exampleCodeBlock, selectCodeUsage, useCodeUsageId } from "../../packages/shared-api/dist/components/example.js";
4
8
  import { ClientCodeBlock } from "../components/codeblock.js";
@@ -7,11 +11,7 @@ import { MethodLabel } from "../components/method-label.js";
7
11
  import { useCodeUsage, useExampleRequests, useOperation, useResponseExamples } from "../../operation.js";
8
12
  import { useOpenAPI, useRenderContext } from "../../utils/create-page.js";
9
13
  import { cn } from "../../utils/cn.js";
10
- import { useState } from "react";
11
- import { getRaw } from "@scalar/json-magic/magic-proxy";
12
14
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
- import { useTranslations } from "@fuma-translate/react";
14
- import { Switch } from "@base-ui/react/switch";
15
15
  // src/ui/operation/usage-tabs.tsx
16
16
  function UsageTabs() {
17
17
  const ctx = useRenderContext();
@@ -1,9 +1,9 @@
1
+ import { ComponentProps, FC, ReactNode } from "react";
1
2
  import { DefaultResultDisplay, ResultDisplayProps } from "./components/result-display.js";
3
+ import { FieldKey } from "@fumari/stf";
2
4
  import { ParameterObject } from "../../types.js";
3
5
  import { PlaygroundOptions, RequestBodyInfo } from "../../playground/use-playground.js";
4
6
  import { ParameterFieldContext } from "./components/request-panel.js";
5
- import { ComponentProps, FC, ReactNode } from "react";
6
- import { FieldKey } from "@fumari/stf";
7
7
  export interface PlaygroundClientProps extends ComponentProps<'div'>, PlaygroundClientOptions {
8
8
  /** @deprecated it defaults to `true` for requests */
9
9
  writeOnly?: boolean;
@@ -1,4 +1,9 @@
1
1
  "use client";
2
+ import { useMemo, useRef, useState } from "react";
3
+ import { flushSync } from "react-dom";
4
+ import { Dialog } from "@base-ui/react/dialog";
5
+ import { X } from "lucide-react";
6
+ import { useOnChange } from "fumadocs-core/utils/use-on-change";
2
7
  import { useOpenAPI } from "../../utils/create-page.js";
3
8
  import { useExampleRequests, useOperation } from "../../operation.js";
4
9
  import { DefaultResultDisplay } from "./components/result-display.js";
@@ -8,19 +13,14 @@ import { DialogPopup, PlaygroundTrigger } from "../../packages/shared-api/dist/c
8
13
  import { cn } from "../../utils/cn.js";
9
14
  import { SchemaProvider } from "../../packages/shared-api/dist/components/playground/schema.js";
10
15
  import { RequestExampleSelect, ViewSwitch, iconButtonClassName } from "../../packages/shared-api/dist/components/playground/panels.js";
16
+ import { StfProvider, useFieldValue } from "@fumari/stf";
17
+ import { useTranslations } from "@fuma-translate/react";
11
18
  import { usePlayground } from "../../playground/use-playground.js";
12
19
  import { UrlBar } from "./components/url-bar.js";
13
20
  import { builtinAuthProviders } from "./components/auth.js";
14
21
  import { RequestPanel } from "./components/request-panel.js";
15
22
  import { ResponsePanel } from "./components/response-panel.js";
16
- import { useMemo, useRef, useState } from "react";
17
23
  import { jsx, jsxs } from "react/jsx-runtime";
18
- import { useTranslations } from "@fuma-translate/react";
19
- import { StfProvider, useFieldValue } from "@fumari/stf";
20
- import { X } from "lucide-react";
21
- import { flushSync } from "react-dom";
22
- import { Dialog } from "@base-ui/react/dialog";
23
- import { useOnChange } from "fumadocs-core/utils/use-on-change";
24
24
  // src/ui/playground/client.tsx
25
25
  function PlaygroundClient({ writeOnly = true, readOnly = false, authProviders, transformAuthInputs, fetchOptions, components, renderParameterField, renderBodyField, ...rest }) {
26
26
  const { doc } = useOpenAPI();
@@ -1,4 +1,10 @@
1
1
  "use client";
2
+ import { Suspense, useEffect, useRef, useState } from "react";
3
+ import { Check, Copy, ExternalLink, ShieldCheck } from "lucide-react";
4
+ import { StfProvider, useDataEngine, useStf } from "@fumari/stf";
5
+ import { useTranslations } from "@fuma-translate/react";
6
+ import { buttonVariants } from "fumadocs-ui/components/ui/button";
7
+ import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
2
8
  import { Spinner } from "../../../packages/shared-api/dist/components/spinner.js";
3
9
  import { useQuery } from "../../../packages/shared-api/dist/utils/use-query.js";
4
10
  import { finishOAuthFlow, requestOAuthToken, useAuthRedirect, useOpenIdConnectFlows } from "../../../playground/auth.js";
@@ -8,13 +14,7 @@ import { useServer } from "../../../utils/use-server.js";
8
14
  import { cn } from "../../../utils/cn.js";
9
15
  import { iconButtonClassName } from "../../../packages/shared-api/dist/components/playground/panels.js";
10
16
  import { CheckRow, SelectRow, TextRow, ValueRow } from "../../../packages/shared-api/dist/components/playground/fields.js";
11
- import { Suspense, useEffect, useRef, useState } from "react";
12
17
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
- import { useTranslations } from "@fuma-translate/react";
14
- import { StfProvider, useDataEngine, useStf } from "@fumari/stf";
15
- import { Check, Copy, ExternalLink, ShieldCheck } from "lucide-react";
16
- import { buttonVariants } from "fumadocs-ui/components/ui/button";
17
- import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
18
18
  // src/ui/playground/components/auth.tsx
19
19
  /** the rows of OAuth and mutual TLS schemes in the built-in UI, after the providers of page */
20
20
  const builtinAuthProviders = [{
@@ -1,7 +1,7 @@
1
- import "../../../playground/use-playground.js";
2
1
  import { ReactNode } from "react";
3
- import { JsonSchema } from "@fumadocs/json-schema";
4
2
  import "@fumari/stf";
3
+ import { JsonSchema } from "@fumadocs/json-schema";
4
+ import "../../../playground/use-playground.js";
5
5
  export interface ParameterFieldContext {
6
6
  /** the default input of parameter, `schema` replaces its schema, like an `enum` of values loaded at runtime */
7
7
  renderDefault: (schema?: JsonSchema) => ReactNode;
@@ -1,4 +1,8 @@
1
1
  "use client";
2
+ import { Fragment, createContext, use, useState } from "react";
3
+ import { Braces, Cookie, KeyRound, PlusIcon, Route, Rows3, SlidersHorizontal } from "lucide-react";
4
+ import { stringifyFieldKey } from "@fumari/stf/lib/utils";
5
+ import { useTranslations } from "@fuma-translate/react";
2
6
  import { anyFields, useResolvedSchema } from "../../../packages/shared-api/dist/components/playground/schema.js";
3
7
  import { FieldRow, FieldRows, LinkRow, ValueRow, getRemoval } from "../../../packages/shared-api/dist/components/playground/fields.js";
4
8
  import { Crumb, FieldPanel, OverviewLayer, Panel, PanelNav, Section, useFieldStack } from "../../../packages/shared-api/dist/components/playground/panels.js";
@@ -7,11 +11,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
7
11
  import { Segmented, SegmentedList } from "../../../packages/shared-api/dist/components/segmented.js";
8
12
  import { useOperation } from "../../../operation.js";
9
13
  import { cn } from "../../../utils/cn.js";
10
- import { Fragment, createContext, use, useState } from "react";
11
14
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
- import { useTranslations } from "@fuma-translate/react";
13
- import { stringifyFieldKey } from "@fumari/stf/lib/utils";
14
- import { Braces, Cookie, KeyRound, PlusIcon, Route, Rows3, SlidersHorizontal } from "lucide-react";
15
15
  // src/ui/playground/components/request-panel.tsx
16
16
  const sectionIcons = {
17
17
  path: Route,
@@ -1,4 +1,7 @@
1
1
  "use client";
2
+ import { useState } from "react";
3
+ import { SendHorizontal } from "lucide-react";
4
+ import { useTranslations } from "@fuma-translate/react";
2
5
  import { useResponseExamples } from "../../../operation.js";
3
6
  import { ExampleSelect } from "../../../packages/shared-api/dist/components/example.js";
4
7
  import { PanelHeader, Placeholder, SendingOverlay, panelCodeBlock, panelTopCodeBlock } from "../../../packages/shared-api/dist/components/playground/panels.js";
@@ -8,10 +11,7 @@ import { CodeUsages } from "../../operation/usage-tabs.js";
8
11
  import { Markdown } from "../../components/markdown.js";
9
12
  import { cn } from "../../../utils/cn.js";
10
13
  import { DefaultResultDisplay } from "./result-display.js";
11
- import { useState } from "react";
12
14
  import { jsx, jsxs } from "react/jsx-runtime";
13
- import { useTranslations } from "@fuma-translate/react";
14
- import { SendHorizontal } from "lucide-react";
15
15
  // src/ui/playground/components/response-panel.tsx
16
16
  function ResponsePanel({ response, loading, onReset, ResultDisplay = DefaultResultDisplay, className }) {
17
17
  const t = useTranslations({ note: "playground" });
@@ -1,5 +1,5 @@
1
- import { FetchResult } from "../../../playground/fetcher.js";
2
1
  import { ComponentProps } from "react";
2
+ import { FetchResult } from "../../../playground/fetcher.js";
3
3
  export interface ResultDisplayProps extends ComponentProps<'div'> {
4
4
  data: FetchResult;
5
5
  reset: () => void;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
+ import { useCallback, useMemo } from "react";
3
+ import { DownloadIcon, FileIcon } from "lucide-react";
2
4
  import { ClientCodeBlock } from "../../components/codeblock.js";
5
+ import { useTranslations } from "@fuma-translate/react";
3
6
  import { iconButtonClassName, panelCodeBlock } from "../../../packages/shared-api/dist/components/playground/panels.js";
4
7
  import { RequestError, ResponseView } from "../../../packages/shared-api/dist/components/playground/result.js";
5
- import { useCallback, useMemo } from "react";
6
8
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useTranslations } from "@fuma-translate/react";
8
- import { DownloadIcon, FileIcon } from "lucide-react";
9
9
  // src/ui/playground/components/result-display.tsx
10
10
  function DefaultResultDisplay({ data, reset, ...rest }) {
11
11
  if (data.type === "client_error") return /* @__PURE__ */ jsx(RequestError, {
@@ -1,9 +1,9 @@
1
1
  "use client";
2
+ import { useTranslations } from "@fuma-translate/react";
2
3
  import { ServerPopover, ServerVariables } from "../../../packages/shared-api/dist/components/playground/server-select.js";
3
4
  import { useServer } from "../../../utils/use-server.js";
4
5
  import { cn } from "../../../utils/cn.js";
5
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { useTranslations } from "@fuma-translate/react";
7
7
  // src/ui/playground/components/server-select.tsx
8
8
  /** the base URL of requests, selects the server and edits its variables */
9
9
  function ServerSelect({ className }) {