diff --git a/src/main/html/javascript/swagger-service-sample.js b/src/main/html/javascript/swagger-service-sample.js
index b3958732..b1dd8af7 100644
--- a/src/main/html/javascript/swagger-service-sample.js
+++ b/src/main/html/javascript/swagger-service-sample.js
@@ -1,6 +1,6 @@
jQuery(function($) {
// create and initialize SwaggerService
- var swaggerService = new SwaggerService();
+ var swaggerService = new SwaggerService("http://swagr.api.wordnik.com/v4");
swaggerService.init();
// Create convenience references to Spine models
diff --git a/src/main/html/javascript/swagger-service.js b/src/main/html/javascript/swagger-service.js
index ce0e8c8e..4e3768b1 100644
--- a/src/main/html/javascript/swagger-service.js
+++ b/src/main/html/javascript/swagger-service.js
@@ -1,7 +1,11 @@
-function SwaggerService(hostUrl) {
+function SwaggerService(hostUrl, rootResourcesApi) {
+ if(!hostUrl)
+ throw new Error("hostUrl must be passed while creating SwaggerService");
+
// constants
- var apiHost = hostUrl || "http://swagr.api.wordnik.com/v4";
+ var apiHost = hostUrl;
+ var rootResourcesApiName = rootResourcesApi || "list";
// utility functions
function log(m) {
@@ -253,9 +257,12 @@ function SwaggerService(hostUrl) {
fetchEndpoints: function() {
var controller = this;
- $.getJSON(apiHost + "/list.json", function(response) {
+ $.getJSON(apiHost + "/" + rootResourcesApiName + ".json", function(response) {
//log(response);
ApiResource.createAll(response.apis);
+ ApiResource.findByAttribute("name", rootResourcesApiName).destroy();
+
+
controller.fetchResources();
});
},
diff --git a/src/main/html/javascript/swagger-ui.js b/src/main/html/javascript/swagger-ui.js
index a835a90b..faef6179 100644
--- a/src/main/html/javascript/swagger-ui.js
+++ b/src/main/html/javascript/swagger-ui.js
@@ -1,6 +1,6 @@
jQuery(function($) {
// create and initialize SwaggerService
- var swaggerService = new SwaggerService();
+ var swaggerService = new SwaggerService("http://swagr.api.wordnik.com/v4");
swaggerService.init();
// Create convenience references to Spine models