UNPKG

mcp-openapi-schema-explorer

Version:
46 lines (45 loc) 2.11 kB
import { OpenAPIV3 } from 'openapi-types'; import { RenderableSpecObject, RenderContext, RenderResultItem } from './types.js'; /** * Wraps an OpenAPIV3.PathItemObject to make it renderable. * Handles rendering the list of methods for a specific path and * the details of specific operations (methods). */ export declare class RenderablePathItem implements RenderableSpecObject { private pathItem; private path; private pathUriSuffix; constructor(pathItem: OpenAPIV3.PathItemObject | undefined, path: string, // The raw, decoded path string e.g., "/users/{userId}" pathUriSuffix: string); /** * Renders a token-efficient list of methods available for this path. * Corresponds to the `openapi://paths/{path}` URI. */ renderList(context: RenderContext): RenderResultItem[]; /** * Renders the detail view for one or more specific operations (methods) * Renders the detail view. For a PathItem, this usually means listing * the methods, similar to renderList. The handler should call * `renderOperationDetail` for specific method details. */ renderDetail(context: RenderContext): RenderResultItem[]; /** * Renders the detail view for one or more specific operations (methods) * within this path item. * Corresponds to the `openapi://paths/{path}/{method*}` URI. * This is called by the handler after identifying the method(s). * * @param context - The rendering context. * @param methods - Array of method names (e.g., ['get', 'post']). * @returns An array of RenderResultItem representing the operation details. */ renderOperationDetail(_context: RenderContext, // Context might be needed later methods: string[]): RenderResultItem[]; /** * Gets the OperationObject for a specific HTTP method within this path item. * Performs case-insensitive lookup. * @param method - The HTTP method string (e.g., 'get', 'POST'). * @returns The OperationObject or undefined if not found. */ getOperation(method: string): OpenAPIV3.OperationObject | undefined; }