// --------------------------------------------------------------------------- // OpenAPI types — minimal subset of OpenAPI 3.0+ needed for tool generation // --------------------------------------------------------------------------- export type OpenApiSpec = { openapi: string; info: { title: string; version: string; description?: string }; servers?: Array<{ url: string; description?: string }>; paths: Record; components?: { schemas?: Record; parameters?: Record; requestBodies?: Record; }; }; export type PathItem = { get?: OperationObject; post?: OperationObject; put?: OperationObject; delete?: OperationObject; patch?: OperationObject; parameters?: Array; }; export type OperationObject = { operationId?: string; summary?: string; description?: string; parameters?: Array; requestBody?: RequestBodyObject | RefObject; responses?: Record; tags?: string[]; deprecated?: boolean; }; export type ParameterObject = { name: string; in: "query" | "header" | "path" | "cookie"; description?: string; required?: boolean; schema?: SchemaObject | RefObject; deprecated?: boolean; }; export type RequestBodyObject = { description?: string; required?: boolean; content: Record; }; export type MediaTypeObject = { schema?: SchemaObject | RefObject; }; export type SchemaObject = { type?: string; format?: string; description?: string; properties?: Record; required?: string[]; items?: SchemaObject | RefObject; enum?: unknown[]; default?: unknown; nullable?: boolean; oneOf?: Array; anyOf?: Array; allOf?: Array; additionalProperties?: boolean | SchemaObject | RefObject; minimum?: number; maximum?: number; minLength?: number; maxLength?: number; pattern?: string; $ref?: string; }; export type RefObject = { $ref: string; }; export type HttpMethod = "get" | "post" | "put" | "delete" | "patch"; export const HTTP_METHODS: HttpMethod[] = ["get", "post", "put", "delete", "patch"]; export type ParsedOperation = { operationId: string; method: HttpMethod; path: string; summary: string; description: string; parameters: ParameterObject[]; requestBody?: RequestBodyObject; deprecated: boolean; }; // --------------------------------------------------------------------------- // Options // --------------------------------------------------------------------------- export type OpenApiAuth = | { type: "bearer"; token: string } | { type: "basic"; username: string; password: string } | { type: "apiKey"; name: string; value: string; in: "header" | "query" }; export type OpenApiToolsOptions = { baseUrl?: string; headers?: Record; auth?: OpenApiAuth; include?: string[]; exclude?: string[]; namePrefix?: string; };