import * as yaml from "js-yaml"; import type { OpenApiSpec } from "./types"; export async function loadSpec(url: string): Promise { const response = await fetch(url); if (!response.ok) { throw new Error(`Failed to fetch spec: ${response.status} ${response.statusText}`); } const text = await response.text(); const parsed = yaml.load(text); if (!parsed || typeof parsed !== "object") { throw new Error("Spec is empty or not an object"); } return parsed as OpenApiSpec; }