MCPcopy Create free account
hub / github.com/ReAPI-com/mcp-openapi / loadSpec

Method loadSpec

src/core/SpecService.ts:286–319  ·  view source on GitHub ↗
(specId: string)

Source from the content-addressed store, hash-verified

284 }
285
286 async loadSpec(specId: string): Promise<OpenAPIV3.Document> {
287 this.logger.debug({ specId }, "Loading specification");
288
289 // Check cache first
290 const cached = this.specCache.get(specId);
291 if (cached) {
292 this.logger.debug({ specId }, "Returning cached specification");
293 return cached;
294 }
295
296 try {
297 const specPath = path.join(this.dereferencedPath, `${specId}.json`);
298 const spec = JSON.parse(await fs.readFile(specPath, "utf-8"));
299
300 // Cache the loaded spec
301 this.specCache.set(specId, spec);
302 this.logger.info({ specId }, "Successfully loaded specification");
303
304 return spec;
305 } catch (error) {
306 this.logger.error({ specId, error }, "Failed to load specification");
307 if ((error as NodeJS.ErrnoException).code === "ENOENT") {
308 throw new SpecServiceError(
309 `Specification not found: ${specId}`,
310 "LOAD_ERROR"
311 );
312 }
313 throw new SpecServiceError(
314 `Failed to load specification ${specId}`,
315 "LOAD_ERROR",
316 error instanceof Error ? error : new Error(String(error))
317 );
318 }
319 }
320
321 public async refresh(): Promise<void> {
322 if (!this.folderPath) {

Callers 1

loadExistingCatalogMethod · 0.95

Calls 5

getMethod · 0.80
setMethod · 0.80
debugMethod · 0.65
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected