diff --git a/dist/lib/swagger-client.js b/dist/lib/swagger-client.js index 1ba5df9f..3783b9d8 100644 --- a/dist/lib/swagger-client.js +++ b/dist/lib/swagger-client.js @@ -206,6 +206,8 @@ var SwaggerClient = function(url, options) { this.failure = options.failure != null ? options.failure : function() {}; this.progress = options.progress != null ? options.progress : function() {}; + this.spec = options.spec; + if (options.success != null) this.build(); } @@ -247,9 +249,18 @@ SwaggerClient.prototype.build = function() { } } }; - var e = (typeof window !== 'undefined' ? window : exports); - var status = e.authorizations.apply(obj); - new SwaggerHttp().execute(obj); + if(this.spec) { + var self = this; + setTimeout(function() { + self.buildFromSpec(self.spec); + }, 10); + } + else { + var e = (typeof window !== 'undefined' ? window : exports); + var status = e.authorizations.apply(obj); + new SwaggerHttp().execute(obj); + } + return this; }; diff --git a/lib/swagger-client.js b/lib/swagger-client.js index 1ba5df9f..3783b9d8 100644 --- a/lib/swagger-client.js +++ b/lib/swagger-client.js @@ -206,6 +206,8 @@ var SwaggerClient = function(url, options) { this.failure = options.failure != null ? options.failure : function() {}; this.progress = options.progress != null ? options.progress : function() {}; + this.spec = options.spec; + if (options.success != null) this.build(); } @@ -247,9 +249,18 @@ SwaggerClient.prototype.build = function() { } } }; - var e = (typeof window !== 'undefined' ? window : exports); - var status = e.authorizations.apply(obj); - new SwaggerHttp().execute(obj); + if(this.spec) { + var self = this; + setTimeout(function() { + self.buildFromSpec(self.spec); + }, 10); + } + else { + var e = (typeof window !== 'undefined' ? window : exports); + var status = e.authorizations.apply(obj); + new SwaggerHttp().execute(obj); + } + return this; };