diff --git a/packages/types/src/openapi.ts b/packages/types/src/openapi.ts index 1930878fa..ec05c8d96 100644 --- a/packages/types/src/openapi.ts +++ b/packages/types/src/openapi.ts @@ -77,7 +77,7 @@ const OpenAPIRequestBodySchema = z.object({ content: z.record(ContentSchema), }); -const OpenAPIOperationSchema = z.object({ +export const OpenAPIOperationSchema = z.object({ title: z.string().optional(), summary: z.string().optional(), description: z.string().optional(), diff --git a/studio/src/pages/RequestorPage/RequestPanel/RequestPanel.tsx b/studio/src/pages/RequestorPage/RequestPanel/RequestPanel.tsx index e914c7c69..acc6d6a86 100644 --- a/studio/src/pages/RequestorPage/RequestPanel/RequestPanel.tsx +++ b/studio/src/pages/RequestorPage/RequestPanel/RequestPanel.tsx @@ -1,7 +1,7 @@ import { Button } from "@/components/ui/button"; import { Tabs } from "@/components/ui/tabs"; import { useToast } from "@/components/ui/use-toast"; -import { cn, objectWithKey } from "@/utils"; +import { cn } from "@/utils"; import { EraserIcon, InfoCircledIcon } from "@radix-ui/react-icons"; import { type Dispatch, type SetStateAction, memo, useMemo } from "react"; import { FormDataForm } from "../FormDataForm"; @@ -22,6 +22,7 @@ import { } from "@/components/CodeMirrorEditor"; import { useRequestorStore } from "../store"; import { RouteDocumentation } from "./RouteDocumentation/RouteDocumentation"; +import { isOpenApiOperation } from "./RouteDocumentation/openapi"; type RequestPanelProps = { aiEnabled: boolean; @@ -37,14 +38,6 @@ type RequestPanelProps = { onSubmit: () => void; }; -function isValidOpenApiSpec(openApiSpec: unknown): boolean { - return ( - objectWithKey(openApiSpec, "parameters") || - objectWithKey(openApiSpec, "requestBody") || - objectWithKey(openApiSpec, "responses") - ); -} - export const RequestPanel = memo(function RequestPanel( props: RequestPanelProps, ) { @@ -116,7 +109,7 @@ export const RequestPanel = memo(function RequestPanel( return null; } }, [activeRoute?.openApiSpec]); - const shouldShowDocs = isValidOpenApiSpec(openApiSpec); + const shouldShowDocs = isOpenApiOperation(openApiSpec); return (