swagger-tools/src/lib/types.ts
rimskij cc789d3b32 feat: initial MCP server for OpenAPI/Swagger parsing
- Parse and validate OpenAPI 3.x / Swagger 2.0 specs
- Query endpoints by method, path pattern, tag, operationId
- Get component schema details
- Generate TypeScript interfaces from schemas
- Support local files and remote URLs

Tools: parse-spec, validate-spec, query-endpoints, get-schema, generate-types

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-12 14:33:10 +01:00

75 lines
1.5 KiB
TypeScript

import type { OpenAPI, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
export type OpenAPISpec = OpenAPI.Document;
export type OpenAPIV3Spec = OpenAPIV3.Document | OpenAPIV3_1.Document;
export interface ParsedSpec {
version: string;
title: string;
description?: string;
servers: string[];
pathCount: number;
schemaCount: number;
operationCount: number;
tags: string[];
}
export interface ValidationError {
path: string;
message: string;
severity: 'error' | 'warning';
}
export interface ValidationResult {
valid: boolean;
errors: ValidationError[];
warnings: ValidationError[];
}
export interface EndpointInfo {
method: string;
path: string;
operationId?: string;
summary?: string;
description?: string;
tags: string[];
parameters: ParameterInfo[];
requestBody?: RequestBodyInfo;
responses: ResponseInfo[];
}
export interface ParameterInfo {
name: string;
in: 'query' | 'header' | 'path' | 'cookie';
required: boolean;
description?: string;
schema?: object;
}
export interface RequestBodyInfo {
required: boolean;
description?: string;
contentTypes: string[];
}
export interface ResponseInfo {
statusCode: string;
description?: string;
contentTypes: string[];
}
export interface EndpointFilter {
method?: string;
pathPattern?: string;
tag?: string;
operationId?: string;
}
export interface SchemaInfo {
name: string;
type?: string;
description?: string;
properties?: Record<string, object>;
required?: string[];
schema: object;
}