Skip to content
Merged
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
28 changes: 28 additions & 0 deletions packages/docusaurus-plugin-openapi/src/plugin-openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,31 @@ declare module "@theme/MarkdownItem" {
const MarkdownItem: (props: Props) => JSX.Element;
export default MarkdownItem;
}

declare module "@theme/ApiDemoPanel" {
import type { Metadata } from "@theme/ApiItem";

export interface Props {
readonly item: NonNullable<Metadata["api"]>;
}

const ApiDemoPanel: (props: Props) => JSX.Element;
export default ApiDemoPanel;
}

declare module "@theme/ApiDemoPanel/Curl" {
import type { Request } from "postman-collection";

export interface Props {
readonly postman: Request;
readonly codeSamples: Array<Any>;
}

const Curl: (props: Props) => JSX.Element;
export default Curl;
}

declare module "@theme/ApiDemoPanel/Response" {
const Response: () => JSX.Element;
export default Response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import React, { useRef, useState, useEffect } from "react";

import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import type { Props } from "@theme/ApiDemoPanel/Curl";
import clsx from "clsx";
// @ts-ignore
import codegen from "postman-code-generators";
import sdk from "postman-collection";
import Highlight, { defaultProps } from "prism-react-renderer";

import { useTypedSelector } from "../hooks";
Expand Down Expand Up @@ -122,11 +122,6 @@ const languageTheme = {
],
};

interface Props {
postman: sdk.Request;
codeSamples: any; // TODO: Type this...
}

function Curl({ postman, codeSamples }: Props) {
// TODO: match theme for vscode.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import React from "react";

import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import { Metadata } from "@theme/ApiItem";
import type { Props } from "@theme/ApiDemoPanel";
import Curl from "@theme/ApiDemoPanel/Curl";
import Response from "@theme/ApiDemoPanel/Response";
import { ParameterObject } from "docusaurus-plugin-openapi/src/openapi/types";
import sdk from "postman-collection";
import { Provider } from "react-redux";
Expand All @@ -18,18 +20,16 @@ import Accept from "./Accept";
import Authorization from "./Authorization";
import { createAuth } from "./Authorization/slice";
import Body from "./Body";
import Curl from "./Curl";
import Execute from "./Execute";
import MethodEndpoint from "./MethodEndpoint";
import ParamOptions from "./ParamOptions";
import { createPersistanceMiddleware } from "./persistanceMiddleware";
import Response from "./Response";
import Server from "./Server";
import { createServer } from "./Server/slice";
import { createStoreWithState } from "./store";
import styles from "./styles.module.css";

function ApiDemoPanel({ item }: { item: NonNullable<Metadata["api"]> }) {
function ApiDemoPanel({ item }: Props) {
const { siteConfig } = useDocusaurusContext();
const themeConfig = siteConfig.themeConfig as ThemeConfig;
const options = themeConfig.api;
Expand Down