UNPKG

mcp-swagger-parser

Version:

Enterprise-grade OpenAPI/Swagger specification parser for Model Context Protocol (MCP) projects

83 lines 3.19 kB
"use strict"; /** * Custom error classes for OpenAPI parsing */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ERROR_CODES = exports.VersionDetectionError = exports.UnsupportedVersionError = exports.Swagger2OpenAPIConversionError = exports.OpenAPIFileError = exports.OpenAPINetworkError = exports.OpenAPIValidationError = exports.OpenAPIParseError = void 0; class OpenAPIParseError extends Error { constructor(message, code, path, cause) { super(message); this.name = 'OpenAPIParseError'; this.code = code; this.path = path; this.cause = cause; } } exports.OpenAPIParseError = OpenAPIParseError; class OpenAPIValidationError extends Error { constructor(message, errors, warnings = []) { super(message); this.name = 'OpenAPIValidationError'; this.errors = errors; this.warnings = warnings; } } exports.OpenAPIValidationError = OpenAPIValidationError; class OpenAPINetworkError extends Error { constructor(message, url, statusCode, cause) { super(message); this.name = 'OpenAPINetworkError'; this.url = url; this.statusCode = statusCode; this.cause = cause; } } exports.OpenAPINetworkError = OpenAPINetworkError; class OpenAPIFileError extends Error { constructor(message, filePath, cause) { super(message); this.name = 'OpenAPIFileError'; this.filePath = filePath; this.cause = cause; } } exports.OpenAPIFileError = OpenAPIFileError; class Swagger2OpenAPIConversionError extends OpenAPIParseError { constructor(message, originalError, conversionOptions) { super(message, exports.ERROR_CODES.CONVERSION_ERROR); this.name = 'Swagger2OpenAPIConversionError'; this.originalError = originalError; this.conversionOptions = conversionOptions; } } exports.Swagger2OpenAPIConversionError = Swagger2OpenAPIConversionError; class UnsupportedVersionError extends OpenAPIParseError { constructor(detectedVersion) { super(`Unsupported API specification version: ${detectedVersion}. Supported versions: Swagger 2.0, OpenAPI 3.0+`, exports.ERROR_CODES.UNSUPPORTED_VERSION); this.name = 'UnsupportedVersionError'; this.detectedVersion = detectedVersion; } } exports.UnsupportedVersionError = UnsupportedVersionError; class VersionDetectionError extends OpenAPIParseError { constructor(message, cause) { super(message, exports.ERROR_CODES.VERSION_DETECTION_FAILED, undefined, cause); this.name = 'VersionDetectionError'; } } exports.VersionDetectionError = VersionDetectionError; // Error codes constants exports.ERROR_CODES = { PARSE_ERROR: 'PARSE_ERROR', VALIDATION_ERROR: 'VALIDATION_ERROR', NETWORK_ERROR: 'NETWORK_ERROR', FILE_NOT_FOUND: 'FILE_NOT_FOUND', INVALID_FORMAT: 'INVALID_FORMAT', REFERENCE_ERROR: 'REFERENCE_ERROR', SCHEMA_ERROR: 'SCHEMA_ERROR', TIMEOUT_ERROR: 'TIMEOUT_ERROR', CONVERSION_ERROR: 'CONVERSION_ERROR', UNSUPPORTED_VERSION: 'UNSUPPORTED_VERSION', VERSION_DETECTION_FAILED: 'VERSION_DETECTION_FAILED' }; //# sourceMappingURL=index.js.map