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
@@ -0,0 +1,45 @@
import React from "react"
import { ApiRunnerParamInput, ApiRunnerParamInputProps } from "../Default"
import clsx from "clsx"
export const ApiRunnerParamObjectInput = ({
paramName,
paramValue,
objPath,
...props
}: ApiRunnerParamInputProps) => {
if (typeof paramValue !== "object") {
return (
<ApiRunnerParamInput
paramName={paramName}
paramValue={paramValue}
objPath={objPath}
{...props}
/>
)
}
return (
<fieldset
className={clsx(
"border border-medusa-border-strong rounded",
"p-docs_0.5"
)}
>
<legend className="px-docs_0.5">
<code>{paramName}</code> Properties
</legend>
{Object.entries(paramValue as Record<string, unknown>).map(
([key, value], index) => (
<ApiRunnerParamInput
paramName={key}
paramValue={value}
objPath={`${objPath.length ? `${objPath}.` : ""}${paramName}`}
key={index}
{...props}
/>
)
)}
</fieldset>
)
}