generator-api-on-calling
Version:
generate frontend api request client according to an openapi shema url
15 lines (12 loc) • 346 B
JavaScript
;
const { request } = require('urllib-next');
/**
* download the schema by url
* - TODO: currently only supports openapi json doc data
* @param {string} schemaUrl - schema url
* @returns {object}
*/
exports.downloadSchema = async (schemaUrl) => {
const { data } = await request(schemaUrl);
return JSON.parse(data + '');
};