fumadocs-openapi 12.5.4 → 12.5.6

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 (135) hide show
  1. package/css/generated/shared.css +1 -1
  2. package/dist/.translations/index.d.ts +6 -3
  3. package/dist/.translations/keys.js +6 -2
  4. package/dist/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/generate-file.d.ts +1 -3
  6. package/dist/generate-file.js +3 -3
  7. package/dist/i18n.d.ts +1 -3
  8. package/dist/i18n.js +1 -2
  9. package/dist/index.browser.d.ts +0 -2
  10. package/dist/index.browser.js +1 -2
  11. package/dist/node_modules/.pnpm/fast-content-type-parse@4.0.1/node_modules/fast-content-type-parse/index.js +1 -2
  12. package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/array-helper.js +1 -2
  13. package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/js2xml.js +1 -2
  14. package/dist/node_modules/.pnpm/xml-js@1.6.11/node_modules/xml-js/lib/options-helper.js +1 -2
  15. package/dist/operation.d.ts +1 -3
  16. package/dist/operation.js +1 -2
  17. package/dist/packages/shared-api/dist/.translations/index.d.ts +2 -5
  18. package/dist/packages/shared-api/dist/.translations/keys.js +2 -2
  19. package/dist/packages/shared-api/dist/auto-anchor/index.js +1 -2
  20. package/dist/packages/shared-api/dist/codegen.d.ts +0 -3
  21. package/dist/packages/shared-api/dist/codegen.js +1 -2
  22. package/dist/packages/shared-api/dist/components/badge.js +1 -2
  23. package/dist/packages/shared-api/dist/components/collapsible.js +1 -2
  24. package/dist/packages/shared-api/dist/components/copy-typescript.js +1 -2
  25. package/dist/packages/shared-api/dist/components/defaults.d.ts +2 -4
  26. package/dist/packages/shared-api/dist/components/defaults.js +21 -21
  27. package/dist/packages/shared-api/dist/components/dialog.js +1 -2
  28. package/dist/packages/shared-api/dist/components/example.js +3 -3
  29. package/dist/packages/shared-api/dist/components/playground/fields.js +27 -9
  30. package/dist/packages/shared-api/dist/components/playground/json-editor.js +1 -2
  31. package/dist/packages/shared-api/dist/components/playground/panels.js +1 -2
  32. package/dist/packages/shared-api/dist/components/playground/param-input.js +1 -2
  33. package/dist/packages/shared-api/dist/components/playground/result.js +1 -2
  34. package/dist/packages/shared-api/dist/components/playground/schema.js +1 -2
  35. package/dist/packages/shared-api/dist/components/playground/server-select.js +1 -2
  36. package/dist/packages/shared-api/dist/components/schema/client.d.ts +1 -4
  37. package/dist/packages/shared-api/dist/components/schema/client.js +3 -2
  38. package/dist/packages/shared-api/dist/components/schema/index.d.ts +0 -3
  39. package/dist/packages/shared-api/dist/components/schema/index.js +1 -2
  40. package/dist/packages/shared-api/dist/components/segmented.js +1 -2
  41. package/dist/packages/shared-api/dist/components/select-tab.js +1 -2
  42. package/dist/packages/shared-api/dist/components/select.js +1 -2
  43. package/dist/packages/shared-api/dist/components/spinner.js +1 -2
  44. package/dist/packages/shared-api/dist/i18n.js +1 -2
  45. package/dist/packages/shared-api/dist/source.d.ts +1 -4
  46. package/dist/packages/shared-api/dist/source.js +1 -2
  47. package/dist/packages/shared-api/dist/utils/document-cache.js +1 -2
  48. package/dist/packages/shared-api/dist/utils/id-to-title.js +1 -2
  49. package/dist/packages/shared-api/dist/utils/is-plain-object.js +1 -2
  50. package/dist/packages/shared-api/dist/utils/url.js +1 -2
  51. package/dist/packages/shared-api/dist/utils/use-query.js +1 -2
  52. package/dist/packages/shared-api/dist/utils/use-server-store.js +1 -2
  53. package/dist/playground/auth.d.ts +2 -2
  54. package/dist/playground/auth.js +1 -2
  55. package/dist/playground/fetcher.d.ts +1 -3
  56. package/dist/playground/fetcher.js +1 -2
  57. package/dist/playground/use-playground.d.ts +1 -3
  58. package/dist/playground/use-playground.js +1 -2
  59. package/dist/requests/generators/all.d.ts +1 -3
  60. package/dist/requests/generators/all.js +1 -2
  61. package/dist/requests/generators/csharp.d.ts +1 -3
  62. package/dist/requests/generators/csharp.js +1 -2
  63. package/dist/requests/generators/curl.d.ts +1 -3
  64. package/dist/requests/generators/curl.js +1 -2
  65. package/dist/requests/generators/go.d.ts +1 -3
  66. package/dist/requests/generators/go.js +1 -2
  67. package/dist/requests/generators/index.d.ts +1 -3
  68. package/dist/requests/generators/index.js +1 -2
  69. package/dist/requests/generators/java.d.ts +1 -3
  70. package/dist/requests/generators/java.js +1 -2
  71. package/dist/requests/generators/javascript.d.ts +1 -3
  72. package/dist/requests/generators/javascript.js +1 -2
  73. package/dist/requests/generators/python.d.ts +1 -3
  74. package/dist/requests/generators/python.js +1 -2
  75. package/dist/requests/generators/rust.d.ts +1 -3
  76. package/dist/requests/generators/rust.js +1 -2
  77. package/dist/requests/media/adapter.d.ts +0 -2
  78. package/dist/requests/media/adapter.js +1 -2
  79. package/dist/requests/media/encode.d.ts +1 -3
  80. package/dist/requests/media/encode.js +1 -2
  81. package/dist/requests/media/resolve-adapter.d.ts +1 -3
  82. package/dist/requests/media/resolve-adapter.js +1 -2
  83. package/dist/requests/string-utils.js +1 -2
  84. package/dist/requests/types.d.ts +1 -3
  85. package/dist/server/index.d.ts +0 -2
  86. package/dist/server/index.js +1 -2
  87. package/dist/server/oauth.d.ts +1 -3
  88. package/dist/server/oauth.js +1 -2
  89. package/dist/server/proxy.d.ts +0 -2
  90. package/dist/server/proxy.js +8 -4
  91. package/dist/types/openapi.d.ts +1 -3
  92. package/dist/types.d.ts +1 -3
  93. package/dist/ui/base.d.ts +1 -6
  94. package/dist/ui/base.js +1 -2
  95. package/dist/ui/components/codeblock.js +1 -2
  96. package/dist/ui/components/endpoint.js +1 -2
  97. package/dist/ui/components/heading.js +1 -2
  98. package/dist/ui/components/markdown.js +1 -2
  99. package/dist/ui/components/method-label.js +1 -2
  100. package/dist/ui/components/schema.js +1 -2
  101. package/dist/ui/index.d.ts +0 -2
  102. package/dist/ui/index.js +1 -2
  103. package/dist/ui/operation/index.js +14 -5
  104. package/dist/ui/operation/usage-tabs.js +12 -5
  105. package/dist/ui/playground/client.d.ts +6 -5
  106. package/dist/ui/playground/client.js +1 -2
  107. package/dist/ui/playground/components/auth.js +1 -2
  108. package/dist/ui/playground/components/request-panel.d.ts +8 -0
  109. package/dist/ui/playground/components/request-panel.js +18 -8
  110. package/dist/ui/playground/components/response-panel.js +1 -2
  111. package/dist/ui/playground/components/result-display.d.ts +1 -3
  112. package/dist/ui/playground/components/result-display.js +1 -2
  113. package/dist/ui/playground/components/server-select.js +1 -2
  114. package/dist/ui/playground/components/url-bar.js +1 -2
  115. package/dist/ui/scalar/client.js +1 -2
  116. package/dist/ui/scalar/index.d.ts +1 -3
  117. package/dist/ui/scalar/index.js +1 -2
  118. package/dist/utils/create-page.d.ts +10 -9
  119. package/dist/utils/create-page.js +14 -8
  120. package/dist/utils/document/dereference.d.ts +1 -3
  121. package/dist/utils/document/dereference.js +1 -2
  122. package/dist/utils/document/load.js +1 -2
  123. package/dist/utils/get-example-requests.js +4 -4
  124. package/dist/utils/pages/builder.d.ts +0 -2
  125. package/dist/utils/pages/builder.js +1 -2
  126. package/dist/utils/pages/preset-auto.d.ts +0 -2
  127. package/dist/utils/pages/preset-auto.js +1 -2
  128. package/dist/utils/pages/to-static-data.d.ts +1 -3
  129. package/dist/utils/pages/to-static-data.js +1 -2
  130. package/dist/utils/pages/to-text.d.ts +1 -3
  131. package/dist/utils/pages/to-text.js +1 -2
  132. package/dist/utils/schema.js +1 -2
  133. package/dist/utils/use-server.d.ts +0 -2
  134. package/dist/utils/use-server.js +1 -2
  135. package/package.json +12 -13
