mcp-openapi-schema-explorer
Version:
MCP OpenAPI schema explorer
68 lines (67 loc) • 3.52 kB
TypeScript
import { OpenAPIV3 } from 'openapi-types';
import { RenderableSpecObject, RenderContext, RenderResultItem } from './types.js';
export type ComponentType = keyof OpenAPIV3.ComponentsObject;
export declare const VALID_COMPONENT_TYPES: ComponentType[];
/**
* Wraps an OpenAPIV3.ComponentsObject to make it renderable.
* Handles listing the available component types.
*/
export declare class RenderableComponents implements RenderableSpecObject {
private components;
constructor(components: OpenAPIV3.ComponentsObject | undefined);
/**
* Renders a list of available component types found in the spec.
* Corresponds to the `openapi://components` URI.
*/
renderList(context: RenderContext): RenderResultItem[];
/**
* Detail view for the main 'components' object isn't meaningful.
*/
renderDetail(context: RenderContext): RenderResultItem[];
/**
* Gets the map object for a specific component type.
* @param type - The component type (e.g., 'schemas').
* @returns The map (e.g., ComponentsObject['schemas']) or undefined.
*/
getComponentMap(type: ComponentType): Record<string, OpenAPIV3.SchemaObject | OpenAPIV3.ResponseObject | OpenAPIV3.ParameterObject | OpenAPIV3.ExampleObject | OpenAPIV3.RequestBodyObject | OpenAPIV3.HeaderObject | OpenAPIV3.SecuritySchemeObject | OpenAPIV3.LinkObject | OpenAPIV3.CallbackObject | OpenAPIV3.ReferenceObject> | undefined;
}
/**
* Wraps a map of components of a specific type (e.g., all schemas).
* Handles listing component names and rendering component details.
*/
export declare class RenderableComponentMap implements RenderableSpecObject {
private componentMap;
private componentType;
private mapUriSuffix;
constructor(componentMap: ReturnType<RenderableComponents['getComponentMap']>, componentType: ComponentType, // e.g., 'schemas'
mapUriSuffix: string);
/**
* Renders a list of component names for the specific type.
* Corresponds to the `openapi://components/{type}` URI.
*/
renderList(context: RenderContext): RenderResultItem[];
/**
* Renders the detail view for one or more specific named components
* Renders the detail view. For a component map, this usually means listing
* the component names, similar to renderList. The handler should call
* `renderComponentDetail` for specific component details.
*/
renderDetail(context: RenderContext): RenderResultItem[];
/**
* Renders the detail view for one or more specific named components
* within this map.
* Corresponds to the `openapi://components/{type}/{name*}` URI.
* This is called by the handler after identifying the name(s).
*
* @param _context - The rendering context (might be needed later).
* @param names - Array of component names.
* @returns An array of RenderResultItem representing the component details.
*/
renderComponentDetail(_context: RenderContext, names: string[]): RenderResultItem[];
/**
* Gets a specific component object by name.
* @param name - The name of the component.
* @returns The component object (or ReferenceObject) or undefined.
*/
getComponent(name: string): OpenAPIV3.SchemaObject | OpenAPIV3.ResponseObject | OpenAPIV3.ParameterObject | OpenAPIV3.ExampleObject | OpenAPIV3.RequestBodyObject | OpenAPIV3.HeaderObject | OpenAPIV3.SecuritySchemeObject | OpenAPIV3.LinkObject | OpenAPIV3.CallbackObject | OpenAPIV3.ReferenceObject | undefined;
}