|
@@ -1,5 +1,5 @@ |
|
|
// swagger.js |
|
|
// swagger.js |
|
|
// version 2.0.22 |
|
|
|
|
|
|
|
|
// version 2.0.23 |
|
|
|
|
|
|
|
|
var __bind = function(fn, me){ |
|
|
var __bind = function(fn, me){ |
|
|
return function(){ |
|
|
return function(){ |
|
@@ -17,13 +17,69 @@ log = function(){ |
|
|
|
|
|
|
|
|
if (!Array.prototype.indexOf) { |
|
|
if (!Array.prototype.indexOf) { |
|
|
Array.prototype.indexOf = function(obj, start) { |
|
|
Array.prototype.indexOf = function(obj, start) { |
|
|
for (var i = (start || 0), j = this.length; i < j; i++) { |
|
|
|
|
|
if (this[i] === obj) { return i; } |
|
|
|
|
|
} |
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
for (var i = (start || 0), j = this.length; i < j; i++) { |
|
|
|
|
|
if (this[i] === obj) { return i; } |
|
|
|
|
|
} |
|
|
|
|
|
return -1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!('filter' in Array.prototype)) { |
|
|
|
|
|
Array.prototype.filter= function(filter, that /*opt*/) { |
|
|
|
|
|
var other= [], v; |
|
|
|
|
|
for (var i=0, n= this.length; i<n; i++) |
|
|
|
|
|
if (i in this && filter.call(that, v= this[i], i, this)) |
|
|
|
|
|
other.push(v); |
|
|
|
|
|
return other; |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!('map' in Array.prototype)) { |
|
|
|
|
|
Array.prototype.map= function(mapper, that /*opt*/) { |
|
|
|
|
|
var other= new Array(this.length); |
|
|
|
|
|
for (var i= 0, n= this.length; i<n; i++) |
|
|
|
|
|
if (i in this) |
|
|
|
|
|
other[i]= mapper.call(that, this[i], i, this); |
|
|
|
|
|
return other; |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Object.keys = Object.keys || (function () { |
|
|
|
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty, |
|
|
|
|
|
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"), |
|
|
|
|
|
DontEnums = [ |
|
|
|
|
|
'toString', |
|
|
|
|
|
'toLocaleString', |
|
|
|
|
|
'valueOf', |
|
|
|
|
|
'hasOwnProperty', |
|
|
|
|
|
'isPrototypeOf', |
|
|
|
|
|
'propertyIsEnumerable', |
|
|
|
|
|
'constructor' |
|
|
|
|
|
], |
|
|
|
|
|
DontEnumsLength = DontEnums.length; |
|
|
|
|
|
|
|
|
|
|
|
return function (o) { |
|
|
|
|
|
if (typeof o != "object" && typeof o != "function" || o === null) |
|
|
|
|
|
throw new TypeError("Object.keys called on a non-object"); |
|
|
|
|
|
|
|
|
|
|
|
var result = []; |
|
|
|
|
|
for (var name in o) { |
|
|
|
|
|
if (hasOwnProperty.call(o, name)) |
|
|
|
|
|
result.push(name); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hasDontEnumBug) { |
|
|
|
|
|
for (var i = 0; i < DontEnumsLength; i++) { |
|
|
|
|
|
if (hasOwnProperty.call(o, DontEnums[i])) |
|
|
|
|
|
result.push(DontEnums[i]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
}; |
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SwaggerApi = function(url, options) { |
|
|
var SwaggerApi = function(url, options) { |
|
|
this.url = null; |
|
|
this.url = null; |
|
|
this.debug = false; |
|
|
this.debug = false; |
|
@@ -104,10 +160,12 @@ SwaggerApi.prototype.buildFromSpec = function(response) { |
|
|
this.info = response.info; |
|
|
this.info = response.info; |
|
|
} |
|
|
} |
|
|
var isApi = false; |
|
|
var isApi = false; |
|
|
for (var i = 0; i < response.apis.length; i++) { |
|
|
|
|
|
|
|
|
var i; |
|
|
|
|
|
for (i = 0; i < response.apis.length; i++) { |
|
|
var api = response.apis[i]; |
|
|
var api = response.apis[i]; |
|
|
if (api.operations) { |
|
|
if (api.operations) { |
|
|
for (var j = 0; j < api.operations.length; j++) { |
|
|
|
|
|
|
|
|
var j; |
|
|
|
|
|
for (j = 0; j < api.operations.length; j++) { |
|
|
operation = api.operations[j]; |
|
|
operation = api.operations[j]; |
|
|
isApi = true; |
|
|
isApi = true; |
|
|
} |
|
|
} |
|
@@ -127,7 +185,8 @@ SwaggerApi.prototype.buildFromSpec = function(response) { |
|
|
this.apis[newName] = res; |
|
|
this.apis[newName] = res; |
|
|
this.apisArray.push(res); |
|
|
this.apisArray.push(res); |
|
|
} else { |
|
|
} else { |
|
|
for (var k = 0; k < response.apis.length; k++) { |
|
|
|
|
|
|
|
|
var k; |
|
|
|
|
|
for (k = 0; k < response.apis.length; k++) { |
|
|
var resource = response.apis[k]; |
|
|
var resource = response.apis[k]; |
|
|
res = new SwaggerResource(resource, this); |
|
|
res = new SwaggerResource(resource, this); |
|
|
this.apis[res.name] = res; |
|
|
this.apis[res.name] = res; |
|
@@ -350,6 +409,7 @@ SwaggerResource.prototype.addApiDeclaration = function(response) { |
|
|
|
|
|
|
|
|
SwaggerResource.prototype.addModels = function(models) { |
|
|
SwaggerResource.prototype.addModels = function(models) { |
|
|
if (models != null) { |
|
|
if (models != null) { |
|
|
|
|
|
var modelName; |
|
|
for (modelName in models) { |
|
|
for (modelName in models) { |
|
|
if (this.models[modelName] == null) { |
|
|
if (this.models[modelName] == null) { |
|
|
var swaggerModel = new SwaggerModel(modelName, models[modelName]); |
|
|
var swaggerModel = new SwaggerModel(modelName, models[modelName]); |
|
@@ -429,6 +489,7 @@ SwaggerResource.prototype.sanitize = function(nickname) { |
|
|
SwaggerResource.prototype.help = function() { |
|
|
SwaggerResource.prototype.help = function() { |
|
|
var op = this.operations; |
|
|
var op = this.operations; |
|
|
var output = []; |
|
|
var output = []; |
|
|
|
|
|
var operation_name; |
|
|
for (operation_name in op) { |
|
|
for (operation_name in op) { |
|
|
operation = op[operation_name]; |
|
|
operation = op[operation_name]; |
|
|
var msg = " " + operation.nickname; |
|
|
var msg = " " + operation.nickname; |
|
@@ -444,8 +505,10 @@ SwaggerResource.prototype.help = function() { |
|
|
var SwaggerModel = function(modelName, obj) { |
|
|
var SwaggerModel = function(modelName, obj) { |
|
|
this.name = obj.id != null ? obj.id : modelName; |
|
|
this.name = obj.id != null ? obj.id : modelName; |
|
|
this.properties = []; |
|
|
this.properties = []; |
|
|
|
|
|
var propertyName; |
|
|
for (propertyName in obj.properties) { |
|
|
for (propertyName in obj.properties) { |
|
|
if (obj.required != null) { |
|
|
if (obj.required != null) { |
|
|
|
|
|
var value; |
|
|
for (value in obj.required) { |
|
|
for (value in obj.required) { |
|
|
if (propertyName === obj.required[value]) { |
|
|
if (propertyName === obj.required[value]) { |
|
|
obj.properties[propertyName].required = true; |
|
|
obj.properties[propertyName].required = true; |
|
@@ -793,6 +856,7 @@ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (possibleParams) { |
|
|
if (possibleParams) { |
|
|
|
|
|
var key; |
|
|
for (key in possibleParams) { |
|
|
for (key in possibleParams) { |
|
|
value = possibleParams[key]; |
|
|
value = possibleParams[key]; |
|
|
if (args[value.name]) { |
|
|
if (args[value.name]) { |
|
@@ -875,6 +939,7 @@ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) { |
|
|
matchingParams[param.name] = args[param.name]; |
|
|
matchingParams[param.name] = args[param.name]; |
|
|
} |
|
|
} |
|
|
var headers = this.resource.api.headers; |
|
|
var headers = this.resource.api.headers; |
|
|
|
|
|
var name; |
|
|
for (name in headers) { |
|
|
for (name in headers) { |
|
|
var value = headers[name]; |
|
|
var value = headers[name]; |
|
|
matchingParams[name] = value; |
|
|
matchingParams[name] = value; |
|
@@ -973,14 +1038,15 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal |
|
|
var fields = {}; |
|
|
var fields = {}; |
|
|
var possibleParams = {}; |
|
|
var possibleParams = {}; |
|
|
var values = {}; |
|
|
var values = {}; |
|
|
|
|
|
|
|
|
for(var key in formParams){ |
|
|
|
|
|
|
|
|
var key; |
|
|
|
|
|
for(key in formParams){ |
|
|
var param = formParams[key]; |
|
|
var param = formParams[key]; |
|
|
values[param.name] = param; |
|
|
values[param.name] = param; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var encoded = ""; |
|
|
var encoded = ""; |
|
|
for(var key in values) { |
|
|
|
|
|
|
|
|
var key; |
|
|
|
|
|
for(key in values) { |
|
|
value = this.params[key]; |
|
|
value = this.params[key]; |
|
|
if(typeof value !== 'undefined'){ |
|
|
if(typeof value !== 'undefined'){ |
|
|
if(encoded !== "") |
|
|
if(encoded !== "") |
|
@@ -990,6 +1056,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal |
|
|
} |
|
|
} |
|
|
body = encoded; |
|
|
body = encoded; |
|
|
} |
|
|
} |
|
|
|
|
|
var name; |
|
|
for (name in this.headers) |
|
|
for (name in this.headers) |
|
|
myHeaders[name] = this.headers[name]; |
|
|
myHeaders[name] = this.headers[name]; |
|
|
if ((requestContentType && body !== "") || (requestContentType === "application/x-www-form-urlencoded")) |
|
|
if ((requestContentType && body !== "") || (requestContentType === "application/x-www-form-urlencoded")) |
|
@@ -1041,6 +1108,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal |
|
|
SwaggerRequest.prototype.asCurl = function() { |
|
|
SwaggerRequest.prototype.asCurl = function() { |
|
|
var results = []; |
|
|
var results = []; |
|
|
if(this.headers) { |
|
|
if(this.headers) { |
|
|
|
|
|
var key; |
|
|
for(key in this.headers) { |
|
|
for(key in this.headers) { |
|
|
results.push("--header \"" + key + ": " + this.headers[v] + "\""); |
|
|
results.push("--header \"" + key + ": " + this.headers[v] + "\""); |
|
|
} |
|
|
} |
|
@@ -1095,6 +1163,7 @@ JQueryHttpClient.prototype.execute = function(obj) { |
|
|
var key, results; |
|
|
var key, results; |
|
|
if (obj.headers) { |
|
|
if (obj.headers) { |
|
|
results = []; |
|
|
results = []; |
|
|
|
|
|
var key; |
|
|
for (key in obj.headers) { |
|
|
for (key in obj.headers) { |
|
|
if (key.toLowerCase() === "content-type") { |
|
|
if (key.toLowerCase() === "content-type") { |
|
|
results.push(obj.contentType = obj.headers[key]); |
|
|
results.push(obj.contentType = obj.headers[key]); |
|
@@ -1262,6 +1331,7 @@ SwaggerAuthorizations.prototype.remove = function(name) { |
|
|
|
|
|
|
|
|
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { |
|
|
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { |
|
|
status = null; |
|
|
status = null; |
|
|
|
|
|
var key; |
|
|
for (key in this.authz) { |
|
|
for (key in this.authz) { |
|
|
value = this.authz[key]; |
|
|
value = this.authz[key]; |
|
|
result = value.apply(obj, authorizations); |
|
|
result = value.apply(obj, authorizations); |
|
|