fumadocs-openapi 7.0.0-beta.0 → 7.0.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.
@@ -29,19 +29,18 @@ export type ClientProps = HTMLAttributes<HTMLFormElement> & {
29
29
  route: string;
30
30
  method: string;
31
31
  authorization?: Security;
32
- path?: PrimitiveRequestField[];
33
- query?: PrimitiveRequestField[];
34
- header?: PrimitiveRequestField[];
32
+ parameters?: PrimitiveRequestField[];
35
33
  body?: RequestSchema & {
36
34
  mediaType: string;
37
35
  };
38
- schemas: Record<string, RequestSchema>;
36
+ /**
37
+ * Resolver for reference schemas you've passed
38
+ */
39
+ references: Record<string, RequestSchema>;
39
40
  proxyUrl?: string;
40
41
  fields?: {
42
+ parameter?: CustomField<`${PrimitiveRequestField['in']}.${string}`, PrimitiveRequestField>;
41
43
  auth?: CustomField<'authorization', RequestSchema>;
42
- path?: CustomField<`path.${string}`, PrimitiveRequestField>;
43
- query?: CustomField<`query.${string}`, PrimitiveRequestField>;
44
- header?: CustomField<`header.${string}`, PrimitiveRequestField>;
45
44
  body?: CustomField<'body', RequestSchema>;
46
45
  };
47
46
  components?: Partial<{
@@ -62,6 +61,6 @@ export type DynamicField = {
62
61
  schema: RequestSchema | ReferenceSchema;
63
62
  };
64
63
  export declare function useSchemaContext(): SchemaContextType;
65
- export declare function Client({ route, method, authorization, path, header, query, body, fields, schemas, proxyUrl, components: { ResultDisplay }, ...props }: ClientProps): import("react/jsx-runtime").JSX.Element;
64
+ export declare function Client({ route, method, authorization, parameters, body, fields, references, proxyUrl, components: { ResultDisplay }, ...props }: ClientProps): import("react/jsx-runtime").JSX.Element;
66
65
  export {};
67
66
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/playground/client.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAInB,KAAK,EAAE,EAGP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QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,aAAa,GAAG,eAAe,CAAC;CACzC,CAAC;AAIN,wBAAgB,gBAAgB,IAAI,iBAAiB,CAIpD;AAkBD,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,MAAc,EACd,aAAa,EACb,UAAe,EACf,IAAI,EACJ,MAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EAAE,EAAE,aAAoC,EAAO,EACzD,GAAG,KAAK,EACT,EAAE,WAAW,2CA2Mb"}
@@ -1,7 +1,7 @@
1
1
  'use client';
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useMemo, useRef, useEffect, Fragment, createContext, useContext, useState, } from 'react';
4
- import { Controller, FormProvider, useForm } from 'react-hook-form';
4
+ import { Controller, FormProvider, useForm, useFormContext, } from 'react-hook-form';
5
5
  import { cn, buttonVariants } from 'fumadocs-ui/components/api';
6
6
  import { useApiContext, useServerSelectContext } from '../ui/contexts/api.js';
7
7
  import { FieldSet, ObjectInput } from './inputs.js';
@@ -34,9 +34,17 @@ function toRequestData(method, mediaType, value) {
34
34
  query: value.query,
35
35
  };
36
36
  }
