UNPKG

mcp-openapi-schema-explorer

Version:
37 lines (36 loc) 1.83 kB
import { OpenAPIV3 } from 'openapi-types'; import { RenderableSpecObject, RenderContext, RenderResultItem } from './types.js'; /** * Wraps an OpenAPIV3.Document to make it renderable. * Handles rendering for top-level fields like 'info', 'servers', etc. * Delegates list rendering for 'paths' and 'components' to respective objects. */ export declare class RenderableDocument implements RenderableSpecObject { private document; constructor(document: OpenAPIV3.Document); /** * Renders a list view. For the document level, this is intended * to be called only when the requested field is 'paths' or 'components'. * The actual routing/delegation will happen in the handler based on the field. */ renderList(_context: RenderContext): RenderResultItem[]; /** * Renders the detail view. For the document level, this should not be called * directly without specifying a field. The handler should call * `renderTopLevelFieldDetail` instead. */ renderDetail(_context: RenderContext): RenderResultItem[]; /** * Renders the detail view for a *specific* top-level field (e.g., 'info', 'servers'). * This is called by the handler after identifying the field. * * @param context - The rendering context. * @param fieldObject - The actual top-level field object to render (e.g., document.info). * @param fieldName - The name of the field being rendered (e.g., 'info'). * @returns An array of RenderResultItem representing the detail view. */ renderTopLevelFieldDetail(context: RenderContext, fieldObject: unknown, fieldName: string): RenderResultItem[]; getPathsObject(): OpenAPIV3.PathsObject | undefined; getComponentsObject(): OpenAPIV3.ComponentsObject | undefined; getTopLevelField(fieldName: string): unknown; }