From ae4e70b156092cf47a12bedd7dfe96b306a689fd Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 7 Dec 2014 21:49:14 -0800 Subject: [PATCH] fixed macros --- lib/swagger.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/swagger.js b/lib/swagger.js index 3178e2b00..17411a6d8 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -18,13 +18,21 @@ }; // if you want to apply conditional formatting of parameter values - var parameterMacro = function (value) { - return value; + var applyParameterMacro = function (value) { + var e = (typeof window !== 'undefined' ? window : exports); + if(e.parameterMacro) + return e.parameterMacro(value); + else + return value; } // if you want to apply conditional formatting of model property values - var modelPropertyMacro = function (value) { - return value; + var applyModelPropertyMacro = function (value) { + var e = (typeof window !== 'undefined' ? window : exports); + if(e.modelPropertyMacro) + return e.modelPropertyMacro(value); + else + return value; } if (!Array.prototype.indexOf) { @@ -613,7 +621,7 @@ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set'); this.descr = obj.description; this.required = obj.required; - this.defaultValue = modelPropertyMacro(obj.defaultValue); + this.defaultValue = applyModelPropertyMacro(obj.defaultValue); if (obj.items != null) { if (obj.items.type != null) { this.refDataType = obj.items.type; @@ -794,7 +802,7 @@ } } } - param.defaultValue = parameterMacro(param.defaultValue); + param.defaultValue = applyParameterMacro(param.defaultValue); } this.resource[this.nickname] = function (args, callback, error) { return _this["do"](args, callback, error); @@ -1674,8 +1682,6 @@ var sampleModels = {}; var cookies = {}; - e.parameterMacro = parameterMacro; - e.modelPropertyMacro = modelPropertyMacro; e.SampleModels = sampleModels; e.SwaggerHttp = SwaggerHttp; e.SwaggerRequest = SwaggerRequest;