parameterized root resources api name and host url. also removed list resource from model
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user