export type GetApiApiV1OpenapiJsonArgs = {'X-Query-Validation'?: 'strict' | undefined}; export type GetApiApiV1OpenapiJsonOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Redirect to the canonical OpenAPI spec * * GET /api/v1/openapi.json */ export const getApiApiV1OpenapiJson = async (args: GetApiApiV1OpenapiJsonArgs, options?: GetApiApiV1OpenapiJsonOptions) => { const {baseUrl = "https://api.0xinsider.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Query-Validation'] != null) headers.set("X-Query-Validation", String(args['X-Query-Validation'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/openapi.json${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };