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($) {
|
jQuery(function($) {
|
||||||
// create and initialize SwaggerService
|
// create and initialize SwaggerService
|
||||||
var swaggerService = new SwaggerService();
|
var swaggerService = new SwaggerService("http://swagr.api.wordnik.com/v4");
|
||||||
swaggerService.init();
|
swaggerService.init();
|
||||||
|
|
||||||
// Create convenience references to Spine models
|
// 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
|
// constants
|
||||||
var apiHost = hostUrl || "http://swagr.api.wordnik.com/v4";
|
var apiHost = hostUrl;
|
||||||
|
var rootResourcesApiName = rootResourcesApi || "list";
|
||||||
|
|
||||||
// utility functions
|
// utility functions
|
||||||
function log(m) {
|
function log(m) {
|
||||||
@@ -253,9 +257,12 @@ function SwaggerService(hostUrl) {
|
|||||||
fetchEndpoints: function() {
|
fetchEndpoints: function() {
|
||||||
var controller = this;
|
var controller = this;
|
||||||
|
|
||||||
$.getJSON(apiHost + "/list.json", function(response) {
|
$.getJSON(apiHost + "/" + rootResourcesApiName + ".json", function(response) {
|
||||||
//log(response);
|
//log(response);
|
||||||
ApiResource.createAll(response.apis);
|
ApiResource.createAll(response.apis);
|
||||||
|
ApiResource.findByAttribute("name", rootResourcesApiName).destroy();
|
||||||
|
|
||||||
|
|
||||||
controller.fetchResources();
|
controller.fetchResources();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
// create and initialize SwaggerService
|
// create and initialize SwaggerService
|
||||||
var swaggerService = new SwaggerService();
|
var swaggerService = new SwaggerService("http://swagr.api.wordnik.com/v4");
|
||||||
swaggerService.init();
|
swaggerService.init();
|
||||||
|
|
||||||
// Create convenience references to Spine models
|
// Create convenience references to Spine models
|
||||||
|
|||||||
Reference in New Issue
Block a user