* Save public spec to disk cache
(cachePath: string, spec: OpenApiSpec)
| 283 | * Save public spec to disk cache |
| 284 | */ |
| 285 | private async saveCache(cachePath: string, spec: OpenApiSpec): Promise<void> { |
| 286 | const cached: CachedSpec = { |
| 287 | fetchedAt: Date.now(), |
| 288 | spec, |
| 289 | }; |
| 290 | |
| 291 | // Ensure directory exists |
| 292 | const dir = join(cachePath, '..'); |
| 293 | await mkdir(dir, { recursive: true }); |
| 294 | |
| 295 | await writeFile(cachePath, JSON.stringify(cached)); |
| 296 | output.debug('Saved OpenAPI spec to cache'); |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Fetch OpenAPI spec from remote with timeout |