lib/swagger/swagger.js
function (files, callback) {
		//loop on all files and write them
		async.each(files, function (fileObj, mCb) {
			var data = swagger.cloneObj(fileObj.data);
			
			//if tokens, replace all occurences with corresponding values
			if (fileObj.tokens) {
				for (var i in fileObj.tokens) {
					var regexp = new RegExp("%" + i + "%", "g");
					data = data.replace(regexp, fileObj.tokens[i]);
				}
			}
			if (fileObj.purify) {
				data = data.replace(/\\"/g, '"').replace(/["]+/g, '"').replace(/"__dirname/g, '__dirname');
				data = data.replace(/("group": "__empty__")/g, '"group": ""');
				data = data.replace(/("prefix": "(\s?|\s+),)/g, '"prefix": "",');
				data = data.replace(/("l": "__empty__")/g, '"l": ""');
				//"__dirname + \"/lib/mw/_get.js\""
				//"__dirname + "/lib/mw/_get.js""
				//"__dirname + "/lib/mw/_get.js"
				//__dirname + "/lib/mw/_get.js"
			}
			console.log("creating file:", fileObj.file);
			fs.writeFile(fileObj.file, data, "utf8", mCb);
		}, function (error) {
			if (error) {
				return callback({"code": 854, "msg": error.message});
			}
			return callback(null, true);
		});
	}
function (files, callback) {
		//loop on all files and write them
		async.each(files, function (fileObj, mCb) {
			var data = swagger.cloneObj(fileObj.data);
			
			//if tokens, replace all occurences with corresponding values
			if (fileObj.tokens) {
				for (var i in fileObj.tokens) {
					var regexp = new RegExp("%" + i + "%", "g");
					data = data.replace(regexp, fileObj.tokens[i]);
				}
			}
			if (fileObj.purify) {
				data = data.replace(/\\"/g, '"').replace(/["]+/g, '"').replace(/"__dirname/g, '__dirname');
				data = data.replace(/("group": "__empty__")/g, '"group": ""');
				data = data.replace(/("prefix": "(\s?|\s+),)/g, '"prefix": "",');
				data = data.replace(/("l": "__empty__")/g, '"l": ""');
				//"__dirname + \"/lib/mw/_get.js\""
				//"__dirname + "/lib/mw/_get.js""
				//"__dirname + "/lib/mw/_get.js"
				//__dirname + "/lib/mw/_get.js"
			}
			console.log("creating file:", fileObj.file);
			fs.writeFile(fileObj.file, data, "utf8", mCb);
		}, function (error) {
			if (error) {
				return callback({"code": 854, "msg": error.message});
			}
			return callback(null, true);
		});
	}
function ( files , callback ) { //loop on all files and write them async . each ( files , function ( fileObj , mCb ) { var data = swagger . cloneObj ( fileObj . data ) ; //if tokens, replace all occurences with corresponding values if ( fileObj . tokens ) { for ( var i in fileObj . tokens ) { var regexp = new RegExp ( "%" + i + "%" , "g" ) ; data = data . replace ( regexp , fileObj . tokens [ i ] ) ; } } if ( fileObj . purify ) { data = data . replace ( / \\" / g , '"' ) . replace ( / ["]+ / g , '"' ) . replace ( / "__dirname / g , '__dirname' ) ; data = data . replace ( / ("group": "__empty__") / g , '"group": ""' ) ; data = data . replace ( / ("prefix": "(\s?|\s+),) / g , '"prefix": "",' ) ; data = data . replace ( / ("l": "__empty__") / g , '"l": ""' ) ; //"__dirname + \"/lib/mw/_get.js\"" //"__dirname + "/lib/mw/_get.js"" //"__dirname + "/lib/mw/_get.js" //__dirname + "/lib/mw/_get.js" } console . log ( "creating file:" , fileObj . file ) ; fs . writeFile ( fileObj . file , data , "utf8" , mCb ) ; } , function ( error ) { if ( error ) { return callback ( { "code" : 854 , "msg" : error . message } ) ; } return callback ( null , true ) ; } ) ; }
function that generates the files for the microservice
@param files
@param callback
function that generates the files for the microservice