(
profile: Profile,
options?: {
refresh?: boolean;
}
)
| 24 | } |
| 25 | |
| 26 | async loadSpec( |
| 27 | profile: Profile, |
| 28 | options?: { |
| 29 | refresh?: boolean; |
| 30 | } |
| 31 | ): Promise<unknown> { |
| 32 | const cachePath = profile.openapiSpecCache; |
| 33 | |
| 34 | if (!options?.refresh && this.fs.existsSync(cachePath)) { |
| 35 | const cached = this.fs.readFileSync(cachePath, "utf-8"); |
| 36 | return JSON.parse(cached); |
| 37 | } |
| 38 | |
| 39 | const spec = await this.loadAndResolveSpec(profile.openapiSpecSource); |
| 40 | this.ensureCacheDir(cachePath); |
| 41 | |
| 42 | const serialized = JSON.stringify(spec, null, 2); |
| 43 | this.fs.writeFileSync(cachePath, serialized); |
| 44 | |
| 45 | return spec; |
| 46 | } |
| 47 | |
| 48 | private async loadAndResolveSpec(source: string): Promise<unknown> { |
| 49 | const rawDocCache = new Map<string, unknown>(); |
no test coverage detected