diff --git a/dist/index.html b/dist/index.html
index b35d28ae..86dec1cf 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -28,7 +28,7 @@
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
- url = "http://petstore.swagger.wordnik.com/v2/swagger.json";
+ url = "http://petstore.swagger.io/v2/swagger.json";
}
window.swaggerUi = new SwaggerUi({
url: url,
diff --git a/dist/lib/swagger-client.js b/dist/lib/swagger-client.js
index eac794f1..02a283d9 100644
--- a/dist/lib/swagger-client.js
+++ b/dist/lib/swagger-client.js
@@ -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;
@@ -291,13 +295,14 @@ var SwaggerClient = function(url, options) {
this.isValid = false;
this.info = null;
this.useJQuery = false;
+ this.resourceCount = 0;
if(typeof url !== 'undefined')
return this.initialize(url, options);
};
SwaggerClient.prototype.initialize = function (url, options) {
- this.models = models;
+ this.models = models = {};
options = (options||{});
@@ -386,7 +391,6 @@ SwaggerClient.prototype.build = function(mock) {
return obj;
new SwaggerHttp().execute(obj);
}
-
return this;
};
@@ -502,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;
};
@@ -592,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') {
@@ -641,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'];
@@ -995,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);
@@ -1439,7 +1446,7 @@ Property.prototype.toString = function() {
type = '';
}
else {
- this.schema.type;
+ type = this.schema.type;
}
if (this.default)
@@ -1500,7 +1507,7 @@ Property.prototype.toString = function() {
optionHtml = function(label, value) {
return '
| ' + label + ': | ' + value + ' |
';
-}
+};
typeFromJsonSchema = function(type, format) {
var str;
@@ -1533,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 = {};
@@ -1569,6 +1576,7 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
this.apisArray.push(res);
} else {
var k;
+ this.expectedResourceCount = response.apis.length;
for (k = 0; k < response.apis.length; k++) {
var resource = response.apis[k];
res = new SwaggerResource(resource, this);
@@ -1577,15 +1585,21 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
}
}
this.isValid = true;
- if (typeof this.success === 'function') {
- this.success();
- }
return this;
};
+SwaggerClient.prototype.finish = function() {
+ if (typeof this.success === 'function') {
+ 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 = [];
@@ -1631,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;
@@ -1660,9 +1674,6 @@ SwaggerClient.prototype.selfReflect = function () {
}
this.setConsolidatedModels();
this.ready = true;
- if (typeof this.success === 'function') {
- return this.success();
- }
};
SwaggerClient.prototype.setConsolidatedModels = function () {
@@ -1702,7 +1713,7 @@ var SwaggerResource = function (resourceObj, api) {
this.operations = {};
this.operationsArray = [];
this.modelsArray = [];
- this.models = {};
+ this.models = api.models || {};
this.rawModels = {};
this.useJQuery = (typeof api.useJQuery !== 'undefined') ? api.useJQuery : null;
@@ -1728,9 +1739,11 @@ var SwaggerResource = function (resourceObj, api) {
on: {
response: function (resp) {
var responseObj = resp.obj || JSON.parse(resp.data);
+ _this.api.resourceCount += 1;
return _this.addApiDeclaration(responseObj);
},
error: function (response) {
+ _this.api.resourceCount += 1;
return _this.api.fail('Unable to read api \'' +
_this.name + '\' from path ' + _this.url + ' (server returned ' + response.statusText + ')');
}
@@ -1784,7 +1797,9 @@ SwaggerResource.prototype.addApiDeclaration = function (response) {
}
this.api[this.name] = this;
this.ready = true;
- return this.api.selfReflect();
+ if(this.api.resourceCount === this.api.expectedResourceCount)
+ this.api.finish();
+ return this;
};
SwaggerResource.prototype.addModels = function (models) {
@@ -2077,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;
@@ -2128,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)
@@ -2208,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')
@@ -2243,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';
@@ -2254,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;
}
@@ -2375,7 +2390,7 @@ SwaggerOperation.prototype.urlify = function (args) {
}
}
}
- if ((queryParams != null) && queryParams.length > 0)
+ if ((queryParams) && queryParams.length > 0)
url += '?' + queryParams;
return url;
};
@@ -2584,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,
@@ -2953,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;
+
})();
\ No newline at end of file
diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js
index 63e68c5e..ccf10c32 100644
--- a/dist/swagger-ui.js
+++ b/dist/swagger-ui.js
@@ -1,6 +1,6 @@
/**
* swagger-ui - Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API
- * @version v2.1.2-M1
+ * @version v2.1.3-M1
* @link http://swagger.io
* @license Apache 2.0
*/
@@ -199,14 +199,6 @@ var Docs = {
}
};
-this["Handlebars"] = this["Handlebars"] || {};
-this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
-this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
- var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
- return "\n\n\n";
-},"useData":true});
var SwaggerUi,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
@@ -292,8 +284,7 @@ SwaggerUi = (function(_super) {
}
this.options.url = url;
this.headerView.update(url);
- this.api = new SwaggerClient(this.options);
- return this.api.build();
+ return this.api = new SwaggerClient(this.options);
};
SwaggerUi.prototype.collapseAll = function() {
@@ -331,7 +322,7 @@ SwaggerUi = (function(_super) {
return function() {
return Docs.shebang();
};
- })(this), 400);
+ })(this), 4000);
};
SwaggerUi.prototype.buildUrl = function(base, url) {
@@ -394,6 +385,14 @@ SwaggerUi = (function(_super) {
window.SwaggerUi = SwaggerUi;
+this["Handlebars"] = this["Handlebars"] || {};
+this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
+this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
+ var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
+ return "\n\n\n";
+},"useData":true});
Handlebars.registerHelper('sanitize', function(html) {
html = html.replace(/