#! /usr/bin/env node /** * This script regenerates the list of real world API definitions from APIs.guru that the test * suite uses for parsing and validating integration tests. * * @see {@link https://github.com/APIs-guru/openapi-directory} */ import fs from 'node:fs'; const __dirname = import.meta.dirname; fetch('https://api.apis.guru/v2/list.json') .then(response => { if (!response.ok) { throw new Error('Unable to download real-world APIs from apis.guru'); } return response.json(); }) .then(apis => { // GitHub's CORS policy blocks this request delete apis['googleapis.com:adsense']; // This API has trouble downloading from GitHub. delete apis['googleapis.com:contentwarehouse']; // These APIs cause infinite loops in json-schema-ref-parser. Still investigating. // https://github.com/APIDevTools/json-schema-ref-parser/issues/56 delete apis['bungie.net']; delete apis['stripe.com']; delete apis['docusign.net']; delete apis['kubernetes.io']; delete apis['microsoft.com:graph']; // hangs delete apis['presalytics.io:ooxml']; // base security declaration in path/get operation (error message below) // "type array but found type null at #/paths//vault/callback/get/security" delete apis['apideck.com:vault']; return apis; }) .then(apis => { const apisMap = []; for (const [name, api] of Object.entries(apis)) { const latestVersion = api.versions[api.preferred]; apisMap.push({ name, version: api.preferred, url: latestVersion.swaggerYamlUrl, }); } return apisMap; }) .then(apis => { fs.writeFileSync( `${__dirname}/../test/specs/real-world/real-world-apis.json`, `${JSON.stringify(apis, null, 2)}\n`, ); });