Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed id construction in toggleOperationContent #411

Merged
merged 1 commit into from
Mar 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 81 additions & 11 deletions dist/lib/swagger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// swagger.js
// version 2.0.22
// version 2.0.23

var __bind = function(fn, me){
return function(){
Expand All @@ -17,13 +17,69 @@ log = function(){

if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}

if (!('filter' in Array.prototype)) {
Array.prototype.filter= function(filter, that /*opt*/) {
var other= [], v;
for (var i=0, n= this.length; i<n; i++)
if (i in this && filter.call(that, v= this[i], i, this))
other.push(v);
return other;
};
}

if (!('map' in Array.prototype)) {
Array.prototype.map= function(mapper, that /*opt*/) {
var other= new Array(this.length);
for (var i= 0, n= this.length; i<n; i++)
if (i in this)
other[i]= mapper.call(that, this[i], i, this);
return other;
};
}

Object.keys = Object.keys || (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
DontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
],
DontEnumsLength = DontEnums.length;

return function (o) {
if (typeof o != "object" && typeof o != "function" || o === null)
throw new TypeError("Object.keys called on a non-object");

var result = [];
for (var name in o) {
if (hasOwnProperty.call(o, name))
result.push(name);
}

if (hasDontEnumBug) {
for (var i = 0; i < DontEnumsLength; i++) {
if (hasOwnProperty.call(o, DontEnums[i]))
result.push(DontEnums[i]);
}
}

return result;
};
})();


var SwaggerApi = function(url, options) {
this.url = null;
this.debug = false;
Expand Down Expand Up @@ -104,10 +160,12 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
this.info = response.info;
}
var isApi = false;
for (var i = 0; i < response.apis.length; i++) {
var i;
for (i = 0; i < response.apis.length; i++) {
var api = response.apis[i];
if (api.operations) {
for (var j = 0; j < api.operations.length; j++) {
var j;
for (j = 0; j < api.operations.length; j++) {
operation = api.operations[j];
isApi = true;
}
Expand All @@ -127,7 +185,8 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
this.apis[newName] = res;
this.apisArray.push(res);
} else {
for (var k = 0; k < response.apis.length; k++) {
var k;
for (k = 0; k < response.apis.length; k++) {
var resource = response.apis[k];
res = new SwaggerResource(resource, this);
this.apis[res.name] = res;
Expand Down Expand Up @@ -350,6 +409,7 @@ SwaggerResource.prototype.addApiDeclaration = function(response) {

SwaggerResource.prototype.addModels = function(models) {
if (models != null) {
var modelName;
for (modelName in models) {
if (this.models[modelName] == null) {
var swaggerModel = new SwaggerModel(modelName, models[modelName]);
Expand Down Expand Up @@ -429,6 +489,7 @@ SwaggerResource.prototype.sanitize = function(nickname) {
SwaggerResource.prototype.help = function() {
var op = this.operations;
var output = [];
var operation_name;
for (operation_name in op) {
operation = op[operation_name];
var msg = " " + operation.nickname;
Expand All @@ -444,8 +505,10 @@ SwaggerResource.prototype.help = function() {
var SwaggerModel = function(modelName, obj) {
this.name = obj.id != null ? obj.id : modelName;
this.properties = [];
var propertyName;
for (propertyName in obj.properties) {
if (obj.required != null) {
var value;
for (value in obj.required) {
if (propertyName === obj.required[value]) {
obj.properties[propertyName].required = true;
Expand Down Expand Up @@ -793,6 +856,7 @@ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
}

if (possibleParams) {
var key;
for (key in possibleParams) {
value = possibleParams[key];
if (args[value.name]) {
Expand Down Expand Up @@ -875,6 +939,7 @@ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
matchingParams[param.name] = args[param.name];
}
var headers = this.resource.api.headers;
var name;
for (name in headers) {
var value = headers[name];
matchingParams[name] = value;
Expand Down Expand Up @@ -973,14 +1038,15 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
var fields = {};
var possibleParams = {};
var values = {};

for(var key in formParams){
var key;
for(key in formParams){
var param = formParams[key];
values[param.name] = param;
}

var encoded = "";
for(var key in values) {
var key;
for(key in values) {
value = this.params[key];
if(typeof value !== 'undefined'){
if(encoded !== "")
Expand All @@ -990,6 +1056,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
}
body = encoded;
}
var name;
for (name in this.headers)
myHeaders[name] = this.headers[name];
if ((requestContentType && body !== "") || (requestContentType === "application/x-www-form-urlencoded"))
Expand Down Expand Up @@ -1041,6 +1108,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
SwaggerRequest.prototype.asCurl = function() {
var results = [];
if(this.headers) {
var key;
for(key in this.headers) {
results.push("--header \"" + key + ": " + this.headers[v] + "\"");
}
Expand Down Expand Up @@ -1095,6 +1163,7 @@ JQueryHttpClient.prototype.execute = function(obj) {
var key, results;
if (obj.headers) {
results = [];
var key;
for (key in obj.headers) {
if (key.toLowerCase() === "content-type") {
results.push(obj.contentType = obj.headers[key]);
Expand Down Expand Up @@ -1262,6 +1331,7 @@ SwaggerAuthorizations.prototype.remove = function(name) {

SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
status = null;
var key;
for (key in this.authz) {
value = this.authz[key];
result = value.apply(obj, authorizations);
Expand Down
2 changes: 1 addition & 1 deletion dist/swagger-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};

OperationView.prototype.toggleOperationContent = function() {
var elem;
elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_" + this.model.method + "_content");
elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_content");
if (elem.is(':visible')) {
return Docs.collapseOperation(elem);
} else {
Expand Down
2 changes: 1 addition & 1 deletion dist/swagger-ui.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"readmeFilename": "README.md",
"dependencies": {
"coffee-script": "~1.5.0",
"swagger-client": "2.0.22",
"swagger-client": "2.0.23",
"handlebars": "~1.0.10",
"less": "~1.4.2"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/coffeescript/view/OperationView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,5 @@ class OperationView extends Backbone.View
hljs.highlightBlock($('.response_body', $(@el))[0])

toggleOperationContent: ->
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_" + @model.method + "_content")
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_content")
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)