renamed discoveryUrl to url to match js change
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
SwaggerApi = (function() {
|
||||
|
||||
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
||||
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
||||
|
||||
SwaggerApi.prototype.debug = false;
|
||||
|
||||
@@ -15,12 +15,21 @@
|
||||
|
||||
SwaggerApi.prototype.authorizationScheme = null;
|
||||
|
||||
function SwaggerApi(options) {
|
||||
function SwaggerApi(url, options) {
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
if (options.discoveryUrl != null) {
|
||||
this.discoveryUrl = options.discoveryUrl;
|
||||
if (url) {
|
||||
if (url.url) {
|
||||
options = url;
|
||||
} else {
|
||||
this.url = url;
|
||||
}
|
||||
} else {
|
||||
options = url;
|
||||
}
|
||||
if (options.url != null) {
|
||||
this.url = options.url;
|
||||
}
|
||||
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
||||
if (options.success != null) {
|
||||
@@ -37,21 +46,21 @@
|
||||
SwaggerApi.prototype.build = function() {
|
||||
var obj,
|
||||
_this = this;
|
||||
this.progress('fetching resource list: ' + this.discoveryUrl);
|
||||
console.log('getting ' + this.discoveryUrl);
|
||||
this.progress('fetching resource list: ' + this.url);
|
||||
console.log('getting ' + this.url);
|
||||
obj = {
|
||||
url: this.discoveryUrl,
|
||||
url: this.url,
|
||||
method: "get",
|
||||
on: {
|
||||
error: function(response) {
|
||||
if (_this.discoveryUrl.substring(0, 4) !== 'http') {
|
||||
return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
|
||||
if (_this.url.substring(0, 4) !== 'http') {
|
||||
return _this.fail('Please specify the protocol for ' + _this.url);
|
||||
} else if (error.status === 0) {
|
||||
return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
|
||||
} else if (error.status === 404) {
|
||||
return _this.fail('Can\'t read swagger JSON from ' + _this.discoveryUrl);
|
||||
return _this.fail('Can\'t read swagger JSON from ' + _this.url);
|
||||
} else {
|
||||
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
|
||||
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
|
||||
}
|
||||
},
|
||||
response: function(rawResponse) {
|
||||
@@ -83,10 +92,10 @@
|
||||
} else {
|
||||
if (response.basePath) {
|
||||
_this.basePath = response.basePath;
|
||||
} else if (_this.discoveryUrl.indexOf('?') > 0) {
|
||||
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
|
||||
} else if (_this.url.indexOf('?') > 0) {
|
||||
_this.basePath = _this.url.substring(0, _this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
_this.basePath = _this.discoveryUrl;
|
||||
_this.basePath = _this.url;
|
||||
}
|
||||
_ref2 = response.apis;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
|
||||
Reference in New Issue
Block a user