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..5745f5d8 100644 --- a/dist/lib/swagger-client.js +++ b/dist/lib/swagger-client.js @@ -291,13 +291,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||{}); @@ -1569,6 +1570,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,12 +1579,17 @@ 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') { + console.log('success'); + 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) @@ -1702,7 +1709,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 +1735,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 +1793,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) { diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 63e68c5e..087cf6c9 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -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