lib/swagger/swagger.js
function (yamlJson, cb) {
		
		let all_apis = {};
		let all_errors = {};
		
		let paths = reformatPaths(yamlJson.paths);
		let definitions = yamlJson.definitions;
		let parameters = yamlJson.parameters;
		
		let convertedDefinitions = {};
		let convertedParameters = {};
		
		// convert definitions first
		if (definitions) {
			let definitionsKeys = Object.keys(definitions);
			definitionsKeys.forEach(function (eachDef) {
				convertedDefinitions[eachDef] = convertItem(null, definitions[eachDef], 1); // 1 ??? definitions should never have schema -=-=-=-=-=
			});
		}
		
		// convert parameters then
		if (parameters) {
			let parametersKeys = Object.keys(parameters);
			parametersKeys.forEach(function (eachParam) {
				convertedParameters[eachParam] = convertItem(convertedDefinitions, parameters[eachParam], 1);
			});
			all_apis.commonFields = convertedParameters;
		}
		
		let pathsKeys = Object.keys(paths);
		pathsKeys.forEach(function (eachPath) {
			let methods = paths[eachPath];
			let methodsKeys = Object.keys(methods);
			
			methodsKeys.forEach(function (eachMethod) {
				let apiData = methods[eachMethod];
				
				if (!all_apis[eachMethod]) {
					all_apis[eachMethod] = {};
				}
				
				var mwFile = eachPath.replace(/\\/g, "_").replace(/:/g, "_").replace(/\//g, "_").replace(/[_]{2,}/g, "_").replace(/{/g, "").replace(/}/g, "");
				mwFile = mwFile.toLowerCase();
				if (mwFile[0] === "_") {
					mwFile = mwFile.substring(1);
				}
				mwFile += "_" + eachMethod.toLowerCase() + ".js";
				
				all_apis[eachMethod][eachPath] = {
					_apiInfo: {},
					"mw": '%dirname% + "/lib/mw/' + mwFile + '"'
				};
				let newSoajsApi = all_apis[eachMethod][eachPath];
				
				let params = apiData.parameters;
				
				let group = apiData.tags ? apiData.tags[0] : "";
				newSoajsApi._apiInfo.group = group && group !== '' ? group : "general";
				newSoajsApi._apiInfo.l = apiData.summary;
				newSoajsApi.imfv = convertParams(convertedDefinitions, convertedParameters, params);
			});
		});
		
		// todo: convert errors
		
		return cb({"schema": all_apis, "errors": all_errors});
	}
function (yamlJson, cb) {
		
		let all_apis = {};
		let all_errors = {};
		
		let paths = reformatPaths(yamlJson.paths);
		let definitions = yamlJson.definitions;
		let parameters = yamlJson.parameters;
		
		let convertedDefinitions = {};
		let convertedParameters = {};
		
		// convert definitions first
		if (definitions) {
			let definitionsKeys = Object.keys(definitions);
			definitionsKeys.forEach(function (eachDef) {
				convertedDefinitions[eachDef] = convertItem(null, definitions[eachDef], 1); // 1 ??? definitions should never have schema -=-=-=-=-=
			});
		}
		
		// convert parameters then
		if (parameters) {
			let parametersKeys = Object.keys(parameters);
			parametersKeys.forEach(function (eachParam) {
				convertedParameters[eachParam] = convertItem(convertedDefinitions, parameters[eachParam], 1);
			});
			all_apis.commonFields = convertedParameters;
		}
		
		let pathsKeys = Object.keys(paths);
		pathsKeys.forEach(function (eachPath) {
			let methods = paths[eachPath];
			let methodsKeys = Object.keys(methods);
			
			methodsKeys.forEach(function (eachMethod) {
				let apiData = methods[eachMethod];
				
				if (!all_apis[eachMethod]) {
					all_apis[eachMethod] = {};
				}
				
				var mwFile = eachPath.replace(/\\/g, "_").replace(/:/g, "_").replace(/\//g, "_").replace(/[_]{2,}/g, "_").replace(/{/g, "").replace(/}/g, "");
				mwFile = mwFile.toLowerCase();
				if (mwFile[0] === "_") {
					mwFile = mwFile.substring(1);
				}
				mwFile += "_" + eachMethod.toLowerCase() + ".js";
				
				all_apis[eachMethod][eachPath] = {
					_apiInfo: {},
					"mw": '%dirname% + "/lib/mw/' + mwFile + '"'
				};
				let newSoajsApi = all_apis[eachMethod][eachPath];
				
				let params = apiData.parameters;
				
				let group = apiData.tags ? apiData.tags[0] : "";
				newSoajsApi._apiInfo.group = group && group !== '' ? group : "general";
				newSoajsApi._apiInfo.l = apiData.summary;
				newSoajsApi.imfv = convertParams(convertedDefinitions, convertedParameters, params);
			});
		});
		
		// todo: convert errors
		
		return cb({"schema": all_apis, "errors": all_errors});
	}
function ( yamlJson , cb ) { let all_apis = { } ; let all_errors = { } ; let paths = reformatPaths ( yamlJson . paths ) ; let definitions = yamlJson . definitions ; let parameters = yamlJson . parameters ; let convertedDefinitions = { } ; let convertedParameters = { } ; // convert definitions first if ( definitions ) { let definitionsKeys = Object . keys ( definitions ) ; definitionsKeys . forEach ( function ( eachDef ) { convertedDefinitions [ eachDef ] = convertItem ( null , definitions [ eachDef ] , 1 ) ; // 1 ??? definitions should never have schema -=-=-=-=-= } ) ; } // convert parameters then if ( parameters ) { let parametersKeys = Object . keys ( parameters ) ; parametersKeys . forEach ( function ( eachParam ) { convertedParameters [ eachParam ] = convertItem ( convertedDefinitions , parameters [ eachParam ] , 1 ) ; } ) ; all_apis . commonFields = convertedParameters ; } let pathsKeys = Object . keys ( paths ) ; pathsKeys . forEach ( function ( eachPath ) { let methods = paths [ eachPath ] ; let methodsKeys = Object . keys ( methods ) ; methodsKeys . forEach ( function ( eachMethod ) { let apiData = methods [ eachMethod ] ; if ( ! all_apis [ eachMethod ] ) { all_apis [ eachMethod ] = { } ; } var mwFile = eachPath . replace ( / \\ / g , "_" ) . replace ( / : / g , "_" ) . replace ( / \/ / g , "_" ) . replace ( / [_]{2,} / g , "_" ) . replace ( / { / g , "" ) . replace ( / } / g , "" ) ; mwFile = mwFile . toLowerCase ( ) ; if ( mwFile [ 0 ] === "_" ) { mwFile = mwFile . substring ( 1 ) ; } mwFile += "_" + eachMethod . toLowerCase ( ) + ".js" ; all_apis [ eachMethod ] [ eachPath ] = { _apiInfo : { } , "mw" : '%dirname% + "/lib/mw/' + mwFile + '"' } ; let newSoajsApi = all_apis [ eachMethod ] [ eachPath ] ; let params = apiData . parameters ; let group = apiData . tags ? apiData . tags [ 0 ] : "" ; newSoajsApi . _apiInfo . group = group && group !== '' ? group : "general" ; newSoajsApi . _apiInfo . l = apiData . summary ; newSoajsApi . imfv = convertParams ( convertedDefinitions , convertedParameters , params ) ; } ) ; } ) ; // todo: convert errors return cb ( { "schema" : all_apis , "errors" : all_errors } ) ; }
map apis to meet service configuraiton schema from a parsed swagger yaml json object
@param yamlJson
@param cb
@returns {*}
map apis to meet service configuraiton schema from a parsed swagger yaml json object