docs: improve API testing feature (#7311)

This commit is contained in:
Shahed Nasser
2024-05-14 10:12:53 +03:00
committed by GitHub
parent 5b26f5f2cf
commit 70c4ffff8b
10 changed files with 368 additions and 68 deletions
@@ -3,14 +3,13 @@
import React, { useMemo, useState } from "react"
import clsx from "clsx"
import { HighlightProps, Highlight, themes } from "prism-react-renderer"
import { CopyButton, Tooltip, Link } from "@/components"
import { ApiRunner, CopyButton, Tooltip, Link } from "@/components"
import { useColorMode } from "@/providers"
import { ExclamationCircle, PlaySolid, SquareTwoStack } from "@medusajs/icons"
import { CodeBlockHeader, CodeBlockHeaderMeta } from "./Header"
import { CodeBlockLine } from "./Line"
import { ApiAuthType, ApiDataOptions, ApiMethod } from "types"
import { CSSTransition } from "react-transition-group"
import { ApiRunner } from "./ApiRunner"
import { GITHUB_ISSUES_PREFIX } from "../.."
export type Highlight = {
@@ -69,7 +68,10 @@ export const CodeBlock = ({
const { colorMode } = useColorMode()
const [showTesting, setShowTesting] = useState(false)
const canShowApiTesting = useMemo(
() => apiTesting && rest.testApiMethod && rest.testApiUrl,
() =>
apiTesting !== undefined &&
rest.testApiMethod !== undefined &&
rest.testApiUrl !== undefined,
[apiTesting, rest]
)