updated to latest swagger-js
This commit is contained in:
1
dist/index.html
vendored
1
dist/index.html
vendored
@@ -45,6 +45,7 @@
|
|||||||
var key = $('#input_apiKey')[0].value;
|
var key = $('#input_apiKey')[0].value;
|
||||||
console.log("key: " + key);
|
console.log("key: " + key);
|
||||||
if(key && key.trim() != "") {
|
if(key && key.trim() != "") {
|
||||||
|
console.log("added key " + key);
|
||||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
122
dist/lib/swagger.js
vendored
122
dist/lib/swagger.js
vendored
@@ -38,6 +38,7 @@
|
|||||||
var obj,
|
var obj,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.progress('fetching resource list: ' + this.discoveryUrl);
|
this.progress('fetching resource list: ' + this.discoveryUrl);
|
||||||
|
console.log('getting ' + this.discoveryUrl);
|
||||||
obj = {
|
obj = {
|
||||||
url: this.discoveryUrl,
|
url: this.discoveryUrl,
|
||||||
method: "get",
|
method: "get",
|
||||||
@@ -79,7 +80,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return new SwaggerHttp().execute(obj);
|
new SwaggerHttp().execute(obj);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerApi.prototype.selfReflect = function() {
|
SwaggerApi.prototype.selfReflect = function() {
|
||||||
@@ -519,6 +521,9 @@
|
|||||||
this.resource[this.nickname] = function(args, callback, error) {
|
this.resource[this.nickname] = function(args, callback, error) {
|
||||||
return _this["do"](args, callback, error);
|
return _this["do"](args, callback, error);
|
||||||
};
|
};
|
||||||
|
this.resource[this.nickname].help = function() {
|
||||||
|
return _this.help();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
SwaggerOperation.prototype.isListType = function(dataType) {
|
SwaggerOperation.prototype.isListType = function(dataType) {
|
||||||
@@ -555,18 +560,25 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
|
||||||
var key, param, params, possibleParams, requestContentType, responseContentType, value;
|
var key, param, params, possibleParams, req, requestContentType, responseContentType, value;
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
args = {};
|
args = {};
|
||||||
}
|
}
|
||||||
|
if (opts == null) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
requestContentType = null;
|
requestContentType = null;
|
||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
if ((typeof args) === "function") {
|
if ((typeof args) === "function") {
|
||||||
error = callback;
|
error = opts;
|
||||||
callback = args;
|
callback = args;
|
||||||
args = {};
|
args = {};
|
||||||
}
|
}
|
||||||
|
if ((typeof opts) === "function") {
|
||||||
|
error = callback;
|
||||||
|
callback = opts;
|
||||||
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
error = function(xhr, textStatus, error) {
|
error = function(xhr, textStatus, error) {
|
||||||
return console.log(xhr, textStatus, error);
|
return console.log(xhr, textStatus, error);
|
||||||
@@ -574,16 +586,17 @@
|
|||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(data) {
|
callback = function(data) {
|
||||||
return console.log("default callback: " + data);
|
var content;
|
||||||
|
content = null;
|
||||||
|
if (data.content != null) {
|
||||||
|
content = data.content.data;
|
||||||
|
} else {
|
||||||
|
content = "no data";
|
||||||
|
}
|
||||||
|
return console.log("default callback: " + content);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
params = {};
|
params = {};
|
||||||
if (args.requestContentType) {
|
|
||||||
requestContentType = args.requestContentType;
|
|
||||||
}
|
|
||||||
if (args.responseContentType) {
|
|
||||||
responseContentType = args.responseContentType;
|
|
||||||
}
|
|
||||||
if (args.headers != null) {
|
if (args.headers != null) {
|
||||||
params.headers = args.headers;
|
params.headers = args.headers;
|
||||||
delete args.headers;
|
delete args.headers;
|
||||||
@@ -612,11 +625,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.mock != null) {
|
req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
|
||||||
params.mock = args["mock"];
|
if (opts.mock != null) {
|
||||||
|
return req;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
params["parent"] = args["parent"];
|
|
||||||
return new SwaggerRequest(this.method, this.urlify(args), params, requestContentType, responseContentType, callback, error, this);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.pathJson = function() {
|
SwaggerOperation.prototype.pathJson = function() {
|
||||||
@@ -716,14 +730,13 @@
|
|||||||
|
|
||||||
SwaggerRequest = (function() {
|
SwaggerRequest = (function() {
|
||||||
|
|
||||||
function SwaggerRequest(type, url, params, requestContentType, responseContentType, successCallback, errorCallback, operation, execution) {
|
function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||||
var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, urlEncoded, value, values,
|
var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.requestContentType = requestContentType;
|
this.opts = opts;
|
||||||
this.responseContentType = responseContentType;
|
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
@@ -750,8 +763,8 @@
|
|||||||
parent = params["parent"];
|
parent = params["parent"];
|
||||||
requestContentType = "application/json";
|
requestContentType = "application/json";
|
||||||
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
|
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
|
||||||
if (this.requestContentType) {
|
if (this.opts.requestContentType) {
|
||||||
requestContentType = this.requestContentType;
|
requestContentType = this.opts.requestContentType;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (((function() {
|
if (((function() {
|
||||||
@@ -777,14 +790,12 @@
|
|||||||
if (this.requestContentType === null) {
|
if (this.requestContentType === null) {
|
||||||
requestContentType = this.operation.consumes[0];
|
requestContentType = this.operation.consumes[0];
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log("it's ok to send " + requestContentType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
if (this.type === "POST" || this.type === "GET") {
|
if (this.type === "POST" || this.type === "GET") {
|
||||||
if (this.responseContentType) {
|
if (this.opts.responseContentType) {
|
||||||
responseContentType = this.responseContentType;
|
responseContentType = this.opts.responseContentType;
|
||||||
} else {
|
} else {
|
||||||
responseContentType = "application/json";
|
responseContentType = "application/json";
|
||||||
}
|
}
|
||||||
@@ -794,12 +805,9 @@
|
|||||||
if (responseContentType && this.operation.produces) {
|
if (responseContentType && this.operation.produces) {
|
||||||
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
||||||
console.log("server can't produce " + responseContentType);
|
console.log("server can't produce " + responseContentType);
|
||||||
} else {
|
|
||||||
console.log("get ready for " + responseContentType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
console.log("pulling fields");
|
|
||||||
fields = {};
|
fields = {};
|
||||||
possibleParams = (function() {
|
possibleParams = (function() {
|
||||||
var _i, _len, _ref, _results;
|
var _i, _len, _ref, _results;
|
||||||
@@ -813,7 +821,6 @@
|
|||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
console.log(possibleParams);
|
|
||||||
values = {};
|
values = {};
|
||||||
for (key in possibleParams) {
|
for (key in possibleParams) {
|
||||||
value = possibleParams[key];
|
value = possibleParams[key];
|
||||||
@@ -845,16 +852,16 @@
|
|||||||
body: body,
|
body: body,
|
||||||
on: {
|
on: {
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
return _this.errorCallback(response, _this.params["parent"]);
|
return _this.errorCallback(response, _this.opts.parent);
|
||||||
},
|
},
|
||||||
redirect: function(response) {
|
redirect: function(response) {
|
||||||
return _this.successCallback(response, _this.params["parent"]);
|
return _this.successCallback(response, _this.opts.parent);
|
||||||
},
|
},
|
||||||
307: function(response) {
|
307: function(response) {
|
||||||
return _this.successCallback(response, _this.params["parent"]);
|
return _this.successCallback(response, _this.opts.parent);
|
||||||
},
|
},
|
||||||
response: function(response) {
|
response: function(response) {
|
||||||
return _this.successCallback(response, _this.params["parent"]);
|
return _this.successCallback(response, _this.opts.parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -865,9 +872,10 @@
|
|||||||
e = exports;
|
e = exports;
|
||||||
}
|
}
|
||||||
e.authorizations.apply(obj);
|
e.authorizations.apply(obj);
|
||||||
if (params.mock == null) {
|
if (opts.mock == null) {
|
||||||
new SwaggerHttp().execute(obj);
|
new SwaggerHttp().execute(obj);
|
||||||
} else {
|
} else {
|
||||||
|
console.log(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -894,33 +902,42 @@
|
|||||||
|
|
||||||
SwaggerHttp = (function() {
|
SwaggerHttp = (function() {
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.Shred = null;
|
||||||
|
|
||||||
SwaggerHttp.prototype.shred = null;
|
SwaggerHttp.prototype.shred = null;
|
||||||
|
|
||||||
function SwaggerHttp() {
|
SwaggerHttp.prototype.content = null;
|
||||||
var Shred;
|
|
||||||
Shred = null;
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
Shred = require("./shred");
|
|
||||||
} else {
|
|
||||||
Shred = require("shred");
|
|
||||||
}
|
|
||||||
this.shred = new Shred();
|
|
||||||
}
|
|
||||||
|
|
||||||
SwaggerHttp.prototype.execute = function(obj) {
|
function SwaggerHttp() {
|
||||||
var Content, identity, toString,
|
var identity, toString,
|
||||||
_this = this;
|
_this = this;
|
||||||
Content = require("./shred/content");
|
if (typeof window !== 'undefined') {
|
||||||
|
this.Shred = require("./shred");
|
||||||
|
} else {
|
||||||
|
this.Shred = require("shred");
|
||||||
|
}
|
||||||
|
this.shred = new this.Shred();
|
||||||
identity = function(x) {
|
identity = function(x) {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
toString = function(x) {
|
toString = function(x) {
|
||||||
return x.toString;
|
return x.toString;
|
||||||
};
|
};
|
||||||
Content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
if (typeof window !== 'undefined') {
|
||||||
parser: identity,
|
this.content = require("./shred/content");
|
||||||
stringify: toString
|
this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
});
|
parser: identity,
|
||||||
|
stringify: toString
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
|
parser: identity,
|
||||||
|
stringify: toString
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.execute = function(obj) {
|
||||||
return this.shred.request(obj);
|
return this.shred.request(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -972,6 +989,7 @@
|
|||||||
|
|
||||||
ApiKeyAuthorization.prototype.apply = function(obj) {
|
ApiKeyAuthorization.prototype.apply = function(obj) {
|
||||||
if (this.type === "query") {
|
if (this.type === "query") {
|
||||||
|
console.log(this.value);
|
||||||
if (obj.url.indexOf('?') > 0) {
|
if (obj.url.indexOf('?') > 0) {
|
||||||
obj.url = obj.url + "&" + this.name + "=" + this.value;
|
obj.url = obj.url + "&" + this.name + "=" + this.value;
|
||||||
} else {
|
} else {
|
||||||
@@ -997,8 +1015,6 @@
|
|||||||
|
|
||||||
this.SwaggerModelProperty = SwaggerModelProperty;
|
this.SwaggerModelProperty = SwaggerModelProperty;
|
||||||
|
|
||||||
this.SwaggerAuthorizations = new SwaggerAuthorizations();
|
|
||||||
|
|
||||||
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||||
|
|
||||||
this.authorizations = new SwaggerAuthorizations();
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|||||||
22
dist/swagger-ui.js
vendored
22
dist/swagger-ui.js
vendored
@@ -1183,7 +1183,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
stack1 = foundHelper || depth0.name;
|
stack1 = foundHelper || depth0.name;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
|
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
|
||||||
buffer += escapeExpression(stack1) + "');\">/";
|
buffer += escapeExpression(stack1) + "');\">";
|
||||||
foundHelper = helpers.name;
|
foundHelper = helpers.name;
|
||||||
stack1 = foundHelper || depth0.name;
|
stack1 = foundHelper || depth0.name;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
@@ -1385,7 +1385,6 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
|
|
||||||
SwaggerUi.prototype.updateSwaggerUi = function(data) {
|
SwaggerUi.prototype.updateSwaggerUi = function(data) {
|
||||||
this.options.discoveryUrl = data.discoveryUrl;
|
this.options.discoveryUrl = data.discoveryUrl;
|
||||||
this.options.apiKey = data.apiKey;
|
|
||||||
return this.load();
|
return this.load();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1394,7 +1393,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
if ((_ref = this.mainView) != null) {
|
if ((_ref = this.mainView) != null) {
|
||||||
_ref.clear();
|
_ref.clear();
|
||||||
}
|
}
|
||||||
this.headerView.update(this.options.discoveryUrl, this.options.apiKey);
|
this.headerView.update(this.options.discoveryUrl);
|
||||||
return this.api = new SwaggerApi(this.options);
|
return this.api = new SwaggerApi(this.options);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1470,15 +1469,13 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
|
|
||||||
HeaderView.prototype.showPetStore = function(e) {
|
HeaderView.prototype.showPetStore = function(e) {
|
||||||
return this.trigger('update-swagger-ui', {
|
return this.trigger('update-swagger-ui', {
|
||||||
discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json",
|
discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json"
|
||||||
apiKey: "special-key"
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
HeaderView.prototype.showWordnikDev = function(e) {
|
HeaderView.prototype.showWordnikDev = function(e) {
|
||||||
return this.trigger('update-swagger-ui', {
|
return this.trigger('update-swagger-ui', {
|
||||||
discoveryUrl: "http://api.wordnik.com/v4/resources.json",
|
discoveryUrl: "http://api.wordnik.com/v4/resources.json"
|
||||||
apiKey: ""
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1675,7 +1672,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.submitOperation = function(e) {
|
OperationView.prototype.submitOperation = function(e) {
|
||||||
var error_free, form, map, o, _i, _len, _ref;
|
var error_free, form, map, o, opts, _i, _len, _ref;
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -1695,7 +1692,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (error_free) {
|
if (error_free) {
|
||||||
map = {
|
map = {};
|
||||||
|
opts = {
|
||||||
parent: this
|
parent: this
|
||||||
};
|
};
|
||||||
_ref = form.serializeArray();
|
_ref = form.serializeArray();
|
||||||
@@ -1706,9 +1704,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(map);
|
console.log(map);
|
||||||
map["responseContentType"] = $("div select[name=responseContentType]", $(this.el)).val();
|
opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
|
||||||
map["requestContentType"] = $("div select[name=parameterContentType]", $(this.el)).val();
|
opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
|
||||||
return this.model["do"](map, this.showCompleteStatus, this.showErrorStatus, this);
|
return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
121
lib/swagger.js
121
lib/swagger.js
@@ -38,6 +38,7 @@
|
|||||||
var obj,
|
var obj,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.progress('fetching resource list: ' + this.discoveryUrl);
|
this.progress('fetching resource list: ' + this.discoveryUrl);
|
||||||
|
console.log('getting ' + this.discoveryUrl);
|
||||||
obj = {
|
obj = {
|
||||||
url: this.discoveryUrl,
|
url: this.discoveryUrl,
|
||||||
method: "get",
|
method: "get",
|
||||||
@@ -79,7 +80,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return new SwaggerHttp().execute(obj);
|
new SwaggerHttp().execute(obj);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerApi.prototype.selfReflect = function() {
|
SwaggerApi.prototype.selfReflect = function() {
|
||||||
@@ -519,6 +521,9 @@
|
|||||||
this.resource[this.nickname] = function(args, callback, error) {
|
this.resource[this.nickname] = function(args, callback, error) {
|
||||||
return _this["do"](args, callback, error);
|
return _this["do"](args, callback, error);
|
||||||
};
|
};
|
||||||
|
this.resource[this.nickname].help = function() {
|
||||||
|
return _this.help();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
SwaggerOperation.prototype.isListType = function(dataType) {
|
SwaggerOperation.prototype.isListType = function(dataType) {
|
||||||
@@ -555,18 +560,25 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
|
||||||
var key, param, params, possibleParams, requestContentType, responseContentType, value;
|
var key, param, params, possibleParams, req, requestContentType, responseContentType, value;
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
args = {};
|
args = {};
|
||||||
}
|
}
|
||||||
|
if (opts == null) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
requestContentType = null;
|
requestContentType = null;
|
||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
if ((typeof args) === "function") {
|
if ((typeof args) === "function") {
|
||||||
error = callback;
|
error = opts;
|
||||||
callback = args;
|
callback = args;
|
||||||
args = {};
|
args = {};
|
||||||
}
|
}
|
||||||
|
if ((typeof opts) === "function") {
|
||||||
|
error = callback;
|
||||||
|
callback = opts;
|
||||||
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
error = function(xhr, textStatus, error) {
|
error = function(xhr, textStatus, error) {
|
||||||
return console.log(xhr, textStatus, error);
|
return console.log(xhr, textStatus, error);
|
||||||
@@ -574,16 +586,17 @@
|
|||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(data) {
|
callback = function(data) {
|
||||||
return console.log("default callback: " + data);
|
var content;
|
||||||
|
content = null;
|
||||||
|
if (data.content != null) {
|
||||||
|
content = data.content.data;
|
||||||
|
} else {
|
||||||
|
content = "no data";
|
||||||
|
}
|
||||||
|
return console.log("default callback: " + content);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
params = {};
|
params = {};
|
||||||
if (args.requestContentType) {
|
|
||||||
requestContentType = args.requestContentType;
|
|
||||||
}
|
|
||||||
if (args.responseContentType) {
|
|
||||||
responseContentType = args.responseContentType;
|
|
||||||
}
|
|
||||||
if (args.headers != null) {
|
if (args.headers != null) {
|
||||||
params.headers = args.headers;
|
params.headers = args.headers;
|
||||||
delete args.headers;
|
delete args.headers;
|
||||||
@@ -612,11 +625,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.mock != null) {
|
req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
|
||||||
params.mock = args["mock"];
|
if (opts.mock != null) {
|
||||||
|
return req;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
params["parent"] = args["parent"];
|
|
||||||
return new SwaggerRequest(this.method, this.urlify(args), params, requestContentType, responseContentType, callback, error, this);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerOperation.prototype.pathJson = function() {
|
SwaggerOperation.prototype.pathJson = function() {
|
||||||
@@ -716,14 +730,13 @@
|
|||||||
|
|
||||||
SwaggerRequest = (function() {
|
SwaggerRequest = (function() {
|
||||||
|
|
||||||
function SwaggerRequest(type, url, params, requestContentType, responseContentType, successCallback, errorCallback, operation, execution) {
|
function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||||
var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, urlEncoded, value, values,
|
var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.requestContentType = requestContentType;
|
this.opts = opts;
|
||||||
this.responseContentType = responseContentType;
|
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
@@ -750,8 +763,8 @@
|
|||||||
parent = params["parent"];
|
parent = params["parent"];
|
||||||
requestContentType = "application/json";
|
requestContentType = "application/json";
|
||||||
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
|
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
|
||||||
if (this.requestContentType) {
|
if (this.opts.requestContentType) {
|
||||||
requestContentType = this.requestContentType;
|
requestContentType = this.opts.requestContentType;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (((function() {
|
if (((function() {
|
||||||
@@ -777,14 +790,12 @@
|
|||||||
if (this.requestContentType === null) {
|
if (this.requestContentType === null) {
|
||||||
requestContentType = this.operation.consumes[0];
|
requestContentType = this.operation.consumes[0];
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log("it's ok to send " + requestContentType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
if (this.type === "POST" || this.type === "GET") {
|
if (this.type === "POST" || this.type === "GET") {
|
||||||
if (this.responseContentType) {
|
if (this.opts.responseContentType) {
|
||||||
responseContentType = this.responseContentType;
|
responseContentType = this.opts.responseContentType;
|
||||||
} else {
|
} else {
|
||||||
responseContentType = "application/json";
|
responseContentType = "application/json";
|
||||||
}
|
}
|
||||||
@@ -794,12 +805,9 @@
|
|||||||
if (responseContentType && this.operation.produces) {
|
if (responseContentType && this.operation.produces) {
|
||||||
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
||||||
console.log("server can't produce " + responseContentType);
|
console.log("server can't produce " + responseContentType);
|
||||||
} else {
|
|
||||||
console.log("get ready for " + responseContentType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
console.log("pulling fields");
|
|
||||||
fields = {};
|
fields = {};
|
||||||
possibleParams = (function() {
|
possibleParams = (function() {
|
||||||
var _i, _len, _ref, _results;
|
var _i, _len, _ref, _results;
|
||||||
@@ -813,7 +821,6 @@
|
|||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
}).call(this);
|
}).call(this);
|
||||||
console.log(possibleParams);
|
|
||||||
values = {};
|
values = {};
|
||||||
for (key in possibleParams) {
|
for (key in possibleParams) {
|
||||||
value = possibleParams[key];
|
value = possibleParams[key];
|
||||||
@@ -845,16 +852,16 @@
|
|||||||
body: body,
|
body: body,
|
||||||
on: {
|
on: {
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
return _this.errorCallback(response, _this.params["parent"]);
|
return _this.errorCallback(response, _this.opts.parent);
|
||||||
},
|
},
|
||||||
redirect: function(response) {
|
redirect: function(response) {
|
||||||
return _this.successCallback(response, _this.params["parent"]);
|
return _this.successCallback(response, _this.opts.parent);
|
||||||
},
|
},
|
||||||
307: function(response) {
|
307: function(response) {
|
||||||
return _this.successCallback(response, _this.params["parent"]);
|
return _this.successCallback(response, _this.opts.parent);
|
||||||
},
|
},
|
||||||
response: function(response) {
|
response: function(response) {
|
||||||
return _this.successCallback(response, _this.params["parent"]);
|
return _this.successCallback(response, _this.opts.parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -865,9 +872,10 @@
|
|||||||
e = exports;
|
e = exports;
|
||||||
}
|
}
|
||||||
e.authorizations.apply(obj);
|
e.authorizations.apply(obj);
|
||||||
if (params.mock == null) {
|
if (opts.mock == null) {
|
||||||
new SwaggerHttp().execute(obj);
|
new SwaggerHttp().execute(obj);
|
||||||
} else {
|
} else {
|
||||||
|
console.log(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -894,33 +902,42 @@
|
|||||||
|
|
||||||
SwaggerHttp = (function() {
|
SwaggerHttp = (function() {
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.Shred = null;
|
||||||
|
|
||||||
SwaggerHttp.prototype.shred = null;
|
SwaggerHttp.prototype.shred = null;
|
||||||
|
|
||||||
function SwaggerHttp() {
|
SwaggerHttp.prototype.content = null;
|
||||||
var Shred;
|
|
||||||
Shred = null;
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
Shred = require("./shred");
|
|
||||||
} else {
|
|
||||||
Shred = require("shred");
|
|
||||||
}
|
|
||||||
this.shred = new Shred();
|
|
||||||
}
|
|
||||||
|
|
||||||
SwaggerHttp.prototype.execute = function(obj) {
|
function SwaggerHttp() {
|
||||||
var Content, identity, toString,
|
var identity, toString,
|
||||||
_this = this;
|
_this = this;
|
||||||
Content = require("./shred/content");
|
if (typeof window !== 'undefined') {
|
||||||
|
this.Shred = require("./shred");
|
||||||
|
} else {
|
||||||
|
this.Shred = require("shred");
|
||||||
|
}
|
||||||
|
this.shred = new this.Shred();
|
||||||
identity = function(x) {
|
identity = function(x) {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
toString = function(x) {
|
toString = function(x) {
|
||||||
return x.toString;
|
return x.toString;
|
||||||
};
|
};
|
||||||
Content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
if (typeof window !== 'undefined') {
|
||||||
parser: identity,
|
this.content = require("./shred/content");
|
||||||
stringify: toString
|
this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
});
|
parser: identity,
|
||||||
|
stringify: toString
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
|
parser: identity,
|
||||||
|
stringify: toString
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.execute = function(obj) {
|
||||||
return this.shred.request(obj);
|
return this.shred.request(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -997,8 +1014,6 @@
|
|||||||
|
|
||||||
this.SwaggerModelProperty = SwaggerModelProperty;
|
this.SwaggerModelProperty = SwaggerModelProperty;
|
||||||
|
|
||||||
this.SwaggerAuthorizations = new SwaggerAuthorizations();
|
|
||||||
|
|
||||||
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
this.ApiKeyAuthorization = ApiKeyAuthorization;
|
||||||
|
|
||||||
this.authorizations = new SwaggerAuthorizations();
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|||||||
@@ -35,14 +35,13 @@ class SwaggerUi extends Backbone.Router
|
|||||||
# Event handler for when url/key is received from user
|
# Event handler for when url/key is received from user
|
||||||
updateSwaggerUi: (data) ->
|
updateSwaggerUi: (data) ->
|
||||||
@options.discoveryUrl = data.discoveryUrl
|
@options.discoveryUrl = data.discoveryUrl
|
||||||
@options.apiKey = data.apiKey
|
|
||||||
@load()
|
@load()
|
||||||
|
|
||||||
# Create an api and render
|
# Create an api and render
|
||||||
load: ->
|
load: ->
|
||||||
# Initialize the API object
|
# Initialize the API object
|
||||||
@mainView?.clear()
|
@mainView?.clear()
|
||||||
@headerView.update(@options.discoveryUrl, @options.apiKey)
|
@headerView.update(@options.discoveryUrl)
|
||||||
@api = new SwaggerApi(@options)
|
@api = new SwaggerApi(@options)
|
||||||
|
|
||||||
# This is bound to success handler for SwaggerApi
|
# This is bound to success handler for SwaggerApi
|
||||||
|
|||||||
@@ -9,17 +9,16 @@ class HeaderView extends Backbone.View
|
|||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
|
|
||||||
|
|
||||||
showPetStore: (e) ->
|
showPetStore: (e) ->
|
||||||
@trigger(
|
@trigger(
|
||||||
'update-swagger-ui'
|
'update-swagger-ui'
|
||||||
{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json", apiKey:"special-key"}
|
{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json"}
|
||||||
)
|
)
|
||||||
|
|
||||||
showWordnikDev: (e) ->
|
showWordnikDev: (e) ->
|
||||||
@trigger(
|
@trigger(
|
||||||
'update-swagger-ui'
|
'update-swagger-ui'
|
||||||
{discoveryUrl:"http://api.wordnik.com/v4/resources.json", apiKey:""}
|
{discoveryUrl:"http://api.wordnik.com/v4/resources.json"}
|
||||||
)
|
)
|
||||||
|
|
||||||
showCustomOnKeyup: (e) ->
|
showCustomOnKeyup: (e) ->
|
||||||
|
|||||||
@@ -68,17 +68,18 @@ class OperationView extends Backbone.View
|
|||||||
|
|
||||||
# if error free submit it
|
# if error free submit it
|
||||||
if error_free
|
if error_free
|
||||||
map = {parent: @}
|
map = {}
|
||||||
|
opts = {parent: @}
|
||||||
for o in form.serializeArray()
|
for o in form.serializeArray()
|
||||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||||
map[o.name] = o.value
|
map[o.name] = o.value
|
||||||
|
|
||||||
console.log map
|
console.log map
|
||||||
|
|
||||||
map["responseContentType"] = $("div select[name=responseContentType]", $(@el)).val()
|
opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
|
||||||
map["requestContentType"] = $("div select[name=parameterContentType]", $(@el)).val()
|
opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
|
||||||
|
|
||||||
@model.do(map, @showCompleteStatus, @showErrorStatus, @)
|
@model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
|
||||||
|
|
||||||
success: (response, parent) ->
|
success: (response, parent) ->
|
||||||
parent.showCompleteStatus response
|
parent.showCompleteStatus response
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
var key = $('#input_apiKey')[0].value;
|
var key = $('#input_apiKey')[0].value;
|
||||||
console.log("key: " + key);
|
console.log("key: " + key);
|
||||||
if(key && key.trim() != "") {
|
if(key && key.trim() != "") {
|
||||||
|
console.log("added key " + key);
|
||||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class='heading'>
|
<div class='heading'>
|
||||||
<h2>
|
<h2>
|
||||||
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">/{{name}}</a>
|
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a>
|
||||||
</h2>
|
</h2>
|
||||||
<ul class='options'>
|
<ul class='options'>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
Reference in New Issue
Block a user