fumadocs-openapi 5.3.2 → 5.4.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.
package/dist/index.d.ts CHANGED
@@ -49,7 +49,9 @@ interface APIPlaygroundProps {
49
49
  route: string;
50
50
  method: string;
51
51
  bodyType: 'json' | 'form-data';
52
- authorization?: PrimitiveRequestField;
52
+ authorization?: PrimitiveRequestField & {
53
+ authType: string;
54
+ };
53
55
  path?: PrimitiveRequestField[];
54
56
  query?: PrimitiveRequestField[];
55
57
  header?: PrimitiveRequestField[];
@@ -50,7 +50,9 @@ interface APIPlaygroundProps {
50
50
  route: string;
51
51
  method: string;
52
52
  bodyType: 'json' | 'form-data';
53
- authorization?: PrimitiveRequestField;
53
+ authorization?: PrimitiveRequestField & {
54
+ authType: string;
55
+ };
54
56
  path?: PrimitiveRequestField[];
55
57
  query?: PrimitiveRequestField[];
56
58
  header?: PrimitiveRequestField[];
@@ -317,6 +317,7 @@ function getAuthorizationField(method, ctx) {
317
317
  return {
318
318
  type: 'string',
319
319
  name: 'Authorization',
320
+ authType: scheme.type,
320
321
  defaultValue: scheme.type === 'oauth2' || scheme.type === 'http' && scheme.scheme === 'bearer' ? 'Bearer' : 'Basic',
321
322
  isRequired: security.every((requirements)=>Object.keys(requirements).length > 0),
322
323
  description: 'The Authorization access token'
@@ -64,7 +64,7 @@ function useSchemaContext() {
64
64
  return ctx;
65
65
  }
66
66
 
67
- const APIPlayground = dynamic(()=>import('./playground-client-CthJtmMz.js').then((mod)=>mod.APIPlayground));
67
+ const APIPlayground = dynamic(()=>import('./playground-client-CB0L6vUj.js').then((mod)=>mod.APIPlayground));
68
68
  function Root({ children, baseUrl, className, ...props }) {
69
69
  return /*#__PURE__*/ jsx("div", {
70
70
  className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className),
@@ -49,7 +49,9 @@ interface APIPlaygroundProps {
49
49
  route: string;
50
50
  method: string;
51
51
  bodyType: 'json' | 'form-data';
52
- authorization?: PrimitiveRequestField;
52
+ authorization?: PrimitiveRequestField & {
53
+ authType: string;
54
+ };
53
55
  path?: PrimitiveRequestField[];
54
56
  query?: PrimitiveRequestField[];
55
57
  header?: PrimitiveRequestField[];
package/dist/ui/index.js CHANGED
@@ -3,8 +3,8 @@ import { cn } from 'fumadocs-ui/components/api';
3
3
  import { Fragment } from 'react';
4
4
  import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
5
5
  import { cva } from 'class-variance-authority';
6
- import { C as CopyRouteButton } from './client-client-CgPBB3ii.js';
7
- export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-CgPBB3ii.js';
6
+ import { C as CopyRouteButton } from './client-client-BUlxkJAI.js';
7
+ export { A as APIPlayground, R as Root, u as useSchemaContext } from './client-client-BUlxkJAI.js';
8
8
 
9
9
  const badgeVariants = cva('rounded border px-1.5 py-1 text-xs font-medium leading-[12px]', {
10
10
  variants: {
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
- import { forwardRef, useId, createContext, useContext, useState, useCallback, useLayoutEffect, useRef, useMemo } from 'react';
4
+ import { forwardRef, useId, createContext, useContext, useState, useCallback, useLayoutEffect, useRef, useEffect, useMemo } from 'react';
5
5
  import { FormProvider, Controller, useFormContext, useFieldArray, useForm, useWatch } from 'react-hook-form';
6
6
  import useSWRImmutable from 'swr/immutable';
7
7
  import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
8
8
  import { cn, buttonVariants } from 'fumadocs-ui/components/api';
9
- import { u as useSchemaContext, a as useApiContext, S as SchemaContext } from './client-client-CgPBB3ii.js';
9
+ import { u as useSchemaContext, a as useApiContext, S as SchemaContext } from './client-client-BUlxkJAI.js';
10
10
  import { Slot } from '@radix-ui/react-slot';
11
11
  import { cva } from 'class-variance-authority';
12
12
  import { CircleCheckIcon, CircleXIcon, ChevronDown, ChevronUp, Check, Trash2, Plus } from 'lucide-react';
@@ -905,6 +905,20 @@ function APIPlayground({ route, method = 'GET', bodyType, authorization, path =
905
905
  }, {
906
906
  shouldRetryOnError: false
907
907
  });
908
+ useEffect(()=>{
909
+ if (!authorization) return;
910
+ const key = `__fumadocs_authorization_${authorization.authType}`;
911
+ const cached = localStorage.getItem(key);
912
+ if (cached) form.setValue('authorization', cached);
913
+ const subscription = form.watch((value, { name })=>{
914
+ if (name !== 'authorization' || !value.authorization) return;
915
+ localStorage.setItem(key, value.authorization);
916
+ });
917
+ return ()=>{
918
+ subscription.unsubscribe();
919
+ };
920
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- mounted only once
921
+ }, []);
908
922
  const onSubmit = form.handleSubmit((value)=>{
909
923
  setInput(value);
910
924
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "5.3.2",
3
+ "version": "5.4.0",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",