← Public packages
@kody/api-research
Research third-party APIs: registry search, provider discovery, OpenAPI summarize, and client scaffold.
src/fetch-spec.ts
26 lines · 893 B · TypeScriptimport { fetchOpenApiSpecText } from './fetch-spec-lib.ts'
export type FetchSpecInput = {
/** HTTPS URL of an OpenAPI 3.x document (JSON or YAML). */
specUrl: string
}
/**
* Fetch an untrusted OpenAPI 3.x document over HTTPS with size and timeout bounds.
* Use when you already have a verified spec URL and want the raw text.
*
* @param input - HTTPS spec URL
* @returns Spec URL and raw document text
*
* @example
* import fetchSpec from 'kody:@kody/api-research/fetch-spec'
* const { text } = await fetchSpec({
* specUrl: 'https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json',
* })
*/
export default async function fetchSpec(
input: FetchSpecInput,
): Promise<{ specUrl: string; text: string }> {
const text = await fetchOpenApiSpecText({ specUrl: input.specUrl })
return { specUrl: input.specUrl, text }
}