UNPKG

@vfarcic/dot-ai

Version:

AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance

214 lines 5.55 kB
/** * OpenAPI 3.0 Specification Generator * * Automatically generates OpenAPI 3.0 documentation from the tool registry * and REST route registry. * * PRD #354: REST API Route Registry with Auto-Generated OpenAPI and Test Fixtures * - Generates paths from RestRouteRegistry for all REST endpoints * - Converts Zod schemas to JSON Schema for complete API documentation */ import { RestToolRegistry } from './rest-registry'; import { RestRouteRegistry } from './rest-route-registry'; import { Logger } from '../core/error-handling'; /** * JSON Schema object type for OpenAPI schemas */ type JsonSchemaObject = { type?: string; properties?: Record<string, JsonSchemaObject>; items?: JsonSchemaObject; required?: string[]; description?: string; enum?: unknown[]; [key: string]: unknown; }; /** * OpenAPI path item structure */ type OpenApiPathItem = { summary?: string; description?: string; operationId?: string; tags?: string[]; parameters?: unknown[]; requestBody?: { required?: boolean; content?: Record<string, { schema: JsonSchemaObject; }>; }; responses?: Record<string, { description: string; content?: Record<string, { schema: JsonSchemaObject; }>; }>; [key: string]: unknown; }; /** * OpenAPI 3.0 specification structure */ export interface OpenApiSpec { openapi: string; info: { title: string; description: string; version: string; contact?: { name: string; url: string; email: string; }; license?: { name: string; url: string; }; }; servers: Array<{ url: string; description: string; }>; paths: Record<string, Record<string, OpenApiPathItem>>; components?: { schemas?: Record<string, JsonSchemaObject>; responses?: Record<string, { description: string; content?: Record<string, { schema: JsonSchemaObject; }>; }>; securitySchemes?: Record<string, { type: string; scheme?: string; bearerFormat?: string; description?: string; }>; }; tags?: Array<{ name: string; description: string; }>; } /** * OpenAPI generator configuration */ export interface OpenApiConfig { title: string; description: string; version: string; basePath: string; apiVersion: string; serverUrl?: string; } /** * OpenAPI 3.0 specification generator */ export declare class OpenApiGenerator { private toolRegistry; private routeRegistry?; private logger; private config; private specCache?; private lastCacheUpdate; private cacheValidityMs; private schemaCache; constructor(toolRegistry: RestToolRegistry, logger: Logger, config?: Partial<OpenApiConfig>, routeRegistry?: RestRouteRegistry); /** * Generate complete OpenAPI 3.0 specification */ generateSpec(): OpenApiSpec; /** * Generate API info section */ private generateInfo; /** * Generate server definitions */ private generateServers; /** * Generate base paths (MCP Protocol endpoints) */ private generateBasePaths; /** * Generate paths for MCP tool endpoints */ private generateToolPaths; /** * Generate paths from REST route registry * PRD #354: Auto-generates OpenAPI paths from registered routes */ private generateRoutePaths; /** * Convert Express-style path to OpenAPI path format * Example: "/api/v1/visualize/:sessionId" -> "/api/v1/visualize/{sessionId}" */ private convertPathToOpenApi; /** * Convert a route definition to an OpenAPI operation object */ private routeToOpenApiOperation; /** * Extract path parameter names from a route path */ private extractPathParams; /** * Get parameter schema from route's params Zod schema */ private getParamSchemaFromRoute; /** * Convert Zod schema to OpenAPI parameters array */ private zodSchemaToParameters; /** * Generate unique schema name for a route */ private getSchemaName; /** * Get human-readable error description for status code */ private getErrorDescription; /** * Convert Zod schema to JSON Schema with caching */ private zodSchemaToJsonSchema; /** * Generate base component schemas (shared across all endpoints) */ private generateBaseSchemas; /** * Generate schemas for MCP tool endpoints */ private generateToolSchemas; /** * Generate schemas from REST route registry * PRD #354: Auto-generates OpenAPI schemas from route Zod schemas */ private generateRouteSchemas; /** * Generate tags for grouping endpoints */ private generateTags; /** * Generate example request body for a tool */ private generateExampleForTool; /** * Generate example value for a property schema */ private generateExampleValue; /** * Invalidate the specification cache */ invalidateCache(): void; /** * Update configuration */ updateConfig(newConfig: Partial<OpenApiConfig>): void; /** * Get current configuration */ getConfig(): OpenApiConfig; } export {}; //# sourceMappingURL=openapi-generator.d.ts.map