* Fetch OpenAPI spec from remote with timeout
(url: string)
| 300 | * Fetch OpenAPI spec from remote with timeout |
| 301 | */ |
| 302 | private async fetchSpec(url: string): Promise<OpenApiSpec> { |
| 303 | const controller = new AbortController(); |
| 304 | const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS); |
| 305 | |
| 306 | try { |
| 307 | const response = await fetch(url, { signal: controller.signal }); |
| 308 | if (!response.ok) { |
| 309 | throw new Error(`Failed to fetch OpenAPI spec: ${response.status}`); |
| 310 | } |
| 311 | const spec = await readSpecResponse<OpenApiSpec>(response, url); |
| 312 | this.validateSpec(spec, url); |
| 313 | return spec; |
| 314 | } finally { |
| 315 | clearTimeout(timeoutId); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | private validateSpec(spec: OpenApiSpec | null, url: string): void { |
| 320 | if (!spec || typeof spec !== 'object') { |
no test coverage detected