Skip to content

Add support for docusaurus 3.5+ #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"re-gen": "yarn clean-all && yarn gen-all"
},
"dependencies": {
"@docusaurus/core": "3.4.0",
"@docusaurus/plugin-google-gtag": "3.4.0",
"@docusaurus/preset-classic": "3.4.0",
"@docusaurus/core": "3.5.2",
"@docusaurus/plugin-google-gtag": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"clsx": "^1.1.1",
"docusaurus-plugin-openapi-docs": "^3.0.1",
"docusaurus-theme-openapi-docs": "^3.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ declare module "@docusaurus/theme-common/internal" {
};

export function useCodeWordWrap(): {
readonly codeBlockRef: RefObject<HTMLPreElement>;
readonly codeBlockRef: RefObject;
readonly isEnabled: boolean;
readonly isCodeScrollable: boolean;
readonly toggle: () => void;
Expand Down
38 changes: 15 additions & 23 deletions packages/docusaurus-theme-openapi-docs/src/theme-openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

declare module "@docusaurus/plugin-content-docs-types" {
// Makes all properties visible when hovering over the type
type Expand<T extends Record<string, unknown>> = { [P in keyof T]: T[P] };
type Expand<T extends Record> = { [P in keyof T]: T[P] };

export type SidebarItemBase = {
className?: string;
customProps?: Record<string, unknown>;
customProps?: Record;
};

export type SidebarItemLink = SidebarItemBase & {
Expand All @@ -32,11 +32,7 @@ declare module "@docusaurus/plugin-content-docs-types" {
collapsible: boolean;
};

export type PropSidebarItemCategory = Expand<
SidebarItemCategoryBase & {
items: PropSidebarItem[];
}
>;
export type PropSidebarItemCategory = Expand;

export type PropSidebarItem = SidebarItemLink | PropSidebarItemCategory;
export type PropSidebar = PropSidebarItem[];
Expand All @@ -46,17 +42,13 @@ declare module "@docusaurus/plugin-content-docs-types" {
}

declare module "docusaurus-theme-openapi-docs" {
export type ThemeConfig = Partial<import("./types").ThemeConfig>;
export type ThemeConfig = Partial;
}

declare module "@theme/ApiItem/hooks" {
export { useTypedDispatch, useTypedSelector };
}

declare module "@theme/ApiItem/Layout" {
export default function Layout(props: any): JSX.Element;
}

declare module "@theme/ApiItem/store" {
export { AppDispatch, RootState };
}
Expand All @@ -75,7 +67,7 @@ declare module "@theme/ApiExplorer/Accept" {

declare module "@theme/ApiExplorer/Accept/slice" {
export { setAccept };
export default accept as Reducer<State, AnyAction>;
export default accept as Reducer;
}

declare module "@theme/ApiExplorer/Authorization" {
Expand All @@ -84,7 +76,7 @@ declare module "@theme/ApiExplorer/Authorization" {

declare module "@theme/ApiExplorer/Authorization/slice" {
export { AuthState, Scheme, setAuthData, setSelectedAuth, createAuth };
export default auth as Reducer<State, AnyAction>;
export default auth as Reducer;
}

declare module "@theme/ApiExplorer/Body" {
Expand All @@ -102,7 +94,7 @@ declare module "@theme/ApiExplorer/Body/slice" {

export { Body, Content, State };
export function setStringRawBody(any, any?): any;
export default body as Reducer<State, AnyAction>;
export default body as Reducer;
}

declare module "@theme/ApiExplorer/buildPostmanRequest" {
Expand All @@ -121,7 +113,7 @@ declare module "@theme/ApiExplorer/ContentType" {

declare module "@theme/ApiExplorer/ContentType/slice" {
export { setContentType };
export default contentType as Reducer<State, AnyAction>;
export default contentType as Reducer;
}

declare module "@theme/ApiExplorer/CodeSnippets" {
Expand Down Expand Up @@ -232,35 +224,35 @@ declare module "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem
declare module "@theme/ApiExplorer/ParamOptions/slice" {
export type { Param };
export const setParam;
export default params as Reducer<State, AnyAction>;
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";
// import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";

export interface RequestProps {
item: NonNullable<ApiItem>;
item: NonNullable;
}
export default function Request(props: RequestProps): JSX.Element;
}

declare module "@theme/ApiExplorer/Response" {
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
// import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";

export interface ResponseProps {
item: NonNullable<ApiItem>;
item: ApiItem;
}

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<State, AnyAction>;
export default response as Reducer;
}

declare module "@theme/ApiExplorer/SecuritySchemes" {
Expand All @@ -276,7 +268,7 @@ declare module "@theme/ApiExplorer/ApiCodeBlock" {
}

declare module "@theme/ApiExplorer/Server/slice" {
export default server as Reducer<State, AnyAction>;
export default server as Reducer;
}

declare module "@theme/ApiExplorer/storage-utils" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// @ts-nocheck
import React, { useState } from "react";

import { useDoc } from "@docusaurus/theme-common/internal";
import { useDoc } from "@docusaurus/plugin-content-docs/client";
import Accept from "@theme/ApiExplorer/Accept";
import Authorization from "@theme/ApiExplorer/Authorization";
import Body from "@theme/ApiExplorer/Body";
Expand All @@ -31,7 +31,7 @@ import { FormProvider, useForm } from "react-hook-form";

import makeRequest from "./makeRequest";

function Request({ item }: { item: NonNullable<ApiItem> }) {
function Request({ item }: { item: ApiItem }) {
const postman = new sdk.Request(item.postman);
const metadata = useDoc();
const { proxy, hide_send_button: hideSendButton } = metadata.frontMatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import React from "react";

// @ts-ignore
import { useDoc } from "@docusaurus/plugin-content-docs/client";
import { usePrismTheme } from "@docusaurus/theme-common";
import { useDoc } from "@docusaurus/theme-common/internal";
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
import SchemaTabs from "@theme/SchemaTabs";
Expand Down Expand Up @@ -38,7 +39,7 @@ function formatXml(xml: string) {
return formatted.substring(1, formatted.length - 3);
}

function Response({ item }: { item: NonNullable<ApiItem> }) {
function Response({ item }: { item: ApiItem }) {
const metadata = useDoc();
const hideSendButton = metadata.frontMatter.hide_send_button;
const prismTheme = usePrismTheme();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import React from "react";

import BrowserOnly from "@docusaurus/BrowserOnly";
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
// @ts-ignore
import { DocProvider } from "@docusaurus/plugin-content-docs/client";
import { HtmlClassNameProvider } from "@docusaurus/theme-common";
import { DocProvider } from "@docusaurus/theme-common/internal";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import useIsBrowser from "@docusaurus/useIsBrowser";
import { createAuth } from "@theme/ApiExplorer/Authorization/slice";
import { createPersistanceMiddleware } from "@theme/ApiExplorer/persistanceMiddleware";
import DocItemLayout from "@theme/ApiItem/Layout";
import type { Props } from "@theme/DocItem";
import DocItemLayout from "@theme/DocItem/Layout";
import DocItemMetadata from "@theme/DocItem/Metadata";
import clsx from "clsx";
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
Expand Down
Loading
Loading