@@ -12,7 +12,7 @@ import { getRaw } from "@scalar/json-magic/magic-proxy";
12
12
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
13
  import { useTranslations } from "@fuma-translate/react";
14
14
  import { Switch } from "@base-ui/react/switch";
15
- //#region src/ui/operation/usage-tabs.tsx
15
+ // src/ui/operation/usage-tabs.tsx
16
16
  function UsageTabs() {
17
17
  const ctx = useRenderContext();
18
18
  const t = useTranslations({ note: "operation page" });
@@ -38,6 +38,7 @@ function UsageTabs() {
38
38
  });
39
39
  }
40
40
  function UsageTabsSelector() {
41
+ const t = useTranslations({ note: "operation page" });
41
42
  const { items, selected, select } = useExampleRequests();
42
43
  function renderItem(item) {
43
44
  return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
@@ -58,6 +59,7 @@ function UsageTabsSelector() {
58
59
  value: selected,
59
60
  onValueChange: (v) => v !== null && select(v),
60
61
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
62
+ "aria-label": t("Example request"),
61
63
  className: "not-prose mb-4 rounded-xl bg-fd-card px-3",
62
64
  children: /* @__PURE__ */ jsx(SelectValue, {})
63
65
  }), /* @__PURE__ */ jsx(SelectContent, { children: options.map((item) => /* @__PURE__ */ jsx(SelectItem, {
@@ -69,6 +71,7 @@ function UsageTabsSelector() {
69
71
  const storageKey = "fumadocs_openapi_requests";
70
72
  /** the code usages of the selected example request, with a select of their languages */
71
73
  function CodeUsages({ title, selectExample = false, className, viewportClassName }) {
74
+ const t = useTranslations({ note: "operation page" });
72
75
  const generators = useOperation().codeUsages.map();
73
76
  const examples = useExampleRequests();
74
77
  const selected = useCodeUsageId(storageKey);
@@ -92,13 +95,15 @@ function CodeUsages({ title, selectExample = false, className, viewportClassName
92
95
  })),
93
96
  value: example.id,
94
97
  onValueChange: examples.select,
98
+ "aria-label": t("Example request"),
95
99
  align: "start",
96
100
  className: "-ms-2 max-w-full text-fd-foreground"
97
101
  }) : title,
98
102
  Actions: exampleActions(/* @__PURE__ */ jsx(ExampleSelect, {
99
103
  items,
100
104
  value: id,
101
- onValueChange: (value) => selectCodeUsage(storageKey, value)
105
+ onValueChange: (value) => selectCodeUsage(storageKey, value),
106
+ "aria-label": t("Code language")
102
107
  })),
103
108
  className: cn(exampleCodeBlock.className, className),
104
109
  viewportProps: { className: viewportClassName }
@@ -143,6 +148,7 @@ function ResponseTabsDefaultContent({ tabs }) {
143
148
  })),
144
149
  value: String(index),
145
150
  onValueChange: (v) => setIndex(Number(v)),
151
+ "aria-label": t("Example"),
146
152
  align: "start",
147
153
  className: "-ms-2"
148
154
  }), example.description && /* @__PURE__ */ jsx("div", {
@@ -183,7 +189,8 @@ function ResponseTabsDefaultContent({ tabs }) {
183
189
  onValueChange: (v) => {
184
190
  setCode(v);
185
191
  setIndex(0);
186
- }
192
+ },
193
+ "aria-label": t("Response status")
187
194
  })]
