fumadocs-openapi 10.8.6 → 10.9.0

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.
@@ -328,7 +328,6 @@
328
328
  @source inline("flex-col-reverse");
329
329
  @source inline("flex-row");
330
330
  @source inline("flex-wrap");
331
- @source inline("flow");
332
331
  @source inline("flows");
333
332
  @source inline("focus-visible:outline-none");
334
333
  @source inline("focus-visible:ring-1");
@@ -355,6 +354,7 @@
355
354
  @source inline("fromServer");
356
355
  @source inline("fs");
357
356
  @source inline("full");
357
+ @source inline("fumadocs-core/i18n");
358
358
  @source inline("fumadocs-core/source");
359
359
  @source inline("fumadocs-core/toc");
360
360
  @source inline("fumadocs-ui/mdx");
@@ -675,7 +675,6 @@
675
675
  @source inline("place");
676
676
  @source inline("placeholder");
677
677
  @source inline("placeholder:text-fd-muted-foreground");
678
- @source inline("placeholders");
679
678
  @source inline("playground");
680
679
  @source inline("playgroundEnabled");
681
680
  @source inline("playgrounds");
@@ -761,6 +760,7 @@
761
760
  @source inline("renderRequestTabsDefault");
762
761
  @source inline("renderResponseTabs");
763
762
  @source inline("renderResponseTabsDefault");
763
+ @source inline("renderTranslation");
764
764
  @source inline("renderTrigger");
765
765
  @source inline("renderWebhookLayout");
766
766
  @source inline("rendered");
@@ -961,6 +961,7 @@
961
961
  @source inline("tab");
962
962
  @source inline("tabs");
963
963
  @source inline("tag");
964
+ @source inline("test");
964
965
  @source inline("testQuery");
965
966
  @source inline("text");
966
967
  @source inline("text-[0.8125rem]");
@@ -1027,7 +1028,6 @@
1027
1028
  @source inline("transition-colors");
1028
1029
  @source inline("transition-transform");
1029
1030
  @source inline("translated");
1030
- @source inline("translation");
1031
1031
  @source inline("tree");
1032
1032
  @source inline("trigger");
1033
1033
  @source inline("true");
@@ -1064,7 +1064,6 @@
1064
1064
  @source inline("useAuth");
1065
1065
  @source inline("useCopyButton");
1066
1066
  @source inline("useFieldValue");
1067
- @source inline("useI18n");
1068
1067
  @source inline("useMemo");
1069
1068
  @source inline("useNamespace");
1070
1069
  @source inline("useObject");
@@ -1080,6 +1079,7 @@
1080
1079
  @source inline("useStorageKey");
1081
1080
  @source inline("useTheme");
1082
1081
  @source inline("useTranslations");
1082
+ @source inline("useTranslationsBase");
1083
1083
  @source inline("useTypeText");
1084
1084
  @source inline("used");
1085
1085
  @source inline("username");
@@ -1114,7 +1114,6 @@
1114
1114
  @source inline("will");
1115
1115
  @source inline("with");
1116
1116
  @source inline("withBase");
1117
- @source inline("withReplacements");
1118
1117
  @source inline("without");
1119
1118
  @source inline("wrap");
1120
1119
  @source inline("wrap-break-word");
package/dist/i18n.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { TranslationValue, TranslationsAPIExtension } from "fumadocs-core/i18n";
1
2
  import { I18nUIConfig } from "fumadocs-ui/i18n";
2
3
 
3
4
  //#region src/i18n.d.ts
