UNPKG

openapi-client-sdk-loader

Version:
46 lines (36 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _lodash = require("lodash"); var _utils = require("../utils"); const createOperations = (api, deref) => Promise.all(Object.keys(deref.paths).reduce((result, path) => { return [...result, ...Object.keys(deref.paths[path]).map(async method => { const operation = deref.paths[path][method]; let schema = { method: method.toUpperCase(), path, mimeType: 'application/json', name: operation.operationId }; if (operation.parameters) { schema = { ...schema, ...(0, _utils.parseParams)(operation.parameters) }; } if (operation.requestBody) { schema = { ...schema, ...(0, _utils.parseBody)(operation.requestBody.content) }; } if (operation.responses) { schema = { ...schema, ...(0, _utils.parseResponses)(operation.responses) }; } return schema; })]; }, [])); var _default = (api, options) => options.parser.dereference((0, _lodash.cloneDeep)(api)).then(deref => createOperations(api, deref)); exports.default = _default;