MCPcopy Create free account
hub / github.com/vercel/vercel / fetchSpec

Method fetchSpec

packages/cli/src/util/openapi/openapi-cache.ts:302–317  ·  view source on GitHub ↗

* Fetch OpenAPI spec from remote with timeout

(url: string)

Source from the content-addressed store, hash-verified

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') {

Callers 2

loadSpecMethod · 0.95
loadCustomSpecMethod · 0.95

Calls 3

validateSpecMethod · 0.95
abortMethod · 0.80
fetchFunction · 0.50

Tested by

no test coverage detected