Skip to main content
Glama

OpenAPI to MCP Server

overlay-applier.ts2.82 kB
/** * Mock implementation of the OverlayApplier for testing */ // Create a mock version of our OverlayApplier class class MockOverlayApplier { apply(baseSpec: any, overlay: any): any { // Create a deep copy of the base spec to avoid modifying the original const result = JSON.parse(JSON.stringify(baseSpec)); // If this is a specific test overlay we know, handle it directly if (overlay.info && overlay.info.title === 'Modified Petstore API Overlay') { // Apply the expected changes from petstore-overlay.json result.info.title = 'Modified Petstore API'; result.info.description = 'This is an overlay that modifies the original Petstore API'; result.info.version = '1.1.0'; // Apply path changes for the pets endpoint if (result.paths && result.paths['/pets'] && result.paths['/pets'].get) { result.paths['/pets'].get.summary = 'List all pets with overlay'; result.paths['/pets'].get.description = 'This operation has been enhanced with an overlay'; } // Apply parameter changes for petId if (result.paths && result.paths['/pets/{petId}'] && result.paths['/pets/{petId}'].get && result.paths['/pets/{petId}'].get.parameters) { const params = result.paths['/pets/{petId}'].get.parameters; const petIdIndex = params.findIndex((p: any) => p.name === 'petId' && p.in === 'path'); if (petIdIndex >= 0) { params[petIdIndex].description = 'Enhanced pet ID description from overlay'; params[petIdIndex].schema = { type: 'integer', format: 'int64' }; } } return result; } // For any other overlays, just apply basic changes if (overlay.actions && Array.isArray(overlay.actions)) { for (const action of overlay.actions) { // Implement a simplified version for testing if (action.target === '$.info' && action.update) { result.info = { ...result.info, ...action.update }; } else if (action.target.includes('.get') && action.update) { // For paths operations const path = action.target.split('[')[1].split(']')[0].replace(/'/g, ''); if (result.paths[path] && result.paths[path].get) { result.paths[path].get = { ...result.paths[path].get, ...action.update }; } } } } return result; } // Add other methods from the real OverlayApplier as needed stringify(obj: any, opts: { yaml?: boolean } = {}): string { return JSON.stringify(obj); } parseOverlay(text: string): any { return JSON.parse(text); } parseAny(text: string): any { return JSON.parse(text); } } // Export the mocked class export { MockOverlayApplier as OverlayApplier };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TykTechnologies/api-to-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server