import clsx from 'clsx'; import type { OpenAPICustomOperationProperties, OpenAPIV3 } from '@gitbook/openapi-parser'; import { Markdown } from './Markdown'; import { OpenAPICodeSample } from './OpenAPICodeSample'; import { OpenAPIPath } from './OpenAPIPath'; import { OpenAPIResponseExample } from './OpenAPIResponseExample'; import { OpenAPISpec } from './OpenAPISpec'; import type { OpenAPIClientContext, OpenAPIContextProps, OpenAPIOperationData } from './types'; import { resolveDescription } from './utils'; /** * Display an interactive OpenAPI operation. */ export function OpenAPIOperation(props: { className?: string; data: OpenAPIOperationData; context: OpenAPIContextProps; }) { const { className, data, context } = props; const { operation } = data; const clientContext: OpenAPIClientContext = { defaultInteractiveOpened: context.defaultInteractiveOpened, icons: context.icons, blockKey: context.blockKey, }; return (
{operation.summary ? context.renderHeading({ deprecated: operation.deprecated ?? false, title: operation.summary, }) : null} {operation.deprecated &&
Deprecated
}
{operation['x-deprecated-sunset'] ? (
This operation is deprecated and will be sunset on{' '} {operation['x-deprecated-sunset']} {'.'}
) : null}
); } function OpenAPIOperationDescription(props: { operation: OpenAPIV3.OperationObject; context: OpenAPIContextProps; }) { const { operation } = props; if (operation['x-gitbook-description-document']) { return (
{props.context.renderDocument({ document: operation['x-gitbook-description-document'], })}
); } const description = resolveDescription(operation); if (!description) { return null; } return (
); }