From fbca820e16a1b00831e0ab312ec7e7c3a12e7604 Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Mon, 25 Aug 2025 10:58:33 -0400 Subject: [PATCH 1/3] refactor: use docusaurus sidebar types --- .../src/plugin-content-docs-types.d.ts | 42 ------------------ .../src/plugin-openapi.d.ts | 2 +- .../src/types.ts | 4 +- .../src/theme-openapi.d.ts | 44 ++++--------------- 4 files changed, 11 insertions(+), 81 deletions(-) delete mode 100644 packages/docusaurus-plugin-openapi-docs/src/plugin-content-docs-types.d.ts diff --git a/packages/docusaurus-plugin-openapi-docs/src/plugin-content-docs-types.d.ts b/packages/docusaurus-plugin-openapi-docs/src/plugin-content-docs-types.d.ts deleted file mode 100644 index e014cf287..000000000 --- a/packages/docusaurus-plugin-openapi-docs/src/plugin-content-docs-types.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* ============================================================================ - * Copyright (c) Palo Alto Networks - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * ========================================================================== */ - -declare module "@docusaurus/plugin-content-docs-types" { - // Makes all properties visible when hovering over the type - type Expand> = { [P in keyof T]: T[P] }; - - export type SidebarItemBase = { - className?: string; - customProps?: Record; - }; - - export type SidebarItemLink = SidebarItemBase & { - type: "link"; - href: string; - label: string; - docId: string; - }; - - type SidebarItemCategoryBase = SidebarItemBase & { - type: "category"; - label: string; - collapsed: boolean; - collapsible: boolean; - }; - - export type PropSidebarItemCategory = Expand< - SidebarItemCategoryBase & { - items: PropSidebarItem[]; - } - >; - - export type PropSidebarItem = SidebarItemLink | PropSidebarItemCategory; - export type PropSidebar = PropSidebarItem[]; - export type PropSidebars = { - [sidebarId: string]: PropSidebar; - }; -} diff --git a/packages/docusaurus-plugin-openapi-docs/src/plugin-openapi.d.ts b/packages/docusaurus-plugin-openapi-docs/src/plugin-openapi.d.ts index 9356fedfa..0417bfeb7 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/plugin-openapi.d.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/plugin-openapi.d.ts @@ -11,7 +11,7 @@ import type { FrontMatter as DocsFrontMatter } from "@docusaurus/types"; import type { Props as DocsProps } from "@docusaurus/types"; declare module "docusaurus-plugin-openapi-docs" { - import type { PropSidebars } from "@docusaurus/plugin-content-docs-types"; + import type { PropSidebars } from "@docusaurus/plugin-content-docs/lib/sidebars/types"; export type Options = Partial; diff --git a/packages/docusaurus-plugin-openapi-docs/src/types.ts b/packages/docusaurus-plugin-openapi-docs/src/types.ts index 4f7310f6d..0c65e4360 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/types.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/types.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * ========================================================================== */ -import { SidebarItemDoc } from "@docusaurus/plugin-content-docs/src/sidebars/types"; +import type { SidebarItemDoc } from "@docusaurus/plugin-content-docs/lib/sidebars/types"; import Request from "postman-collection"; import { @@ -21,7 +21,7 @@ export type { SidebarItemLink, PropSidebar, PropSidebarItem, -} from "@docusaurus/plugin-content-docs-types"; +} from "@docusaurus/plugin-content-docs/lib/sidebars/types"; export interface PluginOptions { id?: string; docsPlugin?: string; diff --git a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts index 1927d6c86..3effc9312 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts +++ b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts @@ -7,43 +7,15 @@ /// -/* eslint-disable @typescript-eslint/no-use-before-define */ +export type { + PropSidebarItemCategory, + SidebarItemLink, + PropSidebar, + PropSidebarItem, + PropSidebars, +} from "@docusaurus/plugin-content-docs/lib/sidebars/types"; -declare module "@docusaurus/plugin-content-docs-types" { - // Makes all properties visible when hovering over the type - type Expand> = { [P in keyof T]: T[P] }; - - export type SidebarItemBase = { - className?: string; - customProps?: Record; - }; - - export type SidebarItemLink = SidebarItemBase & { - type: "link"; - href: string; - label: string; - docId: string; - }; - - type SidebarItemCategoryBase = SidebarItemBase & { - type: "category"; - label: string; - collapsed: boolean; - collapsible: boolean; - }; - - export type PropSidebarItemCategory = Expand< - SidebarItemCategoryBase & { - items: PropSidebarItem[]; - } - >; - - export type PropSidebarItem = SidebarItemLink | PropSidebarItemCategory; - export type PropSidebar = PropSidebarItem[]; - export type PropSidebars = { - [sidebarId: string]: PropSidebar; - }; -} +/* eslint-disable @typescript-eslint/no-use-before-define */ declare module "docusaurus-theme-openapi-docs" { export type ThemeConfig = Partial; From 9fb35c363d8bb91669c94186c3146bd2165bb0bc Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Mon, 25 Aug 2025 11:09:41 -0400 Subject: [PATCH 2/3] fix: resolve theme type conflicts --- .../src/theme-openapi.d.ts | 240 ------------------ .../theme/ApiExplorer/Authorization/index.tsx | 2 +- .../src/theme/ApiExplorer/Body/index.tsx | 2 +- .../src/theme/ApiExplorer/Body/json2xml.d.ts | 8 + .../theme/ApiExplorer/FormTextInput/index.tsx | 2 + .../src/theme/Markdown/index.d.ts | 8 + 6 files changed, 20 insertions(+), 242 deletions(-) create mode 100644 packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/json2xml.d.ts create mode 100644 packages/docusaurus-theme-openapi-docs/src/theme/Markdown/index.d.ts diff --git a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts index 3effc9312..34f296751 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts +++ b/packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts @@ -15,246 +15,6 @@ export type { PropSidebars, } from "@docusaurus/plugin-content-docs/lib/sidebars/types"; -/* eslint-disable @typescript-eslint/no-use-before-define */ - declare module "docusaurus-theme-openapi-docs" { export type ThemeConfig = Partial; } - -declare module "@theme/ApiItem/hooks" { - export { useTypedDispatch, useTypedSelector }; -} - -declare module "@theme/ApiItem/Layout" { - export interface Props { - readonly children: JSX.Element; - } - - export default function Layout(props: any): JSX.Element; -} - -declare module "@theme/ApiItem/store" { - export { AppDispatch, RootState }; -} - -declare module "@theme/SchemaTabs" { - export default function SchemaTabs(props: any): JSX.Element; -} - -declare module "@theme/Markdown" { - export default function Markdown(props: any): JSX.Element; -} - -declare module "@theme/ApiExplorer/Accept" { - export default function Accept(): JSX.Element; -} - -declare module "@theme/ApiExplorer/Accept/slice" { - export { setAccept }; - export default accept as Reducer; -} - -declare module "@theme/ApiExplorer/Authorization" { - export default function Authorization(): JSX.Element; -} - -declare module "@theme/ApiExplorer/Authorization/slice" { - export { AuthState, Scheme, setAuthData, setSelectedAuth, createAuth }; - export default auth as Reducer; -} - -declare module "@theme/ApiExplorer/Body" { - import { Props as BodyProps } from "@theme/ApiExplorer/Body"; - - export default function Body(props: BodyProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/Body/json2xml" { - export default function json2xml(any, any?): any; -} - -declare module "@theme/ApiExplorer/Body/slice" { - import { Body, Content, State } from "@theme/ApiExplorer/Body/slice"; - - export { Body, Content, State }; - export function setStringRawBody(any, any?): any; - export default body as Reducer; -} - -declare module "@theme/ApiExplorer/buildPostmanRequest" { - export default function buildPostmanRequest(any, any?): any; -} - -declare module "@theme/ApiExplorer/CodeTabs" { - import { Props as CodeTabsProps } from "@theme/ApiExplorer/CodeTabs"; - - export default function CodeTabs(props: CodeTabsProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/ContentType" { - export default function ContentType(): JSX.Element; -} - -declare module "@theme/ApiExplorer/ContentType/slice" { - export { setContentType }; - export default contentType as Reducer; -} - -declare module "@theme/ApiExplorer/CodeSnippets" { - import { Props as CurlProps } from "@theme/ApiExplorer/CodeSnippets"; - - export { languageSet, Language } from "@theme/ApiExplorer/CodeSnippets"; - export default function Curl(props: CurlProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/FloatingButton" { - import { Props as FloatingButtonProps } from "@theme/ApiExplorer/FloatingButton"; - - export default function FloatingButton( - props: FloatingButtonProps - ): JSX.Element; -} - -declare module "@theme/ApiExplorer/FormItem" { - import { Props as FormItemProps } from "@theme/ApiExplorer/FormItem"; - - export default function FormItem(props: FormItemProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/FormSelect" { - import { Props as FormSelectProps } from "@theme/ApiExplorer/FormSelect"; - - export default function FormSelect(props: FormSelectProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/FormTextInput" { - import { Props as FormTextInputProps } from "@theme/ApiExplorer/FormTextInput"; - - export default function FormTextInput(props: FormTextInputProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/FormFileUpload" { - import { Props as FormFileUploadProps } from "@theme/ApiExplorer/FormFileUpload"; - - export default function FormFileUpload( - props: FormFileUploadProps - ): JSX.Element; -} - -declare module "@theme/ApiExplorer/FormMultiSelect" { - import { Props as FormMultiSelectProps } from "@theme/ApiExplorer/FormMultiSelect"; - - export default function FormMultiSelect( - props: FormMultiSelectProps - ): JSX.Element; -} - -declare module "@theme/ApiExplorer/Execute" { - import { Props as ExecuteProps } from "@theme/ApiExplorer/Execute"; - - export default function Execute(props: ExecuteProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/LiveEditor" { - export default function LiveEditor(props: any): JSX.Element; -} - -declare module "@theme/ApiExplorer/MethodEndpoint" { - import { Props as MethodEndpointProps } from "@theme/ApiExplorer/MethodEndpoint"; - - export default function MethodEndpoint( - props: MethodEndpointProps - ): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions" { - import { ParamProps } from "@theme/ApiExplorer/ParamOptions"; - - export default function ParamOptions(props: ParamProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem" { - import { ParamProps } from "@theme/ApiExplorer/ParamOptions"; - - export default function ParamMultiSelectFormItem( - props: ParamProps - ): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem" { - import { ParamProps } from "@theme/ApiExplorer/ParamOptions"; - - export default function ParamArrayFormItem(props: ParamProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem" { - import { ParamProps } from "@theme/ApiExplorer/ParamOptions"; - - export default function ParamSelectFormItem(props: ParamProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem" { - import { ParamProps } from "@theme/ApiExplorer/ParamOptions"; - - export default function ParamBooleanFormItem(props: ParamProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem" { - import { ParamProps } from "@theme/ApiExplorer/ParamOptions"; - - export default function ParamTextFormItem(props: ParamProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/ParamOptions/slice" { - export type { Param }; - export const setParam; - export default params as Reducer; -} - -declare module "@theme/ApiExplorer/persistanceMiddleware" { - export { createPersistanceMiddleware }; -} - -declare module "@theme/ApiExplorer/Request" { - import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types"; - - export interface RequestProps { - item: NonNullable; - } - export default function Request(props: RequestProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/Response" { - import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types"; - - export interface ResponseProps { - item: NonNullable; - } - - export default function Response(props: ResponseProps): JSX.Element; -} - -declare module "@theme/ApiExplorer/Response/slice" { - export { setResponse, setCode, setHeaders, clearCode, clearHeaders }; - export default response as Reducer; -} - -declare module "@theme/ApiExplorer/SecuritySchemes" { - export default function SecuritySchemes(props: any): JSX.Element; -} - -declare module "@theme/ApiExplorer/Server" { - export default function Server(): JSX.Element; -} - -declare module "@theme/ApiExplorer/ApiCodeBlock" { - export default function ApiCodeBlock(): JSX.Element; -} - -declare module "@theme/ApiExplorer/Server/slice" { - export default server as Reducer; -} - -declare module "@theme/ApiExplorer/storage-utils" { - export { createStorage, hashArray }; -} diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx index eccd7571c..ad34951e5 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Authorization/index.tsx @@ -36,7 +36,7 @@ function Authorization() { ) => { + onChange={(e: React.ChangeEvent) => { dispatch(setSelectedAuth(e.target.value)); }} /> diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/index.tsx index 36ba7151e..8ce7a54e4 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/index.tsx @@ -168,7 +168,7 @@ function Body({ > ) => { + onChange={(e: React.ChangeEvent) => { const val = e.target.value; if (val === "---") { dispatch(clearFormBodyKey(key)); diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/json2xml.d.ts b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/json2xml.d.ts new file mode 100644 index 000000000..f0b965489 --- /dev/null +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Body/json2xml.d.ts @@ -0,0 +1,8 @@ +/* ============================================================================ + * Copyright (c) Palo Alto Networks + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * ========================================================================== */ + +export default function json2xml(input: any, indent?: any): any; diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx index a429bb6db..6e5775eb1 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/FormTextInput/index.tsx @@ -17,6 +17,8 @@ export interface Props { placeholder?: string; password?: boolean; onChange?: React.ChangeEventHandler; + paramName?: string; + isRequired?: boolean; } function FormTextInput({ diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/Markdown/index.d.ts b/packages/docusaurus-theme-openapi-docs/src/theme/Markdown/index.d.ts new file mode 100644 index 000000000..c73be4ed2 --- /dev/null +++ b/packages/docusaurus-theme-openapi-docs/src/theme/Markdown/index.d.ts @@ -0,0 +1,8 @@ +/* ============================================================================ + * Copyright (c) Palo Alto Networks + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * ========================================================================== */ + +export default function Markdown(props: any): JSX.Element; From 7d8fa742cbf55d5e346747625cf3ca0d976e417a Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Mon, 25 Aug 2025 11:19:20 -0400 Subject: [PATCH 3/3] fix: resolve api explorer type errors --- .../src/theme/ApiExplorer/CodeSnippets/index.tsx | 10 +++++----- .../src/theme/ApiExplorer/CodeTabs/index.tsx | 11 ++++++----- .../src/theme/ApiExplorer/ContentType/index.tsx | 2 +- .../ParamFormItems/ParamArrayFormItem.tsx | 11 ++++++----- .../ParamFormItems/ParamBooleanFormItem.tsx | 5 ++--- .../ParamFormItems/ParamMultiSelectFormItem.tsx | 5 ++--- .../ParamFormItems/ParamSelectFormItem.tsx | 4 ++-- .../src/theme/ApiExplorer/Server/index.tsx | 4 ++-- .../src/theme/ApiItem/Layout/index.tsx | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx index dc0dde0b4..35c571f35 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx @@ -141,9 +141,9 @@ function CodeSnippets({ return defaultLang[0] ?? mergedLangs[0]; }); const [codeText, setCodeText] = useState(""); - const [codeSampleCodeText, setCodeSampleCodeText] = useState< - string | (() => string) - >(() => getCodeSampleSourceFromLanguage(language)); + const [codeSampleCodeText, setCodeSampleCodeText] = useState(() => + getCodeSampleSourceFromLanguage(language) + ); useEffect(() => { if (language && !!language.sample) { @@ -273,7 +273,7 @@ function CodeSnippets({ setSelectedSample: setSelectedSample, }} includeSample={true} - currentLanguage={lang.language} + currentLanguage={lang} defaultValue={selectedSample} languageSet={mergedLangs} lazy @@ -314,7 +314,7 @@ function CodeSnippets({ setSelectedVariant: setSelectedVariant, }} includeVariant={true} - currentLanguage={lang.language} + currentLanguage={lang} defaultValue={selectedVariant} languageSet={mergedLangs} lazy diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/index.tsx index a93a5acff..06cd307dc 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/index.tsx @@ -15,16 +15,17 @@ import { } from "@docusaurus/theme-common/internal"; import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils"; import useIsBrowser from "@docusaurus/useIsBrowser"; -import { Language } from "@theme/ApiExplorer/CodeSnippets"; import clsx from "clsx"; +import { Language } from "../CodeSnippets/code-snippets-types"; + export interface Props { action: { [key: string]: React.Dispatch; }; - currentLanguage: Language; + currentLanguage?: Language; languageSet: Language[]; - includeVariant: boolean; + includeVariant?: boolean; } export interface CodeTabsProps extends Props, TabProps { @@ -94,13 +95,13 @@ function TabList({ let newLanguage: Language; if (currentLanguage && includeVariant) { newLanguage = languageSet.filter( - (lang: Language) => lang.language === currentLanguage + (lang: Language) => lang.language === currentLanguage.language )[0]; newLanguage.variant = newTabValue; action.setSelectedVariant(newTabValue.toLowerCase()); } else if (currentLanguage && includeSample) { newLanguage = languageSet.filter( - (lang: Language) => lang.language === currentLanguage + (lang: Language) => lang.language === currentLanguage.language )[0]; newLanguage.sample = newTabValue; action.setSelectedSample(newTabValue); diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ContentType/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ContentType/index.tsx index 9794c084e..c1461a2d0 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ContentType/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ContentType/index.tsx @@ -27,7 +27,7 @@ function ContentType() { ) => + onChange={(e: React.ChangeEvent) => dispatch(setContentType(e.target.value)) } /> diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx index b119cb4b4..29621e54f 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx @@ -30,7 +30,7 @@ function ArrayItem({ return ( ) => { + onChange={(e: React.ChangeEvent) => { const val = e.target.value; onChange(val === "---" ? undefined : val); }} @@ -87,15 +87,16 @@ export default function ParamArrayFormItem({ param }: ParamProps) { }, [items]); useEffect(() => { - if (param.schema?.example?.length > 0) { - const examplesWithIds = param.schema.example.map((item: any) => ({ + const example = param.schema?.example; + if (Array.isArray(example) && example.length > 0) { + const examplesWithIds = example.map((item: any) => ({ id: nanoid(), value: item.toString(), })); setItems(examplesWithIds); } - }, [param.schema.example, param.schema.length]); + }, [param.schema?.example]); function handleDeleteItem(itemToDelete: { id: string }) { return () => { @@ -123,7 +124,7 @@ export default function ParamArrayFormItem({ param }: ParamProps) { control={control} rules={{ required: param.required ? "This field is required" : false }} name="paramArray" - render={({ field: { onChange, name } }) => ( + render={({ field: { onChange } }) => ( <> {items.map((item) => (
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx index 5774679f1..bda763858 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx @@ -33,11 +33,10 @@ export default function ParamBooleanFormItem({ param }: ParamProps) { control={control} rules={{ required: param.required ? "This field is required" : false }} name="paramBoolean" - render={({ field: { onChange, name } }) => ( + render={({ field: { onChange } }) => ( ) => { + onChange={(e: React.ChangeEvent) => { const val = e.target.value; dispatch( setParam({ diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx index 237a27afa..ae91e5739 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx @@ -63,12 +63,11 @@ export default function ParamMultiSelectFormItem({ param }: ParamProps) { control={control} rules={{ required: param.required ? "This field is required" : false }} name="paramMultiSelect" - render={({ field: { onChange, name } }) => ( + render={({ field: { onChange } }) => ( handleChange(e, onChange)} - showErrors={showErrorMessage} + showErrors={!!showErrorMessage} /> )} /> diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx index 05160ba54..5d4329a6d 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx @@ -35,10 +35,10 @@ export default function ParamSelectFormItem({ param }: ParamProps) { control={control} rules={{ required: param.required ? "This field is required" : false }} name="paramSelect" - render={({ field: { onChange, name } }) => ( + render={({ field: { onChange } }) => ( ) => { + onChange={(e: React.ChangeEvent) => { const val = e.target.value; dispatch( setParam({ diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx index c627d463a..5c21844d0 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx @@ -72,7 +72,7 @@ function Server() { s.url)} - onChange={(e: React.ChangeEvent) => { + onChange={(e: React.ChangeEvent) => { dispatch( setServer( JSON.stringify( @@ -94,7 +94,7 @@ function Server() { ) => { + onChange={(e: React.ChangeEvent) => { dispatch( setServerVariable( JSON.stringify({ key, value: e.target.value }) diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiItem/Layout/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiItem/Layout/index.tsx index bb92ba58d..91d479265 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiItem/Layout/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiItem/Layout/index.tsx @@ -9,11 +9,11 @@ import React, { type JSX } from "react"; import { useDoc } from "@docusaurus/plugin-content-docs/client"; import { useWindowSize } from "@docusaurus/theme-common"; -import type { Props } from "@theme/ApiItem/Layout"; import ContentVisibility from "@theme/ContentVisibility"; import DocBreadcrumbs from "@theme/DocBreadcrumbs"; import DocItemContent from "@theme/DocItem/Content"; import DocItemFooter from "@theme/DocItem/Footer"; +import type { Props } from "@theme/DocItem/Layout"; import DocItemPaginator from "@theme/DocItem/Paginator"; import DocItemTOCDesktop from "@theme/DocItem/TOC/Desktop"; import DocItemTOCMobile from "@theme/DocItem/TOC/Mobile";