188
195
  }), body]
189
196
  });
@@ -226,7 +233,8 @@ function RequestTabsDefaultContent() {
226
233
  label: item.id === "_default" ? t("Default") : item.name
227
234
  })),
228
235
  value: item.id,
229
- onValueChange: select
236
+ onValueChange: select,
237
+ "aria-label": t("Example request")
230
238
  })
231
239
  }),
232
240
  /* @__PURE__ */ jsxs("div", {
@@ -266,5 +274,4 @@ function RequestTabsDefaultContent() {
266
274
  ]
267
275
  });
268
276
  }
269
- //#endregion
270
277
  export { CodeUsages, RequestTabs, UsageTabs };
@@ -1,9 +1,9 @@
1
1
  import { ParameterObject } from "../../types.js";
2
2
  import { DefaultResultDisplay, ResultDisplayProps } from "./components/result-display.js";
3
3
  import { PlaygroundOptions, RequestBodyInfo } from "../../playground/use-playground.js";
4
+ import { ParameterFieldContext } from "./components/request-panel.js";
4
5
  import { ComponentProps, FC, ReactNode } from "react";
5
6
  import { FieldKey } from "@fumari/stf";
6
- //#region src/ui/playground/client.d.ts
7
7
  export interface PlaygroundClientProps extends ComponentProps<'div'>, PlaygroundClientOptions {
8
8
  /** @deprecated it defaults to `true` for requests */
9
9
  writeOnly?: boolean;
@@ -23,14 +23,16 @@ export interface PlaygroundClientOptions extends PlaygroundOptions {
23
23
  ResultDisplay?: FC<ResultDisplayProps>;
24
24
  };
25
25
  /**
26
- * render the parameter inputs of API endpoint.
26
+ * render the parameter inputs of API endpoint, return `undefined` to keep the default input of a parameter.
27
+ *
28
+ * `ctx.renderDefault(schema)` renders the default input with another schema, like an `enum` of values loaded at runtime.
27
29
  *
28
30
  * for updating values, use:
29
31
  * - the `Custom.useController()` from `fumadocs-openapi/ui/playground/client`.
30
32
  *
31
33
  * Recommended types packages: `json-schema-typed`.
32
34
  */
33
- renderParameterField?: (fieldName: FieldKey, param: ParameterObject) => ReactNode;
35
+ renderParameterField?: (fieldName: FieldKey, param: ParameterObject, ctx: ParameterFieldContext) => ReactNode;
34
36
  /**
35
37
  * render the input for API endpoint body.
36
38
  *
@@ -47,5 +49,4 @@ export declare const Custom: {
47
49
  setValue: (newValue: unknown) => boolean;
48
50
  };
49
51
  };
50
- //#endregion
51
- export { DefaultResultDisplay, type ResultDisplayProps };
52
+ export { DefaultResultDisplay, type ParameterFieldContext, type ResultDisplayProps };
@@ -20,7 +20,7 @@ import { useTranslations } from "@fuma-translate/react";
20
20
  import { X } from "lucide-react";
21
21
  import { Dialog } from "@base-ui/react/dialog";
22
22
  import { useOnChange } from "fumadocs-core/utils/use-on-change";
23
- //#region src/ui/playground/client.tsx
23
+ // src/ui/playground/client.tsx
24
24
  function PlaygroundClient({ writeOnly = true, readOnly = false, authProviders, transformAuthInputs, fetchOptions, components, renderParameterField, renderBodyField, ...rest }) {
25
25
  const { doc } = useOpenAPI();
26
26
  const { path, method, operation } = useOperation();
@@ -162,5 +162,4 @@ const Custom = { useController(fieldName, options) {
162
162
  setValue
163
163
  };
164
164
  } };
165
- //#endregion
166
165
  export { Custom, DefaultResultDisplay, PlaygroundClient as default };
@@ -15,7 +15,7 @@ import { useTranslations } from "@fuma-translate/react";
15
15
  import { Check, Copy, ExternalLink, ShieldCheck } from "lucide-react";
16
16
  import { buttonVariants } from "fumadocs-ui/components/ui/button";
17
17
  import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
18
- //#region src/ui/playground/components/auth.tsx
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 = [{
21
21
  on: ({ scheme }) => scheme.type === "oauth2" || scheme.type === "openIdConnect",
@@ -351,5 +351,4 @@ function DeviceVerification({ code, onCancel }) {
351
351
  })]
352
352
  })] });
353
353
  }
354
- //#endregion
355
354
  export { builtinAuthProviders };
@@ -0,0 +1,8 @@
1
+ import "../../../playground/use-playground.js";
2
+ import { ReactNode } from "react";
3
+ import { JsonSchema } from "@fumadocs/json-schema";
4
+ import { FieldKey } from "@fumari/stf";
5
+ export interface ParameterFieldContext {
6
+ /** the default input of parameter, `schema` replaces its schema, like an `enum` of values loaded at runtime */
7
+ renderDefault: (schema?: JsonSchema) => ReactNode;
8
+ }
@@ -12,7 +12,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { stringifyFieldKey } from "@fumari/stf/lib/utils";
13
13
  import { useTranslations } from "@fuma-translate/react";
