From 0061046d3b8ebcd6aff6b29c3a24055c8f5b1054 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Fri, 9 Mar 2012 15:06:38 -0500 Subject: [PATCH 1/3] Support a relative url path to the service. --- source/javascripts/swagger-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/javascripts/swagger-service.js b/source/javascripts/swagger-service.js index af6681dc..a3d5fb34 100644 --- a/source/javascripts/swagger-service.js +++ b/source/javascripts/swagger-service.js @@ -7,7 +7,7 @@ function SwaggerService(discoveryUrl, _apiKey, statusCallback) { if (discoveryUrl.length == 0) throw new Error("discoveryUrl must be passed while creating SwaggerService"); - if (! (discoveryUrl.toLowerCase().indexOf("http:") == 0 || discoveryUrl.toLowerCase().indexOf("https:") == 0)) { + if ( discoveryUrl.indexOf("/")!=0 && ! (discoveryUrl.toLowerCase().indexOf("http:") == 0 || discoveryUrl.toLowerCase().indexOf("https:") == 0)) { discoveryUrl = ("http://" + discoveryUrl); } From 4e1ad46699eaecf6f7781f0e6de9d604731eeebe Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Mon, 19 Mar 2012 09:56:34 -0400 Subject: [PATCH 2/3] Simplify how the name of the resource is constructed so that it can handle resources nested multiple directory levels in. --- source/index.html.haml | 2 +- source/javascripts/swagger-service.js | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/source/index.html.haml b/source/index.html.haml index c2d32553..b6a30ed8 100644 --- a/source/index.html.haml +++ b/source/index.html.haml @@ -5,7 +5,7 @@ %li.resource{:id => "resource_${name}"} .heading %h2 - %a{:href => "#!/${name}", :onclick => "Docs.toggleEndpointListForResource('${name}');"} ${name} + %a{:href => "#!/${name}", :onclick => "Docs.toggleEndpointListForResource('${name}');"} ${path} %ul.options %li %a{:href => "#!/${name}", :id => "endpointListTogger_${name}", :onclick => "Docs.toggleEndpointListForResource('${name}');"} Show/Hide diff --git a/source/javascripts/swagger-service.js b/source/javascripts/swagger-service.js index a3d5fb34..dd4915b5 100644 --- a/source/javascripts/swagger-service.js +++ b/source/javascripts/swagger-service.js @@ -57,17 +57,12 @@ function SwaggerService(discoveryUrl, _apiKey, statusCallback) { ApiResource.include({ path_json: null, path_xml: null, - init: function(atts) { if (atts) this.load(atts); + this.name = this.path.replace(".{format}", "").replace(/\//g, "_"); this.path_json = this.path.replace("{format}", "json"); this.path_xml = this.path.replace("{format}", "xml"); this.baseUrl = globalBasePath; - //execluded 9 letters to remove .{format} from name - this.name = this.path.split("/"); - this.name = this.name[this.name.length - 1]; - this.name = this.name.replace(".{format}",'').replace(/\//g, "_"); - // this.name = this.path.substr(1, this.path.length - formatString.length - 1).replace(/\//g, "_"); this.apiList = Api.sub(); this.modelList = ApiModel.sub(); }, @@ -95,6 +90,9 @@ function SwaggerService(discoveryUrl, _apiKey, statusCallback) { init: function(atts) { if (atts) this.load(atts); + var sep = this.path.lastIndexOf("/"); + this.name = this.path.substr(0, sep).replace(".{format}", "").replace(/\//g, "_"); + var secondPathSeperatorIndex = this.path.indexOf("/", 1); if (secondPathSeperatorIndex > 0) { var prefix = this.path.substr(0, secondPathSeperatorIndex); @@ -102,21 +100,9 @@ function SwaggerService(discoveryUrl, _apiKey, statusCallback) { // log(this.path + ":: " + prefix + "..." + suffix); this.path_json = prefix.replace("{format}", "json") + suffix; this.path_xml = prefix.replace("{format}", "xml") + suffix;; - - if (this.path.indexOf("/") == 0) { - this.name = this.path.substr(1, secondPathSeperatorIndex - formatString.length - 1); - } else { - this.name = this.path.substr(0, secondPathSeperatorIndex - formatString.length - 1); - } } else { this.path_json = this.path.replace("{format}", "json"); this.path_xml = this.path.replace("{format}", "xml"); - - if (this.path.indexOf("/") == 0) { - this.name = this.path.substr(1, this.path.length - formatString.length - 1); - } else { - this.name = this.path.substr(0, this.path.length - formatString.length - 1); - } } var value = this.operations; From bbcb230b2039157f7e7c8d9375d0781efa94e011 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Mon, 19 Mar 2012 09:57:38 -0400 Subject: [PATCH 3/3] Rebuilt using 'middleman build' --- build/index.html | 26 ++--- build/javascripts/swagger-service.js | 142 ++++++++++++++++----------- 2 files changed, 98 insertions(+), 70 deletions(-) diff --git a/build/index.html b/build/index.html index 6c673534..46cd06b0 100644 --- a/build/index.html +++ b/build/index.html @@ -14,20 +14,20 @@
    - - - - - - - -