@@ -14,6 +15,7 @@ declare const defaultTranslations: {
14
15
  body: string;
15
16
  deprecated: string;
16
17
  submit: string;
18
+ test: string;
17
19
  unsupported: string;
18
20
  close: string;
19
21
  inputPlaceholder: string;
@@ -32,7 +34,7 @@ declare const defaultTranslations: {
32
34
  authTokenIn: string;
33
35
  authScope: string;
34
36
  typeScriptDefinitions: string;
35
- useTypeInTypeScript: string;
37
+ useTypeInTypeScript: TranslationValue<"name">;
36
38
  schemaDefault: string;
37
39
  schemaMatch: string;
38
40
  schemaFormat: string;
@@ -43,7 +45,7 @@ declare const defaultTranslations: {
43
45
  schemaItems: string;
44
46
  schemaValueIn: string;
45
47
  schemaExample: string;
46
- responseTabName: string;
48
+ responseTabName: TranslationValue<"key">;
47
49
  responseTabNameDefault: string;
48
50
  closeJsonEditor: string;
49
51
  openJsonEditor: string;
@@ -58,7 +60,8 @@ declare const defaultTranslations: {
58
60
  statusSuccessful: string;
59
61
  statusError: string;
60
62
  statusClientError: string;
61
- statusBinaryBody: string;
63
+ statusBinaryBody: TranslationValue<"length">;
64
+ oauthFlowPlaceholder: string;
62
65
  obtainAccessToken: string;
63
66
  resourceOwnerPassword: string;
64
67
  resourceOwnerPasswordDesc: string;
@@ -96,6 +99,8 @@ declare const defaultTranslations: {
96
99
  playgroundInputUnset: string;
97
100
  };
98
101
  type Translations = typeof defaultTranslations;
102
+ declare function openapiTranslations(): TranslationsAPIExtension<'openapi', Translations>;
103
+ /** @deprecated use `i18n.translations()` & `openapiTranslations()` instead */
99
104
  declare function defineI18nOpenAPI<Languages extends string>(config: I18nUIConfig<Languages>, translations: Partial<Record<NoInfer<Languages>, Partial<Translations>>>): I18nUIConfig<Languages>;
100
105
  //#endregion
101
- export { Translations, defaultTranslations, defineI18nOpenAPI };
106
+ export { Translations, defaultTranslations, defineI18nOpenAPI, openapiTranslations };
package/dist/i18n.js CHANGED
@@ -1,6 +1,4 @@
1
- import { require_deepmerge } from "./node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js";
2
1
  //#region src/i18n.ts
3
- var import_deepmerge = require_deepmerge();
4
2
  const defaultTranslations = {
5
3
  loading: "loading...",
6
4
  empty: "Empty",
@@ -14,6 +12,7 @@ const defaultTranslations = {
14
12
  body: "Body",
15
13
  deprecated: "Deprecated",
16
14
  submit: "Submit",
15
+ test: "Test",
17
16
  unsupported: "Unsupported",
18
17
  close: "Close",
19
18
  inputPlaceholder: "Enter value",
@@ -59,6 +58,7 @@ const defaultTranslations = {
59
58
  statusError: "Error",
60
59
  statusClientError: "Client Error",
61
60
  statusBinaryBody: "Binary response body, {length} bytes",
61
+ oauthFlowPlaceholder: "Select a flow",
62
62
  obtainAccessToken: "Obtain the access token for API.",
63
63
  resourceOwnerPassword: "Resource Owner Password Flow",
64
64
  resourceOwnerPasswordDesc: "Authenticate using username and password.",
@@ -95,8 +95,14 @@ const defaultTranslations = {
95
95
  playgroundInputUpload: "Upload",
96
96
  playgroundInputUnset: "Unset"
97
97
  };
98
+ function openapiTranslations() {
99
+ return {
100
+ namespace: "openapi",
101
+ defaultValue: defaultTranslations
102
+ };
103
+ }
104
+ /** @deprecated use `i18n.translations()` & `openapiTranslations()` instead */
98
105
  function defineI18nOpenAPI(config, translations) {
99
- const dm = (0, import_deepmerge.deepmerge)();
100
106
  return {
101
107
  ...config,
102
108
  provider(locale = config.defaultLanguage) {
@@ -104,11 +110,14 @@ function defineI18nOpenAPI(config, translations) {
104
110
  const data = translations[locale];
105
111
  if (data) {
106
112
  out.translations ??= {};
107
- out.translations.openapi = dm(defaultTranslations, data);
113
+ out.translations.openapi = {
114
+ ...defaultTranslations,
115
+ ...data
116
+ };
108
117
  }
109
118
  return out;
110
119
  }
111
120
  };
112
121
  }
113
122
  //#endregion
114
- export { defaultTranslations, defineI18nOpenAPI };
123
+ export { defaultTranslations, defineI18nOpenAPI, openapiTranslations };
@@ -138,7 +138,7 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
138
138
  /* @__PURE__ */ jsxs(Select, {
139
139
  value: type ?? "",
140
140
  onValueChange: setType,
141
- children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select a flow" }) }), /* @__PURE__ */ jsx(SelectContent, { children: Object.keys(scheme.flows).map((key) => {
141
+ children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t.oauthFlowPlaceholder }) }), /* @__PURE__ */ jsx(SelectContent, { children: Object.keys(scheme.flows).map((key) => {
142
142
  const { name, description } = allFlows[key];
143
143
  return /* @__PURE__ */ jsxs(SelectItem, {
144
144
  value: key,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useTranslations, withReplacements } from "../../ui/client/i18n.js";
2
+ import { useTranslations } from "../../ui/client/i18n.js";
3
3
  import { useStatusInfo } from "../status-info.js";
4
4
  import { cn } from "../../utils/cn.js";
5
5
  import { ClientCodeBlock } from "../../ui/components/codeblock.js";
@@ -7,6 +7,7 @@ import { require_fast_content_type_parse } from "../../node_modules/.pnpm/fast-c
7
7
  import { useEffect, useMemo, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { CircleX } from "lucide-react";
10
+ import { renderTranslation } from "fumadocs-core/i18n";
10
11
  import { buttonVariants } from "fumadocs-ui/components/ui/button";
11
12
  import { cva } from "class-variance-authority";
12
13
  //#region src/playground/components/result-display.tsx
@@ -76,7 +77,7 @@ function ResponseResult({ data, reset, ...rest }) {
76
77
  });
77
78
  else content = /* @__PURE__ */ jsx("p", {
78
79
  className: "p-2 border rounded-lg bg-fd-card text-fd-card-foreground",
79
- children: withReplacements(t.statusBinaryBody, { length: String(data.body.byteLength) })
80
+ children: renderTranslation(t.statusBinaryBody, { length: String(data.body.byteLength) })
80
81
  });
81
82
  }
82
83
  return /* @__PURE__ */ jsxs("div", {
@@ -1,3 +1,4 @@
1
+ import { useTranslations } from "../../ui/client/i18n.js";
1
2
  import { cn } from "../../utils/cn.js";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  import { Loader2Icon } from "lucide-react";
@@ -5,7 +6,7 @@ import { Loader2Icon } from "lucide-react";
5
6
  function Spinner({ className, ...props }) {
6
7
  return /* @__PURE__ */ jsx(Loader2Icon, {
7
8
  role: "status",
8
- "aria-label": "Loading",
9
+ "aria-label": useTranslations().loading,
9
10
  className: cn("size-4 animate-spin", className),
10
11
  ...props
11
12
  });
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { I18nLabel } from "../ui/client/i18n.js";
2
3
  import { cn } from "../utils/cn.js";
3
4
  import { MethodLabel } from "../ui/components/method-label.js";
4
5
  import { useEffect, useState } from "react";
@@ -39,7 +40,7 @@ function ScalarPlayground({ path, method, spec }) {
39
40
  path,
40
41
  method
41
42
  }),
42
- children: "Test"
43
+ children: /* @__PURE__ */ jsx(I18nLabel, { label: "test" })
43
44
  })
44
45
  ]
45
46
  });
@@ -1,19 +1,16 @@
1
1
  "use client";
2
2
  import { defaultTranslations } from "../../i18n.js";
3
- import { useI18n } from "fumadocs-ui/contexts/i18n";
3
+ import { renderTranslation } from "fumadocs-core/i18n";
4
+ import { useTranslations } from "fumadocs-ui/contexts/i18n";
4
5
  //#region src/ui/client/i18n.ts
5
- function useTranslations() {
6
- return useI18n().text.openapi ?? defaultTranslations;
6
+ function useTranslations$1() {
7
+ return useTranslations("openapi") ?? defaultTranslations;
7
8
  }
8
9
  /**
9
10
  * Renders a translated string. Use in server components so the label is resolved on the client from the current locale.
10
11
  */
11
- function I18nLabel({ label, replacements = {} }) {
12
- return withReplacements(useTranslations()[label], replacements);
13
- }
14
- function withReplacements(t, replacements) {
15
- for (const [k, v] of Object.entries(replacements)) t = t.replaceAll(`{${k}}`, v);
16
- return t;
12
+ function I18nLabel({ label, replacements }) {
13
+ return renderTranslation(useTranslations$1()[label], replacements);
17
14
  }
18
15
  //#endregion
19
- export { I18nLabel, useTranslations, withReplacements };
16
+ export { I18nLabel, useTranslations$1 as useTranslations };
@@ -1,5 +1,5 @@
1
- import { require_deepmerge } from "../../node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js";
2
1
  import { isPlainObject } from "../is-plain-object.js";
2
+ import { require_deepmerge } from "../../node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js";
3
3
  import { resolveRefSync } from "./resolve-ref.js";
4
4
  const mergeDeep = (0, require_deepmerge().deepmerge)({
5
5
  all: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "10.8.6",
3
+ "version": "10.9.0",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "Docs",
@@ -72,15 +72,15 @@
72
72
  "tailwindcss": "^4.3.0",
73
73
  "tsdown": "0.22.0",
74
74
  "xml-js": "^1.6.11",
75
- "fumadocs-core": "16.8.12",
76
- "fumadocs-ui": "16.8.12",
75
+ "fumadocs-core": "16.9.0",
76
+ "fumadocs-ui": "16.9.0",
77
77
  "tsconfig": "0.0.0"
78
78
  },
79
79
  "peerDependencies": {
80
80
  "@scalar/api-client-react": "2.0.1",
81
81
  "@types/react": "*",
82
- "fumadocs-core": "^16.7.15",
83
- "fumadocs-ui": "^16.7.15",
82
+ "fumadocs-core": "^16.9.0",
83
+ "fumadocs-ui": "^16.9.0",
84
84
  "json-schema-typed": "*",
85
85
  "react": "^19.2.0",
86
86
  "react-dom": "^19.2.0"