14
14
  import { Braces, Cookie, KeyRound, PlusIcon, Route, Rows3, SlidersHorizontal } from "lucide-react";
15
- //#region src/ui/playground/components/request-panel.tsx
15
+ // src/ui/playground/components/request-panel.tsx
16
16
  const sectionIcons = {
17
17
  path: Route,
18
18
  query: SlidersHorizontal,
@@ -100,12 +100,23 @@ function Overview({ auth, body, sectionNames, onNavigate, onAuthorize, renderPar
100
100
  icon: sectionIcons[type],
101
101
  title: sectionNames[type],
102
102
  count: items.length,
103
- children: items.map((param, i) => renderParameterField ? /* @__PURE__ */ jsx(Fragment, { children: renderParameterField(entries[i].fieldName, param) }, param.name) : /* @__PURE__ */ jsx(FieldRow, {
104
- entry: entries[i],
105
- required: param.required,
106
- description: param.description,
107
- onNavigate: () => onNavigate(entries[i], entries)
108
- }, param.name))
103
+ children: items.map((param, i) => {
104
+ const renderDefault = (schema) => {
105
+ const entry = schema === void 0 ? entries[i] : {
106
+ ...entries[i],
107
+ schema
108
+ };
109
+ const siblings = schema === void 0 ? entries : entries.map((item, index) => index === i ? entry : item);
110
+ return /* @__PURE__ */ jsx(FieldRow, {
111
+ entry,
112
+ required: param.required,
113
+ description: param.description,
114
+ onNavigate: () => onNavigate(entry, siblings)
115
+ });
116
+ };
117
+ const custom = renderParameterField?.(entries[i].fieldName, param, { renderDefault });
118
+ return /* @__PURE__ */ jsx(Fragment, { children: custom === void 0 ? renderDefault() : custom }, param.name);
119
+ })
109
120
  }, type);
110
121
  }),
111
122
  body && /* @__PURE__ */ jsx(BodySection, {
@@ -232,5 +243,4 @@ function BodySection({ body, renderBodyField, onNavigate }) {
232
243
  children: content
233
244
  });
234
245
  }
235
- //#endregion
236
246
  export { RequestPanel };
@@ -12,7 +12,7 @@ import { useState } from "react";
12
12
  import { jsx, jsxs } from "react/jsx-runtime";
13
13
  import { useTranslations } from "@fuma-translate/react";
14
14
  import { SendHorizontal } from "lucide-react";
15
- //#region src/ui/playground/components/response-panel.tsx
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" });
18
18
  return /* @__PURE__ */ jsxs("div", {
@@ -100,5 +100,4 @@ function ResponseExamples() {
100
100
  ]
101
101
  });
102
102
  }
103
- //#endregion
104
103
  export { ResponsePanel };
@@ -1,9 +1,7 @@
1
1
  import { FetchResult } from "../../../playground/fetcher.js";
2
2
  import { ComponentProps } from "react";
3
- //#region src/ui/playground/components/result-display.d.ts
4
3
  export interface ResultDisplayProps extends ComponentProps<'div'> {
5
4
  data: FetchResult;
6
5
  reset: () => void;
7
6
  }
