updated versions
This commit is contained in:
70
dist/lib/swagger-client.js
vendored
70
dist/lib/swagger-client.js
vendored
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* swagger-client - swagger.js is a javascript client for use with swaggering APIs.
|
||||
* @version v2.1.2-M1
|
||||
* @version v2.1.3-M1
|
||||
* @link http://swagger.io
|
||||
* @license apache 2.0
|
||||
*/
|
||||
@@ -82,10 +82,10 @@ SwaggerAuthorizations.prototype.remove = function(name) {
|
||||
|
||||
SwaggerAuthorizations.prototype.apply = function (obj, authorizations) {
|
||||
var status = null;
|
||||
var key, value, result;
|
||||
var key, name, value, result;
|
||||
|
||||
// if the "authorizations" key is undefined, or has an empty array, add all keys
|
||||
if (typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) {
|
||||
if (typeof authorizations === 'undefined' || Object.keys(authorizations).length === 0) {
|
||||
for (key in this.authz) {
|
||||
value = this.authz[key];
|
||||
result = value.apply(obj, authorizations);
|
||||
@@ -280,6 +280,10 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
|
||||
}
|
||||
return returnVal;
|
||||
};
|
||||
var addModel = function(name, model) {
|
||||
models[name] = model;
|
||||
};
|
||||
|
||||
var SwaggerClient = function(url, options) {
|
||||
this.isBuilt = false;
|
||||
this.url = null;
|
||||
@@ -387,7 +391,6 @@ SwaggerClient.prototype.build = function(mock) {
|
||||
return obj;
|
||||
new SwaggerHttp().execute(obj);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -503,8 +506,11 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
|
||||
}
|
||||
}
|
||||
this.isBuilt = true;
|
||||
if (this.success)
|
||||
if (this.success) {
|
||||
this.isValid = true;
|
||||
this.isBuilt = true;
|
||||
this.success();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -593,18 +599,18 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
|
||||
}
|
||||
}
|
||||
|
||||
var i, model;
|
||||
|
||||
if(definitions) {
|
||||
// add to global models
|
||||
var key;
|
||||
for(key in this.definitions) {
|
||||
var model = new Model(key, definitions[key]);
|
||||
model = new Model(key, definitions[key]);
|
||||
if(model) {
|
||||
models[key] = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var i;
|
||||
for(i = 0; i < this.parameters.length; i++) {
|
||||
var param = this.parameters[i];
|
||||
if(param.type === 'array') {
|
||||
@@ -642,7 +648,7 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
|
||||
param.responseClassSignature = param.signature;
|
||||
}
|
||||
|
||||
var defaultResponseCode, response, model, responses = this.responses;
|
||||
var defaultResponseCode, response, responses = this.responses;
|
||||
|
||||
if(responses['200']) {
|
||||
response = responses['200'];
|
||||
@@ -996,9 +1002,9 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
|
||||
var allHeaders = this.getHeaderParams(args);
|
||||
var contentTypeHeaders = this.setContentTypes(args, opts);
|
||||
|
||||
var headers = {};
|
||||
for (var attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; }
|
||||
for (var attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }
|
||||
var headers = {}, attrname;
|
||||
for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; }
|
||||
for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; }
|
||||
|
||||
var body = this.getBody(headers, args);
|
||||
var url = this.urlify(args);
|
||||
@@ -1440,7 +1446,7 @@ Property.prototype.toString = function() {
|
||||
type = '';
|
||||
}
|
||||
else {
|
||||
this.schema.type;
|
||||
type = this.schema.type;
|
||||
}
|
||||
|
||||
if (this.default)
|
||||
@@ -1501,7 +1507,7 @@ Property.prototype.toString = function() {
|
||||
|
||||
optionHtml = function(label, value) {
|
||||
return '<tr><td class="optionName">' + label + ':</td><td>' + value + '</td></tr>';
|
||||
}
|
||||
};
|
||||
|
||||
typeFromJsonSchema = function(type, format) {
|
||||
var str;
|
||||
@@ -1534,7 +1540,7 @@ var cookies = {};
|
||||
var models = {};
|
||||
|
||||
SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
|
||||
if (response.apiVersion != null) {
|
||||
if (response.apiVersion !== null) {
|
||||
this.apiVersion = response.apiVersion;
|
||||
}
|
||||
this.apis = {};
|
||||
@@ -1584,15 +1590,16 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
|
||||
|
||||
SwaggerClient.prototype.finish = function() {
|
||||
if (typeof this.success === 'function') {
|
||||
console.log('success');
|
||||
this.isValid = true;
|
||||
this.isBuilt = true;
|
||||
this.selfReflect();
|
||||
this.success();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
|
||||
log('This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info');
|
||||
if (response.apiVersion != null)
|
||||
if (response.apiVersion !== null)
|
||||
this.apiVersion = response.apiVersion;
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
@@ -1638,7 +1645,7 @@ SwaggerClient.prototype.buildFrom1_1Spec = function (response) {
|
||||
|
||||
SwaggerClient.prototype.convertInfo = function (resp) {
|
||||
if(typeof resp == 'object') {
|
||||
var info = {}
|
||||
var info = {};
|
||||
|
||||
info.title = resp.title;
|
||||
info.description = resp.description;
|
||||
@@ -1667,9 +1674,6 @@ SwaggerClient.prototype.selfReflect = function () {
|
||||
}
|
||||
this.setConsolidatedModels();
|
||||
this.ready = true;
|
||||
if (typeof this.success === 'function') {
|
||||
return this.success();
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerClient.prototype.setConsolidatedModels = function () {
|
||||
@@ -2088,7 +2092,7 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
|
||||
|
||||
this.path = this.path.replace('{format}', 'json');
|
||||
this.method = this.method.toLowerCase();
|
||||
this.isGetMethod = this.method === 'GET';
|
||||
this.isGetMethod = this.method === 'get';
|
||||
|
||||
var i, j, v;
|
||||
this.resourceName = this.resource.name;
|
||||
@@ -2139,17 +2143,17 @@ var SwaggerOperation = function (nickname, path, method, parameters, summary, no
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (param.allowableValues != null) {
|
||||
else if (param.allowableValues) {
|
||||
if (param.allowableValues.valueType === 'RANGE')
|
||||
param.isRange = true;
|
||||
else
|
||||
param.isList = true;
|
||||
if (param.allowableValues != null) {
|
||||
if (param.allowableValues) {
|
||||
param.allowableValues.descriptiveValues = [];
|
||||
if (param.allowableValues.values) {
|
||||
for (j = 0; j < param.allowableValues.values.length; j++) {
|
||||
v = param.allowableValues.values[j];
|
||||
if (param.defaultValue != null) {
|
||||
if (param.defaultValue !== null) {
|
||||
param.allowableValues.descriptiveValues.push({
|
||||
value: String(v),
|
||||
isDefault: (v === param.defaultValue)
|
||||
@@ -2219,7 +2223,7 @@ SwaggerOperation.prototype.getSampleJSON = function (type, models) {
|
||||
var isPrimitive, listType, val;
|
||||
listType = this.isListType(type);
|
||||
isPrimitive = ((typeof listType !== 'undefined') && models[listType]) || (typeof models[type] !== 'undefined') ? false : true;
|
||||
val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
|
||||
val = isPrimitive ? void 0 : (listType ? models[listType].createJSONSample() : models[type].createJSONSample());
|
||||
if (val) {
|
||||
val = listType ? [val] : val;
|
||||
if (typeof val == 'string')
|
||||
@@ -2254,7 +2258,7 @@ SwaggerOperation.prototype['do'] = function (args, opts, callback, error) {
|
||||
callback = function (response) {
|
||||
var content;
|
||||
content = null;
|
||||
if (response != null) {
|
||||
if (response !== null) {
|
||||
content = response.data;
|
||||
} else {
|
||||
content = 'no data';
|
||||
@@ -2265,7 +2269,7 @@ SwaggerOperation.prototype['do'] = function (args, opts, callback, error) {
|
||||
|
||||
params = {};
|
||||
params.headers = [];
|
||||
if (args.headers != null) {
|
||||
if (args.headers) {
|
||||
params.headers = args.headers;
|
||||
delete args.headers;
|
||||
}
|
||||
@@ -2386,7 +2390,7 @@ SwaggerOperation.prototype.urlify = function (args) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((queryParams != null) && queryParams.length > 0)
|
||||
if ((queryParams) && queryParams.length > 0)
|
||||
url += '?' + queryParams;
|
||||
return url;
|
||||
};
|
||||
@@ -2595,7 +2599,7 @@ var SwaggerRequest = function (type, url, params, opts, successCallback, errorCa
|
||||
}
|
||||
|
||||
var obj;
|
||||
if (!((this.headers != null) && (this.headers.mock != null))) {
|
||||
if (!((this.headers) && (this.headers.mock))) {
|
||||
obj = {
|
||||
url: this.url,
|
||||
method: this.type,
|
||||
@@ -2964,7 +2968,9 @@ e.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||
e.PasswordAuthorization = PasswordAuthorization;
|
||||
e.CookieAuthorization = CookieAuthorization;
|
||||
e.SwaggerClient = SwaggerClient;
|
||||
e.SwaggerApi = SwaggerClient;
|
||||
e.Operation = Operation;
|
||||
e.Model = Model;
|
||||
e.models = models;
|
||||
e.addModel = addModel;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user