(spec: OpenAPIV3.Document, specId: string)
| 244 | } |
| 245 | |
| 246 | async saveSpec(spec: OpenAPIV3.Document, specId: string): Promise<void> { |
| 247 | this.logger.debug({ specId }, "Persisting specification"); |
| 248 | try { |
| 249 | await this.ensureDirectory(this.dereferencedPath); |
| 250 | const specPath = path.join(this.dereferencedPath, `${specId}.json`); |
| 251 | await fs.writeFile(specPath, JSON.stringify(spec, null, 2)); |
| 252 | this.specs[specId] = spec; |
| 253 | this.specCache.set(specId, spec); |
| 254 | this.logger.info({ specId }, "Successfully persisted specification"); |
| 255 | } catch (error) { |
| 256 | this.logger.error({ specId, error }, "Failed to persist specification"); |
| 257 | throw new SpecServiceError( |
| 258 | `Failed to persist specification ${specId}`, |
| 259 | "PERSIST_ERROR", |
| 260 | error instanceof Error ? error : new Error(String(error)) |
| 261 | ); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | async saveSpecCatalog(catalog: SpecCatalogEntry[]): Promise<void> { |
| 266 | if (!this.catalogPath) { |
no test coverage detected