8
- export declare function DefaultResultDisplay({ data, reset, ...rest }: ResultDisplayProps): import("react").JSX.Element;
9
- //#endregion
7
+ export declare function DefaultResultDisplay({ data, reset, ...rest }: ResultDisplayProps): import("react").JSX.Element;
@@ -6,7 +6,7 @@ import { useCallback, useMemo } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useTranslations } from "@fuma-translate/react";
8
8
  import { DownloadIcon, FileIcon } from "lucide-react";
9
- //#region src/ui/playground/components/result-display.tsx
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, {
12
12
  ...rest,
@@ -109,5 +109,4 @@ function TextResult({ lang, data }) {
109
109
  codeblock: panelCodeBlock
110
110
  });
111
111
  }
112
- //#endregion
113
112
  export { DefaultResultDisplay };
@@ -4,7 +4,7 @@ import { cn } from "../../../utils/cn.js";
4
4
  import { ServerPopover, ServerVariables } from "../../../packages/shared-api/dist/components/playground/server-select.js";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { useTranslations } from "@fuma-translate/react";
7
- //#region src/ui/playground/components/server-select.tsx
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 }) {
10
10
  const { servers, server, resolveUrl, setServer, setServerVariables } = useServer();
@@ -39,5 +39,4 @@ function ServerSelect({ className }) {
39
39
  }, server.url)
40
40
  });
41
41
  }
42
- //#endregion
43
42
  export { ServerSelect as default };
@@ -5,7 +5,7 @@ import { SendButton } from "../../../packages/shared-api/dist/components/playgro
5
5
  import { ParamInput } from "../../../packages/shared-api/dist/components/playground/param-input.js";
6
6
  import ServerSelect from "./server-select.js";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
- //#region src/ui/playground/components/url-bar.tsx
8
+ // src/ui/playground/components/url-bar.tsx
9
9
  function UrlBar({ method, route, parameters, deprecated = false, loading }) {
10
10
  return /* @__PURE__ */ jsxs("div", {
11
11
  className: "flex items-center gap-2",
@@ -34,5 +34,4 @@ function UrlBar({ method, route, parameters, deprecated = false, loading }) {
34
34
  }), /* @__PURE__ */ jsx(SendButton, { sending: loading })]
35
35
  });
36
36
  }
37
- //#endregion
38
37
  export { UrlBar };
@@ -9,7 +9,7 @@ import { buttonVariants } from "fumadocs-ui/components/ui/button";
9
9
  import { useApiClient } from "@scalar/api-client-react";
10
10
  import { useTheme } from "fumadocs-ui/provider/base";
11
11
  import "@scalar/api-client-react/style.css";
12
- //#region src/ui/scalar/client.tsx
12
+ // src/ui/scalar/client.tsx
13
13
  const noop = () => () => {};
14
14
  function ScalarPlayground({ path, method }) {
15
15
  const { resolvedTheme } = useTheme();
@@ -43,5 +43,4 @@ function ScalarPlayground({ path, method }) {
43
43
  ]
44
44
  });
45
45
  }
46
- //#endregion
47
46
  export { ScalarPlayground as default };
@@ -1,9 +1,7 @@
1
1
  import { CreateOpenAPIPageOptions } from "../index.js";
2
- //#region src/ui/scalar/index.d.ts
3
2
  /**
4
3
  * Enable Scalar for API playgrounds by wrapping your options inside.
5
4
  *
6
5
  * Requires `@scalar/api-client-react` to be installed, it imports the styles automatically.
7
6
  */
8
- export declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
9
- //#endregion
7
+ export declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { lazy } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
- //#region src/ui/scalar/index.tsx
4
+ // src/ui/scalar/index.tsx
5
5
  const Client = lazy(() => import("./client.js"));
6
6
  /**
7
7
  * Enable Scalar for API playgrounds by wrapping your options inside.
@@ -22,5 +22,4 @@ function withScalar(options = {}) {
22
22
  }
23
23
  };
24
24
  }
25
- //#endregion
26
25
  export { withScalar };
@@ -10,7 +10,7 @@ import { PageComponents, ShikiOptions } from "../packages/shared-api/dist/compon
10
10
  import { FC, ReactNode } from "react";
11
11
  import { JsonSchema } from "@fumadocs/json-schema";
12
12
  import { ShikiFactory } from "fumadocs-core/highlight/shiki";
13
- //#region src/utils/create-page.d.ts
13
+ import { Highlighter } from "fumadocs-core/highlight";
14
14
  /** components the UI renders through, so a page can replace them */
15
15
  export interface OpenAPIComponents extends PageComponents {
16
16
  SchemaUI: FC<SchemaUIOptions>;
@@ -95,8 +95,11 @@ export interface PageLayoutProps {
95
95
  * The options the UI renders with, read from `useRenderContext()`.
96
96
  */
97
97
  export interface OpenAPIRenderOptions {
98
- /** the Shiki highlighter of code blocks */
98
+ /** the highlighter of code blocks, defaults to Shiki */
99
+ highlighter?: Highlighter;
100
+ /** @deprecated use `highlighter`, like `createShikiHighlighter()` */
99
101
  shiki?: ShikiFactory;
102
+ /** @deprecated use `highlighter`, like `createShikiHighlighter()` */
100
103
  shikiOptions?: ShikiOptions;
101
104
  /**
102
105
  * Show full response schema instead of only example response & Typescript definitions.
@@ -180,8 +183,9 @@ export interface OpenAPIRenderOptions {
180
183
  * The render options of the page with their defaults applied, read from `useRenderContext()`.
181
184
  */
182
185
  export interface RenderContext extends OpenAPIRenderOptions {
183
- shiki: ShikiFactory;
186
+ /** @deprecated use `highlighter` */
184
187
  shikiOptions: ShikiOptions;
188
+ highlighter: Highlighter;
185
189
  }
186
190
  export interface CreateOpenAPIRendererOptions extends OpenAPIRuntimeOptions, OpenAPIRenderOptions {
187
191
  components: Partial<PageComponents> & {
@@ -208,10 +212,7 @@ export declare function useRenderContext(): RenderContext;
208
212
  */
209
213
  export declare function useTypeScriptDefinitions(schema: JsonSchema | undefined, options: Pick<GenerateTypeScriptDefinitionsContext, 'name' | 'readOnly' | 'writeOnly'>): string | undefined;
210
214
  /**
211
- * `createOpenAPIRenderer()` with nothing built in: it highlights through the `shiki` you pass, and
212
- * generates code usages and TypeScript definitions only when you pass them.
215
+ * `createOpenAPIRenderer()` with nothing built in: it highlights through the `highlighter` you pass,
216
+ * and generates code usages and TypeScript definitions only when you pass them.
213
217
  */
214
- export declare function createOpenAPIBaseRenderer({ components, loadDocument, ...options }: CreateOpenAPIRendererOptions & {
215
- shiki: ShikiFactory;
216
- }): FC<OpenAPIPageProps>;
217
- //#endregion
218
+ export declare function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }: CreateOpenAPIRendererOptions): FC<OpenAPIPageProps>;
@@ -4,14 +4,14 @@ import { defaultAdapters } from "../requests/media/adapter.js";
4
4
  import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
5
5
  import { registerDefault } from "../requests/generators/all.js";
6
6
  import { createDocumentCache } from "../packages/shared-api/dist/utils/document-cache.js";
7
- import { createPageComponents, defaultShikiOptions } from "../packages/shared-api/dist/components/defaults.js";
7
+ import { createPageComponents, defaultShikiOptions, resolveHighlighter } from "../packages/shared-api/dist/components/defaults.js";
8
8
  import { ServerProvider } from "./use-server.js";
9
9
  import { PlaygroundAuthProvider } from "../playground/auth.js";
10
10
  import { createContext, use, useMemo } from "react";
11
11
  import { getRaw } from "@scalar/json-magic/magic-proxy";
12
12
  import { generate } from "@fumari/json-schema-ts";
13
13
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
- //#region src/utils/create-page.tsx
14
+ // src/utils/create-page.tsx
15
15
  const OpenAPIContext = createContext(null);
16
16
  const ComponentsContext = createContext(null);
17
17
  const OptionsContext = createContext(null);
@@ -59,7 +59,7 @@ function useTypeScriptDefinitions(schema, options) {
59
59
  ]);
60
60
  return result instanceof Promise ? use(result) : result;
61
61
  }
62
- function OpenAPIProvider({ document: input, mediaAdapters, codeUsages, generateCodeSamples, generateTypeScriptDefinitions, proxyUrl, storageKeyPrefix = "fumadocs-openapi-", oauthRedirectUrl, shiki, shikiOptions = defaultShikiOptions, showResponseSchema, content, schemaUI, playground, components, children }) {
62
+ function OpenAPIProvider({ document: input, mediaAdapters, codeUsages, generateCodeSamples, generateTypeScriptDefinitions, proxyUrl, storageKeyPrefix = "fumadocs-openapi-", oauthRedirectUrl, shiki, shikiOptions = defaultShikiOptions, highlighter, showResponseSchema, content, schemaUI, playground, components, children }) {
63
63
  const document = input instanceof Promise ? use(input) : input;
64
64
  const runtime = useMemo(() => ({
65
65
  doc: dereferenceBundledDocument(document),
@@ -86,6 +86,7 @@ function OpenAPIProvider({ document: input, mediaAdapters, codeUsages, generateC
86
86
  const render = useMemo(() => ({
87
87
  shiki,
88
88
  shikiOptions,
89
+ highlighter,
89
90
  showResponseSchema,
90
91
  content,
91
92
  schemaUI,
@@ -93,6 +94,7 @@ function OpenAPIProvider({ document: input, mediaAdapters, codeUsages, generateC
93
94
  }), [
94
95
  shiki,
95
96
  shikiOptions,
97
+ highlighter,
96
98
  showResponseSchema,
97
99
  content,
98
100
  schemaUI,
@@ -140,16 +142,21 @@ function createRenderer(options) {
140
142
  });
141
143
  }
142
144
  /**
143
- * `createOpenAPIRenderer()` with nothing built in: it highlights through the `shiki` you pass, and
144
- * generates code usages and TypeScript definitions only when you pass them.
145
+ * `createOpenAPIRenderer()` with nothing built in: it highlights through the `highlighter` you pass,
146
+ * and generates code usages and TypeScript definitions only when you pass them.
145
147
  */
146
- function createOpenAPIBaseRenderer({ components, loadDocument, ...options }) {
148
+ function createOpenAPIBaseRenderer({ components, loadDocument, ...rest }) {
149
+ const highlighter = resolveHighlighter(rest);
150
+ const options = {
151
+ ...rest,
152
+ highlighter
153
+ };
147
154
  const { Operation, Layout = DefaultLayout } = components;
148
155
  const load = createDocumentCache();
149
156
  const slots = {
150
157
  SchemaUI: components.SchemaUI,
151
158
  ...createPageComponents({
152
- ...options,
159
+ highlighter,
153
160
  components
154
161
  })
155
162
  };
@@ -223,5 +230,4 @@ function createOpenAPIBaseRenderer({ components, loadDocument, ...options }) {
223
230
  function DefaultLayout({ operations, webhooks }) {
224
231
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [operations?.map((item) => item.children), webhooks?.map((item) => item.children)] });
225
232
  }
226
- //#endregion
227
233
  export { createOpenAPIBaseRenderer, createRenderer, useComponents, useOpenAPI, useRenderContext, useTypeScriptDefinitions };
@@ -1,6 +1,5 @@
1
1
  import { Document } from "../../types.js";
2
2
  import { DereferencedShallow } from "@fumadocs/json-schema";
3
- //#region src/utils/document/dereference.d.ts
4
3
  export interface DereferencedDocument {
5
4
  /**
6
5
  * document wrapped in a magic proxy (`@scalar/json-magic`).
@@ -15,5 +14,4 @@ export interface DereferencedDocument {
15
14
  */
16
15
  resolve: <T>(node: T) => DereferencedShallow<T>;
17
16
  bundled: Document;
18
- }
19
- //#endregion
17
+ }
@@ -1,6 +1,6 @@
1
1
  import { createMagicProxy } from "@scalar/json-magic/magic-proxy";
2
2
  import { dereference } from "@fumadocs/json-schema";
3
- //#region src/utils/document/dereference.ts
3
+ // src/utils/document/dereference.ts
4
4
  const cache = /* @__PURE__ */ new WeakMap();
5
5
  function dereferenceBundledDocument(bundled) {
6
6
  const cached = cache.get(bundled);
@@ -15,5 +15,4 @@ function dereferenceBundledDocument(bundled) {
15
15
  cache.set(bundled, doc);
16
16
  return doc;
17
17
  }
18
- //#endregion
19
18
  export { dereferenceBundledDocument };
@@ -1,6 +1,6 @@
1
1
  import { upgrade } from "@scalar/openapi-upgrader";
2
2
  import { bundle } from "@fumadocs/json-schema/bundle";
3
- //#region src/utils/document/load.ts
3
+ // src/utils/document/load.ts
4
4
  /**
5
5
  * Process input document to a Fumadocs OpenAPI compatible format
6
6
  */
@@ -11,5 +11,4 @@ async function loadDocument(input) {
11
11
  throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
12
12
  }
13
13
  }
14
- //#endregion
15
14
  export { loadDocument };
@@ -2,7 +2,7 @@ import { encodeRequestData } from "../requests/media/encode.js";
2
2
  import { getExampleValue, getPreferredType, pickExample } from "./schema.js";
3
3
  import { getRaw } from "@scalar/json-magic/magic-proxy";
4
4
  import { dereference, sample } from "@fumadocs/json-schema";
5
- //#region src/utils/get-example-requests.ts
5
+ // src/utils/get-example-requests.ts
6
6
  function getExampleRequests({ path, method, mediaAdapters, operation, parameters }) {
7
7
  const requestBody = dereference(operation.requestBody);
8
8
  const media = requestBody?.content ? getPreferredType(requestBody.content) : null;
@@ -52,7 +52,8 @@ function getRequestData({ method, path, parameters, sampleKey, body }) {
52
52
  method
53
53
  };
54
54
  for (const param of parameters) {
55
- let value = pickExample(param);
55
+ const keyed = sampleKey !== void 0 && param.examples && Object.hasOwn(param.examples, sampleKey) ? param.examples[sampleKey] : void 0;
56
+ let value = keyed !== void 0 ? getExampleValue(dereference(keyed)) : pickExample(param);
56
57
  if (value === void 0 && param.required) {
57
58
  if (param.schema) value = sample(param.schema);
58
59
  else if (param.content) {
@@ -80,7 +81,7 @@ function getRequestData({ method, path, parameters, sampleKey, body }) {
80
81
  if (!type) throw new Error(`Cannot find body schema for ${path} ${method}: missing media type`);
81
82
  result.bodyMediaType = type;
82
83
  const bodyOfType = dereference(body.content[type]);
83
- if (bodyOfType.examples && sampleKey) result.body = getExampleValue(dereference(bodyOfType.examples[sampleKey]));
84
+ if (bodyOfType.examples && sampleKey !== void 0) result.body = getExampleValue(dereference(bodyOfType.examples[sampleKey]));
84
85
  else if (bodyOfType.example) result.body = getRaw(bodyOfType.example);
85
86
  else result.body = sample(bodyOfType?.schema ?? {}, {
86
87
  skipReadOnly: method !== "get",
@@ -90,5 +91,4 @@ function getRequestData({ method, path, parameters, sampleKey, body }) {
90
91
  }
91
92
  return result;
92
93
  }
93
- //#endregion
94
94
  export { getExampleRequests };
@@ -1,6 +1,5 @@
1
1
  import { Document, HttpMethods, OperationObject, PathItemObject, TagObject } from "../../types.js";
2
2
  import { DereferencedShallow } from "@fumadocs/json-schema";
3
- //#region src/utils/pages/builder.d.ts
4
3
  interface BaseEntry {
5
4
  path: string;
6
5
  schemaId: string;
@@ -123,5 +122,4 @@ export type OpenAPIPageProps_Preloaded = GeneratedPageProps & {
123
122
  proxyUrl?: string;
124
123
  };
125
124
  };
126
- //#endregion
127
125
  export {};
@@ -2,7 +2,7 @@ import { dereferenceBundledDocument } from "../document/dereference.js";
2
2
  import { idToTitle } from "../../packages/shared-api/dist/utils/id-to-title.js";
3
3
  import { getTagDisplayName, methodKeys } from "../schema.js";
4
4
  import { dereference } from "@fumadocs/json-schema";
5
- //#region src/utils/pages/builder.ts
5
+ // src/utils/pages/builder.ts
6
6
  function fromSchema(schemaId, bundled, config) {
7
7
  const files = [];
8
8
  const { toPages } = config;
@@ -112,5 +112,4 @@ function getPageProps(entry) {
112
112
  webhooks: entry.webhooks
113
113
  };
114
114
  }
115
- //#endregion
116
115
  export { fromSchema, getPageProps };
@@ -1,6 +1,5 @@
1
1
  import { DistributiveOmit } from "../../types.js";
2
2
  import { OperationOutput, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput } from "./builder.js";
3
- //#region src/utils/pages/preset-auto.d.ts
4
3
  interface OperationConfig extends BaseConfig {
5
4
  /**
6
5
  * Generate a page for each API endpoint/operation (default).
@@ -64,5 +63,4 @@ interface BaseConfig {
64
63
  */
65
64
  slugify?: (name: string) => string;
66
65
  }
67
- //#endregion
68
66
  export {};
@@ -1,7 +1,7 @@
1
1
  import { getTagDisplayName } from "../schema.js";
2
2
  import { dereference } from "@fumadocs/json-schema";
3
3
  import * as path from "node:path";
4
- //#region src/utils/pages/preset-auto.ts
4
+ // src/utils/pages/preset-auto.ts
5
5
  function createAutoPreset(options) {
6
6
  if (options.per === "custom") return options;
7
7
  const { slugify = (s) => {
@@ -208,5 +208,4 @@ function createAutoPreset(options) {
208
208
  for (const entry of root) builder.create(entry);
209
209
  } };
210
210
  }
211
- //#endregion
212
211
  export { createAutoPreset };
@@ -1,12 +1,10 @@
1
1
  import "./builder.js";
2
2
  import { TOCItemType } from "fumadocs-core/toc";
3
3
  import "fumadocs-core/mdx-plugins";
4
- //#region src/utils/pages/to-static-data.d.ts
5
4
  /** the `_openapi` data of pages */
6
5
  export interface InternalOpenAPIMeta {
7
6
  method?: string;
8
7
  webhook?: boolean;
9
8
  deprecated?: boolean;
10
9
  preload?: string[];
11
- }
12
- //#endregion
10
+ }
@@ -2,7 +2,7 @@ import { dereferenceBundledDocument } from "../document/dereference.js";
2
2
  import { idToTitle } from "../../packages/shared-api/dist/utils/id-to-title.js";
3
3
  import { dereference } from "@fumadocs/json-schema";
4
4
  import Slugger from "github-slugger";
5
- //#region src/utils/pages/to-static-data.ts
5
+ // src/utils/pages/to-static-data.ts
6
6
  function toStaticData(page, doc) {
7
7
  const proxied = dereferenceBundledDocument(doc).dereferenced;
8
8
  const slugger = new Slugger();
@@ -45,5 +45,4 @@ function toStaticData(page, doc) {
45
45
  structuredData
46
46
  };
47
47
  }
48
- //#endregion
49
48
  export { toStaticData };
@@ -1,6 +1,5 @@
1
1
  import { TagObject } from "../../types.js";
2
2
  import "./builder.js";
3
- //#region src/utils/pages/to-text.d.ts
4
3
  export interface PagesToTextOptions {
5
4
  /**
6
5
  * Additional imports of your MDX components.
@@ -40,5 +39,4 @@ export type DocumentContext = {
40
39
  type: 'operation';
41
40
  } | {
42
41
  type: 'file';
43
- };
44
- //#endregion
42
+ };
@@ -2,7 +2,7 @@ import { doubleQuote, jsxString } from "../../requests/string-utils.js";
2
2
  import { getPageProps } from "./builder.js";
3
3
  import { toStaticData } from "./to-static-data.js";
4
4
  import { stringify } from "yaml";
5
- //#region src/utils/pages/to-text.ts
5
+ // src/utils/pages/to-text.ts
6
6
  function toText(entry, doc, options = {}) {
7
7
  const { frontmatter, includeDescription = false } = options;
8
8
  const extend = frontmatter?.(entry.info.title, entry.info.description, entry.type === "page" ? entry.tag ? {
@@ -70,5 +70,4 @@ function pageContent({ showTitle, showDescription, document, webhooks, operation
70
70
  );
71
71
  }`;
72
72
  }
73
- //#endregion
74
73
  export { generateDocument, toText };