Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.get('/v2/list.json')
.expect(200);
if (!res.ok) {
throw new Error('Unable to download API listing from apis.guru');
}
// Remove certain APIs that are known to cause problems
const apis = res.body;
// GitHub's CORS policy blocks this request
delete apis['googleapis.com:adsense'];
// These APIs cause infinite loops in json-schema-ref-parser. Still investigating.
// https://github.com/BigstickCarpet/json-schema-ref-parser/issues/56
delete apis['bungie.net'];
delete apis['stripe.com'];
// Flatten the list, so there's an API object for every API version
realWorldAPIs = [];
for (const apiName in apis) {
for (const version in apis[apiName].versions) {
const api = apis[apiName].versions[version];
api.name = apiName;
api.version = version;
realWorldAPIs.push(api);
}
}
});
.end(function (err, res) {
if (err || !res.ok) {
return done(err || new Error('Unable to downlaod real-world APIs from apis.guru'));
}
// Remove certain APIs that are known to cause problems
var apis = res.body;
// GitHub's CORS policy blocks this request
delete apis['googleapis.com:adsense'];
// These APIs cause infinite loops in json-schema-ref-parser. Still investigating.
// https://github.com/BigstickCarpet/json-schema-ref-parser/issues/56
delete apis['bungie.net'];
delete apis['stripe.com'];
// Flatten the list, so there's an API object for every API version
realWorldAPIs = [];
Object.keys(apis).forEach(function (apiName) {
Object.keys(apis[apiName].versions).forEach(function (version) {
var api = apis[apiName].versions[version];
api.name = apiName;
api.version = version;
realWorldAPIs.push(api);
});
});
done();
});
});