From cbead84f8e9fb40b655b2c0b33be510eef671a1f Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sat, 27 Sep 2014 22:59:19 -0700 Subject: [PATCH] updated library --- dist/lib/swagger-client.js | 17 ++++++++++++++--- lib/swagger-client.js | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) 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; };