37
- export function Client({ route, method = 'GET', authorization, path = [], header = [], query = [], body, fields = {}, schemas, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
37
+ export function Client({ route, method = 'GET', authorization, parameters = [], body, fields = {}, references, proxyUrl, components: { ResultDisplay = DefaultResultDisplay } = {}, ...props }) {
38
38
  const { servers } = useApiContext();
39
39
  const { server, setServer, setServerVariables } = useServerSelectContext();
40
+ const params = useMemo(() => {
41
+ return {
42
+ headers: parameters.filter((v) => v.in === 'header'),
43
+ cookies: parameters.filter((v) => v.in === 'cookie'),
44
+ queries: parameters.filter((v) => v.in === 'query'),
45
+ paths: parameters.filter((v) => v.in === 'path'),
46
+ };
47
+ }, [parameters]);
40
48
  const dynamicRef = useRef(new Map());
41
49
  const requestData = useRequestData();
42
50
  const authInfo = usePersistentAuthInfo(authorization);
@@ -70,7 +78,7 @@ export function Client({ route, method = 'GET', authorization, path = [], header
70
78
  const value = _value;
71
79
  if (authorization && value.authorization) {
72
80
  authInfo.saveInfo(value.authorization);
73
- writeAuthHeader(authorization, value.authorization, value.header, value.query);
81
+ writeAuthHeader(authorization, value.authorization, value.header, value.query, value.cookie);
74
82
  }
75
83
  requestData.saveData(toRequestData(method, body?.mediaType, value));
76
84
  });
@@ -88,11 +96,19 @@ export function Client({ route, method = 'GET', authorization, path = [], header
88
96
  }
89
97
  return (_jsx(FieldSet, { name: info.name, fieldName: fieldName, field: info }, key));
90
98
  }
91
- let authField = null;
92
- if (authorization) {
93
- authField = (_jsxs(_Fragment, { children: [renderCustomField('authorization', authorization?.type === 'http' && authorization.scheme === 'basic'
99
+ return (_jsx(FormProvider, { ...form, children: _jsx(SchemaContext.Provider, { value: useMemo(() => ({ references: references, dynamic: dynamicRef }), [references]), children: _jsx(AuthProvider, { authorization: authorization, children: _jsxs("form", { ...props, className: cn('not-prose flex flex-col gap-2 rounded-xl border p-3 shadow-md', props.className), onSubmit: onSubmit, children: [_jsx(FormHeader, { method: method, route: route, isLoading: testQuery.isLoading }), servers.length > 1 ? (_jsx(CollapsiblePanel, { title: "Server URL", children: _jsx(ServerSelect, { server: server, onServerChanged: setServer, onVariablesChanged: setServerVariables }) })) : null, params.headers.length > 0 || authorization ? (_jsxs(CollapsiblePanel, { title: "Headers", children: [authorization ? (_jsx(AuthField, { authorization: authorization })) : null, params.headers.map((field) => renderCustomField(`header.${field.name}`, field, fields.parameter, field.name))] })) : null, params.paths.length > 0 ? (_jsx(CollapsiblePanel, { title: "Path", children: params.paths.map((field) => renderCustomField(`path.${field.name}`, field, fields.parameter, field.name)) })) : null, params.queries.length > 0 ? (_jsx(CollapsiblePanel, { title: "Query", children: params.queries.map((field) => renderCustomField(`query.${field.name}`, field, fields.parameter, field.name)) })) : null, params.cookies.length > 0 ? (_jsx(CollapsiblePanel, { title: "Cookies", children: params.cookies.map((field) => renderCustomField(`cookie.${field.name}`, field, fields.parameter, field.name)) })) : null, body ? (_jsx(CollapsiblePanel, { title: "Body", children: body.type === 'object' && !fields.body ? (_jsx(ObjectInput, { field: body, fieldName: "body" })) : (renderCustomField('body', body, fields.body)) })) : null, testQuery.data ? _jsx(ResultDisplay, { data: testQuery.data }) : null] }) }) }) }));
100
+ }
101
+ function AuthProvider({ authorization, children, }) {
102
+ const form = useFormContext();
103
+ if (!authorization || authorization.type !== 'oauth2')
104
+ return children;
105
+ // only the first one, so it looks simpler :)
106
+ const flow = Object.keys(authorization.flows)[0];
107
+ return (_jsx(OauthDialog, { flow: flow, scheme: authorization, setToken: (token) => form.setValue('authorization', `Bearer ${token}`), children: children }));
108
+ }
109
+ function AuthField({ authorization }) {
110
+ return (_jsxs(_Fragment, { children: [_jsx(FieldSet, { fieldName: "authorization", name: "Authorization", field: authorization?.type === 'http' && authorization.scheme === 'basic'
94
111
  ? {
95
- name: 'Authorization',
96
112
  type: 'object',
97
113
  isRequired: true,
98
114
  properties: {
@@ -107,21 +123,12 @@ export function Client({ route, method = 'GET', authorization, path = [], header
107
123
  },
108
124
  }
109
125
  : {
110
- name: 'Authorization',
111
126
  type: 'string',
112
127
  isRequired: true,
113
128
  description: 'The Authorization access token',
114
- }, fields.auth), authorization?.type === 'oauth2' && (_jsx(OauthDialogTrigger, { type: "button", className: cn(buttonVariants({
115
- color: 'secondary',
116
- })), children: "Open" }))] }));
117
- }
118
- let children = (_jsxs("form", { ...props, className: cn('not-prose flex flex-col gap-2 rounded-xl border p-3 shadow-md', props.className), onSubmit: onSubmit, children: [_jsx(FormHeader, { method: method, route: route, isLoading: testQuery.isLoading }), servers.length > 1 ? (_jsx(CollapsiblePanel, { title: "Server URL", children: _jsx(ServerSelect, { server: server, onServerChanged: setServer, onVariablesChanged: setServerVariables }) })) : null, header.length > 0 || authorization ? (_jsxs(CollapsiblePanel, { title: "Headers", children: [authField, header.map((field) => renderCustomField(`header.${field.name}`, field, fields.header, field.name))] })) : null, path.length > 0 ? (_jsx(CollapsiblePanel, { title: "Path", children: path.map((field) => renderCustomField(`path.${field.name}`, field, fields.path, field.name)) })) : null, query.length > 0 ? (_jsx(CollapsiblePanel, { title: "Query", children: query.map((field) => renderCustomField(`query.${field.name}`, field, fields.query, field.name)) })) : null, body ? (_jsx(CollapsiblePanel, { title: "Body", children: body.type === 'object' && !fields.body ? (_jsx(ObjectInput, { field: body, fieldName: "body" })) : (renderCustomField('body', body, fields.body)) })) : null, testQuery.data ? _jsx(ResultDisplay, { data: testQuery.data }) : null] }));
119
- if (authorization?.type === 'oauth2') {
120
- // only the first one, so it looks simpler :)
121
- const flow = Object.keys(authorization.flows)[0];
122
- children = (_jsx(OauthDialog, { flow: flow, scheme: authorization, setToken: (token) => form.setValue('authorization', `Bearer ${token}`), children: children }));
123
- }
124
- return (_jsx(FormProvider, { ...form, children: _jsx(SchemaContext.Provider, { value: useMemo(() => ({ references: schemas, dynamic: dynamicRef }), [schemas]), children: children }) }));
129
+ } }), authorization?.type === 'oauth2' && (_jsx(OauthDialogTrigger, { type: "button", className: cn(buttonVariants({
130
+ color: 'secondary',
131
+ })), children: "Open" }))] }));
125
132
  }
126
133
  function Route({ route, ...props }) {
127
134
  const segments = route.split('/').filter((part) => part.length > 0);
@@ -174,7 +181,7 @@ function usePersistentAuthInfo(authorization) {
174
181
  function CollapsiblePanel({ title, children, ...props }) {
175
182
  return (_jsxs(Collapsible, { ...props, className: "border rounded-xl bg-fd-card text-fd-card-foreground overflow-hidden", children: [_jsxs(CollapsibleTrigger, { className: "group w-full inline-flex items-center gap-2 justify-between p-3 text-sm font-medium hover:bg-fd-accent", children: [title, _jsx(ChevronDown, { className: "size-4 group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { children: _jsx("div", { className: "flex flex-col gap-4 p-3", children: children }) })] }));
176
183
  }
177
- function writeAuthHeader(authorization, input, header, query) {
184
+ function writeAuthHeader(authorization, input, header, query, cookie) {
178
185
  if (authorization.type === 'apiKey') {
179
186
  if (authorization.in === 'header') {
180
187
  header[authorization.name] = input;
@@ -183,16 +190,7 @@ function writeAuthHeader(authorization, input, header, query) {
183
190
  query[authorization.name] = input;
184
191
  }
185
192
  if (authorization.in === 'cookie') {
186
- if ('cookie' in header) {
187
- header.Cookie = header.cookie;
188
- delete header.cookie;
189
- }
190
- header.Cookie = [
191
- header.Cookie,
192
- `${authorization.name}=${input}`,
193
- ]
194
- .filter((s) => s.length > 0)
195
- .join('; ');
193
+ cookie[authorization.name] = input;
196
194
  }
197
195
  return;
198
196
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/playground/fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACvE;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CA6D9C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,eAAe,CAAC,EACjD,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CAqC5B"}
1
+ {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../src/playground/fetcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACvE;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAkF9C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,eAAe,CAAC,EACjD,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CAqC5B"}
@@ -12,11 +12,30 @@ export function createBrowserFetcher() {
12
12
  if (paramValue.length > 0)
13
13
  headers.append(key, paramValue.toString());
14
14
  }
15
+ const proxyUrl = options.proxyUrl
16
+ ? new URL(options.proxyUrl, window.location.origin)
17
+ : null;
18
+ if (typeof document !== 'undefined') {
19
+ for (const key in options.cookie) {
20
+ const value = options.cookie[key];
21
+ if (!value)
22
+ continue;
23
+ document.cookie = [
24
+ `${key}=${value}`,
25
+ 'HttpOnly',
26
+ proxyUrl && proxyUrl.origin !== window.location.origin
27
+ ? `domain=${proxyUrl.host}`
28
+ : false,
29
+ 'path=/',
30
+ ]
31
+ .filter(Boolean)
32
+ .join(';');
33
+ }
34
+ }
15
35
  let url = getPathnameFromInput(route, options.path, options.query);
16
- if (options.proxyUrl) {
17
- const updated = new URL(options.proxyUrl, window.location.origin);
18
- updated.searchParams.append('url', url);
19
- url = updated.toString();
36
+ if (proxyUrl) {
37
+ proxyUrl.searchParams.append('url', url);
38
+ url = proxyUrl.toString();
20
39
  }
21
40
  return fetch(url, {
22
41
  method: options.method,
@@ -8,7 +8,9 @@ interface BaseSchema {
8
8
  description?: string;
9
9
  isRequired: boolean;
10
10
  }
11
- export type PrimitiveRequestField = BaseRequestField & PrimitiveSchema;
11
+ export type PrimitiveRequestField = BaseRequestField & PrimitiveSchema & {
12
+ in: 'cookie' | 'header' | 'query' | 'path';
13
+ };
12
14
  interface PrimitiveSchema extends BaseSchema {
13
15
  type: 'boolean' | 'string' | 'number';
14
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/playground/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,aAAa,EACd,MAAM,SAAS,CAAC;AAOjB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAEvE,UAAU,eAAgB,SAAQ,UAAU;IAC1C,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACvC;AAED,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,WAAY,SAAQ,UAAU;IACtC,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC;CAC/B;AAED,UAAU,UAAW,SAAQ,UAAU;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,YAAa,SAAQ,UAAU;IACvC,I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AsB,aAAa,CAAC,EAClC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,GACP,EAAE,kBAAkB,oDAuCpB"}
@@ -22,22 +22,14 @@ export async function APIPlayground({ path, method, ctx, client, }) {
22
22
  authorization: getAuthorizationField(method, ctx),
23
23
  method: method.method,
24
24
  route: path,
25
- path: method.parameters
26
- ?.filter((v) => v.in === 'path')
27
- .map((v) => parameterToField(v, context)),
28
- query: method.parameters
29
- ?.filter((v) => v.in === 'query')
30
- .map((v) => parameterToField(v, context)),
31
- header: method.parameters
32
- ?.filter((v) => v.in === 'header')
33
- .map((v) => parameterToField(v, context)),
25
+ parameters: method.parameters?.map((v) => parameterToField(v, context)),
34
26
  body: bodySchema && mediaType
35
27
  ? {
36
28
  ...bodySchema,
37
29
  mediaType: mediaType,
38
30
  }
39
31
  : undefined,
40
- schemas: context.references,
32
+ references: context.references,
41
33
  proxyUrl: ctx.proxyUrl,
42
34
  ...client,
43
35
  };
@@ -73,8 +65,12 @@ function getIdFromSchema(schema, required, ctx) {
73
65
  return registered;
74
66
  }
75
67
  function parameterToField(v, ctx) {
68
+ const allowed = ['header', 'cookie', 'query', 'path'];
69
+ if (!allowed.includes(v.in))
70
+ throw new Error(`Unsupported parameter in: "${v.in}"`);
76
71
  return {
77
72
  name: v.name,
73
+ in: v.in,
78
74
  ...toSchema(v.schema ?? { type: 'string' }, v.required ?? false, ctx),
79
75
  };
80
76
  }
@@ -13,7 +13,7 @@ export default function ScalarPlayground({ path, method, spec, }) {
13
13
  setMounted(true);
14
14
  }, []);
15
15
  return (_jsxs("div", { className: cn('flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose', mounted ? `${resolvedTheme}-mode` : null), children: [_jsx(MethodLabel, { className: "text-xs", children: method }), _jsx("code", { className: "flex-1 overflow-auto text-nowrap text-[13px] text-fd-muted-foreground", children: path }), _jsx(ApiClientModalProvider, { configuration: {
16
- themeId: 'moon',
16
+ theme: 'moon',
17
17
  spec: {
18
18
  content: spec,
19
19
  },
@@ -28,7 +28,7 @@ export function generateDocument(options) {
28
28
  if (banner.length > 0)
29
29
  out.push(`---\n${banner}\n---`);
30
30
  if (addGeneratedComment !== false) {
31
- let commentContent = 'This file was generated by Fumadocs.\nDo not edit this file directly. Any changes should be made by running the generation command again.';
31
+ let commentContent = 'This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again.';
32
32
  if (typeof addGeneratedComment === 'string') {
33
33
  commentContent = addGeneratedComment;
34
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "7.0.0-beta.0",
3
+ "version": "7.0.0",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -52,9 +52,9 @@
52
52
  "class-variance-authority": "^0.7.1",
53
53
  "fast-glob": "^3.3.3",
54
54
  "github-slugger": "^2.0.0",
55
- "hast-util-to-jsx-runtime": "^2.3.5",
55
+ "hast-util-to-jsx-runtime": "^2.3.6",
56
56
  "js-yaml": "^4.1.0",
57
- "lucide-react": "^0.477.0",
57
+ "lucide-react": "^0.479.0",
58
58
  "next-themes": "^0.4.4",
59
59
  "openapi-sampler": "^1.6.1",
60
60
  "react-hook-form": "^7.54.2",
@@ -62,18 +62,18 @@
62
62
  "remark-rehype": "^11.1.1",
63
63
  "shiki": "^3.1.0",
64
64
  "xml-js": "^1.6.11",
65
- "fumadocs-ui": "15.0.15",
66
- "fumadocs-core": "15.0.15"
65
+ "fumadocs-core": "15.0.16",
66
+ "fumadocs-ui": "15.0.16"
67
67
  },
68
68
  "devDependencies": {
69
- "@scalar/api-client-react": "^1.1.35",
69
+ "@scalar/api-client-react": "^1.1.42",
70
70
  "@types/js-yaml": "^4.0.9",
71
- "@types/node": "22.13.9",
71
+ "@types/node": "22.13.10",
72
72
  "@types/openapi-sampler": "^1.0.3",
73
73
  "@types/react": "^19.0.10",
74
74
  "next": "15.2.1",
75
75
  "openapi-types": "^12.1.3",
76
- "tailwindcss": "^4.0.9",
76
+ "tailwindcss": "^4.0.12",
77
77
  "tsc-alias": "^1.8.11",
78
78
  "eslint-config-custom": "0.0.0",
79
79
  "tsconfig": "0.0.0"