fumadocs-openapi 12.6.1 → 12.6.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.
@@ -215,7 +215,7 @@ function SiblingSelect({ entry, siblings, onSelect }) {
215
215
  },
216
216
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
217
217
  "aria-label": t("Switch Field"),
218
- className: "h-7 w-auto min-w-0 gap-1 border-0 bg-transparent px-1.5 py-0 font-mono text-[0.8125rem] font-medium text-fd-foreground hover:bg-fd-accent focus:ring-0 focus-visible:ring-2 data-popup-open:bg-fd-accent",
218
+ className: "h-7 w-auto min-w-0 gap-1.5 border-0 bg-transparent px-1.5 py-0 font-mono text-[0.8125rem] font-medium text-fd-foreground hover:bg-fd-accent focus:ring-0 focus-visible:ring-2 data-popup-open:bg-fd-accent",
219
219
  children: /* @__PURE__ */ jsx(SelectValue, { className: "truncate" })
220
220
  }), /* @__PURE__ */ jsx(SelectContent, { children: items.map((item) => /* @__PURE__ */ jsx(SelectItem, {
221
221
  value: item.value,
@@ -229,7 +229,7 @@ function Section({ icon: Icon, title, count, actions, children }) {
229
229
  return /* @__PURE__ */ jsxs("section", {
230
230
  className: "border-b last:border-b-0",
231
231
  children: [/* @__PURE__ */ jsxs("div", {
232
- className: "sticky top-0 z-10 flex h-10 items-center gap-2 border-b bg-fd-card ps-4 pe-2 @sm:pe-7.5",
232
+ className: "sticky top-0 z-10 flex h-10 items-center gap-2 border-b bg-fd-card ps-4 pe-4",
233
233
  children: [
234
234
  /* @__PURE__ */ jsx(Icon, { className: "size-3.5 shrink-0 text-fd-primary" }),
235
235
  /* @__PURE__ */ jsx("h3", {
@@ -17,11 +17,11 @@ function ServerPopover({ label, title, options, value, onValueChange, className,
17
17
  open,
18
18
  onOpenChange: setOpen,
19
19
  children: [/* @__PURE__ */ jsxs(Popover.Trigger, {
20
- className: cn("group flex min-w-0 shrink items-center gap-1 rounded-lg px-1.5 py-1 text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground", className),
20
+ className: cn("group flex min-w-0 shrink items-center gap-1.5 rounded-lg px-1.5 py-1 text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring data-popup-open:bg-fd-accent data-popup-open:text-fd-accent-foreground", className),
21
21
  children: [/* @__PURE__ */ jsx("span", {
22
22
  className: "truncate",
23
23
  children: label
24
- }), /* @__PURE__ */ jsx(ChevronDown, { className: "size-3 shrink-0 transition-transform duration-200 group-data-popup-open:rotate-180" })]
24
+ }), /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5 shrink-0 transition-transform duration-200 group-data-popup-open:rotate-180" })]
25
25
  }), /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
26
26
  side: "bottom",
27
27
  align: "start",
@@ -41,7 +41,7 @@ function SelectTabTrigger({ items, className, ...props }) {
41
41
  value,
42
42
  onValueChange: setValue,
43
43
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
44
- className: cn("not-prose h-7 w-auto min-w-0 gap-1 border-0 bg-transparent px-1.5 py-0 text-[0.8125rem] font-medium *:min-w-0 hover:bg-fd-accent hover:text-fd-accent-foreground focus:ring-0 focus-visible:ring-2 focus-visible:ring-inset data-popup-open:bg-fd-accent", className),
44
+ className: cn("not-prose h-7 w-auto min-w-0 gap-1.5 border-0 bg-transparent px-1.5 py-0 text-[0.8125rem] font-medium *:min-w-0 hover:bg-fd-accent hover:text-fd-accent-foreground focus:ring-0 focus-visible:ring-2 focus-visible:ring-inset data-popup-open:bg-fd-accent", className),
45
45
  ...props,
46
46
  children: /* @__PURE__ */ jsx(SelectValue, {})
47
47
  }), /* @__PURE__ */ jsx(SelectContent, { children: items.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, {
@@ -2,17 +2,17 @@ import { cn } from "../utils/cn.js";
2
2
  import "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { Check, ChevronDown } from "lucide-react";
5
- import { Select } from "@base-ui/react/select";
5
+ import { Select as Select$1 } from "@base-ui/react/select";
6
6
  // ../shared-api/dist/components/select.js
7
- const Select$2 = Select.Root;
8
- Select.Group;
9
- const SelectValue = Select.Value;
7
+ const Select = Select$1.Root;
8
+ Select$1.Group;
9
+ const SelectValue = Select$1.Value;
10
10
  function SelectTrigger({ className, children, ref, ...props }) {
11
- return /* @__PURE__ */ jsxs(Select.Trigger, {
11
+ return /* @__PURE__ */ jsxs(Select$1.Trigger, {
12
12
  ref,
13
13
  className: cn("flex items-center w-full rounded-md border p-2 gap-2 text-start text-sm text-fd-secondary-foreground bg-fd-secondary hover:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-fd-muted-foreground", className),
14
14
  ...props,
15
- children: [children, /* @__PURE__ */ jsx(Select.Icon, {
15
+ children: [children, /* @__PURE__ */ jsx(Select$1.Icon, {
16
16
  className: "ms-auto text-fd-muted-foreground shrink-0",
17
17
  children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5" })
18
18
  })]
@@ -20,7 +20,7 @@ function SelectTrigger({ className, children, ref, ...props }) {
20
20
  }
21
21
  const scrollArrowClassName = "inset-x-0 z-10 h-6 from-fd-popover to-transparent";
22
22
  function SelectScrollUpButton({ className, ref, ...props }) {
23
- return /* @__PURE__ */ jsx(Select.ScrollUpArrow, {
23
+ return /* @__PURE__ */ jsx(Select$1.ScrollUpArrow, {
24
24
  ref,
25
25
  className: cn(scrollArrowClassName, "top-0 bg-linear-to-b", className),
26
26
  ...props,
@@ -28,7 +28,7 @@ function SelectScrollUpButton({ className, ref, ...props }) {
28
28
  });
29
29
  }
30
30
  function SelectScrollDownButton({ className, ref, ...props }) {
31
- return /* @__PURE__ */ jsx(Select.ScrollDownArrow, {
31
+ return /* @__PURE__ */ jsx(Select$1.ScrollDownArrow, {
32
32
  ref,
33
33
  className: cn(scrollArrowClassName, "bottom-0 bg-linear-to-t", className),
34
34
  ...props,
@@ -36,18 +36,18 @@ function SelectScrollDownButton({ className, ref, ...props }) {
36
36
  });
37
37
  }
38
38
  function SelectContent({ className, children, align = "start", side = "bottom", sideOffset = 4, ref, ...props }) {
39
- return /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, {
39
+ return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(Select$1.Positioner, {
40
40
  align,
41
41
  side,
42
42
  sideOffset,
43
43
  className: "z-50",
44
- children: /* @__PURE__ */ jsxs(Select.Popup, {
44
+ children: /* @__PURE__ */ jsxs(Select$1.Popup, {
45
45
  ref,
46
46
  className: cn("relative z-50 min-w-[calc(var(--anchor-width)+--spacing(2))] overflow-hidden rounded-lg border bg-fd-popover text-fd-popover-foreground shadow-md", className),
47
47
  ...props,
48
48
  children: [
49
49
  /* @__PURE__ */ jsx(SelectScrollUpButton, {}),
50
- /* @__PURE__ */ jsx(Select.List, {
50
+ /* @__PURE__ */ jsx(Select$1.List, {
51
51
  className: "p-1",
52
52
  children
53
53
  }),
@@ -57,18 +57,18 @@ function SelectContent({ className, children, align = "start", side = "bottom",
57
57
  }) });
58
58
  }
59
59
  function SelectItem({ className, children, description, ref, ...props }) {
60
- const text = /* @__PURE__ */ jsx(Select.ItemText, { children });
61
- return /* @__PURE__ */ jsxs(Select.Item, {
60
+ const text = /* @__PURE__ */ jsx(Select$1.ItemText, { children });
61
+ return /* @__PURE__ */ jsxs(Select$1.Item, {
62
62
  ref,
63
63
  className: cn("flex select-none flex-row items-center gap-2 rounded-md py-1.5 px-2 text-sm outline-none data-[highlighted]:bg-fd-accent data-[highlighted]:text-fd-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className),
64
64
  ...props,
65
65
  children: [description ? /* @__PURE__ */ jsxs("div", {
66
66
  className: "flex flex-col",
67
67
  children: [text, description]
68
- }) : text, /* @__PURE__ */ jsx(Select.ItemIndicator, {
68
+ }) : text, /* @__PURE__ */ jsx(Select$1.ItemIndicator, {
69
69
  className: "ms-auto shrink-0",
70
70
  children: /* @__PURE__ */ jsx(Check, { className: "size-3.5 text-fd-primary" })
71
71
  })]
72
72
  });
73
73
  }
74
- export { Select$2 as Select, SelectContent, SelectItem, SelectScrollDownButton, SelectScrollUpButton, SelectTrigger, SelectValue };
74
+ export { Select, SelectContent, SelectItem, SelectScrollDownButton, SelectScrollUpButton, SelectTrigger, SelectValue };
@@ -154,8 +154,11 @@ export interface AuthRenderProps {
154
154
  name: string;
155
155
  type?: string;
156
156
  description?: string;
157
+ /** a secret string by default, entered in a password input */
157
158
  schema?: Exclude<JsonSchema, boolean>;
158
159
  path?: string;
160
+ /** fixed text before the input, like the scheme of a token */
161
+ start?: ReactNode;
159
162
  /** after the input, like a button filling the value */
160
163
  end?: ReactNode;
161
164
  }>;
@@ -189,8 +192,12 @@ export interface AuthFields {
189
192
  select: (index: number) => void;
190
193
  /** the fields of the selected requirement */
191
194
  fields: AuthField[];
192
- /** encode the auth values of page into request data, like the form values */
193
- mapValues: <T>(values: T) => T;
195
+ /**
196
+ * encode the auth values of page into request data, like the form values
197
+ *
198
+ * @param masked - replace the values with `********`, for code usages
199
+ */
200
+ mapValues: <T>(values: T, masked?: boolean) => T;
194
201
  /** restore the persisted values, returns a cleanup */
195
202
  init: () => () => void;
196
203
  }
@@ -247,10 +247,12 @@ const subscribeNever = () => () => {};
247
247
  function getReturnedFlow() {
248
248
  if (returnedFlow === void 0) {
249
249
  const stored = sessionStorage.getItem(pendingFlowKey);
250
+ const returnedUrl = sessionStorage.getItem("fumadocs-openapi-oauth-returned");
250
251
  sessionStorage.removeItem(pendingFlowKey);
252
+ sessionStorage.removeItem("fumadocs-openapi-oauth-returned");
251
253
  returnedFlow = stored ? {
252
254
  ...JSON.parse(stored),
253
- url: new URL(window.location.href)
255
+ url: new URL(returnedUrl ?? window.location.href)
254
256
  } : null;
255
257
  }
256
258
  return returnedFlow ?? void 0;
@@ -361,14 +363,11 @@ const builtinProviders = [
361
363
  name: "username",
362
364
  type: "basic",
363
365
  description: field.scheme.description,
364
- path: "username"
366
+ path: "username",
367
+ schema: { type: "string" }
365
368
  }), /* @__PURE__ */ jsx(Value, {
366
369
  name: "password",
367
- path: "password",
368
- schema: {
369
- type: "string",
370
- format: "password"
371
- }
370
+ path: "password"
372
371
  })] }),
373
372
  onRequest(data, value) {
374
373
  const { username, password } = value;
@@ -392,13 +391,15 @@ const builtinProviders = [
392
391
  onRequest() {}
393
392
  },
394
393
  {
395
- render: ({ field, Value }) => /* @__PURE__ */ jsx(Value, {
394
+ render: ({ field: { scheme }, Value }) => /* @__PURE__ */ jsx(Value, {
396
395
  name: "Authorization",
397
396
  type: "header",
398
- description: field.scheme.description
397
+ start: getAuthScheme(scheme),
398
+ description: scheme.description
399
399
  }),
400
- onRequest(data, value) {
401
- data.header.Authorization = value;
400
+ onRequest(data, value, { scheme }) {
401
+ const token = value;
402
+ data.header.Authorization = token.includes(" ") ? token : `${getAuthScheme(scheme)} ${token}`;
402
403
  }
403
404
  }
404
405
  ];
@@ -412,14 +413,17 @@ function findProvider(providers = [], item) {
412
413
  return provider;
413
414
  }
414
415
  function getDefaultValue(scheme) {
415
- if (scheme.type === "apiKey") return "";
416
416
  if (scheme.type === "mutualTLS") return null;
417
- if (scheme.type !== "http" || !scheme.scheme) return "Bearer ";
418
- if (scheme.scheme.toLowerCase() === "basic") return {
417
+ if (scheme.type === "http" && scheme.scheme?.toLowerCase() === "basic") return {
419
418
  username: "",
420
419
  password: ""
421
420
  };
422
- return `${scheme.scheme[0].toUpperCase()}${scheme.scheme.slice(1)} `;
421
+ return "";
422
+ }
423
+ /** the scheme of `Authorization` header, like `Bearer` */
424
+ function getAuthScheme(scheme) {
425
+ if (scheme.type !== "http" || !scheme.scheme) return "Bearer";
426
+ return `${scheme.scheme[0].toUpperCase()}${scheme.scheme.slice(1)}`;
423
427
  }
424
428
  /**
425
429
  * The auth fields of an API playground: the values it persists, and the request data they encode into.
@@ -490,10 +494,11 @@ function useAuthFields(engine, { operation, providers, transform } = {}) {
490
494
  selected,
491
495
  select,
492
496
  fields,
493
- mapValues: useCallback((values) => {
497
+ mapValues: useCallback((values, masked) => {
498
+ const auth = page.get(["auth"]) ?? {};
494
499
  const cloned = structuredClone({
495
500
  ...values,
496
- auth: page.get(["auth"])
501
+ auth: masked ? JSON.parse(JSON.stringify(auth), (_, v) => typeof v === "string" && v ? "********" : v) : auth
497
502
  });
498
503
  const data = cloned;
499
504
  for (const field of fields) field.provider.onRequest(data, objectGet(data, field.fieldName), field);
@@ -79,14 +79,14 @@ function usePlayground({ authProviders, transformAuthInputs, fetchOptions } = {}
79
79
  providers: authProviders,
80
80
  transform: transformAuthInputs
81
81
  });
82
- function getRequestData() {
82
+ function getRequestData(masked) {
83
83
  return auth.mapValues({
84
84
  ...engine.getData(),
85
85
  method,
86
86
  bodyMediaType: body?.mediaType
87
- });
87
+ }, masked);
88
88
  }
89
- const syncExample = useEffectEvent(() => update(getRequestData()));
89
+ const syncExample = useEffectEvent(() => update(getRequestData(true)));
90
90
  const [selectedFor, setSelectedFor] = useState();
91
91
  if (returnedScheme !== selectedFor) {
92
92
  setSelectedFor(returnedScheme);
@@ -1,6 +1,9 @@
1
1
  // src/server/oauth.ts
2
2
  const script = `const page = sessionStorage.getItem('fumadocs-openapi-oauth');
3
- if (page) location.replace(location.origin + page + location.search + location.hash);`;
3
+ if (page) {
4
+ sessionStorage.setItem('fumadocs-openapi-oauth-returned', location.href);
5
+ location.replace(location.origin + page);
6
+ }`;
4
7
  /**
5
8
  * A route handler for the redirect URI of OAuth flows, it sends users back to the page that started the flow.
6
9
  */
@@ -151,7 +151,7 @@ function AuthSection({ auth, onAuthorize }) {
151
151
  value: selected,
152
152
  onValueChange: (v) => v !== null && select(v),
153
153
  children: [/* @__PURE__ */ jsx(SelectTrigger, {
154
- className: "h-7 w-auto max-w-60 gap-1.5 @sm:-me-2 border-0 bg-transparent px-2 text-xs hover:bg-fd-accent focus:ring-0 focus-visible:ring-2",
154
+ className: "h-7 w-auto max-w-60 -me-3 gap-1.5 border-0 bg-transparent px-2 text-xs hover:bg-fd-accent focus:ring-0 focus-visible:ring-2",
155
155
  children: /* @__PURE__ */ jsx(SelectValue, { className: "truncate" })
156
156
  }), /* @__PURE__ */ jsx(SelectContent, {
157
157
  align: "end",
@@ -182,8 +182,11 @@ function AuthSection({ auth, onAuthorize }) {
182
182
  });
183
183
  }
184
184
  const AuthFieldContext = createContext(null);
185
- const stringSchema = { type: "string" };
186
- function AuthValue({ path, schema = stringSchema, ...props }) {
185
+ const secretSchema = {
186
+ type: "string",
187
+ format: "password"
188
+ };
189
+ function AuthValue({ path, schema = secretSchema, ...props }) {
187
190
  const { field } = use(AuthFieldContext);
188
191
  return /* @__PURE__ */ jsx(ValueRow, {
189
192
  ...props,
@@ -228,7 +231,6 @@ function BodySection({ body, renderBodyField, onNavigate }) {
228
231
  }), allowJson && /* @__PURE__ */ jsx(Segmented, {
229
232
  value: mode,
230
233
  onValueChange: setMode,
231
- className: "@sm:-me-2.5",
232
234
  children: /* @__PURE__ */ jsx(SegmentedList, {
233
235
  "aria-label": t("Editor"),
234
236
  items: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "12.6.1",
3
+ "version": "12.6.3",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "Docs",
@@ -58,13 +58,13 @@
58
58
  "@fumadocs/json-schema": "^0.3.5",
59
59
  "@fumari/json-schema-ts": "^1.0.2",
60
60
  "@fumari/stf": "^1.1.2",
61
- "@scalar/json-magic": "^0.18.0",
62
- "@scalar/openapi-upgrader": "^0.4.7",
61
+ "@scalar/json-magic": "^0.19.0",
62
+ "@scalar/openapi-upgrader": "^0.4.8",
63
63
  "chokidar": "^6.0.0",
64
64
  "class-variance-authority": "^0.7.1",
65
65
  "cn": "^0.5.2",
66
66
  "github-slugger": "^2.0.0",
67
- "lucide-react": "^1.70.0",
67
+ "lucide-react": "^1.71.0",
68
68
  "remark": "^15.0.1",
69
69
  "remark-rehype": "^11.1.2",
70
70
  "shiki": "^4.6.0",
@@ -72,7 +72,7 @@
72
72
  "yaml": "^2.9.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@scalar/api-client-react": "^2.0.64",
75
+ "@scalar/api-client-react": "^2.0.65",
76
76
  "@tailwindcss/oxide": "^4.3.5",
77
77
  "@types/node": "26.6.6",
78
78
  "@types/react": "^19.3.0",