test-openapi
Version:
Automated client requests
43 lines (29 loc) • 1.35 kB
JavaScript
require("core-js/modules/es.array.flat-map");require("core-js/modules/es.array.iterator");require("core-js/modules/es.array.unscopables.flat-map");Object.defineProperty(exports,"__esModule",{value:true});exports.normalizeSpec=void 0;var _lodash=require("lodash");
var _main=require("./params/main.js");
var _response=require("./response.js");
const normalizeSpec=function({spec}){
const operations=getOperations({spec});
return{operations};
};exports.normalizeSpec=normalizeSpec;
const getOperations=function({spec,spec:{paths}}){
return Object.entries(paths).flatMap(([path,pathDef])=>
getOperationsByPath({spec,path,pathDef}));
};
const getOperationsByPath=function({spec,path,pathDef}){
const pathDefA=(0,_lodash.omit)(pathDef,"parameters");
return Object.entries(pathDefA).map(([method,operation])=>
getOperation({spec,path,pathDef,operation,method}));
};
const getOperation=function({spec,path,pathDef,operation,method}){
const operationId=getOperationId({operation});
const params=(0,_main.getParams)({spec,method,path,pathDef,operation});
const responsesA=(0,_response.normalizeResponses)({spec,operation});
return{...operationId,params,responses:responsesA};
};
const getOperationId=function({operation:{operationId}}){
if(operationId===undefined){
return;
}
return{operationId};
};
//# sourceMappingURL=main.js.map
;