Skip to content

Commit

Permalink
fixed macros
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Dec 8, 2014
1 parent 243823a commit ae4e70b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1674,8 +1682,6 @@
var sampleModels = {};
var cookies = {};

e.parameterMacro = parameterMacro;
e.modelPropertyMacro = modelPropertyMacro;
e.SampleModels = sampleModels;
e.SwaggerHttp = SwaggerHttp;
e.SwaggerRequest = SwaggerRequest;
Expand Down

0 comments on commit ae4e70b

Please sign in to comment.